mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 14:57:44 +00:00
Move inventory container sending to its own function
This commit is contained in:
parent
3f6f0d5a5f
commit
f44c6b5efe
5 changed files with 88 additions and 49 deletions
|
@ -1078,7 +1078,7 @@ struct FFXIVIpcCharaNameReq :
|
|||
struct FFXIVIpcItemInfo :
|
||||
FFXIVIpcBasePacket< ItemInfo >
|
||||
{
|
||||
uint32_t sequence;
|
||||
uint32_t containerSequence;
|
||||
uint32_t unknown;
|
||||
uint16_t containerId;
|
||||
uint16_t slot;
|
||||
|
@ -1113,7 +1113,7 @@ struct FFXIVIpcItemInfo :
|
|||
struct FFXIVIpcContainerInfo :
|
||||
FFXIVIpcBasePacket< ContainerInfo >
|
||||
{
|
||||
uint32_t sequence;
|
||||
uint32_t containerSequence;
|
||||
uint32_t numItems;
|
||||
uint32_t containerId;
|
||||
uint32_t unknown;
|
||||
|
@ -1126,7 +1126,7 @@ struct FFXIVIpcContainerInfo :
|
|||
struct FFXIVIpcCurrencyCrystalInfo :
|
||||
FFXIVIpcBasePacket< CurrencyCrystalInfo >
|
||||
{
|
||||
uint32_t sequence;
|
||||
uint32_t containerSequence;
|
||||
uint16_t containerId;
|
||||
uint16_t slot;
|
||||
uint32_t quantity;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "Network/PacketWrappers/ServerNoticePacket.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
||||
|
||||
#include "Manager/InventoryMgr.h"
|
||||
|
||||
#include "Framework.h"
|
||||
#include <Network/CommonActorControl.h>
|
||||
|
@ -358,54 +359,13 @@ void Sapphire::Entity::Player::sendInventory()
|
|||
{
|
||||
InventoryMap::iterator it;
|
||||
|
||||
int32_t count = 0;
|
||||
for( it = m_storageMap.begin(); it != m_storageMap.end(); ++it, count++ )
|
||||
auto pInvMgr = g_fw.get< World::Manager::InventoryMgr >();
|
||||
|
||||
uint32_t count = 0;
|
||||
for( it = m_storageMap.begin(); it != m_storageMap.end(); ++it, ++count )
|
||||
{
|
||||
|
||||
auto pMap = it->second->getItemMap();
|
||||
auto itM = pMap.begin();
|
||||
|
||||
for( ; itM != pMap.end(); ++itM )
|
||||
{
|
||||
if( !itM->second )
|
||||
return;
|
||||
|
||||
if( it->second->getId() == InventoryType::Currency || it->second->getId() == InventoryType::Crystal )
|
||||
{
|
||||
auto currencyInfoPacket = makeZonePacket< FFXIVIpcCurrencyCrystalInfo >( getId() );
|
||||
currencyInfoPacket->data().sequence = count;
|
||||
currencyInfoPacket->data().catalogId = itM->second->getId();
|
||||
currencyInfoPacket->data().unknown = 1;
|
||||
currencyInfoPacket->data().quantity = itM->second->getStackSize();
|
||||
currencyInfoPacket->data().containerId = it->second->getId();
|
||||
currencyInfoPacket->data().slot = 0;
|
||||
queuePacket( currencyInfoPacket );
|
||||
pInvMgr->sendInventoryContainer( *this, it->second, count );
|
||||
}
|
||||
else
|
||||
{
|
||||
auto itemInfoPacket = makeZonePacket< FFXIVIpcItemInfo >( getId() );
|
||||
itemInfoPacket->data().sequence = count;
|
||||
itemInfoPacket->data().containerId = it->second->getId();
|
||||
itemInfoPacket->data().slot = itM->first;
|
||||
itemInfoPacket->data().quantity = itM->second->getStackSize();
|
||||
itemInfoPacket->data().catalogId = itM->second->getId();
|
||||
itemInfoPacket->data().condition = itM->second->getDurability();
|
||||
itemInfoPacket->data().spiritBond = 0;
|
||||
itemInfoPacket->data().hqFlag = itM->second->isHq() ? 1 : 0;
|
||||
itemInfoPacket->data().stain = itM->second->getStain();
|
||||
queuePacket( itemInfoPacket );
|
||||
}
|
||||
}
|
||||
|
||||
auto containerInfoPacket = makeZonePacket< FFXIVIpcContainerInfo >( getId() );
|
||||
containerInfoPacket->data().sequence = count;
|
||||
containerInfoPacket->data().numItems = it->second->getEntryCount();
|
||||
containerInfoPacket->data().containerId = it->second->getId();
|
||||
queuePacket( containerInfoPacket );
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Sapphire::Entity::Player::InvSlotPairVec Sapphire::Entity::Player::getSlotsOfItemsInInventory( uint32_t catalogId )
|
||||
|
|
58
src/world/Manager/InventoryMgr.cpp
Normal file
58
src/world/Manager/InventoryMgr.cpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
#include "InventoryMgr.h"
|
||||
|
||||
#include <Common.h>
|
||||
#include "Actor/Player.h"
|
||||
#include "Inventory/ItemContainer.h"
|
||||
#include "Inventory/Item.h"
|
||||
#include <Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
#include <Network/GamePacketNew.h>
|
||||
|
||||
using namespace Sapphire::Network::Packets;
|
||||
|
||||
void Sapphire::World::Manager::InventoryMgr::sendInventoryContainer( Sapphire::Entity::Player& player,
|
||||
Sapphire::ItemContainerPtr container,
|
||||
uint32_t sequence )
|
||||
{
|
||||
auto pMap = container->getItemMap();
|
||||
|
||||
for( auto itM = pMap.begin(); itM != pMap.end(); ++itM )
|
||||
{
|
||||
if( !itM->second )
|
||||
return;
|
||||
|
||||
if( container->getId() == Common::InventoryType::Currency || container->getId() == Common::InventoryType::Crystal )
|
||||
{
|
||||
auto currencyInfoPacket = makeZonePacket< Server::FFXIVIpcCurrencyCrystalInfo >( player.getId() );
|
||||
currencyInfoPacket->data().containerSequence = sequence;
|
||||
currencyInfoPacket->data().catalogId = itM->second->getId();
|
||||
currencyInfoPacket->data().unknown = 1;
|
||||
currencyInfoPacket->data().quantity = itM->second->getStackSize();
|
||||
currencyInfoPacket->data().containerId = container->getId();
|
||||
currencyInfoPacket->data().slot = 0;
|
||||
|
||||
player.queuePacket( currencyInfoPacket );
|
||||
}
|
||||
else
|
||||
{
|
||||
auto itemInfoPacket = makeZonePacket< Server::FFXIVIpcItemInfo >( player.getId() );
|
||||
itemInfoPacket->data().containerSequence = sequence;
|
||||
itemInfoPacket->data().containerId = container->getId();
|
||||
itemInfoPacket->data().slot = itM->first;
|
||||
itemInfoPacket->data().quantity = itM->second->getStackSize();
|
||||
itemInfoPacket->data().catalogId = itM->second->getId();
|
||||
itemInfoPacket->data().condition = itM->second->getDurability();
|
||||
itemInfoPacket->data().spiritBond = 0;
|
||||
itemInfoPacket->data().hqFlag = itM->second->isHq() ? 1 : 0;
|
||||
itemInfoPacket->data().stain = itM->second->getStain();
|
||||
|
||||
player.queuePacket( itemInfoPacket );
|
||||
}
|
||||
}
|
||||
|
||||
auto containerInfoPacket = makeZonePacket< Server::FFXIVIpcContainerInfo >( player.getId() );
|
||||
containerInfoPacket->data().containerSequence = sequence;
|
||||
containerInfoPacket->data().numItems = container->getEntryCount();
|
||||
containerInfoPacket->data().containerId = container->getId();
|
||||
|
||||
player.queuePacket( containerInfoPacket );
|
||||
}
|
18
src/world/Manager/InventoryMgr.h
Normal file
18
src/world/Manager/InventoryMgr.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef SAPPHIRE_INVENTORYMGR_H
|
||||
#define SAPPHIRE_INVENTORYMGR_H
|
||||
|
||||
#include "ForwardsZone.h"
|
||||
|
||||
namespace Sapphire::World::Manager
|
||||
{
|
||||
|
||||
class InventoryMgr
|
||||
{
|
||||
public:
|
||||
void sendInventoryContainer( Sapphire::Entity::Player& player, Sapphire::ItemContainerPtr container,
|
||||
uint32_t sequence = 0 );
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //SAPPHIRE_INVENTORYMGR_H
|
|
@ -36,6 +36,7 @@
|
|||
#include "DebugCommand/DebugCommandHandler.h"
|
||||
#include "Manager/PlayerMgr.h"
|
||||
#include "Manager/ShopMgr.h"
|
||||
#include "Manager/InventoryMgr.h"
|
||||
|
||||
|
||||
extern Sapphire::Framework g_fw;
|
||||
|
@ -168,10 +169,12 @@ void Sapphire::ServerMgr::run( int32_t argc, char* argv[] )
|
|||
auto pDebugCom = std::make_shared< DebugCommandHandler >();
|
||||
auto pPlayerMgr = std::make_shared< Manager::PlayerMgr >();
|
||||
auto pShopMgr = std::make_shared< Manager::ShopMgr >();
|
||||
auto pInventoryMgr = std::make_shared< Manager::InventoryMgr >();
|
||||
|
||||
g_fw.set< DebugCommandHandler >( pDebugCom );
|
||||
g_fw.set< Manager::PlayerMgr >( pPlayerMgr );
|
||||
g_fw.set< Manager::ShopMgr >( pShopMgr );
|
||||
g_fw.set< Manager::InventoryMgr >( pInventoryMgr );
|
||||
|
||||
pLog->info( "World server running on " + m_ip + ":" + std::to_string( m_port ) );
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue