diff options
Diffstat (limited to 'src/game/QueryHandler.cpp')
-rw-r--r-- | src/game/QueryHandler.cpp | 142 |
1 files changed, 82 insertions, 60 deletions
diff --git a/src/game/QueryHandler.cpp b/src/game/QueryHandler.cpp index 6a99703dbc4..5d13a6a576a 100644 --- a/src/game/QueryHandler.cpp +++ b/src/game/QueryHandler.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,8 +31,8 @@ #include "Player.h" #include "UpdateMask.h" #include "NPCHandler.h" -#include "ObjectAccessor.h" #include "Pet.h" +#include "MapManager.h" void WorldSession::SendNameQueryOpcode(Player *p) { @@ -102,20 +102,20 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32 WorldPacket data( SMSG_NAME_QUERY_RESPONSE, (8+1+4+4+4+10) ); data << MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER); data << name; - data << (uint8)0; - data << (uint32)(field & 0xFF); - data << (uint32)((field >> 16) & 0xFF); - data << (uint32)((field >> 8) & 0xFF); + data << uint8(0); + data << uint32(field & 0xFF); + data << uint32((field >> 16) & 0xFF); + data << uint32((field >> 8) & 0xFF); // if the first declined name field (3) is empty, the rest must be too if(sWorld.getConfig(CONFIG_DECLINED_NAMES_USED) && fields[3].GetCppString() != "") { - data << (uint8)1; // is declined + data << uint8(1); // is declined for(int i = 3; i < MAX_DECLINED_NAME_CASES+3; ++i) data << fields[i].GetCppString(); } else - data << (uint8)0; // is declined + data << uint8(0); // is declined session->SendPacket( &data ); delete result; @@ -123,7 +123,7 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32 void WorldSession::HandleNameQueryOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); + CHECK_PACKET_SIZE(recv_data, 8); uint64 guid; @@ -176,26 +176,24 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data ) sLog.outDetail("WORLD: CMSG_CREATURE_QUERY '%s' - Entry: %u.", ci->Name, entry); // guess size WorldPacket data( SMSG_CREATURE_QUERY_RESPONSE, 100 ); - data << (uint32)entry; // creature entry + data << uint32(entry); // creature entry data << Name; data << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4, always empty data << SubName; data << ci->IconName; // "Directions" for guard, string for Icons 2.3.0 - data << (uint32)ci->type_flags; // flags wdbFeild7=wad flags1 - data << (uint32)ci->type; - data << (uint32)ci->family; // family wdbFeild9 - data << (uint32)ci->rank; // rank wdbFeild10 - data << (uint32)0; // unknown wdbFeild11 - data << (uint32)ci->PetSpellDataId; // Id from CreatureSpellData.dbc wdbField12 + data << uint32(ci->type_flags); // flags + data << uint32(ci->type); // CreatureType.dbc + data << uint32(ci->family); // CreatureFamily.dbc + data << uint32(ci->rank); // Creature Rank (elite, boss, etc) + data << uint32(ci->PetSpellDataId); // Id from CreatureSpellData.dbc wdbField12 data << (uint32)ci->Modelid_A1; // Modelid_A1 data << (uint32)ci->Modelid_A2; // Modelid_A2 data << (uint32)ci->Modelid_H1; // Modelid_H1 data << (uint32)ci->Modelid_H2; // Modelid_H2 - data << (float)1.0f; // unk - data << (float)1.0f; // unk - data << (uint8)ci->RacialLeader; + data << float(ci->unk17); // unk + data << uint8(ci->RacialLeader); SendPacket( &data ); - sLog.outDebug( "WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE " ); + sLog.outDebug( "WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE" ); } else { @@ -207,7 +205,7 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data ) WorldPacket data( SMSG_CREATURE_QUERY_RESPONSE, 4 ); data << uint32(entry | 0x80000000); SendPacket( &data ); - sLog.outDebug( "WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE " ); + sLog.outDebug( "WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE" ); } } @@ -222,11 +220,12 @@ void WorldSession::HandleGameObjectQueryOpcode( WorldPacket & recv_data ) const GameObjectInfo *info = objmgr.GetGameObjectInfo(entryID); if(info) { - std::string Name; + std::string IconName; std::string CastBarCaption; Name = info->name; + IconName = info->IconName; CastBarCaption = info->castBarCaption; int loc_idx = GetSessionDbLocaleIndex(); @@ -243,17 +242,18 @@ void WorldSession::HandleGameObjectQueryOpcode( WorldPacket & recv_data ) } sLog.outDetail("WORLD: CMSG_GAMEOBJECT_QUERY '%s' - Entry: %u. ", info->name, entryID); WorldPacket data ( SMSG_GAMEOBJECT_QUERY_RESPONSE, 150 ); - data << entryID; - data << (uint32)info->type; - data << (uint32)info->displayId; + data << uint32(entryID); + data << uint32(info->type); + data << uint32(info->displayId); data << Name; data << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4 - data << uint8(0); // 2.0.3, string + data << IconName; // 2.0.3, string. Icon name to use instead of default icon for go's (ex: "Attack" makes sword) data << CastBarCaption; // 2.0.3, string. Text will appear in Cast Bar when using GO (ex: "Collecting") - data << uint8(0); // 2.0.3, probably string - data.append(info->raw.data,24); + data << uint8(0); // 2.0.3, string + data.append(info->raw.data, 24); + data << float(info->size); // go size SendPacket( &data ); - sLog.outDebug( "WORLD: Sent CMSG_GAMEOBJECT_QUERY " ); + sLog.outDebug( "WORLD: Sent SMSG_GAMEOBJECT_QUERY_RESPONSE" ); } else { @@ -266,7 +266,7 @@ void WorldSession::HandleGameObjectQueryOpcode( WorldPacket & recv_data ) WorldPacket data ( SMSG_GAMEOBJECT_QUERY_RESPONSE, 4 ); data << uint32(entryID | 0x80000000); SendPacket( &data ); - sLog.outDebug( "WORLD: Sent CMSG_GAMEOBJECT_QUERY " ); + sLog.outDebug( "WORLD: Sent SMSG_GAMEOBJECT_QUERY_RESPONSE" ); } } @@ -276,31 +276,56 @@ void WorldSession::HandleCorpseQueryOpcode(WorldPacket & /*recv_data*/) Corpse *corpse = GetPlayer()->GetCorpse(); - uint8 found = 1; if(!corpse) - found = 0; + { + WorldPacket data(MSG_CORPSE_QUERY, 1); + data << uint8(0); // corpse not found + SendPacket(&data); + return; + } + + int32 mapid = corpse->GetMapId(); + float x = corpse->GetPositionX(); + float y = corpse->GetPositionY(); + float z = corpse->GetPositionZ(); + int32 corpsemapid = mapid; - WorldPacket data(MSG_CORPSE_QUERY, (1+found*(5*4))); - data << uint8(found); - if(found) + // if corpse at different map + if(mapid != _player->GetMapId()) { - data << corpse->GetMapId(); - data << corpse->GetPositionX(); - data << corpse->GetPositionY(); - data << corpse->GetPositionZ(); - data << _player->GetMapId(); + // search entrance map for proper show entrance + if(MapEntry const* corpseMapEntry = sMapStore.LookupEntry(mapid)) + { + if(corpseMapEntry->IsDungeon() && corpseMapEntry->entrance_map >= 0) + { + // if corpse map have entrance + if(Map const* entranceMap = MapManager::Instance().GetBaseMap(corpseMapEntry->entrance_map)) + { + mapid = corpseMapEntry->entrance_map; + x = corpseMapEntry->entrance_x; + y = corpseMapEntry->entrance_y; + z = entranceMap->GetHeight(x, y, MAX_HEIGHT); + } + } + } } + + WorldPacket data(MSG_CORPSE_QUERY, 1+(5*4)); + data << uint8(1); // corpse found + data << int32(mapid); + data << float(x); + data << float(y); + data << float(z); + data << int32(corpsemapid); SendPacket(&data); } void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,4+8); + CHECK_PACKET_SIZE(recv_data, 4 + 8); uint32 textID; uint64 guid; - GossipText *pGossip; - std::string GossipStr; recv_data >> textID; sLog.outDetail("WORLD: CMSG_NPC_TEXT_QUERY ID '%u'", textID); @@ -308,7 +333,7 @@ void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data ) recv_data >> guid; GetPlayer()->SetUInt64Value(UNIT_FIELD_TARGET, guid); - pGossip = objmgr.GetGossipText(textID); + GossipText const* pGossip = objmgr.GetGossipText(textID); WorldPacket data( SMSG_NPC_TEXT_UPDATE, 100 ); // guess size data << textID; @@ -332,7 +357,7 @@ void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data ) else { std::string Text_0[8], Text_1[8]; - for (int i=0;i<8;i++) + for (int i = 0; i < 8; ++i) { Text_0[i]=pGossip->Options[i].Text_0; Text_1[i]=pGossip->Options[i].Text_1; @@ -344,7 +369,7 @@ void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data ) NpcTextLocale const *nl = objmgr.GetNpcTextLocale(textID); if (nl) { - for (int i=0;i<8;i++) + for (int i = 0; i < 8; ++i) { if (nl->Text_0[i].size() > loc_idx && !nl->Text_0[i][loc_idx].empty()) Text_0[i]=nl->Text_0[i][loc_idx]; @@ -354,7 +379,7 @@ void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data ) } } - for (int i=0; i<8; i++) + for (int i = 0; i < 8; ++i) { data << pGossip->Options[i].Probability; @@ -370,25 +395,22 @@ void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data ) data << pGossip->Options[i].Language; - data << pGossip->Options[i].Emotes[0]._Delay; - data << pGossip->Options[i].Emotes[0]._Emote; - - data << pGossip->Options[i].Emotes[1]._Delay; - data << pGossip->Options[i].Emotes[1]._Emote; - - data << pGossip->Options[i].Emotes[2]._Delay; - data << pGossip->Options[i].Emotes[2]._Emote; + for(int j = 0; j < 3; ++j) + { + data << pGossip->Options[i].Emotes[j]._Delay; + data << pGossip->Options[i].Emotes[j]._Emote; + } } } SendPacket( &data ); - sLog.outDebug( "WORLD: Sent SMSG_NPC_TEXT_UPDATE " ); + sLog.outDebug( "WORLD: Sent SMSG_NPC_TEXT_UPDATE" ); } -void WorldSession::HandlePageQueryOpcode( WorldPacket & recv_data ) +void WorldSession::HandlePageTextQueryOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,4); + CHECK_PACKET_SIZE(recv_data, 4); uint32 pageID; @@ -429,7 +451,7 @@ void WorldSession::HandlePageQueryOpcode( WorldPacket & recv_data ) } SendPacket( &data ); - sLog.outDebug( "WORLD: Sent SMSG_PAGE_TEXT_QUERY_RESPONSE " ); + sLog.outDebug( "WORLD: Sent SMSG_PAGE_TEXT_QUERY_RESPONSE" ); } } |