diff --git a/src/world/Manager/HousingMgr.cpp b/src/world/Manager/HousingMgr.cpp index f5ef4403..d38bd9e5 100644 --- a/src/world/Manager/HousingMgr.cpp +++ b/src/world/Manager/HousingMgr.cpp @@ -59,17 +59,16 @@ bool Sapphire::World::Manager::HousingMgr::init() entry.m_landSetId = res->getUInt64( "LandSetId" ); entry.m_landId = res->getUInt64( "LandId" ); - entry.m_type = res->getUInt8( "Type" ); + entry.m_type = static_cast< Common::LandType >( res->getUInt( "Type" ) ); entry.m_size = res->getUInt8( "Size" ); entry.m_status = res->getUInt8( "Status" ); - entry.m_landPrice = res->getUInt64( "LandPrice" ); + entry.m_currentPrice = res->getUInt64( "LandPrice" ); entry.m_updateTime = res->getUInt64( "UpdateTime" ); entry.m_ownerId = res->getUInt64( "OwnerId" ); entry.m_houseId = res->getUInt64( "HouseId" ); // house stuff - entry.m_estateWelcome = res->getString( "Welcome" ); entry.m_estateComment = res->getString( "Comment" ); entry.m_houseName = res->getString( "HouseName" ); @@ -90,7 +89,7 @@ bool Sapphire::World::Manager::HousingMgr::init() if( landSet.second.size() != 60 ) { - log->fatal( "LandSet " + std::to_string( landSet.first ) + " is missing entries. Only have " + std::to_string( count ) + " land entries." ); + log->fatal( "LandSet " + std::to_string( landSet.first ) + " is missing land entries. Only have " + std::to_string( count ) + " land entries." ); return false; } } diff --git a/src/world/Manager/HousingMgr.h b/src/world/Manager/HousingMgr.h index 8716a3ba..a221db71 100644 --- a/src/world/Manager/HousingMgr.h +++ b/src/world/Manager/HousingMgr.h @@ -24,11 +24,11 @@ namespace Sapphire::World::Manager uint64_t m_landSetId; uint64_t m_landId; - uint8_t m_type; + Common::LandType m_type; uint8_t m_size; uint8_t m_status; - uint64_t m_landPrice; + uint64_t m_currentPrice; uint64_t m_updateTime; uint64_t m_ownerId; diff --git a/src/world/Territory/HousingZone.cpp b/src/world/Territory/HousingZone.cpp index 17fdfd3b..761d556f 100644 --- a/src/world/Territory/HousingZone.cpp +++ b/src/world/Territory/HousingZone.cpp @@ -64,40 +64,27 @@ bool Sapphire::HousingZone::init() auto pExdData = g_fw.get< Data::ExdDataGenerated >(); auto info = pExdData->get< Sapphire::Data::HousingLandSet >( housingIndex ); - auto stmt = pDb->getPreparedStatement( Db::LANDSET_SEL ); - stmt->setUInt64( 1, m_landSetId ); - auto res = pDb->query( stmt ); + auto housingMgr = g_fw.get< World::Manager::HousingMgr >(); + auto landCache = housingMgr->getLandCacheMap(); - std::vector< QueuedLandInit > landInit; - - while( res->next() ) + // make sure the landset exists + auto landSetCache = landCache.find( m_landSetId ); + if( landSetCache == landCache.end() ) { - - QueuedLandInit init; - init.m_landId = res->getUInt64( "LandId" ); - init.m_type = static_cast< Common::LandType >( res->getUInt( "Type" ) ); - init.m_size = res->getUInt( "Size" ); - init.m_status = res->getUInt( "Status" ); - init.m_currentPrice = res->getUInt( "LandPrice" ); - init.m_ownerId = res->getUInt64( "OwnerId" ); - init.m_houseId = res->getUInt64( "HouseId" ); - - landInit.push_back( init ); + g_fw.get< Sapphire::Logger >()->fatal( "LandSet " + std::to_string( m_landSetId ) + " is missing from the land cache." ); + return false; } - // nuke current query connection so the queries still in land don't fail - res.reset(); - - // spawn land - for( auto& init : landInit ) + // init the lands + for( auto& entry : landSetCache->second ) { - auto land = make_Land( m_territoryTypeId, getWardNum(), init.m_landId, m_landSetId, info ); - land->init( init.m_type, init.m_size, init.m_status, init.m_currentPrice, init.m_ownerId, init.m_houseId ); + auto land = make_Land( m_territoryTypeId, getWardNum(), entry.m_landId, m_landSetId, info ); + land->init( entry.m_type, entry.m_size, entry.m_status, entry.m_currentPrice, entry.m_ownerId, entry.m_houseId ); - m_landPtrMap[ init.m_landId ] = land; + m_landPtrMap[ entry.m_landId ] = land; - if( init.m_houseId > 0 ) - registerHouseEntranceEObj( init.m_landId ); + if( entry.m_houseId > 0 ) + registerHouseEntranceEObj( entry.m_landId ); } return true;