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] 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; };