mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-25 14:07:46 +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;
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||||
|
|
||||||
CREATE TABLE `houseiteminventory` (
|
CREATE TABLE `houseiteminventory` (
|
||||||
`landIdent` BIGINT(20) UNSIGNED NOT NULL,
|
`LandIdent` BIGINT(20) UNSIGNED NOT NULL,
|
||||||
`containerId` INT(10) UNSIGNED NOT NULL,
|
`ContainerId` INT(10) UNSIGNED NOT NULL,
|
||||||
`itemId` INT(20) NOT NULL,
|
`ItemId` INT(20) NOT NULL,
|
||||||
|
`SlotId` INT(10) UNSIGNED NOT NULL,
|
||||||
INDEX `landIdent` (`landIdent`)
|
INDEX `landIdent` (`landIdent`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||||
|
|
||||||
|
|
|
@ -910,6 +910,8 @@ namespace Sapphire::Entity
|
||||||
|
|
||||||
bool isObtainable( uint32_t catalogId, uint8_t quantity );
|
bool isObtainable( uint32_t catalogId, uint8_t quantity );
|
||||||
|
|
||||||
|
uint32_t getNextInventorySequence();
|
||||||
|
|
||||||
void send();
|
void send();
|
||||||
|
|
||||||
uint8_t getFreeSlotsInBags();
|
uint8_t getFreeSlotsInBags();
|
||||||
|
@ -939,6 +941,8 @@ namespace Sapphire::Entity
|
||||||
|
|
||||||
bool m_onEnterEventDone;
|
bool m_onEnterEventDone;
|
||||||
|
|
||||||
|
uint32_t m_inventorySequence;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using InventoryMap = std::map< uint16_t, Sapphire::ItemContainerPtr >;
|
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()
|
void Sapphire::Entity::Player::sendInventory()
|
||||||
{
|
{
|
||||||
InventoryMap::iterator it;
|
|
||||||
|
|
||||||
auto pInvMgr = g_fw.get< World::Manager::InventoryMgr >();
|
auto pInvMgr = g_fw.get< World::Manager::InventoryMgr >();
|
||||||
|
|
||||||
uint32_t count = 0;
|
for( auto it = m_storageMap.begin(); it != m_storageMap.end(); ++it )
|
||||||
for( it = m_storageMap.begin(); it != m_storageMap.end(); ++it, ++count )
|
|
||||||
{
|
{
|
||||||
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t Sapphire::Entity::Player::getNextInventorySequence()
|
||||||
|
{
|
||||||
|
return m_inventorySequence++;
|
||||||
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "Framework.h"
|
#include "Framework.h"
|
||||||
#include "ServerMgr.h"
|
#include "ServerMgr.h"
|
||||||
#include "Territory/House.h"
|
#include "Territory/House.h"
|
||||||
|
#include "InventoryMgr.h"
|
||||||
|
|
||||||
using namespace Sapphire::Common;
|
using namespace Sapphire::Common;
|
||||||
using namespace Sapphire::Network;
|
using namespace Sapphire::Network;
|
||||||
|
@ -508,5 +509,12 @@ void Sapphire::World::Manager::HousingMgr::sendHousingInventory( Entity::Player&
|
||||||
if( targetLand->getOwnerId() != player.getId() )
|
if( targetLand->getOwnerId() != player.getId() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
auto container = targetLand->getItemContainer( inventoryType );
|
||||||
|
if( !container )
|
||||||
|
return;
|
||||||
|
|
||||||
player.sendDebug( "got inventory for plot: " + targetLand->getHouse()->getHouseName() );
|
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;
|
using namespace Sapphire::Network::Packets;
|
||||||
|
|
||||||
void Sapphire::World::Manager::InventoryMgr::sendInventoryContainer( Sapphire::Entity::Player& player,
|
void Sapphire::World::Manager::InventoryMgr::sendInventoryContainer( Sapphire::Entity::Player& player,
|
||||||
Sapphire::ItemContainerPtr container,
|
Sapphire::ItemContainerPtr container )
|
||||||
uint32_t sequence )
|
|
||||||
{
|
{
|
||||||
|
auto sequence = player.getNextInventorySequence();
|
||||||
auto pMap = container->getItemMap();
|
auto pMap = container->getItemMap();
|
||||||
|
|
||||||
for( auto itM = pMap.begin(); itM != pMap.end(); ++itM )
|
for( auto itM = pMap.begin(); itM != pMap.end(); ++itM )
|
||||||
|
|
|
@ -9,8 +9,7 @@ namespace Sapphire::World::Manager
|
||||||
class InventoryMgr
|
class InventoryMgr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void sendInventoryContainer( Sapphire::Entity::Player& player, Sapphire::ItemContainerPtr container,
|
void sendInventoryContainer( Sapphire::Entity::Player& player, Sapphire::ItemContainerPtr container );
|
||||||
uint32_t sequence = 0 );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue