Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp
- index 4da0d82..6e96755 100644
- --- a/src/server/game/Handlers/MiscHandler.cpp
- +++ b/src/server/game/Handlers/MiscHandler.cpp
- @@ -100,6 +100,7 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recvData)
- if (_player->PlayerTalkClass->IsGossipOptionCoded(gossipListId))
- recvData >> code;
- + Item* item = NULL;
- Creature* unit = NULL;
- GameObject* go = NULL;
- if (IS_CRE_OR_VEH_GUID(guid))
- @@ -120,6 +121,32 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recvData)
- return;
- }
- }
- + else if (IS_GAMEOBJECT_GUID(guid))
- + {
- + go = _player->GetMap()->GetGameObject(guid);
- + if (!go)
- + {
- + TC_LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - GameObject (GUID: %u) not found.", uint32(GUID_LOPART(guid)));
- + return;
- + }
- + }
- + else if (IS_ITEM_GUID(guid))
- + {
- + item = _player->GetItemByGuid(guid);
- + if (!item)
- + {
- + TC_LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - Item (GUID: %u) not found.", uint32(GUID_LOPART(guid)));
- + return;
- + }
- + }
- + else if (IS_PLAYER_GUID(guid))
- + {
- + if (_player->GetGUID() != guid)
- + {
- + TC_LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - Player (GUID: %u) not receiver.", uint32(GUID_LOPART(guid)));
- + return;
- + }
- + }
- else
- {
- TC_LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - unsupported GUID type for highguid %u. lowpart %u.", uint32(GUID_HIPART(guid)), uint32(GUID_LOPART(guid)));
- @@ -148,11 +175,19 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recvData)
- if (!sScriptMgr->OnGossipSelectCode(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str()))
- _player->OnGossipSelect(unit, gossipListId, menuId);
- }
- - else
- + else if (go)
- {
- go->AI()->GossipSelectCode(_player, menuId, gossipListId, code.c_str());
- sScriptMgr->OnGossipSelectCode(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str());
- }
- + else if (item)
- + {
- + sScriptMgr->OnGossipSelectCode(_player, item, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str());
- + }
- + else if (_player->PlayerTalkClass->GetGossipMenu().GetMenuId() == menuId)
- + {
- + sScriptMgr->OnGossipSelectCode(_player, menuId, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str());
- + }
- }
- else
- {
- @@ -162,12 +197,20 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recvData)
- if (!sScriptMgr->OnGossipSelect(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId)))
- _player->OnGossipSelect(unit, gossipListId, menuId);
- }
- - else
- + else if (go)
- {
- go->AI()->GossipSelect(_player, menuId, gossipListId);
- if (!sScriptMgr->OnGossipSelect(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId)))
- _player->OnGossipSelect(go, gossipListId, menuId);
- }
- + else if (item)
- + {
- + sScriptMgr->OnGossipSelect(_player, item, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId));
- + }
- + else if (_player->PlayerTalkClass->GetGossipMenu().GetMenuId() == menuId)
- + {
- + sScriptMgr->OnGossipSelect(_player, menuId, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId));
- + }
- }
- }
- diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp
- index 3674f8f..24bb94e 100644
- --- a/src/server/game/Scripting/ScriptMgr.cpp
- +++ b/src/server/game/Scripting/ScriptMgr.cpp
- @@ -691,6 +691,24 @@ bool ScriptMgr::OnItemExpire(Player* player, ItemTemplate const* proto)
- return tmpscript->OnExpire(player, proto);
- }
- +void ScriptMgr::OnGossipSelect(Player* player, Item* item, uint32 sender, uint32 action)
- +{
- + ASSERT(player);
- + ASSERT(item);
- +
- + GET_SCRIPT(ItemScript, item->GetScriptId(), tmpscript);
- + tmpscript->OnGossipSelect(player, item, sender, action);
- +}
- +
- +void ScriptMgr::OnGossipSelectCode(Player* player, Item* item, uint32 sender, uint32 action, const char* code)
- +{
- + ASSERT(player);
- + ASSERT(item);
- +
- + GET_SCRIPT(ItemScript, item->GetScriptId(), tmpscript);
- + tmpscript->OnGossipSelectCode(player, item, sender, action, code);
- +}
- +
- bool ScriptMgr::OnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex, Creature* target)
- {
- ASSERT(caster);
- @@ -1270,6 +1288,20 @@ void ScriptMgr::OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newAre
- FOREACH_SCRIPT(PlayerScript)->OnUpdateZone(player, newZone, newArea);
- }
- +void ScriptMgr::OnGossipSelect(Player* player, uint32 menu_id, uint32 sender, uint32 action)
- +{
- + ASSERT(player);
- +
- + FOREACH_SCRIPT(PlayerScript)->OnGossipSelect(player, menu_id, sender, action);
- +}
- +
- +void ScriptMgr::OnGossipSelectCode(Player* player, uint32 menu_id, uint32 sender, uint32 action, const char* code)
- +{
- + ASSERT(player);
- +
- + FOREACH_SCRIPT(PlayerScript)->OnGossipSelectCode(player, menu_id, sender, action, code);
- +}
- +
- // Guild
- void ScriptMgr::OnGuildAddMember(Guild* guild, Player* player, uint8& plRank)
- {
- diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h
- index 401be45..38b4d8d 100644
- --- a/src/server/game/Scripting/ScriptMgr.h
- +++ b/src/server/game/Scripting/ScriptMgr.h
- @@ -387,6 +387,12 @@ class ItemScript : public ScriptObject
- // Called when the item expires (is destroyed).
- virtual bool OnExpire(Player* /*player*/, ItemTemplate const* /*proto*/) { return false; }
- +
- + // Called when a player selects an option in an item gossip window
- + virtual void OnGossipSelect(Player* /*player*/, Item* /*item*/, uint32 /*sender*/, uint32 /*action*/) { }
- +
- + // Called when a player selects an option in an item gossip window
- + virtual void OnGossipSelectCode(Player* /*player*/, Item* /*item*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { }
- };
- class UnitScript : public ScriptObject
- @@ -760,6 +766,12 @@ class PlayerScript : public UnitScript
- // Called when a player changes to a new map (after moving to new map)
- virtual void OnMapChanged(Player* /*player*/) { }
- +
- + // Called when a player selects an option in a player gossip window
- + virtual void OnGossipSelect(Player* /*player*/, uint32 /*menu_id*/, uint32 /*sender*/, uint32 /*action*/) { }
- +
- + // Called when a player selects an option in a player gossip window
- + virtual void OnGossipSelectCode(Player* /*player*/, uint32 /*menu_id*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { }
- };
- class GuildScript : public ScriptObject
- @@ -917,6 +929,8 @@ class ScriptMgr
- bool OnQuestAccept(Player* player, Item* item, Quest const* quest);
- bool OnItemUse(Player* player, Item* item, SpellCastTargets const& targets);
- bool OnItemExpire(Player* player, ItemTemplate const* proto);
- + void OnGossipSelect(Player* player, Item* item, uint32 sender, uint32 action);
- + void OnGossipSelectCode(Player* player, Item* item, uint32 sender, uint32 action, const char* code);
- public: /* CreatureScript */
- @@ -1034,6 +1048,8 @@ class ScriptMgr
- void OnPlayerSave(Player* player);
- void OnPlayerBindToInstance(Player* player, Difficulty difficulty, uint32 mapid, bool permanent);
- void OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newArea);
- + void OnGossipSelect(Player* player, uint32 menu_id, uint32 sender, uint32 action);
- + void OnGossipSelectCode(Player* player, uint32 menu_id, uint32 sender, uint32 action, const char* code);
- public: /* GuildScript */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement