mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-25 05:57:45 +00:00
handle inventory packet sequencing properly for items & containers
This commit is contained in:
parent
dbd6804d7d
commit
332456ffd0
6 changed files with 26 additions and 12 deletions
|
@ -530,9 +530,10 @@ CREATE TABLE `landset` (
|
|||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE `houseiteminventory` (
|
||||
`landIdent` BIGINT(20) UNSIGNED NOT NULL,
|
||||
`containerId` INT(10) UNSIGNED NOT NULL,
|
||||
`itemId` INT(20) NOT NULL,
|
||||
`LandIdent` BIGINT(20) UNSIGNED NOT NULL,
|
||||
`ContainerId` INT(10) UNSIGNED NOT NULL,
|
||||
`ItemId` INT(20) NOT NULL,
|
||||
`SlotId` INT(10) UNSIGNED NOT NULL,
|
||||
INDEX `landIdent` (`landIdent`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
|
|
|
@ -910,6 +910,8 @@ namespace Sapphire::Entity
|
|||
|
||||
bool isObtainable( uint32_t catalogId, uint8_t quantity );
|
||||
|
||||
uint32_t getNextInventorySequence();
|
||||
|
||||
void send();
|
||||
|
||||
uint8_t getFreeSlotsInBags();
|
||||
|
@ -939,6 +941,8 @@ namespace Sapphire::Entity
|
|||
|
||||
bool m_onEnterEventDone;
|
||||
|
||||
uint32_t m_inventorySequence;
|
||||
|
||||
private:
|
||||
using InventoryMap = std::map< uint16_t, Sapphire::ItemContainerPtr >;
|
||||
|
||||
|
|
|
@ -357,14 +357,11 @@ void Sapphire::Entity::Player::removeCrystal( Common::CrystalType type, uint32_t
|
|||
|
||||
void Sapphire::Entity::Player::sendInventory()
|
||||
{
|
||||
InventoryMap::iterator it;
|
||||
|
||||
auto pInvMgr = g_fw.get< World::Manager::InventoryMgr >();
|
||||
|
||||
uint32_t count = 0;
|
||||
for( it = m_storageMap.begin(); it != m_storageMap.end(); ++it, ++count )
|
||||
for( auto it = m_storageMap.begin(); it != m_storageMap.end(); ++it )
|
||||
{
|
||||
pInvMgr->sendInventoryContainer( *this, it->second, count );
|
||||
pInvMgr->sendInventoryContainer( *this, it->second );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -867,3 +864,8 @@ bool Sapphire::Entity::Player::collectHandInItems( std::vector< uint32_t > itemI
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::Player::getNextInventorySequence()
|
||||
{
|
||||
return m_inventorySequence++;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "Framework.h"
|
||||
#include "ServerMgr.h"
|
||||
#include "Territory/House.h"
|
||||
#include "InventoryMgr.h"
|
||||
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::Network;
|
||||
|
@ -508,5 +509,12 @@ void Sapphire::World::Manager::HousingMgr::sendHousingInventory( Entity::Player&
|
|||
if( targetLand->getOwnerId() != player.getId() )
|
||||
return;
|
||||
|
||||
auto container = targetLand->getItemContainer( inventoryType );
|
||||
if( !container )
|
||||
return;
|
||||
|
||||
player.sendDebug( "got inventory for plot: " + targetLand->getHouse()->getHouseName() );
|
||||
|
||||
auto invMgr = g_fw.get< Manager::InventoryMgr >();
|
||||
invMgr->sendInventoryContainer( player, container );
|
||||
}
|
|
@ -10,9 +10,9 @@
|
|||
using namespace Sapphire::Network::Packets;
|
||||
|
||||
void Sapphire::World::Manager::InventoryMgr::sendInventoryContainer( Sapphire::Entity::Player& player,
|
||||
Sapphire::ItemContainerPtr container,
|
||||
uint32_t sequence )
|
||||
Sapphire::ItemContainerPtr container )
|
||||
{
|
||||
auto sequence = player.getNextInventorySequence();
|
||||
auto pMap = container->getItemMap();
|
||||
|
||||
for( auto itM = pMap.begin(); itM != pMap.end(); ++itM )
|
||||
|
|
|
@ -9,8 +9,7 @@ namespace Sapphire::World::Manager
|
|||
class InventoryMgr
|
||||
{
|
||||
public:
|
||||
void sendInventoryContainer( Sapphire::Entity::Player& player, Sapphire::ItemContainerPtr container,
|
||||
uint32_t sequence = 0 );
|
||||
void sendInventoryContainer( Sapphire::Entity::Player& player, Sapphire::ItemContainerPtr container );
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue