mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-22 20:57:46 +00:00
Houseing data initializing and signs
This commit is contained in:
parent
a0616c8d7c
commit
7b7ab34eb9
10 changed files with 146 additions and 35 deletions
|
@ -2740,6 +2740,16 @@ Core::Data::HousingFurniture::HousingFurniture( uint32_t row_id, Core::Data::Exd
|
|||
tooltip = exdData->getField< bool >( row, 9 );
|
||||
}
|
||||
|
||||
Core::Data::HousingLandSet::HousingLandSet( uint32_t row_id, Core::Data::ExdDataGenerated* 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 = 300; i < 300 + 60; i++ )
|
||||
prices.push_back( exdData->getField< uint32_t >( row, i ) );
|
||||
|
||||
}
|
||||
|
||||
Core::Data::HousingPlacement::HousingPlacement( uint32_t row_id, Core::Data::ExdDataGenerated* exdData )
|
||||
{
|
||||
auto row = exdData->m_HousingPlacementDat.get_row( row_id );
|
||||
|
@ -5525,6 +5535,7 @@ bool Core::Data::ExdDataGenerated::init( const std::string& path )
|
|||
m_HousingEmploymentNpcListDat = setupDatAccess( "HousingEmploymentNpcList", xiv::exd::Language::none );
|
||||
m_HousingEmploymentNpcRaceDat = setupDatAccess( "HousingEmploymentNpcRace", xiv::exd::Language::en );
|
||||
m_HousingFurnitureDat = setupDatAccess( "HousingFurniture", xiv::exd::Language::none );
|
||||
m_HousingLandSetDat = setupDatAccess( "HousingLandSet", xiv::exd::Language::none );
|
||||
m_HousingPlacementDat = setupDatAccess( "HousingPlacement", xiv::exd::Language::en );
|
||||
m_HousingPresetDat = setupDatAccess( "HousingPreset", xiv::exd::Language::en );
|
||||
m_HousingYardObjectDat = setupDatAccess( "HousingYardObject", xiv::exd::Language::none );
|
||||
|
|
|
@ -256,6 +256,7 @@ struct HousingAethernet;
|
|||
struct HousingEmploymentNpcList;
|
||||
struct HousingEmploymentNpcRace;
|
||||
struct HousingFurniture;
|
||||
struct HousingLandSet;
|
||||
struct HousingPlacement;
|
||||
struct HousingPreset;
|
||||
struct HousingYardObject;
|
||||
|
@ -2849,6 +2850,14 @@ struct HousingPlacement
|
|||
HousingPlacement( uint32_t row_id, Core::Data::ExdDataGenerated* exdData );
|
||||
};
|
||||
|
||||
struct HousingLandSet
|
||||
{
|
||||
std::vector< uint8_t > sizes;
|
||||
std::vector< uint32_t > prices;
|
||||
|
||||
HousingLandSet( uint32_t row_id, Core::Data::ExdDataGenerated* exdData );
|
||||
};
|
||||
|
||||
struct HousingPreset
|
||||
{
|
||||
std::string singular;
|
||||
|
@ -5054,6 +5063,7 @@ struct ZoneSharedGroup
|
|||
xiv::exd::Exd m_HousingEmploymentNpcListDat;
|
||||
xiv::exd::Exd m_HousingEmploymentNpcRaceDat;
|
||||
xiv::exd::Exd m_HousingFurnitureDat;
|
||||
xiv::exd::Exd m_HousingLandSetDat;
|
||||
xiv::exd::Exd m_HousingPlacementDat;
|
||||
xiv::exd::Exd m_HousingPresetDat;
|
||||
xiv::exd::Exd m_HousingYardObjectDat;
|
||||
|
@ -5484,6 +5494,7 @@ struct ZoneSharedGroup
|
|||
using HousingEmploymentNpcListPtr = std::shared_ptr< HousingEmploymentNpcList >;
|
||||
using HousingEmploymentNpcRacePtr = std::shared_ptr< HousingEmploymentNpcRace >;
|
||||
using HousingFurniturePtr = std::shared_ptr< HousingFurniture >;
|
||||
using HousingLandSetPtr = std::shared_ptr< HousingLandSet >;
|
||||
using HousingPlacementPtr = std::shared_ptr< HousingPlacement >;
|
||||
using HousingPresetPtr = std::shared_ptr< HousingPreset >;
|
||||
using HousingYardObjectPtr = std::shared_ptr< HousingYardObject >;
|
||||
|
@ -5929,6 +5940,7 @@ struct ZoneSharedGroup
|
|||
std::set< uint32_t > m_HousingEmploymentNpcListIdList;
|
||||
std::set< uint32_t > m_HousingEmploymentNpcRaceIdList;
|
||||
std::set< uint32_t > m_HousingFurnitureIdList;
|
||||
std::set< uint32_t > m_HousingLandSetIdList;
|
||||
std::set< uint32_t > m_HousingPlacementIdList;
|
||||
std::set< uint32_t > m_HousingPresetIdList;
|
||||
std::set< uint32_t > m_HousingYardObjectIdList;
|
||||
|
@ -7549,6 +7561,12 @@ const std::set< uint32_t >& getHousingFurnitureIdList()
|
|||
loadIdList( m_HousingFurnitureDat, m_HousingFurnitureIdList );
|
||||
return m_HousingFurnitureIdList;
|
||||
}
|
||||
const std::set< uint32_t >& getHousingLandSetIdList()
|
||||
{
|
||||
if( m_HousingLandSetIdList.size() == 0 )
|
||||
loadIdList( m_HousingLandSetDat, m_HousingLandSetIdList );
|
||||
return m_HousingLandSetIdList;
|
||||
}
|
||||
const std::set< uint32_t >& getHousingPlacementIdList()
|
||||
{
|
||||
if( m_HousingPlacementIdList.size() == 0 )
|
||||
|
|
|
@ -286,6 +286,7 @@ enum ClientTriggerType
|
|||
AchievementCritReq = 0x3E8,
|
||||
AchievementList = 0x3E9,
|
||||
|
||||
RequestHousingSign = 0x451,
|
||||
RequestSharedEstateSettings = 0x46F,
|
||||
|
||||
CompanionAction = 0x6A4,
|
||||
|
|
|
@ -188,7 +188,8 @@ namespace Core::Network::Packets
|
|||
LandSetInitialize = 0x0220, // updated 4.4
|
||||
LandUpdate = 0x0221, // updated 4.4
|
||||
YardObjectSpawn = 0x0222, // updated 4.4
|
||||
LandPriceUpdate = 0x0225, // updated 4.3
|
||||
|
||||
LandPriceUpdate = 0x0224, // updated 4.3
|
||||
LandPermission = 0x0229, // updated 4.4
|
||||
LandSetYardInitialize = 0x022C, // updated 4.4
|
||||
YardObjectMove = 0x0230, // updated 4.4
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#include "Zone/Zone.h"
|
||||
#include "Zone/ZonePosition.h"
|
||||
#include "Zone/HousingZone.h"
|
||||
#include "Zone/Land.h"
|
||||
|
||||
#include "Network/GameConnection.h"
|
||||
|
||||
|
@ -307,7 +309,28 @@ void Core::Network::GameConnection::clientTriggerHandler( const Packets::FFXIVAR
|
|||
player.removeQuest( static_cast< uint16_t >( param1 ) );
|
||||
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 ) );
|
||||
|
||||
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();
|
||||
|
||||
player.queuePacket( plotPricePacket );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <Util/Util.h>
|
||||
#include <Util/UtilMath.h>
|
||||
#include <Database/DatabaseDef.h>
|
||||
|
||||
#include <Exd/ExdDataGenerated.h>
|
||||
#include <Network/GamePacketNew.h>
|
||||
#include <Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
|
||||
|
@ -21,24 +21,46 @@ using namespace Core::Common;
|
|||
using namespace Core::Network::Packets;
|
||||
using namespace Core::Network::Packets::Server;
|
||||
|
||||
Core::HousingZone::HousingZone( uint8_t landSetId,
|
||||
Core::HousingZone::HousingZone( uint8_t wardNum,
|
||||
uint16_t territoryId,
|
||||
uint32_t guId,
|
||||
const std::string& internalName,
|
||||
const std::string& contentName ) :
|
||||
Zone( territoryId, guId, internalName, contentName ),
|
||||
m_landSetId( landSetId ),
|
||||
m_zoneId( territoryId )
|
||||
m_wardNum( wardNum ),
|
||||
m_zoneId( territoryId ),
|
||||
m_landSetId( ( static_cast< uint32_t >( territoryId ) << 16 ) | wardNum )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool Core::HousingZone::init()
|
||||
{
|
||||
|
||||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
auto res = pDb->query( "SELECT * FROM landset WHERE landsetid = " + std::to_string( m_landSetId ) );
|
||||
if( !res->next() )
|
||||
{
|
||||
pDb->directExecute( "INSERT INTO landset ( landsetid ) VALUES ( " + std::to_string( m_landSetId ) + " );" );
|
||||
}
|
||||
|
||||
int housingIndex;
|
||||
if( m_zoneId == 339 )
|
||||
housingIndex = 0;
|
||||
else if( m_zoneId == 340 )
|
||||
housingIndex = 1;
|
||||
else if( m_zoneId == 341 )
|
||||
housingIndex = 2;
|
||||
else if( m_zoneId == 641 )
|
||||
housingIndex = 3;
|
||||
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto info = pExdData->get< Core::Data::HousingLandSet >( housingIndex );
|
||||
|
||||
uint32_t landId;
|
||||
for( landId = 0; landId < 60; landId++ )
|
||||
{
|
||||
auto pObject = make_Land( m_territoryId, getLandSetId(), landId );
|
||||
auto pObject = make_Land( m_territoryId, getWardNum(), landId, m_landSetId, info );
|
||||
pObject->setHouseSize( 1 );
|
||||
m_landPtrMap[ landId ] = pObject;
|
||||
}
|
||||
|
@ -60,7 +82,7 @@ void Core::HousingZone::onPlayerZoneIn(Entity::Player& player)
|
|||
uint32_t yardPacketNum;
|
||||
uint32_t yardPacketTotal = 8;
|
||||
|
||||
sendMap( player );
|
||||
sendLandSet( player );
|
||||
|
||||
for( yardPacketNum = 0; yardPacketNum < yardPacketTotal; yardPacketNum++ )
|
||||
{
|
||||
|
@ -78,7 +100,7 @@ void Core::HousingZone::onPlayerZoneIn(Entity::Player& player)
|
|||
|
||||
}
|
||||
|
||||
void Core::HousingZone::sendMap( Entity::Player& player )
|
||||
void Core::HousingZone::sendLandSet( Entity::Player& player )
|
||||
{
|
||||
auto landsetInitializePacket = makeZonePacket< FFXIVIpcLandSetInitialize >( player.getId() );
|
||||
|
||||
|
@ -89,11 +111,10 @@ void Core::HousingZone::sendMap( Entity::Player& player )
|
|||
landsetInitializePacket->data().subInstance = isPlayerSubInstance( player ) == false ? 1 : 2;
|
||||
|
||||
uint8_t startIndex = isPlayerSubInstance( player ) == false ? 0 : 30;
|
||||
uint8_t count = 0;
|
||||
for( uint8_t i = startIndex; i < ( startIndex + 30 ); i++ )
|
||||
|
||||
for( uint8_t i = startIndex, count = 0; i < ( startIndex + 30 ); i++ )
|
||||
{
|
||||
memcpy( &landsetInitializePacket->data().land[ count ], &getLand( i )->getLand(), sizeof( Common::LandStruct ) );
|
||||
count++;
|
||||
memcpy( &landsetInitializePacket->data().land[ count++ ], &getLand( i )->getLand(), sizeof( Common::LandStruct ) );
|
||||
}
|
||||
|
||||
player.queuePacket( landsetInitializePacket );
|
||||
|
@ -112,7 +133,12 @@ void Core::HousingZone::onUpdate( uint32_t currTime )
|
|||
}
|
||||
}
|
||||
|
||||
uint8_t Core::HousingZone::getLandSetId() const
|
||||
uint8_t Core::HousingZone::getWardNum() const
|
||||
{
|
||||
return m_wardNum;
|
||||
}
|
||||
|
||||
uint32_t Core::HousingZone::getLandSetId() const
|
||||
{
|
||||
return m_landSetId;
|
||||
}
|
||||
|
|
|
@ -22,18 +22,21 @@ namespace Core
|
|||
void onPlayerZoneIn( Entity::Player& player ) override;
|
||||
void onUpdate( uint32_t currTime ) override;
|
||||
|
||||
void sendMap( Entity::Player& player );
|
||||
void sendLandSet( Entity::Player& player );
|
||||
bool isPlayerSubInstance( Entity::Player& player );
|
||||
|
||||
/* returns current ward number for this zone */
|
||||
uint8_t getLandSetId() const;
|
||||
uint8_t getWardNum() const;
|
||||
|
||||
uint32_t getLandSetId() const;
|
||||
Core::LandPtr getLand( uint8_t id );
|
||||
|
||||
const uint32_t m_wardMaxNum = 18;
|
||||
private:
|
||||
using LandPtrMap = std::unordered_map< uint8_t, Core::LandPtr >;
|
||||
const uint32_t m_landSetMax = 18;
|
||||
LandPtrMap m_landPtrMap;
|
||||
uint8_t m_landSetId;
|
||||
uint8_t m_wardNum;
|
||||
uint32_t m_landSetId;
|
||||
uint32_t m_zoneId;
|
||||
};
|
||||
|
||||
|
|
|
@ -25,14 +25,16 @@ extern Core::Framework g_fw;
|
|||
|
||||
using namespace Core::Common;
|
||||
|
||||
Core::Land::Land( uint16_t zoneId, uint8_t wardNum, uint8_t landId ) :
|
||||
Core::Land::Land( uint16_t zoneId, uint8_t wardNum, uint8_t landId, uint32_t landSetId,
|
||||
Core::Data::HousingLandSetPtr info ) :
|
||||
m_zoneId( zoneId ),
|
||||
m_wardNum( wardNum ),
|
||||
m_landId( landId ),
|
||||
m_currentPrice( 0 ),
|
||||
m_nextDrop( 0 )
|
||||
m_nextDrop( 0 ),
|
||||
m_landSetId( landSetId ),
|
||||
m_landInfo( info )
|
||||
{
|
||||
m_landKey = ( m_zoneId << 16 ) | ( m_wardNum << 8 ) | m_landId;
|
||||
memset( &m_land, 0x00, sizeof( LandStruct ) );
|
||||
load();
|
||||
}
|
||||
|
@ -44,8 +46,31 @@ Core::Land::~Land()
|
|||
|
||||
void Core::Land::load()
|
||||
{
|
||||
m_land.houseSize = 1;
|
||||
|
||||
m_land.houseState = HouseState::forSale;
|
||||
|
||||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
auto res = pDb->query( "SELECT * FROM land WHERE landsetid = " + std::to_string( m_landSetId ) + " "
|
||||
"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_land.houseSize = m_landInfo->sizes[ m_landId ];
|
||||
}
|
||||
else
|
||||
{
|
||||
m_land.houseSize = res->getUInt( "size" );
|
||||
m_land.houseState = res->getUInt( "status" );
|
||||
m_currentPrice = res->getUInt( "LandPrice" );;
|
||||
}
|
||||
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 ) );
|
||||
|
@ -88,6 +113,11 @@ uint16_t Core::Land::convertItemIdToHousingItemId( uint16_t itemId )
|
|||
return info->additionalData;
|
||||
}
|
||||
|
||||
uint32_t Core::Land::getCurrentPrice() const
|
||||
{
|
||||
return m_currentPrice;
|
||||
}
|
||||
|
||||
void Core::Land::setPreset( uint32_t id )
|
||||
{
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
|
@ -197,11 +227,6 @@ uint32_t Core::Land::getPlayerOwner()
|
|||
return m_ownerPlayerId;
|
||||
}
|
||||
|
||||
uint32_t Core::Land::getLandKey()
|
||||
{
|
||||
return m_landKey;
|
||||
}
|
||||
|
||||
const LandStruct& Core::Land::getLand()
|
||||
{
|
||||
return m_land;
|
||||
|
@ -215,19 +240,15 @@ uint32_t Core::Land::getMaxItems()
|
|||
void Core::Land::init()
|
||||
{
|
||||
|
||||
|
||||
switch( getHouseSize() )
|
||||
{
|
||||
case HouseSize::small:
|
||||
m_initPrice = 3750000;
|
||||
m_maxItems = 20;
|
||||
break;
|
||||
case HouseSize::medium:
|
||||
m_initPrice = 20000000;
|
||||
m_maxItems = 30;
|
||||
break;
|
||||
case HouseSize::big:
|
||||
m_initPrice = 50000000;
|
||||
m_maxItems = 40;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -5,11 +5,16 @@
|
|||
|
||||
namespace Core
|
||||
{
|
||||
namespace Data
|
||||
{
|
||||
using HousingLandSetPtr = std::shared_ptr< HousingLandSet >;
|
||||
}
|
||||
|
||||
class Land
|
||||
{
|
||||
public:
|
||||
|
||||
Land( uint16_t zoneId, uint8_t wardNum, uint8_t landId );
|
||||
Land( uint16_t zoneId, uint8_t wardNum, uint8_t landId, uint32_t landSetId, Core::Data::HousingLandSetPtr info );
|
||||
virtual ~Land();
|
||||
|
||||
void load();
|
||||
|
@ -48,21 +53,23 @@ namespace Core
|
|||
void UpdateDatabase();
|
||||
void Update( uint32_t currTime );
|
||||
void onUpdate();
|
||||
uint32_t getLandKey();
|
||||
|
||||
const Common::LandStruct& getLand();
|
||||
uint32_t getMaxItems();
|
||||
|
||||
uint32_t getCurrentPrice() const;
|
||||
|
||||
private:
|
||||
uint16_t convertItemIdToHousingItemId( uint16_t itemId );
|
||||
void init();
|
||||
|
||||
uint32_t m_landKey;
|
||||
uint8_t m_wardNum;
|
||||
uint8_t m_landId;
|
||||
uint32_t m_landSetId;
|
||||
uint16_t m_zoneId;
|
||||
Common::LandStruct m_land;
|
||||
uint32_t m_ownerPlayerId;
|
||||
Core::Data::HousingLandSetPtr m_landInfo;
|
||||
|
||||
|
||||
//item storage
|
||||
|
|
|
@ -175,7 +175,7 @@ bool Core::TerritoryMgr::createHousingTerritories()
|
|||
|
||||
auto pHousingZone = make_HousingZone( wardNum, territoryId, guid, territoryInfo->name, pPlaceName->name );
|
||||
pHousingZone->init();
|
||||
wardMaxNum = pHousingZone->m_wardMaxNum;
|
||||
wardMaxNum = 18;
|
||||
|
||||
InstanceIdToZonePtrMap instanceMap;
|
||||
instanceMap[ guid ] = pHousingZone;
|
||||
|
|
Loading…
Add table
Reference in a new issue