Advertisement
Rochet2

Item&Player gossip diff

Dec 21st, 2013
668
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 8.63 KB | None | 0 0
  1. diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp
  2. index 4da0d82..6e96755 100644
  3. --- a/src/server/game/Handlers/MiscHandler.cpp
  4. +++ b/src/server/game/Handlers/MiscHandler.cpp
  5. @@ -100,6 +100,7 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recvData)
  6.      if (_player->PlayerTalkClass->IsGossipOptionCoded(gossipListId))
  7.          recvData >> code;
  8.  
  9. +    Item* item = NULL;
  10.      Creature* unit = NULL;
  11.      GameObject* go = NULL;
  12.      if (IS_CRE_OR_VEH_GUID(guid))
  13. @@ -120,6 +121,32 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recvData)
  14.              return;
  15.          }
  16.      }
  17. +    else if (IS_GAMEOBJECT_GUID(guid))
  18. +    {
  19. +        go = _player->GetMap()->GetGameObject(guid);
  20. +        if (!go)
  21. +        {
  22. +            TC_LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - GameObject (GUID: %u) not found.", uint32(GUID_LOPART(guid)));
  23. +            return;
  24. +        }
  25. +    }
  26. +    else if (IS_ITEM_GUID(guid))
  27. +    {
  28. +        item = _player->GetItemByGuid(guid);
  29. +        if (!item)
  30. +        {
  31. +            TC_LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - Item (GUID: %u) not found.", uint32(GUID_LOPART(guid)));
  32. +            return;
  33. +        }
  34. +    }
  35. +    else if (IS_PLAYER_GUID(guid))
  36. +    {
  37. +        if (_player->GetGUID() != guid)
  38. +        {
  39. +            TC_LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - Player (GUID: %u) not receiver.", uint32(GUID_LOPART(guid)));
  40. +            return;
  41. +        }
  42. +    }
  43.      else
  44.      {
  45.          TC_LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - unsupported GUID type for highguid %u. lowpart %u.", uint32(GUID_HIPART(guid)), uint32(GUID_LOPART(guid)));
  46. @@ -148,11 +175,19 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recvData)
  47.              if (!sScriptMgr->OnGossipSelectCode(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str()))
  48.                  _player->OnGossipSelect(unit, gossipListId, menuId);
  49.          }
  50. -        else
  51. +        else if (go)
  52.          {
  53.              go->AI()->GossipSelectCode(_player, menuId, gossipListId, code.c_str());
  54.              sScriptMgr->OnGossipSelectCode(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str());
  55.          }
  56. +        else if (item)
  57. +        {
  58. +            sScriptMgr->OnGossipSelectCode(_player, item, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str());
  59. +        }
  60. +        else if (_player->PlayerTalkClass->GetGossipMenu().GetMenuId() == menuId)
  61. +        {
  62. +            sScriptMgr->OnGossipSelectCode(_player, menuId, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str());
  63. +        }
  64.      }
  65.      else
  66.      {
  67. @@ -162,12 +197,20 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recvData)
  68.              if (!sScriptMgr->OnGossipSelect(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId)))
  69.                  _player->OnGossipSelect(unit, gossipListId, menuId);
  70.          }
  71. -        else
  72. +        else if (go)
  73.          {
  74.              go->AI()->GossipSelect(_player, menuId, gossipListId);
  75.              if (!sScriptMgr->OnGossipSelect(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId)))
  76.                  _player->OnGossipSelect(go, gossipListId, menuId);
  77.          }
  78. +        else if (item)
  79. +        {
  80. +            sScriptMgr->OnGossipSelect(_player, item, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId));
  81. +        }
  82. +        else if (_player->PlayerTalkClass->GetGossipMenu().GetMenuId() == menuId)
  83. +        {
  84. +            sScriptMgr->OnGossipSelect(_player, menuId, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId));
  85. +        }
  86.      }
  87.  }
  88.  
  89. diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp
  90. index 3674f8f..24bb94e 100644
  91. --- a/src/server/game/Scripting/ScriptMgr.cpp
  92. +++ b/src/server/game/Scripting/ScriptMgr.cpp
  93. @@ -691,6 +691,24 @@ bool ScriptMgr::OnItemExpire(Player* player, ItemTemplate const* proto)
  94.      return tmpscript->OnExpire(player, proto);
  95.  }
  96.  
  97. +void ScriptMgr::OnGossipSelect(Player* player, Item* item, uint32 sender, uint32 action)
  98. +{
  99. +    ASSERT(player);
  100. +    ASSERT(item);
  101. +
  102. +    GET_SCRIPT(ItemScript, item->GetScriptId(), tmpscript);
  103. +    tmpscript->OnGossipSelect(player, item, sender, action);
  104. +}
  105. +
  106. +void ScriptMgr::OnGossipSelectCode(Player* player, Item* item, uint32 sender, uint32 action, const char* code)
  107. +{
  108. +    ASSERT(player);
  109. +    ASSERT(item);
  110. +
  111. +    GET_SCRIPT(ItemScript, item->GetScriptId(), tmpscript);
  112. +    tmpscript->OnGossipSelectCode(player, item, sender, action, code);
  113. +}
  114. +
  115.  bool ScriptMgr::OnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex, Creature* target)
  116.  {
  117.      ASSERT(caster);
  118. @@ -1270,6 +1288,20 @@ void ScriptMgr::OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newAre
  119.      FOREACH_SCRIPT(PlayerScript)->OnUpdateZone(player, newZone, newArea);
  120.  }
  121.  
  122. +void ScriptMgr::OnGossipSelect(Player* player, uint32 menu_id, uint32 sender, uint32 action)
  123. +{
  124. +    ASSERT(player);
  125. +
  126. +    FOREACH_SCRIPT(PlayerScript)->OnGossipSelect(player, menu_id, sender, action);
  127. +}
  128. +
  129. +void ScriptMgr::OnGossipSelectCode(Player* player, uint32 menu_id, uint32 sender, uint32 action, const char* code)
  130. +{
  131. +    ASSERT(player);
  132. +
  133. +    FOREACH_SCRIPT(PlayerScript)->OnGossipSelectCode(player, menu_id, sender, action, code);
  134. +}
  135. +
  136.  // Guild
  137.  void ScriptMgr::OnGuildAddMember(Guild* guild, Player* player, uint8& plRank)
  138.  {
  139. diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h
  140. index 401be45..38b4d8d 100644
  141. --- a/src/server/game/Scripting/ScriptMgr.h
  142. +++ b/src/server/game/Scripting/ScriptMgr.h
  143. @@ -387,6 +387,12 @@ class ItemScript : public ScriptObject
  144.  
  145.          // Called when the item expires (is destroyed).
  146.          virtual bool OnExpire(Player* /*player*/, ItemTemplate const* /*proto*/) { return false; }
  147. +
  148. +        // Called when a player selects an option in an item gossip window
  149. +        virtual void OnGossipSelect(Player* /*player*/, Item* /*item*/, uint32 /*sender*/, uint32 /*action*/) { }
  150. +
  151. +        // Called when a player selects an option in an item gossip window
  152. +        virtual void OnGossipSelectCode(Player* /*player*/, Item* /*item*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { }
  153.  };
  154.  
  155.  class UnitScript : public ScriptObject
  156. @@ -760,6 +766,12 @@ class PlayerScript : public UnitScript
  157.  
  158.          // Called when a player changes to a new map (after moving to new map)
  159.          virtual void OnMapChanged(Player* /*player*/) { }
  160. +
  161. +        // Called when a player selects an option in a player gossip window
  162. +        virtual void OnGossipSelect(Player* /*player*/, uint32 /*menu_id*/, uint32 /*sender*/, uint32 /*action*/) { }
  163. +
  164. +        // Called when a player selects an option in a player gossip window
  165. +        virtual void OnGossipSelectCode(Player* /*player*/, uint32 /*menu_id*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { }
  166.  };
  167.  
  168.  class GuildScript : public ScriptObject
  169. @@ -917,6 +929,8 @@ class ScriptMgr
  170.          bool OnQuestAccept(Player* player, Item* item, Quest const* quest);
  171.          bool OnItemUse(Player* player, Item* item, SpellCastTargets const& targets);
  172.          bool OnItemExpire(Player* player, ItemTemplate const* proto);
  173. +        void OnGossipSelect(Player* player, Item* item, uint32 sender, uint32 action);
  174. +        void OnGossipSelectCode(Player* player, Item* item, uint32 sender, uint32 action, const char* code);
  175.  
  176.      public: /* CreatureScript */
  177.  
  178. @@ -1034,6 +1048,8 @@ class ScriptMgr
  179.          void OnPlayerSave(Player* player);
  180.          void OnPlayerBindToInstance(Player* player, Difficulty difficulty, uint32 mapid, bool permanent);
  181.          void OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newArea);
  182. +        void OnGossipSelect(Player* player, uint32 menu_id, uint32 sender, uint32 action);
  183. +        void OnGossipSelectCode(Player* player, uint32 menu_id, uint32 sender, uint32 action, const char* code);
  184.  
  185.      public: /* GuildScript */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement