diff options
author | Duarte Duarte <dnpd.dd@gmail.com> | 2015-02-12 04:23:19 +0000 |
---|---|---|
committer | Duarte Duarte <dnpd.dd@gmail.com> | 2015-02-12 04:23:19 +0000 |
commit | 97e62c0ea5a53da71dfb788dfa88f429d04dd8c4 (patch) | |
tree | 7cb390e402a9be5066825ebd399c2ab06264730b /src/server/game/Handlers/MiscHandler.cpp | |
parent | 20aa605485a0772910766255a8e5e4ba2f2d92bc (diff) |
Core/Packets: Update and enable CMSG_GOSSIP_SELECT_OPTION, SMSG_BINDER_CONFIRM, SMSG_GOSSIP_COMPLETE and SMSG_PLAYER_BOUND
Fixes #14115
Diffstat (limited to 'src/server/game/Handlers/MiscHandler.cpp')
-rw-r--r-- | src/server/game/Handlers/MiscHandler.cpp | 70 |
1 files changed, 30 insertions, 40 deletions
diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index 02fdb9bd4e4..7a983f7b847 100644 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -59,6 +59,7 @@ #include "CharacterPackets.h" #include "ClientConfigPackets.h" #include "MiscPackets.h" +#include "NPCPackets.h" #include "AchievementPackets.h" #include "WhoPackets.h" @@ -90,53 +91,40 @@ void WorldSession::HandleRepopRequest(WorldPackets::Misc::RepopRequest& packet) GetPlayer()->RepopAtGraveyard(); } -void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recvData) +void WorldSession::HandleGossipSelectOptionOpcode(WorldPackets::NPC::GossipSelectOption& packet) { - TC_LOG_DEBUG("network", "WORLD: CMSG_GOSSIP_SELECT_OPTION"); - - uint32 gossipListId; - uint32 menuId; - ObjectGuid guid; - std::string code = ""; - - recvData >> guid >> menuId >> gossipListId; - - if (!_player->PlayerTalkClass->GetGossipMenu().GetItem(gossipListId)) - { - recvData.rfinish(); + if (!_player->PlayerTalkClass->GetGossipMenu().GetItem(packet.GossipIndex)) return; - } - - if (_player->PlayerTalkClass->IsGossipOptionCoded(gossipListId)) - recvData >> code; // Prevent cheating on C++ scripted menus - if (_player->PlayerTalkClass->GetGossipMenu().GetSenderGUID() != guid) + if (_player->PlayerTalkClass->GetGossipMenu().GetSenderGUID() != packet.GossipUnit) return; - Creature* unit = NULL; - GameObject* go = NULL; - if (guid.IsCreatureOrVehicle()) + Creature* unit = nullptr; + GameObject* go = nullptr; + if (packet.GossipUnit.IsCreatureOrVehicle()) { - unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); + unit = GetPlayer()->GetNPCIfCanInteractWith(packet.GossipUnit, UNIT_NPC_FLAG_NONE); if (!unit) { - TC_LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - %s not found or you can't interact with him.", guid.ToString().c_str()); + + TC_LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - %s not found or you can't interact with him.", packet.GossipUnit.ToString().c_str()); return; } } - else if (guid.IsGameObject()) + else if (packet.GossipUnit.IsGameObject()) { - go = _player->GetMap()->GetGameObject(guid); + go = _player->GetMap()->GetGameObject(packet.GossipUnit); if (!go) { - TC_LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - %s not found.", guid.ToString().c_str()); + TC_LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - %s not found.", packet.GossipUnit.ToString().c_str()); return; } } else { - TC_LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - unsupported %s.", guid.ToString().c_str()); + + TC_LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - unsupported %s.", packet.GossipUnit.ToString().c_str()); return; } @@ -149,39 +137,41 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recvData) TC_LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - Script reloaded while in use, ignoring and set new scipt id"); if (unit) unit->LastUsedScriptID = unit->GetCreatureTemplate()->ScriptID; + if (go) go->LastUsedScriptID = go->GetGOInfo()->ScriptId; _player->PlayerTalkClass->SendCloseGossip(); return; } - if (!code.empty()) + + if (!packet.PromotionCode.empty()) { if (unit) { - unit->AI()->sGossipSelectCode(_player, menuId, gossipListId, code.c_str()); - if (!sScriptMgr->OnGossipSelectCode(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str())) - _player->OnGossipSelect(unit, gossipListId, menuId); + unit->AI()->sGossipSelectCode(_player, packet.GossipID, packet.GossipIndex, packet.PromotionCode.c_str()); + if (!sScriptMgr->OnGossipSelectCode(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(packet.GossipIndex), _player->PlayerTalkClass->GetGossipOptionAction(packet.GossipIndex), packet.PromotionCode.c_str())) + _player->OnGossipSelect(unit, packet.GossipIndex, packet.GossipID); } else { - go->AI()->GossipSelectCode(_player, menuId, gossipListId, code.c_str()); - if (!sScriptMgr->OnGossipSelectCode(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str())) - _player->OnGossipSelect(go, gossipListId, menuId); + go->AI()->GossipSelectCode(_player, packet.GossipID, packet.GossipIndex, packet.PromotionCode.c_str()); + if (!sScriptMgr->OnGossipSelectCode(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(packet.GossipIndex), _player->PlayerTalkClass->GetGossipOptionAction(packet.GossipIndex), packet.PromotionCode.c_str())) + _player->OnGossipSelect(go, packet.GossipIndex, packet.GossipID); } } else { if (unit) { - unit->AI()->sGossipSelect(_player, menuId, gossipListId); - if (!sScriptMgr->OnGossipSelect(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId))) - _player->OnGossipSelect(unit, gossipListId, menuId); + unit->AI()->sGossipSelect(_player, packet.GossipID, packet.GossipIndex); + if (!sScriptMgr->OnGossipSelect(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(packet.GossipIndex), _player->PlayerTalkClass->GetGossipOptionAction(packet.GossipIndex))) + _player->OnGossipSelect(unit, packet.GossipIndex, packet.GossipID); } else { - go->AI()->GossipSelect(_player, menuId, gossipListId); - if (!sScriptMgr->OnGossipSelect(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId))) - _player->OnGossipSelect(go, gossipListId, menuId); + go->AI()->GossipSelect(_player, packet.GossipID, packet.GossipIndex); + if (!sScriptMgr->OnGossipSelect(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(packet.GossipIndex), _player->PlayerTalkClass->GetGossipOptionAction(packet.GossipIndex))) + _player->OnGossipSelect(go, packet.GossipIndex, packet.GossipID); } } } |