1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 22:57:45 +00:00

Started moveing more housing code into HousingMgr

This commit is contained in:
Mordred 2018-11-13 23:46:10 +01:00
parent a8040d9236
commit 361b0b463b
4 changed files with 349 additions and 337 deletions

View file

@ -10,12 +10,10 @@
// The following enumerations are structures to require their type be included. // The following enumerations are structures to require their type be included.
// They are also defined within the Core::Common namespace to avoid collisions. // They are also defined within the Core::Common namespace to avoid collisions.
// +--------------------------------------------------------------------------- // +---------------------------------------------------------------------------
namespace Core { namespace Core::Network::ActorControl
namespace Network { {
namespace ActorControl {
enum ActorControlType : enum ActorControlType : uint16_t
uint16_t
{ {
/*! Toggles weapon status -> Sheathed/UnSheathed /*! Toggles weapon status -> Sheathed/UnSheathed
\param param1 status 0|1 */ \param param1 status 0|1 */
@ -229,10 +227,10 @@ enum ActorControlType :
SetDutyActionHud = 0x5E9, // disable/enable SetDutyActionHud = 0x5E9, // disable/enable
SetDutyActionActive = 0x5EA, SetDutyActionActive = 0x5EA,
SetDutyActionRemaining = 0x5EB, SetDutyActionRemaining = 0x5EB,
}; };
enum ClientTriggerType enum ClientTriggerType
{ {
ToggleSheathe = 0x01, ToggleSheathe = 0x01,
ToggleAutoAttack = 0x02, ToggleAutoAttack = 0x02,
ChangeTarget = 0x03, ChangeTarget = 0x03,
@ -292,9 +290,9 @@ enum ClientTriggerType
AchievementList = 0x3E9, AchievementList = 0x3E9,
RequestHousingBuildPreset = 0x44C, RequestHousingBuildPreset = 0x44C,
RequestHousingSign = 0x451, RequestLandSignFree = 0x451,
RequestHousingInfoSign = 0x452, RequestLandSignOwned = 0x452,
RequestHousingRename = 0x45A, RequestEstateRename = 0x45A,
RequestHousingItemUI = 0x463, RequestHousingItemUI = 0x463,
RequestSharedEstateSettings = 0x46F, RequestSharedEstateSettings = 0x46F,
@ -310,10 +308,8 @@ enum ClientTriggerType
OpenDuelUI = 0x898, // Open a duel ui OpenDuelUI = 0x898, // Open a duel ui
DuelRequestResult = 0x899, // either accept/reject DuelRequestResult = 0x899, // either accept/reject
}; };
} /* ActorControl */ }
} /* Common */
} /* Core */
#endif #endif

View file

@ -327,71 +327,23 @@ void Core::Network::GameConnection::clientTriggerHandler( const Packets::FFXIVAR
break; break;
} }
case ClientTriggerType::RequestHousingSign: case ClientTriggerType::RequestLandSignFree:
{
auto plotPricePacket = makeZonePacket< Server::FFXIVIpcLandPriceUpdate >( player.getId() );
uint8_t ward = ( param12 & 0xFF00 ) >> 8;
uint8_t plot = ( param12 & 0xFF );
pLog->debug( " Ward: " + std::to_string( ward ) + " Plot: " + std::to_string( plot ) );
player.setActiveLand( plot, ward );
auto zone = player.getCurrentZone();
auto hZone = std::dynamic_pointer_cast< HousingZone >( zone );
if( !hZone )
return;
auto land = hZone->getLand( plot );
plotPricePacket->data().price = land->getCurrentPrice();
plotPricePacket->data().timeLeft = land->getDevaluationTime();
player.queuePacket( plotPricePacket );
break;
}
case ClientTriggerType::RequestHousingInfoSign:
{
auto landInfoSignPacket = makeZonePacket< Server::FFXIVIpcLandInfoSign >( player.getId() );
uint8_t ward = ( param12 & 0xFF00 ) >> 8;
uint8_t plot = ( param12 & 0xFF );
pLog->debug( " Ward: " + std::to_string( ward ) + " Plot: " + std::to_string( plot ) );
player.setActiveLand( plot, ward );
auto zone = player.getCurrentZone();
auto hZone = std::dynamic_pointer_cast< HousingZone >( zone );
auto land = hZone->getLand( plot );
if( !land )
{ {
auto ward = static_cast< uint8_t >( ( param12 & 0xFF00 ) >> 8 );
auto plot = static_cast< uint8_t >( param12 & 0xFF );
auto pHousingMgr = g_fw.get< HousingMgr >(); auto pHousingMgr = g_fw.get< HousingMgr >();
land = pHousingMgr->getLandByOwnerId( player.getId() ); pHousingMgr->sendLandSignFree( player, ward, plot );
}
uint32_t playerId = land->getPlayerOwner();
std::string playerName = g_fw.get< Core::ServerZone >()->getPlayerNameFromDb( playerId );
//memcpy( &landInfoSignPacket->data().estateGreeting, "Hello World", 11 );
//memcpy( &landInfoSignPacket->data().estateName, land->getLandName().c_str(), land->getLandName().size() );
landInfoSignPacket->data().houseSize = land->getPlotSize();
landInfoSignPacket->data().houseType = static_cast< uint8_t >( land->getLandType() );
landInfoSignPacket->data().landId = land->getLandId();
landInfoSignPacket->data().ownerId = player.getContentId(); // should be real owner contentId, not player.contentId()
memcpy( &landInfoSignPacket->data().ownerName, playerName.c_str(), playerName.size() );
landInfoSignPacket->data().wardNum = land->getWardNum();
landInfoSignPacket->data().worldId = 67;
landInfoSignPacket->data().zoneId = land->getZoneId();
player.queuePacket( landInfoSignPacket );
break; break;
} }
case ClientTriggerType::RequestHousingRename: case ClientTriggerType::RequestLandSignOwned:
{
auto ward = static_cast< uint8_t >( ( param12 & 0xFF00 ) >> 8 );
auto plot = static_cast< uint8_t >( param12 & 0xFF );
auto pHousingMgr = g_fw.get< HousingMgr >();
pHousingMgr->sendLandSignOwned( player, ward, plot );
break;
}
case ClientTriggerType::RequestEstateRename:
{ {
auto landRenamePacket = makeZonePacket< Server::FFXIVIpcLandRename >( player.getId() ); auto landRenamePacket = makeZonePacket< Server::FFXIVIpcLandRename >( player.getId() );

View file

@ -3,6 +3,11 @@
#include <Logging/Logger.h> #include <Logging/Logger.h>
#include <Database/DatabaseDef.h> #include <Database/DatabaseDef.h>
#include <Exd/ExdDataGenerated.h> #include <Exd/ExdDataGenerated.h>
#include <Network/PacketContainer.h>
#include <Network/PacketDef/Zone/ServerZoneDef.h>
#include <Network/PacketWrappers/ActorControlPacket142.h>
#include <Network/PacketWrappers/ActorControlPacket143.h>
#include <Network/CommonActorControl.h>
#include <unordered_map> #include <unordered_map>
@ -13,6 +18,12 @@
#include "HousingMgr.h" #include "HousingMgr.h"
#include "Land.h" #include "Land.h"
#include "Framework.h" #include "Framework.h"
#include "ServerZone.h"
using namespace Core::Common;
using namespace Core::Network;
using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server;
extern Core::Framework g_fw; extern Core::Framework g_fw;
@ -84,3 +95,53 @@ Core::LandPtr Core::HousingMgr::getLandByOwnerId( uint32_t id )
} }
return nullptr; return nullptr;
} }
void Core::HousingMgr::sendLandSignOwned( Entity::Player& player, uint8_t ward, uint8_t plot )
{
player.setActiveLand( plot, ward );
auto zone = player.getCurrentZone();
auto hZone = std::dynamic_pointer_cast< HousingZone >( zone );
if( !hZone )
return;
auto land = hZone->getLand( plot );
if( !land )
{
land = getLandByOwnerId( player.getId() );
}
auto landInfoSignPacket = makeZonePacket< Server::FFXIVIpcLandInfoSign >( player.getId() );
uint32_t playerId = land->getPlayerOwner();
std::string playerName = g_fw.get< Core::ServerZone >()->getPlayerNameFromDb( playerId );
//memcpy( &landInfoSignPacket->data().estateGreeting, "Hello World", 11 );
//memcpy( &landInfoSignPacket->data().estateName, land->getLandName().c_str(), land->getLandName().size() );
landInfoSignPacket->data().houseSize = land->getPlotSize();
landInfoSignPacket->data().houseType = static_cast< uint8_t >( land->getLandType() );
landInfoSignPacket->data().landId = land->getLandId();
landInfoSignPacket->data().ownerId = player.getContentId(); // should be real owner contentId, not player.contentId()
memcpy( &landInfoSignPacket->data().ownerName, playerName.c_str(), playerName.size() );
landInfoSignPacket->data().wardNum = land->getWardNum();
landInfoSignPacket->data().worldId = 67;
landInfoSignPacket->data().zoneId = land->getZoneId();
player.queuePacket( landInfoSignPacket );
}
void Core::HousingMgr::sendLandSignFree( Entity::Player& player, uint8_t ward, uint8_t plot )
{
player.setActiveLand( plot, ward );
auto zone = player.getCurrentZone();
auto hZone = std::dynamic_pointer_cast< HousingZone >( zone );
if( !hZone )
return;
auto land = hZone->getLand( plot );
auto plotPricePacket = makeZonePacket< Server::FFXIVIpcLandPriceUpdate >( player.getId() );
plotPricePacket->data().price = land->getCurrentPrice();
plotPricePacket->data().timeLeft = land->getDevaluationTime();
player.queuePacket( plotPricePacket );
}

View file

@ -28,6 +28,9 @@ namespace Core
Core::Data::HousingZonePtr getHousingZoneByLandSetId( uint32_t id ); Core::Data::HousingZonePtr getHousingZoneByLandSetId( uint32_t id );
Core::LandPtr getLandByOwnerId( uint32_t id ); Core::LandPtr getLandByOwnerId( uint32_t id );
void sendLandSignOwned( Entity::Player& player, uint8_t ward, uint8_t plot );
void sendLandSignFree( Entity::Player& player, uint8_t ward, uint8_t plot );
private: private:
using HousingZonePtrMap = std::unordered_map< uint16_t, Core::Data::HousingZonePtr >; using HousingZonePtrMap = std::unordered_map< uint16_t, Core::Data::HousingZonePtr >;
uint16_t m_lastLandId; uint16_t m_lastLandId;