From 5aacca21c25c7a14d6ee02093ebfe735d45dd1dd Mon Sep 17 00:00:00 2001 From: AriAvery <41122212+AriAvery@users.noreply.github.com> Date: Wed, 7 Nov 2018 09:05:03 +0100 Subject: [PATCH 01/14] added housing item UI --- src/common/Network/CommonActorControl.h | 4 ++++ .../Network/Handlers/ClientTriggerHandler.cpp | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/common/Network/CommonActorControl.h b/src/common/Network/CommonActorControl.h index 0d510483..ee2833e2 100644 --- a/src/common/Network/CommonActorControl.h +++ b/src/common/Network/CommonActorControl.h @@ -212,6 +212,9 @@ enum ActorControlType : BeginReplayAck = 0x3A1, EndReplayAck = 0x3A2, + // Housing + ShowHousingItemUI = 0x3F7, + // PvP Duel SetPvPState = 0x5E0, // param3 must be 6 to engage a duel (hardcoded in the client) EndDuelSession = 0x5E1, // because someone went oob? @@ -287,6 +290,7 @@ enum ClientTriggerType AchievementList = 0x3E9, RequestHousingSign = 0x451, + RequestHousingItemUI = 0x463, RequestSharedEstateSettings = 0x46F, CompanionAction = 0x6A4, diff --git a/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp b/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp index dfffc85c..d1590728 100644 --- a/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp @@ -332,6 +332,17 @@ void Core::Network::GameConnection::clientTriggerHandler( const Packets::FFXIVAR break; } + case ClientTriggerType::RequestHousingItemUI: + { + uint8_t plot = param2; + auto pShowHousingItemUIPacket = makeActorControl142(player.getId(), ShowHousingItemUI, 0, plot); + + //TODO: show item housing container + + player.queuePacket( pShowHousingItemUIPacket ); + break; + } + default: { pLog->debug( "[" + std::to_string( m_pSession->getId() ) + "] Unhandled action: " + From 903b38f32b8b5945cbea946e06e5951603422b58 Mon Sep 17 00:00:00 2001 From: AriAvery <41122212+AriAvery@users.noreply.github.com> Date: Wed, 7 Nov 2018 09:27:57 +0100 Subject: [PATCH 02/14] some fix --- .../sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp b/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp index d1590728..9db8f886 100644 --- a/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp @@ -334,12 +334,13 @@ void Core::Network::GameConnection::clientTriggerHandler( const Packets::FFXIVAR case ClientTriggerType::RequestHousingItemUI: { - uint8_t plot = param2; + uint32_t plot = param2; auto pShowHousingItemUIPacket = makeActorControl142(player.getId(), ShowHousingItemUI, 0, plot); + player.queuePacket( pShowHousingItemUIPacket ); + //TODO: show item housing container - player.queuePacket( pShowHousingItemUIPacket ); break; } From 23d354208860bd40dded70c91c5ecdff21822283 Mon Sep 17 00:00:00 2001 From: AriAvery <41122212+AriAvery@users.noreply.github.com> Date: Wed, 7 Nov 2018 10:49:02 +0100 Subject: [PATCH 03/14] removed space --- .../sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp b/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp index 9db8f886..af30a278 100644 --- a/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp @@ -331,7 +331,6 @@ void Core::Network::GameConnection::clientTriggerHandler( const Packets::FFXIVAR break; } - case ClientTriggerType::RequestHousingItemUI: { uint32_t plot = param2; From 0f8637426469fe79da807a4f6c3ff69f6986276e Mon Sep 17 00:00:00 2001 From: AriAvery <41122212+AriAvery@users.noreply.github.com> Date: Wed, 7 Nov 2018 11:08:07 +0100 Subject: [PATCH 04/14] added devaluation timer --- .../Network/Handlers/ClientTriggerHandler.cpp | 1 + src/servers/sapphire_zone/Zone/Land.cpp | 28 +++++++++++++------ src/servers/sapphire_zone/Zone/Land.h | 2 ++ 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp b/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp index af30a278..380e746a 100644 --- a/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp @@ -326,6 +326,7 @@ void Core::Network::GameConnection::clientTriggerHandler( const Packets::FFXIVAR auto land = hZone->getLand( plot ); plotPricePacket->data().price = land->getCurrentPrice(); + plotPricePacket->data().timeLeft = land->getDevaluationTime(); player.queuePacket( plotPricePacket ); diff --git a/src/servers/sapphire_zone/Zone/Land.cpp b/src/servers/sapphire_zone/Zone/Land.cpp index d9575b31..4b8384fe 100644 --- a/src/servers/sapphire_zone/Zone/Land.cpp +++ b/src/servers/sapphire_zone/Zone/Land.cpp @@ -237,6 +237,11 @@ uint32_t Core::Land::getMaxItems() return m_maxItems; } +uint32_t Core::Land::getDevaluationTime() +{ + return m_devaluationTime; +} + void Core::Land::init() { @@ -269,18 +274,23 @@ void Core::Land::UpdateDatabase() void Core::Land::Update( uint32_t currTime ) { - if( m_currentPrice == 0 && getState() == HouseState::forSale ) + if( getState() == HouseState::forSale ) { - m_currentPrice = m_initPrice; - m_nextDrop = 0; - UpdateDatabase(); - } - if( m_nextDrop < currTime && getState() == HouseState::forSale ) - { - m_currentPrice = ( m_currentPrice / 100 ) * 90; - m_nextDrop = currTime + 86400; + if( m_nextDrop < currTime ) + { + m_nextDrop = currTime + 21600; // +6 hours + if( m_currentPrice == 0 ) + { + m_currentPrice = m_initPrice; + } + else + { + m_currentPrice = ( m_currentPrice / 100 ) * 99.58; + } + } UpdateDatabase(); } + m_devaluationTime = m_nextDrop - currTime; onUpdate(); } diff --git a/src/servers/sapphire_zone/Zone/Land.h b/src/servers/sapphire_zone/Zone/Land.h index c3f958f8..746b2b63 100644 --- a/src/servers/sapphire_zone/Zone/Land.h +++ b/src/servers/sapphire_zone/Zone/Land.h @@ -58,6 +58,7 @@ namespace Core uint32_t getMaxItems(); uint32_t getCurrentPrice() const; + uint32_t getDevaluationTime(); private: uint16_t convertItemIdToHousingItemId( uint16_t itemId ); @@ -79,6 +80,7 @@ namespace Core //price uint32_t m_initPrice; uint32_t m_nextDrop; + uint32_t m_devaluationTime; uint32_t m_currentPrice; }; From e832c078d504cb7fb88065ddb3cf754d7a1292db Mon Sep 17 00:00:00 2001 From: AriAvery <41122212+AriAvery@users.noreply.github.com> Date: Wed, 7 Nov 2018 11:56:49 +0100 Subject: [PATCH 05/14] added Land Update function --- src/servers/sapphire_zone/Zone/HousingZone.cpp | 14 ++++++++++++++ src/servers/sapphire_zone/Zone/HousingZone.h | 1 + 2 files changed, 15 insertions(+) diff --git a/src/servers/sapphire_zone/Zone/HousingZone.cpp b/src/servers/sapphire_zone/Zone/HousingZone.cpp index 094425eb..22ee225e 100644 --- a/src/servers/sapphire_zone/Zone/HousingZone.cpp +++ b/src/servers/sapphire_zone/Zone/HousingZone.cpp @@ -131,6 +131,20 @@ void Core::HousingZone::sendLandSet( Entity::Player& player ) player.queuePacket( landsetInitializePacket ); } +void Core::HousingZone::sendLandUpdate( uint8_t landId ) +{ + for( const auto& playerIt : m_playerMap ) + { + auto pPlayer = playerIt.second; + + auto landUpdatePacket = makeZonePacket< FFXIVIpcLandUpdate >( pPlayer->getId() ); + landUpdatePacket->data().landId = landId; + landUpdatePacket->data().land = getLand( landId )->getLand(); + + pPlayer->queuePacket( landUpdatePacket ); + } +} + bool Core::HousingZone::isPlayerSubInstance( Entity::Player& player ) { return player.getPos().x < -15000.0f; //ToDo: get correct pos diff --git a/src/servers/sapphire_zone/Zone/HousingZone.h b/src/servers/sapphire_zone/Zone/HousingZone.h index 4d265df2..c2c6619f 100644 --- a/src/servers/sapphire_zone/Zone/HousingZone.h +++ b/src/servers/sapphire_zone/Zone/HousingZone.h @@ -23,6 +23,7 @@ namespace Core void onUpdate( uint32_t currTime ) override; void sendLandSet( Entity::Player& player ); + void sendLandUpdate( uint8_t landId ); bool isPlayerSubInstance( Entity::Player& player ); /* returns current ward number for this zone */ From e73613f4434127d3d30c44dfae9d8e729ccca8b9 Mon Sep 17 00:00:00 2001 From: AriAvery <41122212+AriAvery@users.noreply.github.com> Date: Wed, 7 Nov 2018 11:59:59 +0100 Subject: [PATCH 06/14] More stuff --- src/common/Common.h | 11 ++- .../Network/PacketDef/Zone/ServerZoneDef.h | 12 +-- src/servers/sapphire_zone/Actor/Player.cpp | 79 +++++++++---------- src/servers/sapphire_zone/Actor/Player.h | 9 +++ src/servers/sapphire_zone/Zone/Land.cpp | 8 +- src/servers/sapphire_zone/Zone/Land.h | 1 - 6 files changed, 63 insertions(+), 57 deletions(-) diff --git a/src/common/Common.h b/src/common/Common.h index c06868c6..1596cfe4 100644 --- a/src/common/Common.h +++ b/src/common/Common.h @@ -759,7 +759,16 @@ namespace Core::Common uint8_t color[ 8 ]; // 36 }; - struct HousePermissionSet + enum LandPermissionSlot + { + FreeCompany, + Private, + Apartment, + SharedHouse1, + SharedHouse2 + }; + + struct LandPermissionSet { int16_t landSetId; //00 int16_t wardNum; //02 diff --git a/src/common/Network/PacketDef/Zone/ServerZoneDef.h b/src/common/Network/PacketDef/Zone/ServerZoneDef.h index 15da9755..b17910cf 100644 --- a/src/common/Network/PacketDef/Zone/ServerZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ServerZoneDef.h @@ -1578,21 +1578,21 @@ struct FFXIVIpcPerformNote : FFXIVIpcBasePacket< PerformNote > //IPCs struct FFXIVIpcLandPermission : FFXIVIpcBasePacket { - Common::HousePermissionSet freeCompanyHouse; // 00 + Common::LandPermissionSet freeCompanyHouse; // 00 uint64_t unkown1; - Common::HousePermissionSet privateHouse; // 24 + Common::LandPermissionSet privateHouse; // 24 uint64_t unkown2; - Common::HousePermissionSet apartment; // 48 + Common::LandPermissionSet apartment; // 48 uint64_t unkown3; - Common::HousePermissionSet sharedHouse[2]; //72 + Common::LandPermissionSet sharedHouse[2]; //72 uint64_t unkown4; - Common::HousePermissionSet unkownHouse; + Common::LandPermissionSet unkownHouse; uint64_t unkown5; }; struct FFXIVIpcLandUpdate : FFXIVIpcBasePacket< LandUpdate > { - uint16_t landSetId; + uint16_t landId; uint16_t unknow0; uint16_t unknow1; uint16_t unknow2; diff --git a/src/servers/sapphire_zone/Actor/Player.cpp b/src/servers/sapphire_zone/Actor/Player.cpp index 658727bc..e989149f 100644 --- a/src/servers/sapphire_zone/Actor/Player.cpp +++ b/src/servers/sapphire_zone/Actor/Player.cpp @@ -89,6 +89,12 @@ Core::Entity::Player::Player() : memset( m_classArray, 0, sizeof( m_classArray ) ); memset( m_expArray, 0, sizeof( m_expArray ) ); + for ( uint8_t i = 0; i < 5; i++ ) + { + memset( &m_housePermission[i], 0xFF, 8 ); + memset( &m_housePermission[i].permissionMask, 0, 8 ); + } + m_objSpawnIndexAllocator.init( MAX_DISPLAYED_EOBJS ); m_actorSpawnIndexAllocator.init( MAX_DISPLAYED_ACTORS, true ); } @@ -1568,48 +1574,7 @@ void Core::Entity::Player::sendZonePackets() sendItemLevel(); } - struct HousePermissionSet - { - int16_t landSetId; //00 - int16_t wardNum; //02 - int16_t zoneId; //04 - int16_t worldId; //06 - uint32_t permissionMask; //08 - uint32_t unkown1; //12 - }; - - auto landPermissions = makeZonePacket< FFXIVIpcLandPermission >( getId() ); - landPermissions->data().freeCompanyHouse.landSetId = -1; - landPermissions->data().freeCompanyHouse.wardNum = -1; - landPermissions->data().freeCompanyHouse.zoneId = -1; - landPermissions->data().freeCompanyHouse.worldId = -1; - landPermissions->data().unkown1 = 0; - landPermissions->data().privateHouse.landSetId = -1; - landPermissions->data().privateHouse.wardNum = -1; - landPermissions->data().privateHouse.zoneId = -1; - landPermissions->data().privateHouse.worldId = -1; - landPermissions->data().unkown2 = 0; - landPermissions->data().apartment.landSetId = -1; - landPermissions->data().apartment.wardNum = -1; - landPermissions->data().apartment.zoneId = -1; - landPermissions->data().apartment.worldId = -1; - landPermissions->data().unkown3 = 0; - landPermissions->data().sharedHouse[0].landSetId = -1; - landPermissions->data().sharedHouse[0].wardNum = -1; - landPermissions->data().sharedHouse[0].zoneId = -1; - landPermissions->data().sharedHouse[0].worldId = -1; - landPermissions->data().sharedHouse[1].landSetId = -1; - landPermissions->data().sharedHouse[1].wardNum = -1; - landPermissions->data().sharedHouse[1].zoneId = -1; - landPermissions->data().sharedHouse[1].worldId = -1; - landPermissions->data().unkown4 = 0; - landPermissions->data().unkownHouse.landSetId = -1; - landPermissions->data().unkownHouse.wardNum = -1; - landPermissions->data().unkownHouse.zoneId = -1; - landPermissions->data().unkownHouse.worldId = -1; - landPermissions->data().unkown5 = 2; - queuePacket( landPermissions ); - + sendLandPermissions(); auto initZonePacket = makeZonePacket< FFXIVIpcInitZone >( getId() ); initZonePacket->data().zoneId = getCurrentZone()->getTerritoryTypeId(); @@ -1786,3 +1751,33 @@ bool Core::Entity::Player::isOnEnterEventDone() const { return m_onEnterEventDone; } + +void Core::Entity::Player::setLandPermissions( uint8_t permissionSet, uint32_t permissionMask, int16_t landSetId, int16_t wardNum, int16_t zoneId ) +{ + m_housePermission[permissionSet].landSetId = landSetId; + m_housePermission[permissionSet].permissionMask = permissionMask; + m_housePermission[permissionSet].wardNum = wardNum; + m_housePermission[permissionSet].worldId = 67; + m_housePermission[permissionSet].unkown1 = 0; +} + +void Core::Entity::Player::sendLandPermissions() +{ + auto landPermissions = makeZonePacket< FFXIVIpcLandPermission >( getId() ); + + landPermissions->data().freeCompanyHouse = m_housePermission[Common::LandPermissionSlot::FreeCompany]; + landPermissions->data().privateHouse = m_housePermission[Common::LandPermissionSlot::Private]; + landPermissions->data().apartment = m_housePermission[Common::LandPermissionSlot::Apartment]; + landPermissions->data().sharedHouse[0] = m_housePermission[Common::LandPermissionSlot::SharedHouse1]; + landPermissions->data().sharedHouse[1] = m_housePermission[Common::LandPermissionSlot::SharedHouse2]; + memset( &landPermissions->data().unkownHouse, 0xFF, 8 ); + memset( &landPermissions->data().unkownHouse.permissionMask, 0, 8 ); + landPermissions->data().unkownHouse.permissionMask = 2; + landPermissions->data().unkown1 = 0; + landPermissions->data().unkown2 = 0; + landPermissions->data().unkown3 = 0; + landPermissions->data().unkown4 = 0; + landPermissions->data().unkown5 = 0; + + queuePacket( landPermissions ); +} \ No newline at end of file diff --git a/src/servers/sapphire_zone/Actor/Player.h b/src/servers/sapphire_zone/Actor/Player.h index 1bf9fe72..f0aefd21 100644 --- a/src/servers/sapphire_zone/Actor/Player.h +++ b/src/servers/sapphire_zone/Actor/Player.h @@ -761,6 +761,12 @@ namespace Core::Entity void setDirectorInitialized( bool isInitialized ); + // Housing Handling + ////////////////////////////////////////////////////////////////////////////////////////////////////// + void setLandPermissions( uint8_t permissionSet, uint32_t permissionMask, int16_t landSetId, int16_t wardNum, int16_t zoneId ); + + void sendLandPermissions(); + // Player Battle Handling ////////////////////////////////////////////////////////////////////////////////////////////////////// void initHateSlotQueue(); @@ -1013,6 +1019,9 @@ namespace Core::Entity uint8_t m_searchSelectRegion; // regions selected to show up in profile uint8_t m_searchSelectClass; // class selected to show up in profile + // housing info + Common::LandPermissionSet m_housePermission[5]; + // gc info uint8_t m_gc; uint8_t m_gcRank[3]; diff --git a/src/servers/sapphire_zone/Zone/Land.cpp b/src/servers/sapphire_zone/Zone/Land.cpp index 4b8384fe..7b8881ea 100644 --- a/src/servers/sapphire_zone/Zone/Land.cpp +++ b/src/servers/sapphire_zone/Zone/Land.cpp @@ -288,13 +288,7 @@ void Core::Land::Update( uint32_t currTime ) m_currentPrice = ( m_currentPrice / 100 ) * 99.58; } } + m_devaluationTime = m_nextDrop - currTime; UpdateDatabase(); } - m_devaluationTime = m_nextDrop - currTime; - onUpdate(); -} - -void Core::Land::onUpdate() -{ - } \ 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 746b2b63..891e00b4 100644 --- a/src/servers/sapphire_zone/Zone/Land.h +++ b/src/servers/sapphire_zone/Zone/Land.h @@ -52,7 +52,6 @@ namespace Core void setPreset( uint32_t itemId ); void UpdateDatabase(); void Update( uint32_t currTime ); - void onUpdate(); const Common::LandStruct& getLand(); uint32_t getMaxItems(); From 49b3e35e15f32c3767546723453cf6fa105f8fe6 Mon Sep 17 00:00:00 2001 From: AriAvery <41122212+AriAvery@users.noreply.github.com> Date: Wed, 7 Nov 2018 13:16:25 +0100 Subject: [PATCH 07/14] class fix --- src/servers/sapphire_zone/Zone/Land.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/servers/sapphire_zone/Zone/Land.cpp b/src/servers/sapphire_zone/Zone/Land.cpp index 7b8881ea..a9c93b67 100644 --- a/src/servers/sapphire_zone/Zone/Land.cpp +++ b/src/servers/sapphire_zone/Zone/Land.cpp @@ -33,7 +33,8 @@ Core::Land::Land( uint16_t zoneId, uint8_t wardNum, uint8_t landId, uint32_t lan m_currentPrice( 0 ), m_nextDrop( 0 ), m_landSetId( landSetId ), - m_landInfo( info ) + m_landInfo( info ), + m_devaluationTime( 0 ) { memset( &m_land, 0x00, sizeof( LandStruct ) ); load(); From 9dcc9666227513c205e1180bf1ae5315e70b3557 Mon Sep 17 00:00:00 2001 From: AriAvery <41122212+AriAvery@users.noreply.github.com> Date: Thu, 8 Nov 2018 10:54:37 +0100 Subject: [PATCH 08/14] added housing debugHandler --- .../DebugCommand/DebugCommandHandler.cpp | 49 +++++++++++++++++++ .../DebugCommand/DebugCommandHandler.h | 2 + 2 files changed, 51 insertions(+) diff --git a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp index 276acd3a..daae8d45 100644 --- a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp +++ b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp @@ -27,6 +27,7 @@ #include "Actor/BNpc.h" #include "Zone/Zone.h" +#include "Zone/HousingZone.h" #include "Zone/InstanceContent.h" #include "Zone/TerritoryMgr.h" #include "Event/EventDefs.h" @@ -57,6 +58,7 @@ Core::DebugCommandHandler::DebugCommandHandler() registerCommand( "help", &DebugCommandHandler::help, "Shows registered commands.", 0 ); registerCommand( "script", &DebugCommandHandler::script, "Server script utilities.", 1 ); registerCommand( "instance", &DebugCommandHandler::instance, "Instance utilities", 1 ); + registerCommand( "housing", &DebugCommandHandler::housing, "Housing utilities", 1 ); } // clear all loaded commands @@ -981,3 +983,50 @@ Core::DebugCommandHandler::instance( char* data, Entity::Player& player, std::sh player.sendDebug( "Unknown sub command." ); } } + +void Core::DebugCommandHandler::housing( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ) +{ + auto pTeriMgr = g_fw.get< TerritoryMgr >(); + std::string cmd( data ), params, subCommand; + auto cmdPos = cmd.find_first_of( ' ' ); + + if( cmdPos != std::string::npos ) + { + params = cmd.substr( cmdPos + 1 ); + + auto p = params.find_first_of( ' ' ); + + if( p != std::string::npos ) + { + subCommand = params.substr( 0, p ); + params = params.substr( subCommand.length() + 1 ); + } + else + subCommand = params; + } + + if( subCommand == "permission" || subCommand == "perm" ) + { + uint8_t permissionSet; + sscanf( params.c_str(), "%hhu", &permissionSet ); + + if ( permissionSet < 5 ) + { + auto pZone = player.getCurrentZone(); + if( pTeriMgr->isHousingTerritory( pZone->getTerritoryTypeId() ) ) + { + auto pHousing = std::dynamic_pointer_cast( pZone ); + if( pHousing ) + player.setLandPermissions( permissionSet, 8, pHousing->getLandSetId(), pHousing->getWardNum(), pHousing->getTerritoryTypeId() ); + else + player.sendDebug( "You aren't in a housing Zone." ); + } + } + else + player.sendDebug( "PermissionSet out of range." ); + } + else + { + player.sendDebug( "Unknown sub command." ); + } +} \ No newline at end of file diff --git a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.h b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.h index 89373038..3a9ebc80 100644 --- a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.h +++ b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.h @@ -53,6 +53,8 @@ namespace Core void instance( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ); + void housing( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command) ; + void script( char* data, Entity::Player& player, std::shared_ptr< DebugCommand > command ); }; From 84c5555cdd581ee5707b79c52618448386a3a45a Mon Sep 17 00:00:00 2001 From: AriAvery <41122212+AriAvery@users.noreply.github.com> Date: Thu, 8 Nov 2018 22:17:25 +0100 Subject: [PATCH 09/14] fixed style --- src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp index daae8d45..24108b0e 100644 --- a/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp +++ b/src/servers/sapphire_zone/DebugCommand/DebugCommandHandler.cpp @@ -1015,7 +1015,7 @@ void Core::DebugCommandHandler::housing( char* data, Entity::Player& player, std auto pZone = player.getCurrentZone(); if( pTeriMgr->isHousingTerritory( pZone->getTerritoryTypeId() ) ) { - auto pHousing = std::dynamic_pointer_cast( pZone ); + auto pHousing = std::dynamic_pointer_cast< HousingZone >( pZone ); if( pHousing ) player.setLandPermissions( permissionSet, 8, pHousing->getLandSetId(), pHousing->getWardNum(), pHousing->getTerritoryTypeId() ); else From c551a766f3280f30659ce666f1da9c8d7898293f Mon Sep 17 00:00:00 2001 From: AriAvery <41122212+AriAvery@users.noreply.github.com> Date: Thu, 8 Nov 2018 22:19:26 +0100 Subject: [PATCH 10/14] fixed style 2 --- .../sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp b/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp index 380e746a..cb30f491 100644 --- a/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/ClientTriggerHandler.cpp @@ -335,7 +335,7 @@ void Core::Network::GameConnection::clientTriggerHandler( const Packets::FFXIVAR case ClientTriggerType::RequestHousingItemUI: { uint32_t plot = param2; - auto pShowHousingItemUIPacket = makeActorControl142(player.getId(), ShowHousingItemUI, 0, plot); + auto pShowHousingItemUIPacket = makeActorControl142( player.getId(), ShowHousingItemUI, 0, plot ); player.queuePacket( pShowHousingItemUIPacket ); From 9cc2cd633fa1f60a34472dd444f60969e2407f05 Mon Sep 17 00:00:00 2001 From: AriAvery <41122212+AriAvery@users.noreply.github.com> Date: Fri, 9 Nov 2018 09:49:43 +0100 Subject: [PATCH 11/14] added min prices --- src/common/Exd/ExdDataGenerated.cpp | 2 ++ src/common/Exd/ExdDataGenerated.h | 1 + src/servers/sapphire_zone/Zone/Land.cpp | 12 +++++++----- src/servers/sapphire_zone/Zone/Land.h | 1 + 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/common/Exd/ExdDataGenerated.cpp b/src/common/Exd/ExdDataGenerated.cpp index 5359bbc7..83cd85e0 100644 --- a/src/common/Exd/ExdDataGenerated.cpp +++ b/src/common/Exd/ExdDataGenerated.cpp @@ -2745,6 +2745,8 @@ Core::Data::HousingLandSet::HousingLandSet( uint32_t row_id, Core::Data::ExdData auto row = exdData->m_HousingLandSetDat.get_row( row_id ); for ( int i = 0; i < 60; i++ ) sizes.push_back( exdData->getField< uint8_t >( row, i ) ); + for ( int i = 60; i < 60 + 60; i++ ) + minPrices.push_back( exdData->getField< uint8_t >( row, i ) ); for ( int i = 300; i < 300 + 60; i++ ) prices.push_back( exdData->getField< uint32_t >( row, i ) ); diff --git a/src/common/Exd/ExdDataGenerated.h b/src/common/Exd/ExdDataGenerated.h index d77e606e..b4da203b 100644 --- a/src/common/Exd/ExdDataGenerated.h +++ b/src/common/Exd/ExdDataGenerated.h @@ -2853,6 +2853,7 @@ struct HousingPlacement struct HousingLandSet { std::vector< uint8_t > sizes; + std::vector< uint32_t > minPrices; std::vector< uint32_t > prices; HousingLandSet( uint32_t row_id, Core::Data::ExdDataGenerated* exdData ); diff --git a/src/servers/sapphire_zone/Zone/Land.cpp b/src/servers/sapphire_zone/Zone/Land.cpp index a9c93b67..97d4b3b2 100644 --- a/src/servers/sapphire_zone/Zone/Land.cpp +++ b/src/servers/sapphire_zone/Zone/Land.cpp @@ -47,7 +47,6 @@ Core::Land::~Land() void Core::Land::load() { - m_land.houseState = HouseState::forSale; auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >(); @@ -55,14 +54,13 @@ void Core::Land::load() "AND landid = " + std::to_string( m_landId ) ); if( !res->next() ) { - - pDb->directExecute( "INSERT INTO land ( landsetid, landid, size, status, landprice ) " "VALUES ( " + std::to_string( m_landSetId ) + "," + std::to_string( m_landId ) + "," + std::to_string( m_landInfo->sizes[ m_landId ] ) + "," + " 1, " + std::to_string( m_landInfo->prices[ m_landId ] ) + " );" ); m_currentPrice = m_landInfo->prices[ m_landId ]; + m_minPrice = m_landInfo->minPrices[ m_landId ]; m_land.houseSize = m_landInfo->sizes[ m_landId ]; } else @@ -284,12 +282,16 @@ void Core::Land::Update( uint32_t currTime ) { m_currentPrice = m_initPrice; } - else + else if( m_minPrice < m_currentPrice ) { m_currentPrice = ( m_currentPrice / 100 ) * 99.58; + m_devaluationTime = m_nextDrop - currTime; + } + else + { + m_devaluationTime = 0; } } - m_devaluationTime = m_nextDrop - currTime; UpdateDatabase(); } } \ 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 891e00b4..3add13d1 100644 --- a/src/servers/sapphire_zone/Zone/Land.h +++ b/src/servers/sapphire_zone/Zone/Land.h @@ -81,6 +81,7 @@ namespace Core uint32_t m_nextDrop; uint32_t m_devaluationTime; uint32_t m_currentPrice; + uint32_t m_minPrice; }; } From d6118e9d80c79cf07d66cbcda4a57266d2beeecc Mon Sep 17 00:00:00 2001 From: AriAvery <41122212+AriAvery@users.noreply.github.com> Date: Fri, 9 Nov 2018 10:00:36 +0100 Subject: [PATCH 12/14] :/ --- src/common/Exd/ExdDataGenerated.cpp | 2 +- src/servers/sapphire_zone/Zone/Land.cpp | 24 +++++++++--------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/common/Exd/ExdDataGenerated.cpp b/src/common/Exd/ExdDataGenerated.cpp index 83cd85e0..aafcb458 100644 --- a/src/common/Exd/ExdDataGenerated.cpp +++ b/src/common/Exd/ExdDataGenerated.cpp @@ -2746,7 +2746,7 @@ Core::Data::HousingLandSet::HousingLandSet( uint32_t row_id, Core::Data::ExdData for ( int i = 0; i < 60; i++ ) sizes.push_back( exdData->getField< uint8_t >( row, i ) ); for ( int i = 60; i < 60 + 60; i++ ) - minPrices.push_back( exdData->getField< uint8_t >( row, i ) ); + minPrices.push_back( exdData->getField< uint32_t >( row, i ) ); for ( int i = 300; i < 300 + 60; i++ ) prices.push_back( exdData->getField< uint32_t >( row, i ) ); diff --git a/src/servers/sapphire_zone/Zone/Land.cpp b/src/servers/sapphire_zone/Zone/Land.cpp index 97d4b3b2..ac6c9e76 100644 --- a/src/servers/sapphire_zone/Zone/Land.cpp +++ b/src/servers/sapphire_zone/Zone/Land.cpp @@ -275,23 +275,17 @@ void Core::Land::Update( uint32_t currTime ) { if( getState() == HouseState::forSale ) { - if( m_nextDrop < currTime ) + if( m_nextDrop < currTime && m_minPrice < m_currentPrice ) { - m_nextDrop = currTime + 21600; // +6 hours - if( m_currentPrice == 0 ) - { - m_currentPrice = m_initPrice; - } - else if( m_minPrice < m_currentPrice ) - { - m_currentPrice = ( m_currentPrice / 100 ) * 99.58; - m_devaluationTime = m_nextDrop - currTime; - } - else - { - m_devaluationTime = 0; - } + m_nextDrop = currTime + 21600; + m_currentPrice = ( m_currentPrice / 100 ) * 99.58; } + else if( m_currentPrice == 0 ) + { + m_nextDrop = currTime + 21600; + m_currentPrice = m_initPrice; + } + m_devaluationTime = m_nextDrop - currTime; UpdateDatabase(); } } \ No newline at end of file From c726d7074b0fc1c4b6b19a077f566c0b59181c8b Mon Sep 17 00:00:00 2001 From: AriAvery <41122212+AriAvery@users.noreply.github.com> Date: Fri, 9 Nov 2018 10:39:56 +0100 Subject: [PATCH 13/14] removed senseless case --- src/servers/sapphire_zone/Zone/Land.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/servers/sapphire_zone/Zone/Land.cpp b/src/servers/sapphire_zone/Zone/Land.cpp index ac6c9e76..47f53701 100644 --- a/src/servers/sapphire_zone/Zone/Land.cpp +++ b/src/servers/sapphire_zone/Zone/Land.cpp @@ -280,11 +280,6 @@ void Core::Land::Update( uint32_t currTime ) m_nextDrop = currTime + 21600; m_currentPrice = ( m_currentPrice / 100 ) * 99.58; } - else if( m_currentPrice == 0 ) - { - m_nextDrop = currTime + 21600; - m_currentPrice = m_initPrice; - } m_devaluationTime = m_nextDrop - currTime; UpdateDatabase(); } From 4babbd59b4cf67227f12cef9a05e02fe91ca5110 Mon Sep 17 00:00:00 2001 From: AriAvery <41122212+AriAvery@users.noreply.github.com> Date: Fri, 9 Nov 2018 10:53:11 +0100 Subject: [PATCH 14/14] fixes --- src/servers/sapphire_zone/Zone/Land.cpp | 7 +++---- src/servers/sapphire_zone/Zone/Land.h | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/servers/sapphire_zone/Zone/Land.cpp b/src/servers/sapphire_zone/Zone/Land.cpp index 47f53701..44828849 100644 --- a/src/servers/sapphire_zone/Zone/Land.cpp +++ b/src/servers/sapphire_zone/Zone/Land.cpp @@ -31,10 +31,10 @@ Core::Land::Land( uint16_t zoneId, uint8_t wardNum, uint8_t landId, uint32_t lan m_wardNum( wardNum ), m_landId( landId ), m_currentPrice( 0 ), + m_minPrice( 0 ), m_nextDrop( 0 ), m_landSetId( landSetId ), - m_landInfo( info ), - m_devaluationTime( 0 ) + m_landInfo( info ) { memset( &m_land, 0x00, sizeof( LandStruct ) ); load(); @@ -238,7 +238,7 @@ uint32_t Core::Land::getMaxItems() uint32_t Core::Land::getDevaluationTime() { - return m_devaluationTime; + return m_nextDrop - Util::getTimeSeconds(); } void Core::Land::init() @@ -280,7 +280,6 @@ void Core::Land::Update( uint32_t currTime ) m_nextDrop = currTime + 21600; m_currentPrice = ( m_currentPrice / 100 ) * 99.58; } - m_devaluationTime = m_nextDrop - currTime; UpdateDatabase(); } } \ 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 3add13d1..cc1b6ac5 100644 --- a/src/servers/sapphire_zone/Zone/Land.h +++ b/src/servers/sapphire_zone/Zone/Land.h @@ -79,7 +79,6 @@ namespace Core //price uint32_t m_initPrice; uint32_t m_nextDrop; - uint32_t m_devaluationTime; uint32_t m_currentPrice; uint32_t m_minPrice; };