diff --git a/src/servers/sapphire_zone/ServerZone.cpp b/src/servers/sapphire_zone/ServerZone.cpp index 2f3f4adc..0844538e 100644 --- a/src/servers/sapphire_zone/ServerZone.cpp +++ b/src/servers/sapphire_zone/ServerZone.cpp @@ -31,7 +31,8 @@ extern Core::Framework g_fw; Core::ServerZone::ServerZone( const std::string& configName ) : m_configName( configName ), m_bRunning( true ), - m_lastDBPingTime( 0 ) + m_lastDBPingTime( 0 ), + m_worldId( 67 ) { } @@ -188,6 +189,16 @@ void Core::ServerZone::run( int32_t argc, char* argv[] ) } +uint16_t Core::ServerZone::getWorldId() const +{ + return m_worldId; +} + +void Core::ServerZone::setWorldId( uint16_t worldId ) +{ + m_worldId = worldId; +} + void Core::ServerZone::printBanner() const { auto pLog = g_fw.get< Core::Logger >(); diff --git a/src/servers/sapphire_zone/ServerZone.h b/src/servers/sapphire_zone/ServerZone.h index 1045e322..52101668 100644 --- a/src/servers/sapphire_zone/ServerZone.h +++ b/src/servers/sapphire_zone/ServerZone.h @@ -29,6 +29,9 @@ public: size_t getSessionCount() const; + uint16_t getWorldId() const; + void setWorldId( uint16_t worldId ); + void mainLoop(); bool isRunning() const; @@ -47,8 +50,8 @@ private: uint16_t m_port; std::string m_ip; int64_t m_lastDBPingTime; - bool m_bRunning; + uint16_t m_worldId; std::string m_configName; @@ -56,9 +59,7 @@ private: std::map< uint32_t, SessionPtr > m_sessionMapById; std::map< std::string, SessionPtr > m_sessionMapByName; - std::map< uint32_t, uint32_t > m_zones; - std::map< std::string, Entity::BNpcTemplatePtr > m_bNpcTemplateMap; }; diff --git a/src/servers/sapphire_zone/Zone/HousingZone.cpp b/src/servers/sapphire_zone/Zone/HousingZone.cpp index a0ed7e93..125531d3 100644 --- a/src/servers/sapphire_zone/Zone/HousingZone.cpp +++ b/src/servers/sapphire_zone/Zone/HousingZone.cpp @@ -127,9 +127,15 @@ void Core::HousingZone::sendLandSet( Entity::Player& player ) uint8_t startIndex = isPlayerSubInstance( player ) == false ? 0 : 30; - for( uint8_t i = startIndex, count = 0; i < ( startIndex + 30 ); i++ ) + for( uint8_t i = startIndex, count = 0; i < ( startIndex + 30 ); ++i, ++count ) { - memcpy( &landsetInitializePacket->data().land[ count++ ], &getLand( i )->getLand(), sizeof( Common::LandStruct ) ); + landsetInitializePacket->data().land[ count ].plotSize = getLand( i )->getPlotSize(); + landsetInitializePacket->data().land[ count ].houseState = getLand( i )->getState(); + landsetInitializePacket->data().land[ count ].iconColor = getLand( i )->getOwnership(); + landsetInitializePacket->data().land[ count ].iconAddIcon = getLand( i )->getPlotSize(); + landsetInitializePacket->data().land[ count ].fcId = getLand( i )->getFcId(); + landsetInitializePacket->data().land[ count ].fcIcon = getLand( i )->getFcIcon(); + landsetInitializePacket->data().land[ count ].fcIconColor = getLand( i )->getFcColor(); } player.queuePacket( landsetInitializePacket ); @@ -140,10 +146,17 @@ void Core::HousingZone::sendLandUpdate( uint8_t landId ) for( const auto& playerIt : m_playerMap ) { auto pPlayer = playerIt.second; + auto pLand = getLand( landId ); auto landUpdatePacket = makeZonePacket< FFXIVIpcLandUpdate >( pPlayer->getId() ); landUpdatePacket->data().landId = landId; - landUpdatePacket->data().land = getLand( landId )->getLand(); + landUpdatePacket->data().land.plotSize = pLand->getPlotSize(); + landUpdatePacket->data().land.houseState = pLand->getState(); + landUpdatePacket->data().land.iconColor = pLand->getOwnership(); + landUpdatePacket->data().land.iconAddIcon = pLand->getPlotSize(); + landUpdatePacket->data().land.fcId = pLand->getFcId(); + landUpdatePacket->data().land.fcIcon = pLand->getFcIcon(); + landUpdatePacket->data().land.fcIconColor = pLand->getFcColor(); pPlayer->queuePacket( landUpdatePacket ); } @@ -231,4 +244,4 @@ Core::LandPtr Core::HousingZone::getLand( uint8_t id ) return nullptr; return it->second; -} \ No newline at end of file +} diff --git a/src/servers/sapphire_zone/Zone/Land.cpp b/src/servers/sapphire_zone/Zone/Land.cpp index 54e90c8a..5b530822 100644 --- a/src/servers/sapphire_zone/Zone/Land.cpp +++ b/src/servers/sapphire_zone/Zone/Land.cpp @@ -38,7 +38,6 @@ Core::Land::Land( uint16_t zoneId, uint8_t wardNum, uint8_t landId, uint32_t lan m_landInfo( info ), m_type( Common::LandType::Private ) { - memset( &m_land, 0x00, sizeof( LandStruct ) ); memset( &m_tag, 0x00, 3 ); memset( &m_landMsg, 0x00, 193 ); memset( &m_landName, 0x00, 23 ); @@ -66,52 +65,19 @@ void Core::Land::load() m_currentPrice = m_landInfo->prices[ m_landId ]; m_minPrice = m_landInfo->minPrices[ m_landId ]; - m_land.plotSize = m_landInfo->sizes[ m_landId ]; - m_land.houseState = HouseState::forSale; + m_size = m_landInfo->sizes[ m_landId ]; + m_state = HouseState::forSale; } else { m_type = static_cast< Common::LandType >( res->getUInt( "Type" ) ); - m_land.plotSize = res->getUInt( "Size" ); - m_land.houseState = res->getUInt( "Status" ); + m_size = res->getUInt( "Size" ); + m_state = res->getUInt( "Status" ); m_currentPrice = res->getUInt( "LandPrice" ); m_ownerPlayerId = res->getUInt( "OwnerId" ); m_minPrice = m_landInfo->minPrices[ m_landId ]; } init(); -// setPreset( 262145 ); -/* auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >(); - auto res = pDb->query( "SELECT * FROM land WHERE Id = " + std::to_string( m_landKey ) ); - if( !res->next() ) - { - setHouseSize( HouseSizeType::smallHouse );//ToDo: get house site from ExD (Landset first 60 rows) - m_currentPrice = m_initPrice; - m_land.color[ 7 ] = 0xFF; - m_ownerPlayerId = 0; - m_nextDrop = 0; - setState( HouseStateType::forSell ); - auto stmt = pDb->getPreparedStatement( Db::ZoneDbStatements::LAND_INS ); - stmt->setUInt( 1, m_landKey ); - pDb->directExecute( stmt ); - Init(); - } - else - { - Init(); - if( getState() == HouseStateType::privateHouse || getState() == HouseStateType::sold ) - { - m_ownerPlayerId = res->getUInt( "ownerPlayerId" ); - } - else if( getState() == HouseStateType::forSell ) - { - m_currentPrice = res->getUInt( "currentPrice" ); - m_nextDrop = res->getUInt( "nextDrop" ); - m_ownerPlayerId = 0; - } - } - ItemsOutdoorContainer = make_ItemContainer( InventoryType::HousingOutdoorItems, - m_maxItems, - "housingoutdooritems", true );*/ } uint16_t Core::Land::convertItemIdToHousingItemId( uint16_t itemId ) @@ -126,37 +92,25 @@ uint32_t Core::Land::getCurrentPrice() const return m_currentPrice; } -void Core::Land::setPreset( uint32_t id ) -{ - auto pExdData = g_fw.get< Data::ExdDataGenerated >(); - auto info = pExdData->get< Core::Data::HousingPreset >( convertItemIdToHousingItemId( id ) ); - setHousePart( Common::HousePartSlot::ExteriorRoof, info->exteriorRoof ); - setHousePart( Common::HousePartSlot::ExteriorWall, info->exteriorWall ); - setHousePart( Common::HousePartSlot::ExteriorWindow, info->exteriorWindow ); - setHousePart( Common::HousePartSlot::BasementWall, info->basementWall ); - setHousePart( Common::HousePartSlot::OtherFloorFlooring, info->otherFloorFlooring ); - setHousePart( Common::HousePartSlot::OtherFloorWall, info->otherFloorWall ); -} - //Primary State void Core::Land::setHouseSize( uint8_t size ) { - m_land.plotSize = size; + m_size = size; } void Core::Land::setState( uint8_t state ) { - m_land.houseState = state; + m_state = state; } void Core::Land::setOwnership( uint8_t state ) { - m_land.iconColor = state; + m_iconColor = state; } void Core::Land::setSharing( uint8_t state ) { - m_land.iconAddIcon = state; + m_iconAddIcon = state; } void Core::Land::setLandName( const std::string& name ) @@ -171,22 +125,22 @@ void Core::Land::setLandType( Common::LandType type ) uint8_t Core::Land::getPlotSize() const { - return m_land.plotSize; + return m_size; } uint8_t Core::Land::getState() const { - return m_land.houseState; + return m_state; } uint8_t Core::Land::getOwnership() const { - return m_land.iconColor; + return m_iconColor; } uint8_t Core::Land::getSharing() const { - return m_land.iconAddIcon; + return m_iconAddIcon; } uint32_t Core::Land::getLandSetId() const @@ -222,46 +176,24 @@ Core::Common::LandType Core::Land::getLandType() const //Free Comapny void Core::Land::setFreeCompany( uint32_t id, uint32_t icon, uint32_t color ) { - m_land.fcId = id; - m_land.fcIcon = icon; - m_land.fcIconColor = color; //RGBA + m_fcId = id; + m_fcIcon = icon; + m_fcIconColor = color; //RGBA } uint32_t Core::Land::getFcId() { - return m_land.fcIcon; + return m_fcIcon; } uint32_t Core::Land::getFcIcon() { - return m_land.fcIcon; + return m_fcIcon; } uint32_t Core::Land::getFcColor() { - return m_land.fcIconColor; -} - -//House Data -void Core::Land::setHousePart( Common::HousePartSlot slot, uint16_t id ) -{ - m_land.housePart[ slot ] = convertItemIdToHousingItemId( id ); -} - -uint16_t Core::Land::getHousePart( Common::HousePartSlot slot ) -{ - return m_land.housePart[ slot ]; -} - -//Color -void Core::Land::setColor( uint8_t slot, uint8_t color ) -{ - m_land.color[ slot ] = color; -} - -uint8_t Core::Land::getColor( uint8_t slot ) -{ - return m_land.color[ slot ]; + return m_fcIconColor; } //Player @@ -275,11 +207,6 @@ uint32_t Core::Land::getPlayerOwner() return m_ownerPlayerId; } -const LandStruct& Core::Land::getLand() -{ - return m_land; -} - uint32_t Core::Land::getMaxItems() { return m_maxItems; @@ -322,7 +249,7 @@ void Core::Land::init() void Core::Land::UpdateLandDb() { auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >(); - pDb->directExecute( "UPDATE land SET status = " + std::to_string( m_land.houseState ) + pDb->directExecute( "UPDATE land SET status = " + std::to_string( m_state ) + ", LandPrice = " + std::to_string( getCurrentPrice() ) + ", UpdateTime = " + std::to_string( getDevaluationTime() ) + ", OwnerId = " + std::to_string( getPlayerOwner() ) @@ -343,4 +270,4 @@ void Core::Land::Update( uint32_t currTime ) UpdateLandDb(); } } -} \ No newline at end of file +} diff --git a/src/servers/sapphire_zone/Zone/Land.h b/src/servers/sapphire_zone/Zone/Land.h index f8e64a49..51e4e982 100644 --- a/src/servers/sapphire_zone/Zone/Land.h +++ b/src/servers/sapphire_zone/Zone/Land.h @@ -62,7 +62,6 @@ namespace Core void UpdateLandDb(); void Update( uint32_t currTime ); - const Common::LandStruct& getLand(); uint32_t getMaxItems(); uint32_t getCurrentPrice() const; @@ -80,7 +79,14 @@ namespace Core uint8_t m_landId; uint32_t m_landSetId; uint16_t m_zoneId; - Common::LandStruct m_land; + uint8_t m_size; + uint8_t m_state; + uint8_t m_iconColor; + uint8_t m_iconAddIcon; + uint32_t m_fcId; + uint32_t m_fcIcon; + uint32_t m_fcIconColor; + Common::LandType m_type; uint32_t m_ownerPlayerId; Core::Data::HousingLandSetPtr m_landInfo; @@ -105,4 +111,4 @@ namespace Core }; } -#endif \ No newline at end of file +#endif