From f303cb3ebc6bd69dde8d4f6ec09609dafaec6239 Mon Sep 17 00:00:00 2001 From: Mordred Date: Sun, 29 Jan 2023 12:35:43 +0100 Subject: [PATCH] Fixing placement and storage of yard items --- src/world/Manager/InventoryMgr.cpp | 16 ++++++---------- src/world/Territory/HousingZone.cpp | 11 +++++------ src/world/Territory/HousingZone.h | 8 ++++---- src/world/Territory/Land.cpp | 10 ---------- 4 files changed, 15 insertions(+), 30 deletions(-) diff --git a/src/world/Manager/InventoryMgr.cpp b/src/world/Manager/InventoryMgr.cpp index 6714207d..22a9748c 100644 --- a/src/world/Manager/InventoryMgr.cpp +++ b/src/world/Manager/InventoryMgr.cpp @@ -147,22 +147,18 @@ void InventoryMgr::updateHousingItemPosition( Inventory::HousingItemPtr item ) auto pos = item->getPos(); - auto posX = static_cast< uint32_t >( pos.x ); - auto posY = static_cast< uint32_t >( pos.y ); - auto posZ = static_cast< uint32_t >( pos.z ); - auto rot = static_cast< int32_t >( item->getRot() ); stmt->setUInt64( 1, item->getUId() ); - stmt->setUInt( 2, posX ); - stmt->setUInt( 3, posY ); - stmt->setUInt( 4, posZ ); + stmt->setDouble( 2, pos.x ); + stmt->setDouble( 3, pos.y ); + stmt->setDouble( 4, pos.z ); stmt->setInt( 5, rot ); - stmt->setUInt( 6, posX ); - stmt->setUInt( 7, posY ); - stmt->setUInt( 8, posZ ); + stmt->setDouble( 6, pos.x ); + stmt->setDouble( 7, pos.y ); + stmt->setDouble( 8, pos.z ); stmt->setInt( 9, rot ); db.execute( stmt ); diff --git a/src/world/Territory/HousingZone.cpp b/src/world/Territory/HousingZone.cpp index 20a42cfa..014b29a4 100644 --- a/src/world/Territory/HousingZone.cpp +++ b/src/world/Territory/HousingZone.cpp @@ -166,17 +166,14 @@ void Sapphire::HousingZone::onPlayerZoneIn( Entity::Player& player ) sendLandSet( player ); + auto yardObjectSize = sizeof( Common::Furniture ); for( yardPacketNum = 0; yardPacketNum < yardPacketTotal; yardPacketNum++ ) { auto housingObjectInit = makeZonePacket< FFXIVIpcYardObjectList >( player.getId() ); housingObjectInit->data().PacketIndex = yardPacketNum; - auto yardObjectSize = sizeof( Common::Furniture ); - housingObjectInit->data().PacketIndex = yardPacketNum; - housingObjectInit->data().PacketEnd = yardPacketTotal; + auto& objects = m_yardObjects; - auto& objects = m_yardObjects[ isInSubdivision ? 1 : 0 ]; - - memcpy( &housingObjectInit->data().YardObjects, &objects + ( yardPacketNum * 100 ), yardObjectSize * 100 ); + memcpy( &housingObjectInit->data().YardObjects, &objects[ yardPacketNum * 400 ], yardObjectSize * 400 ); server.queueForPlayer( player.getCharacterId(), housingObjectInit ); } @@ -363,11 +360,13 @@ void Sapphire::HousingZone::updateYardObjects( Sapphire::Common::LandIdent ident for( const auto& item : yardContainer->getItemMap() ) { + auto housingItem = std::dynamic_pointer_cast< Inventory::HousingItem >( item.second ); assert( housingItem ); auto idx = item.first + arrayBounds.first; m_yardObjects[ idx ] = housingMgr.getYardObjectForItem( housingItem ); + Logger::debug( "Loading yard item {} {}", item.second->getId(), idx ); } } diff --git a/src/world/Territory/HousingZone.h b/src/world/Territory/HousingZone.h index 943ccc54..d3e17182 100644 --- a/src/world/Territory/HousingZone.h +++ b/src/world/Territory/HousingZone.h @@ -1,5 +1,4 @@ -#ifndef SAPPHIRE_HOUSINGZONE_H -#define SAPPHIRE_HOUSINGZONE_H +#pragma once #include "Territory.h" #include "Forwards.h" @@ -62,7 +61,9 @@ namespace Sapphire private: using LandPtrMap = std::unordered_map< uint8_t, Sapphire::LandPtr >; - using YardObjectArray = std::array< Common::Furniture, 800 >; + + /*! @brief global storage for all yard items in the ward */ + using YardObjectArray = std::array< Common::Furniture, 1200 >; /*! * @brief Maps the start and end index of the yard object array for a specific plot @@ -87,4 +88,3 @@ namespace Sapphire }; } -#endif //SAPPHIRE_HOUSINGZONE_H diff --git a/src/world/Territory/Land.cpp b/src/world/Territory/Land.cpp index d34ef1df..de522293 100644 --- a/src/world/Territory/Land.cpp +++ b/src/world/Territory/Land.cpp @@ -62,16 +62,6 @@ void Sapphire::Land::init( Common::LandType type, Common::HouseSize size, Common m_state = state; m_currentPrice = currentPrice; m_ownerId = ownerId; - - auto& exdData = Common::Service< Data::ExdData >::ref(); - // EXD TODO: This does not exist in 2.3 - /*auto info = exdData.getRow< Excel::HousingMapMarkerInfo >( m_landIdent.territoryTypeId, m_landIdent.landId ); - if( info ) - { - m_mapMarkerPosition.x = info->x; - m_mapMarkerPosition.y = info->y; - m_mapMarkerPosition.z = info->z; - }*/ } uint32_t Sapphire::Land::getCurrentPrice() const