mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 14:57:44 +00:00
Started moveing more housing code into HousingMgr
This commit is contained in:
parent
a8040d9236
commit
361b0b463b
4 changed files with 349 additions and 337 deletions
|
@ -10,12 +10,10 @@
|
|||
// The following enumerations are structures to require their type be included.
|
||||
// They are also defined within the Core::Common namespace to avoid collisions.
|
||||
// +---------------------------------------------------------------------------
|
||||
namespace Core {
|
||||
namespace Network {
|
||||
namespace ActorControl {
|
||||
namespace Core::Network::ActorControl
|
||||
{
|
||||
|
||||
enum ActorControlType :
|
||||
uint16_t
|
||||
enum ActorControlType : uint16_t
|
||||
{
|
||||
/*! Toggles weapon status -> Sheathed/UnSheathed
|
||||
\param param1 status 0|1 */
|
||||
|
@ -292,9 +290,9 @@ enum ClientTriggerType
|
|||
AchievementList = 0x3E9,
|
||||
|
||||
RequestHousingBuildPreset = 0x44C,
|
||||
RequestHousingSign = 0x451,
|
||||
RequestHousingInfoSign = 0x452,
|
||||
RequestHousingRename = 0x45A,
|
||||
RequestLandSignFree = 0x451,
|
||||
RequestLandSignOwned = 0x452,
|
||||
RequestEstateRename = 0x45A,
|
||||
RequestHousingItemUI = 0x463,
|
||||
RequestSharedEstateSettings = 0x46F,
|
||||
|
||||
|
@ -312,8 +310,6 @@ enum ClientTriggerType
|
|||
|
||||
};
|
||||
|
||||
} /* ActorControl */
|
||||
} /* Common */
|
||||
} /* Core */
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -327,71 +327,23 @@ void Core::Network::GameConnection::clientTriggerHandler( const Packets::FFXIVAR
|
|||
|
||||
break;
|
||||
}
|
||||
case ClientTriggerType::RequestHousingSign:
|
||||
{
|
||||
|
||||
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 )
|
||||
case ClientTriggerType::RequestLandSignFree:
|
||||
{
|
||||
auto ward = static_cast< uint8_t >( ( param12 & 0xFF00 ) >> 8 );
|
||||
auto plot = static_cast< uint8_t >( param12 & 0xFF );
|
||||
auto pHousingMgr = g_fw.get< HousingMgr >();
|
||||
land = pHousingMgr->getLandByOwnerId( 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 );
|
||||
|
||||
pHousingMgr->sendLandSignFree( player, ward, plot );
|
||||
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() );
|
||||
|
||||
|
|
|
@ -3,6 +3,11 @@
|
|||
#include <Logging/Logger.h>
|
||||
#include <Database/DatabaseDef.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>
|
||||
|
||||
|
@ -13,6 +18,12 @@
|
|||
#include "HousingMgr.h"
|
||||
#include "Land.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;
|
||||
|
||||
|
@ -84,3 +95,53 @@ Core::LandPtr Core::HousingMgr::getLandByOwnerId( uint32_t id )
|
|||
}
|
||||
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 );
|
||||
}
|
||||
|
|
|
@ -28,6 +28,9 @@ namespace Core
|
|||
Core::Data::HousingZonePtr getHousingZoneByLandSetId( 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:
|
||||
using HousingZonePtrMap = std::unordered_map< uint16_t, Core::Data::HousingZonePtr >;
|
||||
uint16_t m_lastLandId;
|
||||
|
|
Loading…
Add table
Reference in a new issue