diff --git a/src/common/Database/ZoneDbConnection.cpp b/src/common/Database/ZoneDbConnection.cpp index fe8c90e9..4fa47ceb 100644 --- a/src/common/Database/ZoneDbConnection.cpp +++ b/src/common/Database/ZoneDbConnection.cpp @@ -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, diff --git a/src/world/ForwardsZone.h b/src/world/ForwardsZone.h index 585eb46c..82ad0e04 100644 --- a/src/world/ForwardsZone.h +++ b/src/world/ForwardsZone.h @@ -35,6 +35,11 @@ namespace World::Territory::Housing TYPE_FORWARD( HousingInteriorTerritory ); } +namespace Inventory +{ +TYPE_FORWARD( HousingItem ); +} + namespace World::Manager { TYPE_FORWARD( HousingMgr ); diff --git a/src/world/Inventory/HousingItem.cpp b/src/world/Inventory/HousingItem.cpp new file mode 100644 index 00000000..2b32736e --- /dev/null +++ b/src/world/Inventory/HousingItem.cpp @@ -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; +} \ No newline at end of file diff --git a/src/world/Inventory/HousingItem.h b/src/world/Inventory/HousingItem.h new file mode 100644 index 00000000..83fa20e3 --- /dev/null +++ b/src/world/Inventory/HousingItem.h @@ -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 diff --git a/src/world/Manager/HousingMgr.cpp b/src/world/Manager/HousingMgr.cpp index fd294cef..e62f87ec 100644 --- a/src/world/Manager/HousingMgr.cpp +++ b/src/world/Manager/HousingMgr.cpp @@ -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& diff --git a/src/world/Manager/InventoryMgr.cpp b/src/world/Manager/InventoryMgr.cpp index c813a571..e81b79e0 100644 --- a/src/world/Manager/InventoryMgr.cpp +++ b/src/world/Manager/InventoryMgr.cpp @@ -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() );