Advertisement
Rochet2

Multi Vendor

Jan 12th, 2013
715
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.96 KB | None | 0 0
  1. diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
  2. index e501471..00ee2e2 100644
  3. --- a/src/server/game/Entities/Player/Player.cpp
  4. +++ b/src/server/game/Entities/Player/Player.cpp
  5. @@ -14275,7 +14275,7 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool
  6.                      break;
  7.                  case GOSSIP_OPTION_VENDOR:
  8.                  {
  9. -                    VendorItemData const* vendorItems = creature->GetVendorItems();
  10. +                    VendorItemData const* vendorItems = itr->second.ActionMenuId ? sObjectMgr->GetNpcVendorItemList(itr->second.ActionMenuId) : creature->GetVendorItems();
  11.                      if (!vendorItems || vendorItems->Empty())
  12.                      {
  13.                          sLog->outError(LOG_FILTER_SQL, "Creature %u (Entry: %u) have UNIT_NPC_FLAG_VENDOR but have empty trading item list.", creature->GetGUIDLow(), creature->GetEntry());
  14. @@ -14467,7 +14467,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men
  15.              break;
  16.          case GOSSIP_OPTION_VENDOR:
  17.          case GOSSIP_OPTION_ARMORER:
  18. -            GetSession()->SendListInventory(guid);
  19. +            GetSession()->SendListInventory(guid, menuItemData->GossipActionMenuId);
  20.              break;
  21.          case GOSSIP_OPTION_STABLEPET:
  22.              GetSession()->SendStablePet(guid);
  23. @@ -21147,7 +21147,7 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
  24.          return false;
  25.      }
  26.  
  27. -    VendorItemData const* vItems = creature->GetVendorItems();
  28. +    VendorItemData const* vItems = GetSession()->GetCurrentVendor() ? sObjectMgr->GetNpcVendorItemList(GetSession()->GetCurrentVendor()) : creature->GetVendorItems();
  29.      if (!vItems || vItems->Empty())
  30.      {
  31.          SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, item, 0);
  32. diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp
  33. index 77d44df..72377c6 100644
  34. --- a/src/server/game/Handlers/ItemHandler.cpp
  35. +++ b/src/server/game/Handlers/ItemHandler.cpp
  36. @@ -717,7 +717,7 @@ void WorldSession::HandleListInventoryOpcode(WorldPacket& recvData)
  37.      SendListInventory(guid);
  38.  }
  39.  
  40. -void WorldSession::SendListInventory(uint64 vendorGuid)
  41. +void WorldSession::SendListInventory(uint64 vendorGuid, uint32 vendorEntry)
  42.  {
  43.      sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_LIST_INVENTORY");
  44.  
  45. @@ -737,7 +737,7 @@ void WorldSession::SendListInventory(uint64 vendorGuid)
  46.      if (vendor->HasUnitState(UNIT_STATE_MOVING))
  47.          vendor->StopMoving();
  48.  
  49. -    VendorItemData const* items = vendor->GetVendorItems();
  50. +    VendorItemData const* items = vendorEntry ? sObjectMgr->GetNpcVendorItemList(vendorEntry) : vendor->GetVendorItems();
  51.      if (!items)
  52.      {
  53.          WorldPacket data(SMSG_LIST_INVENTORY, 8 + 1 + 1);
  54. @@ -748,6 +748,8 @@ void WorldSession::SendListInventory(uint64 vendorGuid)
  55.          return;
  56.      }
  57.  
  58. +    SetCurrentVendor(vendorEntry);
  59. +
  60.      uint8 itemCount = items->GetItemCount();
  61.      uint8 count = 0;
  62.  
  63. diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp
  64. index 484a382..a41a24f 100644
  65. --- a/src/server/game/Server/WorldSession.cpp
  66. +++ b/src/server/game/Server/WorldSession.cpp
  67. @@ -102,7 +102,7 @@ m_playerRecentlyLogout(false), m_playerSave(false),
  68.  m_sessionDbcLocale(sWorld->GetAvailableDbcLocale(locale)),
  69.  m_sessionDbLocaleIndex(locale),
  70.  m_latency(0), m_TutorialsChanged(false), recruiterId(recruiter),
  71. -isRecruiter(isARecruiter), timeLastWhoCommand(0)
  72. +isRecruiter(isARecruiter), timeLastWhoCommand(0), m_CurrentVendor(0)
  73.  {
  74.      _warden = NULL;
  75.  
  76. diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
  77. index 5561834..8175d58 100644
  78. --- a/src/server/game/Server/WorldSession.h
  79. +++ b/src/server/game/Server/WorldSession.h
  80. @@ -222,6 +222,9 @@ class WorldSession
  81.          std::string const& GetPlayerName() const;
  82.          std::string GetPlayerInfo() const;
  83.  
  84. +        uint32 GetCurrentVendor() const { return m_CurrentVendor; }
  85. +        void SetCurrentVendor(uint32 entry) { m_CurrentVendor = entry; }
  86. +
  87.          uint32 GetGuidLow() const;
  88.          void SetSecurity(AccountTypes security) { _security = security; }
  89.          std::string const& GetRemoteAddress() { return m_Address; }
  90. @@ -262,7 +265,7 @@ class WorldSession
  91.  
  92.          void SendTrainerList(uint64 guid);
  93.          void SendTrainerList(uint64 guid, std::string const& strTitle);
  94. -        void SendListInventory(uint64 guid);
  95. +        void SendListInventory(uint64 guid, uint32 vendorEntry = 0);
  96.          void SendShowBank(uint64 guid);
  97.          void SendTabardVendorActivate(uint64 guid);
  98.          void SendSpiritResurrect();
  99. @@ -927,6 +930,7 @@ class WorldSession
  100.          Player* _player;
  101.          WorldSocket* m_Socket;
  102.          std::string m_Address;
  103. +        uint32 m_CurrentVendor;
  104.  
  105.          AccountTypes _security;
  106.          uint32 _accountId;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement