1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-08 11:47:45 +00:00

use HousingItem instead of Item for housing inventories

This commit is contained in:
NotAdam 2018-12-23 22:43:35 +11:00
parent b77d4e6ff3
commit b4e0c2a406
6 changed files with 72 additions and 16 deletions

View file

@ -201,10 +201,13 @@ void Sapphire::Db::ZoneDbConnection::doPrepareStatements()
CONNECTION_BOTH );
prepareStatement( LAND_INV_SEL_ALL,
"SELECT houseiteminventory.*, charaglobalitem.catalogId, charaglobalitem.stain, charaglobalitem.CharacterId "
"SELECT houseiteminventory.*, charaglobalitem.catalogId, charaglobalitem.stain, charaglobalitem.CharacterId, "
"landplaceditems.PosX, landplaceditems.PosY, landplaceditems.PosZ, landplaceditems.Rotation "
"FROM houseiteminventory "
"LEFT JOIN charaglobalitem "
"ON houseiteminventory.ItemId = charaglobalitem.itemId;",
"ON houseiteminventory.ItemId = charaglobalitem.itemId "
"LEFT JOIN landplaceditems "
"ON houseiteminventory.ItemId = landplaceditems.ItemId;",
CONNECTION_BOTH );
prepareStatement( LAND_INV_SEL_HOUSE,

View file

@ -35,6 +35,11 @@ namespace World::Territory::Housing
TYPE_FORWARD( HousingInteriorTerritory );
}
namespace Inventory
{
TYPE_FORWARD( HousingItem );
}
namespace World::Manager
{
TYPE_FORWARD( HousingMgr );

View file

@ -0,0 +1,25 @@
#include "HousingItem.h"
Sapphire::Inventory::HousingItem::HousingItem( uint64_t uId, uint32_t catalogId ) :
Sapphire::Item( uId, catalogId, 0, 0, false )
{ }
float Sapphire::Inventory::HousingItem::getRot() const
{
return m_rotation;
}
void Sapphire::Inventory::HousingItem::setRot( float rot )
{
m_rotation = rot;
}
Sapphire::Common::FFXIVARR_POSITION3 Sapphire::Inventory::HousingItem::getPos() const
{
return m_position;
}
void Sapphire::Inventory::HousingItem::setPos( Sapphire::Common::FFXIVARR_POSITION3 pos )
{
m_position = pos;
}

View file

@ -0,0 +1,25 @@
#ifndef SAPPHIRE_HOUSINGITEM_H
#define SAPPHIRE_HOUSINGITEM_H
#include "Item.h"
namespace Sapphire::Inventory
{
class HousingItem : public Item
{
public:
HousingItem( uint64_t uId, uint32_t catalogId );
void setRot( float rot );
float getRot() const;
void setPos( Common::FFXIVARR_POSITION3 pos );
Common::FFXIVARR_POSITION3 getPos() const;
private:
Common::FFXIVARR_POSITION3 m_position;
float m_rotation;
};
}
#endif //SAPPHIRE_HOUSINGITEM_H

View file

@ -25,7 +25,7 @@
#include "ServerMgr.h"
#include "Territory/House.h"
#include "InventoryMgr.h"
#include "Inventory/Item.h"
#include "Inventory/HousingItem.h"
#include "Inventory/ItemContainer.h"
using namespace Sapphire::Common;
@ -91,15 +91,15 @@ bool Sapphire::World::Manager::HousingMgr::loadEstateInventories()
while( res->next() )
{
//uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t model2, bool isHq
auto ident = res->getUInt64( "LandIdent" );
auto containerId = res->getUInt16( "ContainerId" );
auto itemId = res->getUInt64( "ItemId" );
auto slot = res->getUInt16( "SlotId" );
auto catalogId = res->getUInt( "catalogId" );
auto stain = res->getUInt8( "stain" );
auto characterId = res->getUInt64( "CharacterId" );
auto ident = res->getUInt64( "LandIdent" );
auto containerId = res->getUInt16( "ContainerId" );
auto itemId = res->getUInt64( "ItemId" );
auto slot = res->getUInt16( "SlotId" );
auto catalogId = res->getUInt( "catalogId" );
auto stain = res->getUInt8( "stain" );
auto characterId = res->getUInt64( "CharacterId" );
auto item = make_Item( itemId, catalogId, 0, 0, 0 );
auto item = Inventory::make_HousingItem( itemId, catalogId );
item->setStain( stain );
// todo: need to set the owner character id on the item
@ -739,12 +739,10 @@ void Sapphire::World::Manager::HousingMgr::sendEstateInventory( Entity::Player&
if( targetLand->getOwnerId() != player.getId() )
return;
auto container = getEstateInventory( targetLand->getLandIdent() )[ inventoryType ];
if( !container )
return;
auto& containers = getEstateInventory( targetLand->getLandIdent() );
auto invMgr = g_fw.get< Manager::InventoryMgr >();
invMgr->sendInventoryContainer( player, container );
invMgr->sendInventoryContainer( player, containers[ inventoryType ] );
}
const Sapphire::World::Manager::HousingMgr::LandSetLandCacheMap&

View file

@ -83,7 +83,7 @@ Sapphire::ItemPtr Sapphire::World::Manager::InventoryMgr::createItem( Entity::Pl
auto stmt = pDb->getPreparedStatement( Db::CHARA_ITEMGLOBAL_INS );
stmt->setUInt( 1, player.getId() );
stmt->setUInt( 2, item->getUId() );
stmt->setUInt64( 2, item->getUId() );
stmt->setUInt( 3, item->getId() );
stmt->setUInt( 4, item->getStackSize() );