From 851e15c70ac60f8b5dd967c48561e896bcea9232 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 21 Oct 2010 06:38:24 +0400 Subject: [PATCH] [10635] Convert many opcode handlers to ObjectGuid use. Also re-enabled anticheating check for bank window open base at .bank command access rights. --- src/game/BattleGroundHandler.cpp | 6 +-- src/game/CalendarHandler.cpp | 4 +- src/game/CharacterHandler.cpp | 50 +++++++++--------- src/game/ChatHandler.cpp | 2 +- src/game/DuelHandler.cpp | 13 ++--- src/game/GossipDef.cpp | 26 +++++----- src/game/GossipDef.h | 12 ++--- src/game/GroupHandler.cpp | 10 ++-- src/game/ItemHandler.cpp | 60 ++++++++++++++------- src/game/Level2.cpp | 11 ++-- src/game/Level3.cpp | 8 +-- src/game/LootHandler.cpp | 4 +- src/game/MiscHandler.cpp | 18 +++---- src/game/NPCHandler.cpp | 89 ++++++++++++++------------------ src/game/PetHandler.cpp | 56 +++++++++----------- src/game/PetitionsHandler.cpp | 10 ++-- src/game/Player.cpp | 41 +++++++-------- src/game/Player.h | 26 +++++----- src/game/QueryHandler.cpp | 18 +++---- src/game/QuestHandler.cpp | 88 +++++++++++++++---------------- src/game/SkillHandler.cpp | 10 ++-- src/game/SpellEffects.cpp | 4 +- src/game/SpellHandler.cpp | 22 ++++---- src/game/TaxiHandler.cpp | 39 +++++++------- src/game/WorldSession.h | 19 +++---- src/shared/revision_nr.h | 2 +- 26 files changed, 322 insertions(+), 326 deletions(-) diff --git a/src/game/BattleGroundHandler.cpp b/src/game/BattleGroundHandler.cpp index 79940001a..6f5b2c808 100644 --- a/src/game/BattleGroundHandler.cpp +++ b/src/game/BattleGroundHandler.cpp @@ -562,7 +562,7 @@ void WorldSession::HandleAreaSpiritHealerQueryOpcode( WorldPacket & recv_data ) if (!bg) return; - uint64 guid; + ObjectGuid guid; recv_data >> guid; Creature *unit = GetPlayer()->GetMap()->GetCreature(guid); @@ -583,7 +583,7 @@ void WorldSession::HandleAreaSpiritHealerQueueOpcode( WorldPacket & recv_data ) if (!bg) return; - uint64 guid; + ObjectGuid guid; recv_data >> guid; Creature *unit = GetPlayer()->GetMap()->GetCreature(guid); @@ -601,7 +601,7 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data ) DEBUG_LOG("WORLD: CMSG_BATTLEMASTER_JOIN_ARENA"); //recv_data.hexlike(); - uint64 guid; // arena Battlemaster guid + ObjectGuid guid; // arena Battlemaster guid uint8 arenaslot; // 2v2, 3v3 or 5v5 uint8 asGroup; // asGroup uint8 isRated; // isRated diff --git a/src/game/CalendarHandler.cpp b/src/game/CalendarHandler.cpp index 9e26d5e3c..9c82b96c6 100644 --- a/src/game/CalendarHandler.cpp +++ b/src/game/CalendarHandler.cpp @@ -117,10 +117,10 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket &recv_data) // if (count) // { // uint8 unk12,unk13; - // uint64 guid; + // ObjectGuid guid; // for (int i=0;i> guid.ReadAsPacked(); // recv_data >> (uint8)unk12; // recv_data >> (uint8)unk13; // } diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index f22cc4f07..08bf61e02 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -880,7 +880,7 @@ void WorldSession::HandleShowingCloakOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleCharRenameOpcode(WorldPacket& recv_data) { - uint64 guid; + ObjectGuid guid; std::string newname; recv_data >> guid; @@ -921,7 +921,7 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recv_data) CharacterDatabase.AsyncPQuery(&WorldSession::HandleChangePlayerNameOpcodeCallBack, GetAccountId(), newname, "SELECT guid, name FROM characters WHERE guid = %d AND account = %d AND (at_login & %d) = %d AND NOT EXISTS (SELECT NULL FROM characters WHERE name = '%s')", - GUID_LOPART(guid), GetAccountId(), AT_LOGIN_RENAME, AT_LOGIN_RENAME, escaped_newname.c_str() + guid.GetCounter(), GetAccountId(), AT_LOGIN_RENAME, AT_LOGIN_RENAME, escaped_newname.c_str() ); } @@ -962,7 +962,7 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult *result, uin void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data) { - uint64 guid; + ObjectGuid guid; recv_data >> guid; @@ -972,7 +972,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data) { WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); data << uint32(1); - data << uint64(guid); + data << ObjectGuid(guid); SendPacket(&data); return; } @@ -982,7 +982,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data) { WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); data << uint32(1); - data << uint64(guid); + data << ObjectGuid(guid); SendPacket(&data); return; } @@ -991,7 +991,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data) { WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); data << uint32(1); - data << uint64(guid); + data << ObjectGuid(guid); SendPacket(&data); return; } @@ -1005,7 +1005,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data) { WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); data << uint32(1); - data << uint64(guid); + data << ObjectGuid(guid); SendPacket(&data); return; } @@ -1017,7 +1017,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data) { WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); data << uint32(1); - data << uint64(guid); + data << ObjectGuid(guid); SendPacket(&data); return; } @@ -1027,7 +1027,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data) { WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); data << uint32(1); - data << uint64(guid); + data << ObjectGuid(guid); SendPacket(&data); return; } @@ -1036,14 +1036,14 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data) CharacterDatabase.escape_string(declinedname.name[i]); CharacterDatabase.BeginTransaction(); - CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid = '%u'", GUID_LOPART(guid)); + CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid = '%u'", guid.GetCounter()); CharacterDatabase.PExecute("INSERT INTO character_declinedname (guid, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u','%s','%s','%s','%s','%s')", - GUID_LOPART(guid), declinedname.name[0].c_str(), declinedname.name[1].c_str(), declinedname.name[2].c_str(), declinedname.name[3].c_str(), declinedname.name[4].c_str()); + guid.GetCounter(), declinedname.name[0].c_str(), declinedname.name[1].c_str(), declinedname.name[2].c_str(), declinedname.name[3].c_str(), declinedname.name[4].c_str()); CharacterDatabase.CommitTransaction(); WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); data << uint32(0); // OK - data << uint64(guid); + data << ObjectGuid(guid); SendPacket(&data); } @@ -1116,7 +1116,7 @@ void WorldSession::HandleRemoveGlyphOpcode( WorldPacket & recv_data ) void WorldSession::HandleCharCustomizeOpcode(WorldPacket& recv_data) { - uint64 guid; + ObjectGuid guid; std::string newname; recv_data >> guid; @@ -1125,7 +1125,7 @@ void WorldSession::HandleCharCustomizeOpcode(WorldPacket& recv_data) uint8 gender, skin, face, hairStyle, hairColor, facialHair; recv_data >> gender >> skin >> hairColor >> hairStyle >> facialHair >> face; - QueryResult *result = CharacterDatabase.PQuery("SELECT at_login FROM characters WHERE guid ='%u'", GUID_LOPART(guid)); + QueryResult *result = CharacterDatabase.PQuery("SELECT at_login FROM characters WHERE guid ='%u'", guid.GetCounter()); if (!result) { WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1); @@ -1174,28 +1174,26 @@ void WorldSession::HandleCharCustomizeOpcode(WorldPacket& recv_data) } // character with this name already exist - if (uint64 newguid = sObjectMgr.GetPlayerGUIDByName(newname)) + ObjectGuid newguid = sObjectMgr.GetPlayerGUIDByName(newname); + if (!newguid.IsEmpty() && newguid != guid) { - if (newguid != guid) - { - WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1); - data << uint8(CHAR_CREATE_NAME_IN_USE); - SendPacket( &data ); - return; - } + WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1); + data << uint8(CHAR_CREATE_NAME_IN_USE); + SendPacket(&data); + return; } CharacterDatabase.escape_string(newname); Player::Customize(guid, gender, skin, face, hairStyle, hairColor, facialHair); - CharacterDatabase.PExecute("UPDATE characters set name = '%s', at_login = at_login & ~ %u WHERE guid ='%u'", newname.c_str(), uint32(AT_LOGIN_CUSTOMIZE), GUID_LOPART(guid)); - CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid ='%u'", GUID_LOPART(guid)); + CharacterDatabase.PExecute("UPDATE characters set name = '%s', at_login = at_login & ~ %u WHERE guid ='%u'", newname.c_str(), uint32(AT_LOGIN_CUSTOMIZE), guid.GetCounter()); + CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid ='%u'", guid.GetCounter()); std::string IP_str = GetRemoteAddress(); - sLog.outChar("Account: %d (IP: %s), Character guid: %u Customized to: %s", GetAccountId(), IP_str.c_str(), GUID_LOPART(guid), newname.c_str()); + sLog.outChar("Account: %d (IP: %s), Character %s customized to: %s", GetAccountId(), IP_str.c_str(), guid.GetString().c_str(), newname.c_str()); WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1+8+(newname.size()+1)+6); data << uint8(RESPONSE_SUCCESS); - data << uint64(guid); + data << ObjectGuid(guid); data << newname; data << uint8(gender); data << uint8(skin); diff --git a/src/game/ChatHandler.cpp b/src/game/ChatHandler.cpp index fbc23b0e9..2f03ca07c 100644 --- a/src/game/ChatHandler.cpp +++ b/src/game/ChatHandler.cpp @@ -552,7 +552,7 @@ void WorldSession::HandleTextEmoteOpcode( WorldPacket & recv_data ) } uint32 text_emote, emoteNum; - uint64 guid; + ObjectGuid guid; recv_data >> text_emote; recv_data >> emoteNum; diff --git a/src/game/DuelHandler.cpp b/src/game/DuelHandler.cpp index d94a9a52d..d03d0558f 100644 --- a/src/game/DuelHandler.cpp +++ b/src/game/DuelHandler.cpp @@ -26,17 +26,14 @@ void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket) { - uint64 guid; - Player *pl; - Player *plTarget; + ObjectGuid guid; + recvPacket >> guid; if(!GetPlayer()->duel) // ignore accept from duel-sender return; - recvPacket >> guid; - - pl = GetPlayer(); - plTarget = pl->duel->opponent; + Player *pl = GetPlayer(); + Player *plTarget = pl->duel->opponent; if(pl == pl->duel->initiator || !plTarget || pl == plTarget || pl->duel->startTime != 0 || plTarget->duel->startTime != 0) return; @@ -75,7 +72,7 @@ void WorldSession::HandleDuelCancelledOpcode(WorldPacket& recvPacket) // player either discarded the duel using the "discard button" // or used "/forfeit" before countdown reached 0 - uint64 guid; + ObjectGuid guid; recvPacket >> guid; GetPlayer()->DuelComplete(DUEL_INTERUPTED); diff --git a/src/game/GossipDef.cpp b/src/game/GossipDef.cpp index b8a934635..06ac32a2e 100644 --- a/src/game/GossipDef.cpp +++ b/src/game/GossipDef.cpp @@ -386,10 +386,10 @@ void QuestMenu::ClearMenu() m_qItems.clear(); } -void PlayerMenu::SendQuestGiverQuestList( QEmote eEmote, const std::string& Title, uint64 npcGUID ) +void PlayerMenu::SendQuestGiverQuestList(QEmote eEmote, const std::string& Title, ObjectGuid npcGUID) { WorldPacket data( SMSG_QUESTGIVER_QUEST_LIST, 100 ); // guess size - data << uint64(npcGUID); + data << ObjectGuid(npcGUID); data << Title; data << uint32(eEmote._Delay ); // player emote data << uint32(eEmote._Emote ); // NPC emote @@ -427,7 +427,7 @@ void PlayerMenu::SendQuestGiverQuestList( QEmote eEmote, const std::string& Titl } data.put(count_pos, count); GetMenuSession()->SendPacket( &data ); - DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC Guid=%u", GUID_LOPART(npcGUID)); + DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC Guid = %s", npcGUID.GetString().c_str()); } void PlayerMenu::SendQuestGiverStatus( uint8 questStatus, ObjectGuid npcGUID ) @@ -440,7 +440,7 @@ void PlayerMenu::SendQuestGiverStatus( uint8 questStatus, ObjectGuid npcGUID ) DEBUG_LOG( "WORLD: Sent SMSG_QUESTGIVER_STATUS for %s", npcGUID.GetString().c_str()); } -void PlayerMenu::SendQuestGiverQuestDetails( Quest const *pQuest, uint64 npcGUID, bool ActivateAccept ) +void PlayerMenu::SendQuestGiverQuestDetails(Quest const *pQuest, ObjectGuid npcGUID, bool ActivateAccept) { std::string Title = pQuest->GetTitle(); std::string Details = pQuest->GetDetails(); @@ -461,7 +461,7 @@ void PlayerMenu::SendQuestGiverQuestDetails( Quest const *pQuest, uint64 npcGUID } WorldPacket data(SMSG_QUESTGIVER_QUEST_DETAILS, 100); // guess size - data << uint64(npcGUID); + data << ObjectGuid(npcGUID); data << uint64(0); // wotlk, something todo with quest sharing? data << uint32(pQuest->GetQuestId()); data << Title; @@ -559,7 +559,7 @@ void PlayerMenu::SendQuestGiverQuestDetails( Quest const *pQuest, uint64 npcGUID GetMenuSession()->SendPacket( &data ); - DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), pQuest->GetQuestId()); + DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS NPCGuid = %s, questid = %u", npcGUID.GetString().c_str(), pQuest->GetQuestId()); } // send only static data in this packet! @@ -712,7 +712,7 @@ void PlayerMenu::SendQuestQueryResponse( Quest const *pQuest ) DEBUG_LOG( "WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid=%u", pQuest->GetQuestId() ); } -void PlayerMenu::SendQuestGiverOfferReward( Quest const* pQuest, uint64 npcGUID, bool EnableNext ) +void PlayerMenu::SendQuestGiverOfferReward(Quest const* pQuest, ObjectGuid npcGUID, bool EnableNext) { std::string Title = pQuest->GetTitle(); std::string OfferRewardText = pQuest->GetOfferRewardText(); @@ -731,7 +731,7 @@ void PlayerMenu::SendQuestGiverOfferReward( Quest const* pQuest, uint64 npcGUID, WorldPacket data( SMSG_QUESTGIVER_OFFER_REWARD, 50 ); // guess size - data << uint64(npcGUID); + data << ObjectGuid(npcGUID); data << uint32(pQuest->GetQuestId()); data << Title; data << OfferRewardText; @@ -815,11 +815,11 @@ void PlayerMenu::SendQuestGiverOfferReward( Quest const* pQuest, uint64 npcGUID, data << int32(0); //data << int32(pQuest->RewRepValue[i]); - GetMenuSession()->SendPacket( &data ); - DEBUG_LOG( "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), pQuest->GetQuestId() ); + GetMenuSession()->SendPacket(&data); + DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid = %s, questid = %u", npcGUID.GetString().c_str(), pQuest->GetQuestId()); } -void PlayerMenu::SendQuestGiverRequestItems( Quest const *pQuest, uint64 npcGUID, bool Completable, bool CloseOnCancel ) +void PlayerMenu::SendQuestGiverRequestItems(Quest const *pQuest, ObjectGuid npcGUID, bool Completable, bool CloseOnCancel) { // We can always call to RequestItems, but this packet only goes out if there are actually // items. Otherwise, we'll skip straight to the OfferReward @@ -846,7 +846,7 @@ void PlayerMenu::SendQuestGiverRequestItems( Quest const *pQuest, uint64 npcGUID } WorldPacket data( SMSG_QUESTGIVER_REQUEST_ITEMS, 50 ); // guess size - data << uint64(npcGUID); + data << ObjectGuid(npcGUID); data << uint32(pQuest->GetQuestId()); data << Title; data << RequestItemsText; @@ -896,5 +896,5 @@ void PlayerMenu::SendQuestGiverRequestItems( Quest const *pQuest, uint64 npcGUID data << uint32(0x10); // flags4 GetMenuSession()->SendPacket( &data ); - DEBUG_LOG( "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), pQuest->GetQuestId() ); + DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid = %s, questid = %u", npcGUID.GetString().c_str(), pQuest->GetQuestId()); } diff --git a/src/game/GossipDef.h b/src/game/GossipDef.h index 391ccb9df..e49830b07 100644 --- a/src/game/GossipDef.h +++ b/src/game/GossipDef.h @@ -274,14 +274,14 @@ class MANGOS_DLL_SPEC PlayerMenu /*********************************************************/ /*** QUEST SYSTEM ***/ /*********************************************************/ - void SendQuestGiverStatus( uint8 questStatus, ObjectGuid npcGUID ); + void SendQuestGiverStatus(uint8 questStatus, ObjectGuid npcGUID); - void SendQuestGiverQuestList( QEmote eEmote, const std::string& Title, uint64 npcGUID ); + void SendQuestGiverQuestList(QEmote eEmote, const std::string& Title, ObjectGuid npcGUID); - void SendQuestQueryResponse ( Quest const *pQuest ); - void SendQuestGiverQuestDetails( Quest const *pQuest, uint64 npcGUID, bool ActivateAccept); + void SendQuestQueryResponse(Quest const *pQuest); + void SendQuestGiverQuestDetails(Quest const *pQuest, ObjectGuid npcGUID, bool ActivateAccept); - void SendQuestGiverOfferReward( Quest const* pQuest, uint64 npcGUID, bool EnbleNext ); - void SendQuestGiverRequestItems( Quest const *pQuest, uint64 npcGUID, bool Completable, bool CloseOnCancel ); + void SendQuestGiverOfferReward(Quest const* pQuest, ObjectGuid npcGUID, bool EnbleNext); + void SendQuestGiverRequestItems(Quest const *pQuest, ObjectGuid npcGUID, bool Completable, bool CloseOnCancel); }; #endif diff --git a/src/game/GroupHandler.cpp b/src/game/GroupHandler.cpp index a8ef69542..e541595f4 100644 --- a/src/game/GroupHandler.cpp +++ b/src/game/GroupHandler.cpp @@ -282,7 +282,7 @@ void WorldSession::HandleGroupUninviteOpcode(WorldPacket & recv_data) // can't uninvite yourself if (GetPlayer()->GetName() == membername) { - sLog.outError("WorldSession::HandleGroupUninviteOpcode: leader %s tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetObjectGuid().GetString().c_str()); + sLog.outError("WorldSession::HandleGroupUninviteOpcode: leader %s tried to uninvite himself from the group.", GetPlayer()->GetObjectGuid().GetString().c_str()); return; } @@ -803,15 +803,15 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacke void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data ) { DEBUG_LOG("WORLD: Received CMSG_REQUEST_PARTY_MEMBER_STATS"); - uint64 Guid; - recv_data >> Guid; + ObjectGuid guid; + recv_data >> guid; - Player *player = sObjectMgr.GetPlayer(Guid); + Player *player = sObjectMgr.GetPlayer(guid); if(!player) { WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 3+4+2); data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related - data.appendPackGUID(Guid); + data << guid.WriteAsPacked(); data << uint32(GROUP_UPDATE_FLAG_STATUS); data << uint16(MEMBER_STATUS_OFFLINE); SendPacket(&data); diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp index 643924727..08b338646 100644 --- a/src/game/ItemHandler.cpp +++ b/src/game/ItemHandler.cpp @@ -25,6 +25,7 @@ #include "Player.h" #include "Item.h" #include "UpdateData.h" +#include "Chat.h" void WorldSession::HandleSplitItemOpcode( WorldPacket & recv_data ) { @@ -481,7 +482,7 @@ void WorldSession::HandlePageQuerySkippedOpcode( WorldPacket & recv_data ) recv_data >> itemid >> guid; - DETAIL_LOG( "Packet Info: itemid: %u guid: %s", itemid, guid.GetString().c_str()); + DETAIL_LOG("Packet Info: itemid: %u guid: %s", itemid, guid.GetString().c_str()); } void WorldSession::HandleSellItemOpcode( WorldPacket & recv_data ) @@ -707,19 +708,19 @@ void WorldSession::HandleBuyItemOpcode( WorldPacket & recv_data ) void WorldSession::HandleListInventoryOpcode( WorldPacket & recv_data ) { - uint64 guid; + ObjectGuid guid; recv_data >> guid; - if(!GetPlayer()->isAlive()) + if (!GetPlayer()->isAlive()) return; - DEBUG_LOG( "WORLD: Recvd CMSG_LIST_INVENTORY" ); + DEBUG_LOG("WORLD: Recvd CMSG_LIST_INVENTORY"); SendListInventory( guid ); } -void WorldSession::SendListInventory(uint64 vendorguid) +void WorldSession::SendListInventory(ObjectGuid vendorguid) { DEBUG_LOG("WORLD: Sent SMSG_LIST_INVENTORY"); @@ -727,7 +728,7 @@ void WorldSession::SendListInventory(uint64 vendorguid) if (!pCreature) { - DEBUG_LOG("WORLD: SendListInventory - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(vendorguid))); + DEBUG_LOG("WORLD: SendListInventory - %s not found or you can't interact with him.", vendorguid.GetString().c_str()); _player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, NULL, 0, 0); return; } @@ -745,7 +746,7 @@ void WorldSession::SendListInventory(uint64 vendorguid) if (!vItems) { WorldPacket data( SMSG_LIST_INVENTORY, (8+1+1) ); - data << uint64(vendorguid); + data << ObjectGuid(vendorguid); data << uint8(0); // count==0, next will be error code data << uint8(0); // "Vendor has no inventory" SendPacket(&data); @@ -756,7 +757,7 @@ void WorldSession::SendListInventory(uint64 vendorguid) uint8 count = 0; WorldPacket data( SMSG_LIST_INVENTORY, (8+1+numitems*8*4) ); - data << uint64(vendorguid); + data << ObjectGuid(vendorguid); size_t count_pos = data.wpos(); data << uint8(count); // placeholder, client limit 150 items (as of 3.3.3) @@ -865,22 +866,41 @@ void WorldSession::HandleAutoStoreBagItemOpcode( WorldPacket & recv_data ) _player->StoreItem( dest, pItem, true ); } + +bool WorldSession::CheckBanker(ObjectGuid guid) +{ + // GM case + if (guid == GetPlayer()->GetObjectGuid()) + { + // command case will return only if player have real access to command + if (!ChatHandler(GetPlayer()).FindCommand("bank")) + { + DEBUG_LOG("%s attempt open bank in cheating way.", guid.GetString().c_str()); + return false; + } + } + // banker case + else + { + if (!GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_BANKER)) + { + DEBUG_LOG("Banker %s not found or you can't interact with him.", guid.GetString().c_str()); + return false; + } + } + + return true; +} + void WorldSession::HandleBuyBankSlotOpcode(WorldPacket& recvPacket) { DEBUG_LOG("WORLD: CMSG_BUY_BANK_SLOT"); - uint64 guid; + ObjectGuid guid; recvPacket >> guid; - // cheating protection - /* not critical if "cheated", and check skip allow by slots in bank windows open by .bank command. - Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_BANKER); - if(!pCreature) - { - DEBUG_LOG( "WORLD: HandleBuyBankSlotOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + if (!CheckBanker(guid)) return; - } - */ uint32 slot = _player->GetBankBagSlotCount(); @@ -1407,10 +1427,10 @@ void WorldSession::HandleItemRefundInfoRequest(WorldPacket& recv_data) { DEBUG_LOG("WORLD: CMSG_ITEM_REFUND_INFO_REQUEST"); - uint64 guid; - recv_data >> guid; // item guid + ObjectGuid itemGuid; + recv_data >> itemGuid; - Item *item = _player->GetItemByGuid(guid); + Item *item = _player->GetItemByGuid(itemGuid); if(!item) { diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 0a8c229c2..30416c99f 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -2310,9 +2310,8 @@ bool ChatHandler::HandleNpcNameCommand(char* /*args*/) } } - uint64 guid; - guid = m_session->GetPlayer()->GetSelection(); - if (guid == 0) + ObjectGuid guid = m_session->GetPlayer()->GetSelectionGuid(); + if (guid.IsEmpty()) { SendSysMessage(LANG_NO_SELECTION); return true; @@ -2358,9 +2357,9 @@ bool ChatHandler::HandleNpcSubNameCommand(char* /*args*/) return false; } } - uint64 guid; - guid = m_session->GetPlayer()->GetSelection(); - if (guid == 0) + + ObjectGuid guid = m_session->GetPlayer()->GetSelectionGuid(); + if (guid.IsEmpty()) { SendSysMessage(LANG_NO_SELECTION); return true; diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 5d051483a..d8d30e24e 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -4094,8 +4094,8 @@ bool ChatHandler::HandleNpcAddWeaponCommand(char* /*args*/) /*if (!*args) return false; - uint64 guid = m_session->GetPlayer()->GetSelection(); - if (guid == 0) + ObjectGuid guid = m_session->GetPlayer()->GetSelectionGuid(); + if (guid.IsEmpty()) { SendSysMessage(LANG_NO_SELECTION); return true; @@ -4428,14 +4428,14 @@ bool ChatHandler::HandleAuctionCommand(char* /*args*/) bool ChatHandler::HandleBankCommand(char* /*args*/) { - m_session->SendShowBank( m_session->GetPlayer()->GetGUID() ); + m_session->SendShowBank(m_session->GetPlayer()->GetObjectGuid()); return true; } bool ChatHandler::HandleStableCommand(char* /*args*/) { - m_session->SendStablePet(m_session->GetPlayer()->GetGUID()); + m_session->SendStablePet(m_session->GetPlayer()->GetObjectGuid()); return true; } diff --git a/src/game/LootHandler.cpp b/src/game/LootHandler.cpp index 0d96249c7..cae50ce96 100644 --- a/src/game/LootHandler.cpp +++ b/src/game/LootHandler.cpp @@ -264,11 +264,11 @@ void WorldSession::HandleLootOpcode( WorldPacket & recv_data ) { DEBUG_LOG("WORLD: CMSG_LOOT"); - uint64 guid; + ObjectGuid guid; recv_data >> guid; // Check possible cheat - if(!_player->isAlive()) + if (!_player->isAlive()) return; GetPlayer()->SendLoot(guid, LOOT_CORPSE); diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index b414d01ca..e5a7b9a89 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -587,10 +587,10 @@ void WorldSession::HandleDelIgnoreOpcode( WorldPacket & recv_data ) void WorldSession::HandleSetContactNotesOpcode( WorldPacket & recv_data ) { DEBUG_LOG("CMSG_SET_CONTACT_NOTES"); - uint64 guid; + ObjectGuid guid; std::string note; recv_data >> guid >> note; - _player->GetSocial()->SetFriendNote(GUID_LOPART(guid), note); + _player->GetSocial()->SetFriendNote(guid.GetCounter(), note); } void WorldSession::HandleBugOpcode( WorldPacket & recv_data ) @@ -619,7 +619,7 @@ void WorldSession::HandleReclaimCorpseOpcode(WorldPacket &recv_data) { DETAIL_LOG("WORLD: Received CMSG_RECLAIM_CORPSE"); - uint64 guid; + ObjectGuid guid; recv_data >> guid; if (GetPlayer()->isAlive()) @@ -656,7 +656,7 @@ void WorldSession::HandleResurrectResponseOpcode(WorldPacket & recv_data) { DETAIL_LOG("WORLD: Received CMSG_RESURRECT_RESPONSE"); - uint64 guid; + ObjectGuid guid; uint8 status; recv_data >> guid; recv_data >> status; @@ -965,7 +965,7 @@ void WorldSession::HandleMoveTimeSkippedOpcode( WorldPacket & recv_data ) recv_data >> Unused(); /* - uint64 guid; + ObjectGuid guid; uint32 time_skipped; recv_data >> guid; recv_data >> time_skipped; @@ -992,7 +992,7 @@ void WorldSession::HandleMoveUnRootAck(WorldPacket& recv_data) // no used recv_data.rpos(recv_data.wpos()); // prevent warnings spam /* - uint64 guid; + ObjectGuid guid; recv_data >> guid; // now can skip not our packet @@ -1016,11 +1016,11 @@ void WorldSession::HandleMoveRootAck(WorldPacket& recv_data) // no used recv_data.rpos(recv_data.wpos()); // prevent warnings spam /* - uint64 guid; + ObjectGuid guid; recv_data >> guid; // now can skip not our packet - if(_player->GetGUID() != guid) + if(_player->GetObjectGuid() != guid) { recv_data.rpos(recv_data.wpos()); // prevent warnings spam return; @@ -1106,7 +1106,7 @@ void WorldSession::HandleInspectOpcode(WorldPacket& recv_data) void WorldSession::HandleInspectHonorStatsOpcode(WorldPacket& recv_data) { - uint64 guid; + ObjectGuid guid; recv_data >> guid; Player *player = sObjectMgr.GetPlayer(guid); diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp index e583172f3..933d9fe5c 100644 --- a/src/game/NPCHandler.cpp +++ b/src/game/NPCHandler.cpp @@ -47,13 +47,13 @@ enum StableResultCode void WorldSession::HandleTabardVendorActivateOpcode( WorldPacket & recv_data ) { - uint64 guid; + ObjectGuid guid; recv_data >> guid; - Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_TABARDDESIGNER); + Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TABARDDESIGNER); if (!unit) { - DEBUG_LOG( "WORLD: HandleTabardVendorActivateOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + DEBUG_LOG("WORLD: HandleTabardVendorActivateOpcode - %s not found or you can't interact with him.", guid.GetString().c_str()); return; } @@ -64,27 +64,23 @@ void WorldSession::HandleTabardVendorActivateOpcode( WorldPacket & recv_data ) SendTabardVendorActivate(guid); } -void WorldSession::SendTabardVendorActivate( uint64 guid ) +void WorldSession::SendTabardVendorActivate(ObjectGuid guid) { WorldPacket data( MSG_TABARDVENDOR_ACTIVATE, 8 ); - data << guid; - SendPacket( &data ); + data << ObjectGuid(guid); + SendPacket(&data); } void WorldSession::HandleBankerActivateOpcode( WorldPacket & recv_data ) { - uint64 guid; + ObjectGuid guid; - DEBUG_LOG( "WORLD: Received CMSG_BANKER_ACTIVATE" ); + DEBUG_LOG("WORLD: Received CMSG_BANKER_ACTIVATE"); recv_data >> guid; - Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_BANKER); - if (!unit) - { - DEBUG_LOG( "WORLD: HandleBankerActivateOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + if (!CheckBanker(guid)) return; - } // remove fake death if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) @@ -93,64 +89,60 @@ void WorldSession::HandleBankerActivateOpcode( WorldPacket & recv_data ) SendShowBank(guid); } -void WorldSession::SendShowBank( uint64 guid ) +void WorldSession::SendShowBank(ObjectGuid guid) { - WorldPacket data( SMSG_SHOW_BANK, 8 ); - data << guid; - SendPacket( &data ); + WorldPacket data(SMSG_SHOW_BANK, 8); + data << ObjectGuid(guid); + SendPacket(&data); } void WorldSession::HandleTrainerListOpcode( WorldPacket & recv_data ) { - uint64 guid; + ObjectGuid guid; recv_data >> guid; - SendTrainerList( guid ); + + SendTrainerList(guid); } -void WorldSession::SendTrainerList( uint64 guid ) +void WorldSession::SendTrainerList(ObjectGuid guid) { std::string str = GetMangosString(LANG_NPC_TAINER_HELLO); - SendTrainerList( guid, str ); + SendTrainerList(guid, str); } -void WorldSession::SendTrainerList( uint64 guid, const std::string& strTitle ) +void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle) { DEBUG_LOG( "WORLD: SendTrainerList" ); Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_TRAINER); if (!unit) { - DEBUG_LOG( "WORLD: SendTrainerList - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + DEBUG_LOG("WORLD: SendTrainerList - %s not found or you can't interact with him.", guid.GetString().c_str()); return; } // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); // trainer list loaded at check; - if(!unit->IsTrainerOf(_player,true)) + if (!unit->IsTrainerOf(_player,true)) return; CreatureInfo const *ci = unit->GetCreatureInfo(); - if (!ci) - { - DEBUG_LOG( "WORLD: SendTrainerList - (GUID: %u) NO CREATUREINFO!",GUID_LOPART(guid) ); return; - } TrainerSpellData const* trainer_spells = unit->GetTrainerSpells(); - if(!trainer_spells) + if (!trainer_spells) { - DEBUG_LOG( "WORLD: SendTrainerList - Training spells not found for creature (GUID: %u Entry: %u)", - GUID_LOPART(guid), unit->GetEntry()); + DEBUG_LOG("WORLD: SendTrainerList - Training spells not found for %s", guid.GetString().c_str()); return; } WorldPacket data( SMSG_TRAINER_LIST, 8+4+4+trainer_spells->spellList.size()*38 + strTitle.size()+1); - data << uint64(guid); + data << ObjectGuid(guid); data << uint32(trainer_spells->trainerType); size_t count_pos = data.wpos(); @@ -197,38 +189,38 @@ void WorldSession::SendTrainerList( uint64 guid, const std::string& strTitle ) void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data ) { - uint64 guid; + ObjectGuid guid; uint32 spellId = 0; recv_data >> guid >> spellId; - DEBUG_LOG( "WORLD: Received CMSG_TRAINER_BUY_SPELL NpcGUID=%u, learn spell id is: %u",uint32(GUID_LOPART(guid)), spellId ); + DEBUG_LOG("WORLD: Received CMSG_TRAINER_BUY_SPELL Trainer: %s, learn spell id is: %u", guid.GetString().c_str(), spellId); Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TRAINER); if (!unit) { - DEBUG_LOG( "WORLD: HandleTrainerBuySpellOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + DEBUG_LOG("WORLD: HandleTrainerBuySpellOpcode - %s not found or you can't interact with him.", guid.GetString().c_str()); return; } // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - if(!unit->IsTrainerOf(_player,true)) + if (!unit->IsTrainerOf(_player, true)) return; // check present spell in trainer spell list TrainerSpellData const* trainer_spells = unit->GetTrainerSpells(); - if(!trainer_spells) + if (!trainer_spells) return; // not found, cheat? TrainerSpell const* trainer_spell = trainer_spells->Find(spellId); - if(!trainer_spell) + if (!trainer_spell) return; // can't be learn, cheat? Or double learn with lags... - if(_player->GetTrainerSpellState(trainer_spell) != TRAINER_SPELL_GREEN) + if (_player->GetTrainerSpellState(trainer_spell) != TRAINER_SPELL_GREEN) return; // apply reputation discount @@ -241,7 +233,7 @@ void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data ) _player->ModifyMoney( -int32(nSpellCost) ); WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 12); // visual effect on trainer - data << uint64(guid); + data << ObjectGuid(guid); data << uint32(0xB3); // index from SpellVisualKit.dbc SendPacket(&data); @@ -257,7 +249,7 @@ void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data ) _player->learnSpell(spellId, false); data.Initialize(SMSG_TRAINER_BUY_SUCCEEDED, 12); - data << uint64(guid); + data << ObjectGuid(guid); data << uint32(spellId); // should be same as in packet from client SendPacket(&data); } @@ -266,14 +258,13 @@ void WorldSession::HandleGossipHelloOpcode(WorldPacket & recv_data) { DEBUG_LOG("WORLD: Received CMSG_GOSSIP_HELLO"); - uint64 guid; + ObjectGuid guid; recv_data >> guid; Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); - if (!pCreature) { - DEBUG_LOG("WORLD: HandleGossipHelloOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid))); + DEBUG_LOG("WORLD: HandleGossipHelloOpcode - %s not found or you can't interact with him.", guid.GetString().c_str()); return; } @@ -364,19 +355,19 @@ void WorldSession::HandleSpiritHealerActivateOpcode( WorldPacket & recv_data ) { DEBUG_LOG("WORLD: CMSG_SPIRIT_HEALER_ACTIVATE"); - uint64 guid; + ObjectGuid guid; recv_data >> guid; Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_SPIRITHEALER); if (!unit) { - DEBUG_LOG( "WORLD: HandleSpiritHealerActivateOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + DEBUG_LOG( "WORLD: HandleSpiritHealerActivateOpcode - %s not found or you can't interact with him.", guid.GetString().c_str()); return; } // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); SendSpiritResurrect(); diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index 61c6be4c8..83602cf73 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -525,11 +525,12 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data ) void WorldSession::HandlePetAbandon( WorldPacket & recv_data ) { - uint64 guid; + ObjectGuid guid; recv_data >> guid; //pet guid - DETAIL_LOG( "HandlePetAbandon. CMSG_PET_ABANDON pet guid is %u", GUID_LOPART(guid) ); - if(!_player->IsInWorld()) + DETAIL_LOG("HandlePetAbandon. CMSG_PET_ABANDON pet guid is %s", guid.GetString().c_str()); + + if (!_player->IsInWorld()) return; // pet/charmed @@ -555,24 +556,24 @@ void WorldSession::HandlePetAbandon( WorldPacket & recv_data ) void WorldSession::HandlePetUnlearnOpcode(WorldPacket& recvPacket) { DETAIL_LOG("CMSG_PET_UNLEARN"); - uint64 guid; + ObjectGuid guid; recvPacket >> guid; // Pet guid Pet* pet = _player->GetPet(); - if(!pet || pet->getPetType() != HUNTER_PET || pet->m_usedTalentCount == 0) - return; - - if(guid != pet->GetGUID()) + if (!pet || guid != pet->GetObjectGuid()) { - sLog.outError( "HandlePetUnlearnOpcode.Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() ); + sLog.outError("HandlePetUnlearnOpcode. %s isn't pet of %s .", guid.GetString().c_str(), GetPlayer()->GetObjectGuid().GetString().c_str()); return; } + if (pet->getPetType() != HUNTER_PET || pet->m_usedTalentCount == 0) + return; + CharmInfo *charmInfo = pet->GetCharmInfo(); - if(!charmInfo) + if (!charmInfo) { - sLog.outError("WorldSession::HandlePetUnlearnOpcode: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId()); + sLog.outError("WorldSession::HandlePetUnlearnOpcode: %s is considered pet-like but doesn't have a charminfo!", pet->GetObjectGuid().GetString().c_str()); return; } pet->resetTalents(); @@ -582,34 +583,30 @@ void WorldSession::HandlePetUnlearnOpcode(WorldPacket& recvPacket) void WorldSession::HandlePetSpellAutocastOpcode( WorldPacket& recvPacket ) { DETAIL_LOG("CMSG_PET_SPELL_AUTOCAST"); - uint64 guid; + ObjectGuid guid; uint32 spellid; uint8 state; //1 for on, 0 for off recvPacket >> guid >> spellid >> state; - if(!_player->GetPet() && !_player->GetCharm()) - return; - Creature* pet = _player->GetMap()->GetAnyTypeCreature(guid); - - if(!pet || (pet != _player->GetPet() && pet != _player->GetCharm())) + if (!pet || (guid.GetRawValue() != _player->GetPetGUID() && guid.GetRawValue() != _player->GetCharmGUID())) { - sLog.outError( "HandlePetSpellAutocastOpcode.Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() ); + sLog.outError("HandlePetSpellAutocastOpcode. %s isn't pet of %s .", guid.GetString().c_str(), GetPlayer()->GetObjectGuid().GetString().c_str()); return; } // do not add not learned spells/ passive spells - if(!pet->HasSpell(spellid) || IsPassiveSpell(spellid)) + if (!pet->HasSpell(spellid) || IsPassiveSpell(spellid)) return; CharmInfo *charmInfo = pet->GetCharmInfo(); - if(!charmInfo) + if (!charmInfo) { - sLog.outError("WorldSession::HandlePetSpellAutocastOpcod: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId()); + sLog.outError("WorldSession::HandlePetSpellAutocastOpcod: %s is considered pet-like but doesn't have a charminfo!", guid.GetString().c_str()); return; } - if(pet->isCharmed()) + if (pet->isCharmed()) //state can be used as boolean pet->GetCharmInfo()->ToggleCreatureAutocast(spellid, state); else @@ -622,23 +619,20 @@ void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket ) { DETAIL_LOG("WORLD: CMSG_PET_CAST_SPELL"); - uint64 guid; + ObjectGuid guid; uint32 spellid; uint8 cast_count; uint8 unk_flags; // flags (if 0x02 - some additional data are received) recvPacket >> guid >> cast_count >> spellid >> unk_flags; - DEBUG_LOG("WORLD: CMSG_PET_CAST_SPELL, cast_count: %u, spellid %u, unk_flags %u", cast_count, spellid, unk_flags); - - if (!_player->GetPet() && !_player->GetCharm()) - return; + DEBUG_LOG("WORLD: CMSG_PET_CAST_SPELL, %s, cast_count: %u, spellid %u, unk_flags %u", guid.GetString().c_str(), cast_count, spellid, unk_flags); Creature* pet = _player->GetMap()->GetAnyTypeCreature(guid); - if (!pet || (pet != _player->GetPet() && pet!= _player->GetCharm())) + if (!pet || (guid.GetRawValue() != _player->GetPetGUID() && guid.GetRawValue() != _player->GetCharmGUID())) { - sLog.outError( "HandlePetCastSpellOpcode: Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() ); + sLog.outError("HandlePetCastSpellOpcode: %s isn't pet of %s .", guid.GetString().c_str(), GetPlayer()->GetObjectGuid().GetString().c_str()); return; } @@ -714,7 +708,7 @@ void WorldSession::HandlePetLearnTalent( WorldPacket & recv_data ) { DEBUG_LOG("WORLD: CMSG_PET_LEARN_TALENT"); - uint64 guid; + ObjectGuid guid; uint32 talent_id, requested_rank; recv_data >> guid >> talent_id >> requested_rank; @@ -726,7 +720,7 @@ void WorldSession::HandleLearnPreviewTalentsPet( WorldPacket & recv_data ) { DEBUG_LOG("CMSG_LEARN_PREVIEW_TALENTS_PET"); - uint64 guid; + ObjectGuid guid; recv_data >> guid; uint32 talentsCount; diff --git a/src/game/PetitionsHandler.cpp b/src/game/PetitionsHandler.cpp index f2947cde3..85b9806da 100644 --- a/src/game/PetitionsHandler.cpp +++ b/src/game/PetitionsHandler.cpp @@ -899,21 +899,21 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) void WorldSession::HandlePetitionShowListOpcode(WorldPacket & recv_data) { - DEBUG_LOG("Received CMSG_PETITION_SHOWLIST"); // ok + DEBUG_LOG("Received CMSG_PETITION_SHOWLIST"); //recv_data.hexlike(); - uint64 guid; + ObjectGuid guid; recv_data >> guid; SendPetitionShowList(guid); } -void WorldSession::SendPetitionShowList(uint64 guid) +void WorldSession::SendPetitionShowList(ObjectGuid guid) { Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_PETITIONER); if (!pCreature) { - DEBUG_LOG("WORLD: HandlePetitionShowListOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid))); + DEBUG_LOG("WORLD: HandlePetitionShowListOpcode - %s not found or you can't interact with him.", guid.GetString().c_str()); return; } @@ -928,7 +928,7 @@ void WorldSession::SendPetitionShowList(uint64 guid) count = 3; WorldPacket data(SMSG_PETITION_SHOWLIST, 8+1+4*6); - data << uint64(guid); // npc guid + data << ObjectGuid(guid); // npc guid data << uint8(count); // count if(count == 1) { diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 2f77eec29..623406d18 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -8538,17 +8538,17 @@ uint32 Player::GetXPRestBonus(uint32 xp) return rested_bonus; } -void Player::SetBindPoint(uint64 guid) +void Player::SetBindPoint(ObjectGuid guid) { WorldPacket data(SMSG_BINDER_CONFIRM, 8); - data << uint64(guid); + data << ObjectGuid(guid); GetSession()->SendPacket( &data ); } -void Player::SendTalentWipeConfirm(uint64 guid) +void Player::SendTalentWipeConfirm(ObjectGuid guid) { WorldPacket data(MSG_TALENT_WIPE_CONFIRM, (8+4)); - data << uint64(guid); + data << ObjectGuid(guid); data << uint32(resetTalentsCost()); GetSession()->SendPacket( &data ); } @@ -12736,7 +12736,7 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId) canTalkToCredit = false; break; case GOSSIP_OPTION_QUESTGIVER: - PrepareQuestMenu(pSource->GetGUID()); + PrepareQuestMenu(pSource->GetObjectGuid()); hasMenuItem = false; break; case GOSSIP_OPTION_ARMORER: @@ -12801,7 +12801,7 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId) { case GOSSIP_OPTION_QUESTGIVER: if (pGo->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER) - PrepareQuestMenu(pSource->GetGUID()); + PrepareQuestMenu(pSource->GetObjectGuid()); hasMenuItem = false; break; case GOSSIP_OPTION_GOSSIP: @@ -12873,7 +12873,7 @@ void Player::SendPreparedGossip(WorldObject *pSource) // in case no gossip flag and quest menu not empty, open quest menu (client expect gossip menu with this flag) if (!((Creature*)pSource)->HasFlag(UNIT_NPC_FLAGS,UNIT_NPC_FLAG_GOSSIP) && !PlayerTalkClass->GetQuestMenu().Empty()) { - SendPreparedQuest(pSource->GetGUID()); + SendPreparedQuest(pSource->GetObjectGuid()); return; } } @@ -12882,7 +12882,7 @@ void Player::SendPreparedGossip(WorldObject *pSource) // probably need to find a better way here if (!PlayerTalkClass->GetGossipMenu().GetMenuId() && !PlayerTalkClass->GetQuestMenu().Empty()) { - SendPreparedQuest(pSource->GetGUID()); + SendPreparedQuest(pSource->GetObjectGuid()); return; } } @@ -12912,7 +12912,7 @@ void Player::OnGossipSelect(WorldObject* pSource, uint32 gossipListId, uint32 me GossipMenuItem const& menu_item = gossipmenu.GetItem(gossipListId); uint32 gossipOptionId = menu_item.m_gOptionId; - uint64 guid = pSource->GetGUID(); + ObjectGuid guid = pSource->GetObjectGuid(); uint32 moneyTake = menu_item.m_gBoxMoney; // if this function called and player have money for pay MoneyTake or cheating, proccess both cases @@ -13068,7 +13068,7 @@ uint32 Player::GetDefaultGossipMenuForSource(WorldObject *pSource) /*** QUEST SYSTEM ***/ /*********************************************************/ -void Player::PrepareQuestMenu(uint64 guid) +void Player::PrepareQuestMenu(ObjectGuid guid) { QuestRelationsMapBounds rbounds; QuestRelationsMapBounds irbounds; @@ -13128,7 +13128,7 @@ void Player::PrepareQuestMenu(uint64 guid) } } -void Player::SendPreparedQuest(uint64 guid) +void Player::SendPreparedQuest(ObjectGuid guid) { QuestMenu& questMenu = PlayerTalkClass->GetQuestMenu(); @@ -13236,7 +13236,7 @@ bool Player::IsCurrentQuest( uint32 quest_id ) const return itr->second.m_status == QUEST_STATUS_INCOMPLETE || itr->second.m_status == QUEST_STATUS_COMPLETE && !itr->second.m_rewarded; } -Quest const* Player::GetNextQuest(uint64 guid, Quest const *pQuest) +Quest const* Player::GetNextQuest(ObjectGuid guid, Quest const *pQuest) { QuestRelationsMapBounds rbounds; @@ -17453,11 +17453,11 @@ void Player::SetUInt32ValueInArray(Tokens& tokens,uint16 index, uint32 value) tokens[index] = buf; } -void Player::Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair) +void Player::Customize(ObjectGuid guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair) { // 0 - QueryResult* result = CharacterDatabase.PQuery("SELECT playerBytes2 FROM characters WHERE guid = '%u'", GUID_LOPART(guid)); - if(!result) + QueryResult* result = CharacterDatabase.PQuery("SELECT playerBytes2 FROM characters WHERE guid = '%u'", guid.GetCounter()); + if (!result) return; Field* fields = result->Fetch(); @@ -17466,7 +17466,7 @@ void Player::Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 player_bytes2 &= ~0xFF; player_bytes2 |= facialHair; - CharacterDatabase.PExecute("UPDATE characters SET gender = '%u', playerBytes = '%u', playerBytes2 = '%u' WHERE guid = '%u'", gender, skin | (face << 8) | (hairStyle << 16) | (hairColor << 24), player_bytes2, GUID_LOPART(guid)); + CharacterDatabase.PExecute("UPDATE characters SET gender = '%u', playerBytes = '%u', playerBytes2 = '%u' WHERE guid = '%u'", gender, skin | (face << 8) | (hairStyle << 16) | (hairColor << 24), player_bytes2, guid.GetCounter()); delete result; } @@ -20446,7 +20446,7 @@ uint32 Player::GetBaseWeaponSkillValue (WeaponAttackType attType) const void Player::ResurectUsingRequestData() { /// Teleport before resurrecting by player, otherwise the player might get attacked from creatures near his corpse - if(IS_PLAYER_GUID(m_resurrectGUID)) + if (m_resurrectGuid.IsPlayer()) TeleportTo(m_resurrectMap, m_resurrectX, m_resurrectY, m_resurrectZ, GetOrientation()); //we cannot resurrect player when we triggered far teleport @@ -21501,14 +21501,13 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank) DETAIL_LOG("TalentID: %u Rank: %u Spell: %u\n", talentId, talentRank, spellid); } -void Player::LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank) +void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRank) { Pet *pet = GetPet(); - - if(!pet) + if (!pet) return; - if(petGuid != pet->GetGUID()) + if (petGuid != pet->GetObjectGuid()) return; uint32 CurTalentPoints = pet->GetFreeTalentPoints(); diff --git a/src/game/Player.h b/src/game/Player.h index 593886c1e..297d905be 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1403,11 +1403,11 @@ class MANGOS_DLL_SPEC Player : public Unit // Return player level when QuestLevel is dynamic (-1) uint32 GetQuestLevelForPlayer(Quest const* pQuest) const { return pQuest && (pQuest->GetQuestLevel() > 0) ? (uint32)pQuest->GetQuestLevel() : getLevel(); } - void PrepareQuestMenu( uint64 guid ); - void SendPreparedQuest( uint64 guid ); + void PrepareQuestMenu(ObjectGuid guid ); + void SendPreparedQuest(ObjectGuid guid); bool IsActiveQuest( uint32 quest_id ) const; // can be taken or taken bool IsCurrentQuest( uint32 quest_id ) const; // taken and not yet rewarded - Quest const *GetNextQuest( uint64 guid, Quest const *pQuest ); + Quest const *GetNextQuest(ObjectGuid guid, Quest const *pQuest ); bool CanSeeStartQuest( Quest const *pQuest ) const; bool CanTakeQuest( Quest const *pQuest, bool msg ) const; bool CanAddQuest( Quest const *pQuest, bool msg ) const; @@ -1536,7 +1536,7 @@ class MANGOS_DLL_SPEC Player : public Unit void SaveGoldToDB(); static void SetUInt32ValueInArray(Tokens& data,uint16 index, uint32 value); static void SetFloatValueInArray(Tokens& data,uint16 index, float value); - static void Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair); + static void Customize(ObjectGuid guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair); static void SavePositionInDB(uint32 mapid, float x,float y,float z,float o,uint32 zone,uint64 guid); static void DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRealmChars = true, bool deleteFinally = false); @@ -1547,8 +1547,8 @@ class MANGOS_DLL_SPEC Player : public Unit void SendPetTameFailure(PetTameFailureReason reason); - void SetBindPoint(uint64 guid); - void SendTalentWipeConfirm(uint64 guid); + void SetBindPoint(ObjectGuid guid); + void SendTalentWipeConfirm(ObjectGuid guid); void RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker ); void SendPetSkillWipeConfirm(); void CalcRage( uint32 damage,bool attacker ); @@ -1666,7 +1666,7 @@ class MANGOS_DLL_SPEC Player : public Unit void BuildPetTalentsInfoData(WorldPacket *data); void SendTalentsInfoData(bool pet); void LearnTalent(uint32 talentId, uint32 talentRank); - void LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank); + void LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRank); uint32 CalculateTalentsPoints() const; @@ -1734,9 +1734,9 @@ class MANGOS_DLL_SPEC Player : public Unit uint32 GetLastPotionId() { return m_lastPotionId; } void UpdatePotionCooldown(Spell* spell = NULL); - void setResurrectRequestData(uint64 guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana) + void setResurrectRequestData(ObjectGuid guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana) { - m_resurrectGUID = guid; + m_resurrectGuid = guid; m_resurrectMap = mapId; m_resurrectX = X; m_resurrectY = Y; @@ -1744,9 +1744,9 @@ class MANGOS_DLL_SPEC Player : public Unit m_resurrectHealth = health; m_resurrectMana = mana; } - void clearResurrectRequestData() { setResurrectRequestData(0,0,0.0f,0.0f,0.0f,0,0); } - bool isRessurectRequestedBy(uint64 guid) const { return m_resurrectGUID == guid; } - bool isRessurectRequested() const { return m_resurrectGUID != 0; } + void clearResurrectRequestData() { setResurrectRequestData(ObjectGuid(), 0, 0.0f, 0.0f, 0.0f, 0, 0); } + bool isRessurectRequestedBy(ObjectGuid guid) const { return m_resurrectGuid == guid; } + bool isRessurectRequested() const { return !m_resurrectGuid.IsEmpty(); } void ResurectUsingRequestData(); int getCinematic() @@ -2549,7 +2549,7 @@ class MANGOS_DLL_SPEC Player : public Unit EnchantDurationList m_enchantDuration; ItemDurationList m_itemDuration; - uint64 m_resurrectGUID; + ObjectGuid m_resurrectGuid; uint32 m_resurrectMap; float m_resurrectX, m_resurrectY, m_resurrectZ; uint32 m_resurrectHealth, m_resurrectMana; diff --git a/src/game/QueryHandler.cpp b/src/game/QueryHandler.cpp index d55b3926a..8ccd2fe93 100644 --- a/src/game/QueryHandler.cpp +++ b/src/game/QueryHandler.cpp @@ -58,7 +58,7 @@ void WorldSession::SendNameQueryOpcode(Player *p) SendPacket(&data); } -void WorldSession::SendNameQueryOpcodeFromDB(uint64 guid) +void WorldSession::SendNameQueryOpcodeFromDB(ObjectGuid guid) { CharacterDatabase.AsyncPQuery(&WorldSession::SendNameQueryOpcodeFromDBCallBack, GetAccountId(), !sWorld.getConfig(CONFIG_BOOL_DECLINED_NAMES_USED) ? @@ -73,7 +73,7 @@ void WorldSession::SendNameQueryOpcodeFromDB(uint64 guid) // 5 6 7 8 9 "genitive, dative, accusative, instrumental, prepositional " "FROM characters LEFT JOIN character_declinedname ON characters.guid = character_declinedname.guid WHERE characters.guid = '%u'", - GUID_LOPART(guid)); + guid.GetCounter()); } void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32 accountId) @@ -126,7 +126,7 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32 void WorldSession::HandleNameQueryOpcode( WorldPacket & recv_data ) { - uint64 guid; + ObjectGuid guid; recv_data >> guid; @@ -148,7 +148,7 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data ) { uint32 entry; recv_data >> entry; - uint64 guid; + ObjectGuid guid; recv_data >> guid; CreatureInfo const *ci = ObjectMgr::GetCreatureTemplate(entry); @@ -199,8 +199,8 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data ) } else { - DEBUG_LOG("WORLD: CMSG_CREATURE_QUERY - NO CREATURE INFO! (GUID: %u, ENTRY: %u)", - GUID_LOPART(guid), entry); + DEBUG_LOG("WORLD: CMSG_CREATURE_QUERY - Guid: %s Entry: %u NO CREATURE INFO!", + guid.GetString().c_str(), entry); WorldPacket data( SMSG_CREATURE_QUERY_RESPONSE, 4 ); data << uint32(entry | 0x80000000); SendPacket( &data ); @@ -213,7 +213,7 @@ void WorldSession::HandleGameObjectQueryOpcode( WorldPacket & recv_data ) { uint32 entryID; recv_data >> entryID; - uint64 guid; + ObjectGuid guid; recv_data >> guid; const GameObjectInfo *info = ObjectMgr::GetGameObjectInfo(entryID); @@ -258,8 +258,8 @@ void WorldSession::HandleGameObjectQueryOpcode( WorldPacket & recv_data ) } else { - DEBUG_LOG( "WORLD: CMSG_GAMEOBJECT_QUERY - Missing gameobject info for (GUID: %u, ENTRY: %u)", - GUID_LOPART(guid), entryID ); + DEBUG_LOG("WORLD: CMSG_GAMEOBJECT_QUERY - Guid: %s Entry: %u Missing gameobject info!", + guid.GetString().c_str(), entryID); WorldPacket data ( SMSG_GAMEOBJECT_QUERY_RESPONSE, 4 ); data << uint32(entryID | 0x80000000); SendPacket( &data ); diff --git a/src/game/QuestHandler.cpp b/src/game/QuestHandler.cpp index 432eba3a1..86823005b 100644 --- a/src/game/QuestHandler.cpp +++ b/src/game/QuestHandler.cpp @@ -82,16 +82,16 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode( WorldPacket & recv_data ) void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket & recv_data) { - uint64 guid; + ObjectGuid guid; recv_data >> guid; - DEBUG_LOG ("WORLD: Received CMSG_QUESTGIVER_HELLO npc = %u", GUID_LOPART(guid)); + DEBUG_LOG("WORLD: Received CMSG_QUESTGIVER_HELLO npc: %s", guid.GetString().c_str()); Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); if (!pCreature) { - DEBUG_LOG ("WORLD: HandleQuestgiverHelloOpcode - Unit (GUID: %u) not found or you can't interact with him.", GUID_LOPART(guid)); + DEBUG_LOG ("WORLD: HandleQuestgiverHelloOpcode - %s not found or you can't interact with him.", guid.GetString().c_str()); return; } @@ -112,15 +112,15 @@ void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket & recv_data) void WorldSession::HandleQuestgiverAcceptQuestOpcode( WorldPacket & recv_data ) { - uint64 guid; + ObjectGuid guid; uint32 quest; uint32 unk1; recv_data >> guid >> quest >> unk1; - if(!GetPlayer()->isAlive()) + if (!GetPlayer()->isAlive()) return; - DEBUG_LOG( "WORLD: Received CMSG_QUESTGIVER_ACCEPT_QUEST npc = %u, quest = %u, unk1 = %u", uint32(GUID_LOPART(guid)), quest, unk1 ); + DEBUG_LOG("WORLD: Received CMSG_QUESTGIVER_ACCEPT_QUEST npc = %s, quest = %u, unk1 = %u", guid.GetString().c_str(), quest, unk1 ); Object* pObject = _player->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_GAMEOBJECT_PLAYER_OR_ITEM); @@ -233,11 +233,12 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode( WorldPacket & recv_data ) void WorldSession::HandleQuestgiverQueryQuestOpcode( WorldPacket & recv_data ) { - uint64 guid; + ObjectGuid guid; uint32 quest; uint8 unk1; recv_data >> guid >> quest >> unk1; - DEBUG_LOG( "WORLD: Received CMSG_QUESTGIVER_QUERY_QUEST npc = %u, quest = %u, unk1 = %u", uint32(GUID_LOPART(guid)), quest, unk1 ); + + DEBUG_LOG("WORLD: Received CMSG_QUESTGIVER_QUERY_QUEST npc = %s, quest = %u, unk1 = %u", guid.GetString().c_str(), quest, unk1 ); // Verify that the guid is valid and is a questgiver or involved in the requested quest Object* pObject = _player->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_GAMEOBJECT_OR_ITEM); @@ -247,11 +248,8 @@ void WorldSession::HandleQuestgiverQueryQuestOpcode( WorldPacket & recv_data ) return; } - Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest); - if ( pQuest ) - { - _player->PlayerTalkClass->SendQuestGiverQuestDetails(pQuest, pObject->GetGUID(), true); - } + if (Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest)) + _player->PlayerTalkClass->SendQuestGiverQuestDetails(pQuest, pObject->GetObjectGuid(), true); } void WorldSession::HandleQuestQueryOpcode( WorldPacket & recv_data ) @@ -270,7 +268,7 @@ void WorldSession::HandleQuestQueryOpcode( WorldPacket & recv_data ) void WorldSession::HandleQuestgiverChooseRewardOpcode( WorldPacket & recv_data ) { uint32 quest, reward; - uint64 guid; + ObjectGuid guid; recv_data >> guid >> quest >> reward; if(reward >= QUEST_REWARD_CHOICES_COUNT) @@ -282,7 +280,7 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode( WorldPacket & recv_data ) if(!GetPlayer()->isAlive()) return; - DEBUG_LOG( "WORLD: Received CMSG_QUESTGIVER_CHOOSE_REWARD npc = %u, quest = %u, reward = %u",uint32(GUID_LOPART(guid)),quest,reward ); + DEBUG_LOG("WORLD: Received CMSG_QUESTGIVER_CHOOSE_REWARD npc = %s, quest = %u, reward = %u", guid.GetString().c_str(), quest, reward); Object* pObject = _player->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_OR_GAMEOBJECT); if(!pObject) @@ -301,51 +299,51 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode( WorldPacket & recv_data ) switch(pObject->GetTypeId()) { case TYPEID_UNIT: - if( !(Script->ChooseReward( _player, ((Creature*)pObject), pQuest, reward )) ) + if (!(Script->ChooseReward(_player, ((Creature*)pObject), pQuest, reward))) { // Send next quest - if(Quest const* nextquest = _player->GetNextQuest( guid ,pQuest ) ) - _player->PlayerTalkClass->SendQuestGiverQuestDetails(nextquest,guid,true); + if (Quest const* nextquest = _player->GetNextQuest(guid, pQuest)) + _player->PlayerTalkClass->SendQuestGiverQuestDetails(nextquest, guid, true); } break; case TYPEID_GAMEOBJECT: - if( !Script->GOChooseReward( _player, ((GameObject*)pObject), pQuest, reward ) ) + if (!Script->GOChooseReward(_player, ((GameObject*)pObject), pQuest, reward)) { // Send next quest - if(Quest const* nextquest = _player->GetNextQuest( guid ,pQuest ) ) - _player->PlayerTalkClass->SendQuestGiverQuestDetails(nextquest,guid,true); + if (Quest const* nextquest = _player->GetNextQuest(guid ,pQuest)) + _player->PlayerTalkClass->SendQuestGiverQuestDetails(nextquest, guid, true); } break; } } else - _player->PlayerTalkClass->SendQuestGiverOfferReward( pQuest, guid, true ); + _player->PlayerTalkClass->SendQuestGiverOfferReward(pQuest, guid, true); } } void WorldSession::HandleQuestgiverRequestRewardOpcode( WorldPacket & recv_data ) { uint32 quest; - uint64 guid; + ObjectGuid guid; recv_data >> guid >> quest; - if(!GetPlayer()->isAlive()) + if (!GetPlayer()->isAlive()) return; - DEBUG_LOG( "WORLD: Received CMSG_QUESTGIVER_REQUEST_REWARD npc = %u, quest = %u",uint32(GUID_LOPART(guid)),quest ); + DEBUG_LOG("WORLD: Received CMSG_QUESTGIVER_REQUEST_REWARD npc = %s, quest = %u", guid.GetString().c_str(), quest); Object* pObject = _player->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_OR_GAMEOBJECT); - if(!pObject||!pObject->HasInvolvedQuest(quest)) + if (!pObject||!pObject->HasInvolvedQuest(quest)) return; - if ( _player->CanCompleteQuest( quest ) ) - _player->CompleteQuest( quest ); + if (_player->CanCompleteQuest(quest)) + _player->CompleteQuest(quest); - if( _player->GetQuestStatus( quest ) != QUEST_STATUS_COMPLETE ) + if (_player->GetQuestStatus(quest) != QUEST_STATUS_COMPLETE) return; - if(Quest const *pQuest = sObjectMgr.GetQuestTemplate(quest)) - _player->PlayerTalkClass->SendQuestGiverOfferReward( pQuest, guid, true ); + if (Quest const *pQuest = sObjectMgr.GetQuestTemplate(quest)) + _player->PlayerTalkClass->SendQuestGiverOfferReward(pQuest, guid, true); } void WorldSession::HandleQuestgiverCancel(WorldPacket& /*recv_data*/ ) @@ -435,27 +433,26 @@ void WorldSession::HandleQuestConfirmAccept(WorldPacket& recv_data) void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recv_data) { uint32 quest; - uint64 guid; + ObjectGuid guid; recv_data >> guid >> quest; - if(!GetPlayer()->isAlive()) + if (!GetPlayer()->isAlive()) return; - DEBUG_LOG( "WORLD: Received CMSG_QUESTGIVER_COMPLETE_QUEST npc = %u, quest = %u",uint32(GUID_LOPART(guid)),quest ); + DEBUG_LOG("WORLD: Received CMSG_QUESTGIVER_COMPLETE_QUEST npc = %s, quest = %u", guid.GetString().c_str(), quest); - Quest const *pQuest = sObjectMgr.GetQuestTemplate(quest); - if( pQuest ) + if (Quest const *pQuest = sObjectMgr.GetQuestTemplate(quest)) { - if( _player->GetQuestStatus( quest ) != QUEST_STATUS_COMPLETE ) + if (_player->GetQuestStatus( quest ) != QUEST_STATUS_COMPLETE) { - if( pQuest->IsRepeatable() ) + if (pQuest->IsRepeatable()) _player->PlayerTalkClass->SendQuestGiverRequestItems(pQuest, guid, _player->CanCompleteRepeatableQuest(pQuest), false); else _player->PlayerTalkClass->SendQuestGiverRequestItems(pQuest, guid, _player->CanRewardQuest(pQuest,false), false); } else { - if(pQuest->GetReqItemsCount()) // some items required + if (pQuest->GetReqItemsCount()) // some items required _player->PlayerTalkClass->SendQuestGiverRequestItems(pQuest, guid, _player->CanRewardQuest(pQuest,false), false); else // no items required _player->PlayerTalkClass->SendQuestGiverOfferReward(pQuest, guid, true); @@ -518,7 +515,7 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket) continue; } - pPlayer->PlayerTalkClass->SendQuestGiverQuestDetails(pQuest, _player->GetGUID(), true); + pPlayer->PlayerTalkClass->SendQuestGiverQuestDetails(pQuest, _player->GetObjectGuid(), true); pPlayer->SetDivider(_player->GetGUID()); } } @@ -527,19 +524,18 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket) void WorldSession::HandleQuestPushResult(WorldPacket& recvPacket) { - uint64 guid; + ObjectGuid guid; uint8 msg; recvPacket >> guid >> msg; - DEBUG_LOG( "WORLD: Received MSG_QUEST_PUSH_RESULT" ); + DEBUG_LOG("WORLD: Received MSG_QUEST_PUSH_RESULT"); - if( _player->GetDivider() != 0 ) + if (_player->GetDivider() != 0) { - Player *pPlayer = ObjectAccessor::FindPlayer( _player->GetDivider() ); - if( pPlayer ) + if (Player *pPlayer = ObjectAccessor::FindPlayer(_player->GetDivider())) { WorldPacket data( MSG_QUEST_PUSH_RESULT, (8+1) ); - data << uint64(guid); + data << ObjectGuid(guid); data << uint8(msg); // valid values: 0-8 pPlayer->GetSession()->SendPacket(&data); _player->SetDivider( 0 ); diff --git a/src/game/SkillHandler.cpp b/src/game/SkillHandler.cpp index 83ff3c2fc..233c838c2 100644 --- a/src/game/SkillHandler.cpp +++ b/src/game/SkillHandler.cpp @@ -56,21 +56,21 @@ void WorldSession::HandleLearnPreviewTalents(WorldPacket& recvPacket) void WorldSession::HandleTalentWipeConfirmOpcode( WorldPacket & recv_data ) { DETAIL_LOG("MSG_TALENT_WIPE_CONFIRM"); - uint64 guid; + ObjectGuid guid; recv_data >> guid; - Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_TRAINER); + Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TRAINER); if (!unit) { - DEBUG_LOG( "WORLD: HandleTalentWipeConfirmOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + DEBUG_LOG( "WORLD: HandleTalentWipeConfirmOpcode - %s not found or you can't interact with him.", guid.GetString().c_str()); return; } // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - if(!(_player->resetTalents())) + if (!(_player->resetTalents())) { WorldPacket data( MSG_TALENT_WIPE_CONFIRM, 8+4); //you have not any talent data << uint64(0); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 891a0ee30..56c494e2f 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -260,7 +260,7 @@ void Spell::EffectResurrectNew(SpellEffectIndex eff_idx) uint32 health = damage; uint32 mana = m_spellInfo->EffectMiscValue[eff_idx]; - pTarget->setResurrectRequestData(m_caster->GetGUID(), m_caster->GetMapId(), m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), health, mana); + pTarget->setResurrectRequestData(m_caster->GetObjectGuid(), m_caster->GetMapId(), m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), health, mana); SendResurrectRequest(pTarget); } @@ -7239,7 +7239,7 @@ void Spell::EffectResurrect(SpellEffectIndex /*eff_idx*/) uint32 health = pTarget->GetMaxHealth() * damage / 100; uint32 mana = pTarget->GetMaxPower(POWER_MANA) * damage / 100; - pTarget->setResurrectRequestData(m_caster->GetGUID(), m_caster->GetMapId(), m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), health, mana); + pTarget->setResurrectRequestData(m_caster->GetObjectGuid(), m_caster->GetMapId(), m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), health, mana); SendResurrectRequest(pTarget); } diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp index e24a3fa25..2b03f5bd5 100644 --- a/src/game/SpellHandler.cpp +++ b/src/game/SpellHandler.cpp @@ -270,11 +270,11 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket) void WorldSession::HandleGameObjectUseOpcode( WorldPacket & recv_data ) { - uint64 guid; + ObjectGuid guid; recv_data >> guid; - DEBUG_LOG( "WORLD: Recvd CMSG_GAMEOBJ_USE Message [guid=%u]", GUID_LOPART(guid)); + DEBUG_LOG("WORLD: Recvd CMSG_GAMEOBJ_USE Message guid: %s", guid.GetString().c_str()); // ignore for remote control state if (!_player->IsSelfMover()) @@ -297,17 +297,17 @@ void WorldSession::HandleGameObjectUseOpcode( WorldPacket & recv_data ) void WorldSession::HandleGameobjectReportUse(WorldPacket& recvPacket) { - uint64 guid; + ObjectGuid guid; recvPacket >> guid; - DEBUG_LOG( "WORLD: Recvd CMSG_GAMEOBJ_REPORT_USE Message [in game guid: %u]", GUID_LOPART(guid)); + DEBUG_LOG("WORLD: Recvd CMSG_GAMEOBJ_REPORT_USE Message guid: %s", guid.GetString().c_str()); // ignore for remote control state if (!_player->IsSelfMover()) return; GameObject* go = GetPlayer()->GetMap()->GetGameObject(guid); - if(!go) + if (!go) return; if(!go->IsWithinDistInMap(_player,INTERACTION_DISTANCE)) @@ -484,7 +484,7 @@ void WorldSession::HandleCancelAuraOpcode( WorldPacket& recvPacket) void WorldSession::HandlePetCancelAuraOpcode( WorldPacket& recvPacket) { - uint64 guid; + ObjectGuid guid; uint32 spellId; recvPacket >> guid; @@ -503,15 +503,15 @@ void WorldSession::HandlePetCancelAuraOpcode( WorldPacket& recvPacket) Creature* pet = GetPlayer()->GetMap()->GetAnyTypeCreature(guid); - if(!pet) + if (!pet) { - sLog.outError( "Pet %u not exist.", uint32(GUID_LOPART(guid)) ); + sLog.outError("HandlePetCancelAuraOpcode - %s not exist.", guid.GetString().c_str()); return; } - if(pet != GetPlayer()->GetPet() && pet != GetPlayer()->GetCharm()) + if (guid.GetRawValue() != GetPlayer()->GetPetGUID() && guid.GetRawValue() != GetPlayer()->GetCharmGUID()) { - sLog.outError( "HandlePetCancelAura.Pet %u isn't pet of player %s", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() ); + sLog.outError("HandlePetCancelAura. %s isn't pet of %s", guid.GetString().c_str(), GetPlayer()->GetObjectGuid().GetString().c_str()); return; } @@ -583,7 +583,7 @@ void WorldSession::HandleSelfResOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleSpellClick( WorldPacket & recv_data ) { - uint64 guid; + ObjectGuid guid; recv_data >> guid; if (_player->isInCombat()) // client prevent click and set different icon at combat state diff --git a/src/game/TaxiHandler.cpp b/src/game/TaxiHandler.cpp index 86ad5fd44..9c2ebc37f 100644 --- a/src/game/TaxiHandler.cpp +++ b/src/game/TaxiHandler.cpp @@ -31,51 +31,52 @@ void WorldSession::HandleTaxiNodeStatusQueryOpcode( WorldPacket & recv_data ) { - DEBUG_LOG( "WORLD: Received CMSG_TAXINODE_STATUS_QUERY" ); + DEBUG_LOG("WORLD: Received CMSG_TAXINODE_STATUS_QUERY"); - uint64 guid; + ObjectGuid guid; recv_data >> guid; SendTaxiStatus( guid ); } -void WorldSession::SendTaxiStatus( uint64 guid ) +void WorldSession::SendTaxiStatus(ObjectGuid guid) { // cheating checks Creature *unit = GetPlayer()->GetMap()->GetCreature(guid); if (!unit) { - DEBUG_LOG( "WorldSession::SendTaxiStatus - Unit (GUID: %u) not found.", uint32(GUID_LOPART(guid)) ); + DEBUG_LOG("WorldSession::SendTaxiStatus - %s not found or you can't interact with it.", guid.GetString().c_str()); return; } uint32 curloc = sObjectMgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId(),GetPlayer( )->GetTeam()); // not found nearest - if(curloc == 0) + if (curloc == 0) return; - DEBUG_LOG( "WORLD: current location %u ",curloc); + DEBUG_LOG("WORLD: current location %u ",curloc); - WorldPacket data( SMSG_TAXINODE_STATUS, 9 ); - data << guid; - data << uint8( GetPlayer( )->m_taxi.IsTaximaskNodeKnown(curloc) ? 1 : 0 ); - SendPacket( &data ); - DEBUG_LOG( "WORLD: Sent SMSG_TAXINODE_STATUS" ); + WorldPacket data(SMSG_TAXINODE_STATUS, 9); + data << ObjectGuid(guid); + data << uint8(GetPlayer()->m_taxi.IsTaximaskNodeKnown(curloc) ? 1 : 0); + SendPacket(&data); + + DEBUG_LOG("WORLD: Sent SMSG_TAXINODE_STATUS"); } void WorldSession::HandleTaxiQueryAvailableNodes( WorldPacket & recv_data ) { DEBUG_LOG( "WORLD: Received CMSG_TAXIQUERYAVAILABLENODES" ); - uint64 guid; + ObjectGuid guid; recv_data >> guid; // cheating checks Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER); if (!unit) { - DEBUG_LOG( "WORLD: HandleTaxiQueryAvailableNodes - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + DEBUG_LOG("WORLD: HandleTaxiQueryAvailableNodes - %s not found or you can't interact with him.", guid.GetString().c_str()); return; } @@ -154,7 +155,7 @@ void WorldSession::HandleActivateTaxiExpressOpcode ( WorldPacket & recv_data ) { DEBUG_LOG( "WORLD: Received CMSG_ACTIVATETAXIEXPRESS" ); - uint64 guid; + ObjectGuid guid; uint32 node_count; recv_data >> guid >> node_count; @@ -162,7 +163,7 @@ void WorldSession::HandleActivateTaxiExpressOpcode ( WorldPacket & recv_data ) Creature *npc = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER); if (!npc) { - DEBUG_LOG( "WORLD: HandleActivateTaxiExpressOpcode - Unit (GUID: %u) not found or you can't interact with it.", uint32(GUID_LOPART(guid)) ); + DEBUG_LOG( "WORLD: HandleActivateTaxiExpressOpcode - %s not found or you can't interact with it.", guid.GetString().c_str()); return; } std::vector nodes; @@ -257,18 +258,18 @@ void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& recv_data) void WorldSession::HandleActivateTaxiOpcode( WorldPacket & recv_data ) { - DEBUG_LOG( "WORLD: Received CMSG_ACTIVATETAXI" ); + DEBUG_LOG("WORLD: Received CMSG_ACTIVATETAXI"); - uint64 guid; + ObjectGuid guid; std::vector nodes; nodes.resize(2); recv_data >> guid >> nodes[0] >> nodes[1]; - DEBUG_LOG( "WORLD: Received CMSG_ACTIVATETAXI from %d to %d" ,nodes[0],nodes[1]); + DEBUG_LOG("WORLD: Received CMSG_ACTIVATETAXI from %d to %d" ,nodes[0],nodes[1]); Creature *npc = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER); if (!npc) { - DEBUG_LOG( "WORLD: HandleActivateTaxiOpcode - Unit (GUID: %u) not found or you can't interact with it.", uint32(GUID_LOPART(guid)) ); + DEBUG_LOG("WORLD: HandleActivateTaxiOpcode - %s not found or you can't interact with it.", guid.GetString().c_str()); return; } diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index 8af868e97..e6ff09b79 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -25,6 +25,7 @@ #include "Common.h" #include "SharedDefines.h" +#include "ObjectGuid.h" struct ItemPrototype; struct AuctionEntry; @@ -206,16 +207,16 @@ class MANGOS_DLL_SPEC WorldSession /// Handle the authentication waiting queue (to be completed) void SendAuthWaitQue(uint32 position); - //void SendTestCreatureQueryOpcode( uint32 entry, uint64 guid, uint32 testvalue ); void SendNameQueryOpcode(Player* p); - void SendNameQueryOpcodeFromDB(uint64 guid); + void SendNameQueryOpcodeFromDB(ObjectGuid guid); static void SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32 accountId); - void SendTrainerList( uint64 guid ); - void SendTrainerList( uint64 guid, const std::string& strTitle ); - void SendListInventory( uint64 guid ); - void SendShowBank( uint64 guid ); - void SendTabardVendorActivate( uint64 guid ); + void SendTrainerList(ObjectGuid guid); + void SendTrainerList(ObjectGuid guid, const std::string& strTitle ); + void SendListInventory(ObjectGuid guid); + bool CheckBanker(ObjectGuid guid); + void SendShowBank(ObjectGuid guid); + void SendTabardVendorActivate(ObjectGuid guid); void SendSpiritResurrect(); void SendBindPoint(Creature* npc); void SendGMTicketGetTicket(uint32 status, GMTicket *ticket = NULL); @@ -277,7 +278,7 @@ class MANGOS_DLL_SPEC WorldSession void SendItemEnchantTimeUpdate(uint64 Playerguid, uint64 Itemguid,uint32 slot,uint32 Duration); //Taxi - void SendTaxiStatus( uint64 guid ); + void SendTaxiStatus(ObjectGuid guid); void SendTaxiMenu( Creature* unit ); void SendDoFlight( uint32 mountDisplayId, uint32 path, uint32 pathNode = 0 ); bool SendLearnNewTaxiNode( Creature* unit ); @@ -286,7 +287,7 @@ class MANGOS_DLL_SPEC WorldSession void SendGuildCommandResult(uint32 typecmd, const std::string& str, uint32 cmdresult); void SendArenaTeamCommandResult(uint32 team_action, const std::string& team, const std::string& player, uint32 error_id); void SendNotInArenaTeamPacket(uint8 type); - void SendPetitionShowList( uint64 guid ); + void SendPetitionShowList(ObjectGuid guid); void SendSaveGuildEmblem( uint32 msg ); // Looking For Group diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 915ec9769..df27ebafa 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10634" + #define REVISION_NR "10635" #endif // __REVISION_NR_H__