mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-02 08:57:44 +00:00
Housing cleanup
This commit is contained in:
parent
fd9bf92a25
commit
5479a77d6d
11 changed files with 636 additions and 657 deletions
|
@ -733,7 +733,7 @@ namespace Core::Common
|
|||
};
|
||||
|
||||
//Structs
|
||||
struct LandsetStruct
|
||||
struct LandStruct
|
||||
{
|
||||
uint8_t houseSize; //0
|
||||
uint8_t houseState; // 2
|
||||
|
|
|
@ -191,7 +191,7 @@ void Core::Db::ZoneDbConnection::doPrepareStatements()
|
|||
"UPDATE charaglobalitem SET IS_DELETE = 1 WHERE ItemId = ?;",
|
||||
CONNECTION_BOTH );
|
||||
|
||||
prepareStatement( LAND_INS,
|
||||
/*prepareStatement( LAND_INS,
|
||||
"INSERT INTO land ( LandSetId ) VALUES ( ? );",
|
||||
CONNECTION_BOTH );
|
||||
|
||||
|
@ -211,5 +211,5 @@ void Core::Db::ZoneDbConnection::doPrepareStatements()
|
|||
"colorSlot_5 = ?, colorSlot_6 = ?, colorSlot_7 = ?, ownerPlayerId = ?, nextDrop = ?, "
|
||||
"dropCount = ?, currentPrice = ?"
|
||||
" WHERE LandSetId = ?;",
|
||||
CONNECTION_BOTH );
|
||||
CONNECTION_BOTH );*/
|
||||
}
|
||||
|
|
|
@ -3,17 +3,15 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace Core {
|
||||
namespace Network {
|
||||
namespace Packets {
|
||||
namespace Core::Network::Packets
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Lobby Connection IPC Codes
|
||||
/**
|
||||
* Server IPC Lobby Type Codes.
|
||||
*/
|
||||
enum ServerLobbyIpcType :
|
||||
uint16_t
|
||||
enum ServerLobbyIpcType : uint16_t
|
||||
{
|
||||
LobbyError = 0x0002,
|
||||
LobbyServiceAccountList = 0x000C,
|
||||
|
@ -28,8 +26,7 @@ enum ServerLobbyIpcType :
|
|||
/**
|
||||
* Client IPC Lobby Type Codes.
|
||||
*/
|
||||
enum ClientLobbyIpcType :
|
||||
uint16_t
|
||||
enum ClientLobbyIpcType : uint16_t
|
||||
{
|
||||
ReqCharList = 0x0003,
|
||||
ReqEnterWorld = 0x0004,
|
||||
|
@ -44,8 +41,7 @@ enum ClientLobbyIpcType :
|
|||
/**
|
||||
* Server IPC Zone Type Codes.
|
||||
*/
|
||||
enum ServerZoneIpcType :
|
||||
uint16_t
|
||||
enum ServerZoneIpcType : uint16_t
|
||||
{
|
||||
|
||||
// static opcode ( the ones that rarely, if ever, change )
|
||||
|
@ -188,14 +184,15 @@ enum ServerZoneIpcType :
|
|||
|
||||
EquipDisplayFlags = 0x020C, // updated 4.4
|
||||
|
||||
LandsetInitialize = 0x0220, // updated 4.4
|
||||
// housing
|
||||
LandSetInitialize = 0x0220, // updated 4.4
|
||||
LandUpdate = 0x0221, // updated 4.4
|
||||
YardObjectSpawn = 0x0222, // updated 4.4
|
||||
LandsetPriceUpdate = 0x0225, // updated 4.3
|
||||
LandsetPermission = 0x0229, // updated 4.4
|
||||
LandsetYardInitialize = 0x022C, // updated 4.4
|
||||
LandPriceUpdate = 0x0225, // updated 4.3
|
||||
LandPermission = 0x0229, // updated 4.4
|
||||
LandSetYardInitialize = 0x022C, // updated 4.4
|
||||
YardObjectMove = 0x0230, // updated 4.4
|
||||
LandsetExtending = 0x0251, // updated 4.4
|
||||
LandsetUpdate = 0x0221, // updated 4.4
|
||||
LandSetExtending = 0x0251, // updated 4.4
|
||||
|
||||
SharedEstateSettingsResponse = 0x023C, // updated 4.4
|
||||
|
||||
|
@ -215,8 +212,7 @@ enum ServerZoneIpcType :
|
|||
/**
|
||||
* Client IPC Zone Type Codes.
|
||||
*/
|
||||
enum ClientZoneIpcType :
|
||||
uint16_t
|
||||
enum ClientZoneIpcType : uint16_t
|
||||
{
|
||||
|
||||
PingHandler = 0x0065, // unchanged 4.3
|
||||
|
@ -304,8 +300,7 @@ enum ClientZoneIpcType :
|
|||
/**
|
||||
* Server IPC Chat Type Codes.
|
||||
*/
|
||||
enum ServerChatIpcType :
|
||||
uint16_t
|
||||
enum ServerChatIpcType : uint16_t
|
||||
{
|
||||
Tell = 0x0064, // updated for sb
|
||||
TellErrNotFound = 0x0066,
|
||||
|
@ -314,15 +309,12 @@ enum ServerChatIpcType :
|
|||
/**
|
||||
* Client IPC Chat Type Codes.
|
||||
*/
|
||||
enum ClientChatIpcType :
|
||||
uint16_t
|
||||
enum ClientChatIpcType : uint16_t
|
||||
{
|
||||
TellReq = 0x0064,
|
||||
};
|
||||
|
||||
|
||||
} /* Packets */
|
||||
} /* Network */
|
||||
} /* Core */
|
||||
}
|
||||
|
||||
#endif /*_CORE_NETWORK_PACKETS_IPCS_H*/
|
||||
|
|
|
@ -1541,8 +1541,7 @@ struct FFXIVIpcEquipDisplayFlags :
|
|||
* Structural representation of the packet sent by the server
|
||||
* to mount a player
|
||||
*/
|
||||
struct FFXIVIpcMount :
|
||||
FFXIVIpcBasePacket< Mount >
|
||||
struct FFXIVIpcMount : FFXIVIpcBasePacket< Mount >
|
||||
{
|
||||
uint32_t id;
|
||||
};
|
||||
|
@ -1551,8 +1550,7 @@ struct FFXIVIpcMount :
|
|||
* Structural representation of the packet sent by the server
|
||||
* to mount a player
|
||||
*/
|
||||
struct FFXIVIpcDirectorVars :
|
||||
FFXIVIpcBasePacket< DirectorVars >
|
||||
struct FFXIVIpcDirectorVars : FFXIVIpcBasePacket< DirectorVars >
|
||||
{
|
||||
/*! DirectorType | ContentId */
|
||||
uint32_t m_directorId;
|
||||
|
@ -1565,22 +1563,19 @@ struct FFXIVIpcDirectorVars :
|
|||
};
|
||||
|
||||
|
||||
struct FFXIVIpcActorGauge :
|
||||
FFXIVIpcBasePacket< ActorGauge >
|
||||
struct FFXIVIpcActorGauge : FFXIVIpcBasePacket< ActorGauge >
|
||||
{
|
||||
uint8_t classJobId;
|
||||
uint8_t data[15]; // depends on classJobId
|
||||
};
|
||||
|
||||
struct FFXIVIpcPerformNote :
|
||||
FFXIVIpcBasePacket< PerformNote >
|
||||
struct FFXIVIpcPerformNote : FFXIVIpcBasePacket< PerformNote >
|
||||
{
|
||||
uint8_t data[32];
|
||||
};
|
||||
|
||||
//IPCs
|
||||
struct FFXIVIpcLandsetPermission :
|
||||
FFXIVIpcBasePacket<LandsetPermission >
|
||||
struct FFXIVIpcLandPermission : FFXIVIpcBasePacket<LandPermission >
|
||||
{
|
||||
Common::HousePermissionSet freeCompanyHouse; // 00
|
||||
uint64_t unkown1;
|
||||
|
@ -1594,25 +1589,22 @@ struct FFXIVIpcLandsetPermission :
|
|||
uint64_t unkown5;
|
||||
};
|
||||
|
||||
struct FFXIVIpcLandsetUpdate :
|
||||
FFXIVIpcBasePacket< LandsetUpdate >
|
||||
struct FFXIVIpcLandUpdate : FFXIVIpcBasePacket< LandUpdate >
|
||||
{
|
||||
uint16_t landSetId;
|
||||
uint16_t unknow0;
|
||||
uint16_t unknow1;
|
||||
uint16_t unknow2;
|
||||
Common::LandsetStruct landset;
|
||||
Common::LandStruct land;
|
||||
};
|
||||
|
||||
struct FFXIVIpcLandsetPriceUpdate :
|
||||
FFXIVIpcBasePacket< LandsetPriceUpdate >
|
||||
struct FFXIVIpcLandPriceUpdate : FFXIVIpcBasePacket< LandPriceUpdate >
|
||||
{
|
||||
uint32_t price;
|
||||
uint32_t timeLeft;
|
||||
};
|
||||
|
||||
struct FFXIVIpcLandsetExtend :
|
||||
FFXIVIpcBasePacket< LandsetExtending >
|
||||
struct FFXIVIpcLandSetExtend : FFXIVIpcBasePacket< LandSetExtending >
|
||||
{
|
||||
struct
|
||||
{
|
||||
|
@ -1623,11 +1615,10 @@ struct FFXIVIpcLandsetExtend :
|
|||
} landset[30];
|
||||
};
|
||||
|
||||
struct FFXIVIpcLandsetInitialize :
|
||||
FFXIVIpcBasePacket< LandsetInitialize >
|
||||
struct FFXIVIpcLandSetInitialize : FFXIVIpcBasePacket< LandSetInitialize >
|
||||
{
|
||||
uint16_t unknown0;
|
||||
uint16_t wardNum; // set 1 for "Mist, Ward 2"
|
||||
uint16_t landSetId; // set 1 for "Mist, Ward 2"
|
||||
uint16_t zoneId;
|
||||
uint16_t worldId;
|
||||
uint8_t unknown1;
|
||||
|
@ -1638,11 +1629,10 @@ struct FFXIVIpcLandsetInitialize :
|
|||
uint8_t unknown6;
|
||||
uint8_t unknown7;
|
||||
uint8_t unknown8;
|
||||
Common::LandsetStruct landset[30];
|
||||
Common::LandStruct land[30];
|
||||
};
|
||||
|
||||
struct FFXIVIpcYardObjectSpawn :
|
||||
FFXIVIpcBasePacket<YardObjectSpawn>
|
||||
struct FFXIVIpcYardObjectSpawn : FFXIVIpcBasePacket<YardObjectSpawn>
|
||||
{
|
||||
uint8_t landSetId;
|
||||
uint8_t objectArray;
|
||||
|
@ -1654,8 +1644,7 @@ struct FFXIVIpcYardObjectSpawn :
|
|||
uint16_t pos_z;
|
||||
};
|
||||
|
||||
struct FFXIVIpcYardObjectMove :
|
||||
FFXIVIpcBasePacket<YardObjectMove>
|
||||
struct FFXIVIpcYardObjectMove : FFXIVIpcBasePacket<YardObjectMove>
|
||||
{
|
||||
uint16_t itemRotation;
|
||||
uint8_t objectArray;
|
||||
|
@ -1668,8 +1657,7 @@ struct FFXIVIpcYardObjectMove :
|
|||
uint16_t unknown3;
|
||||
};
|
||||
|
||||
struct FFXIVIpcLandsetYardInitialize :
|
||||
FFXIVIpcBasePacket< LandsetYardInitialize >
|
||||
struct FFXIVIpcLandSetYardInitialize : FFXIVIpcBasePacket< LandSetYardInitialize >
|
||||
{
|
||||
uint32_t unknown1; //always 0xFFFFFFFF
|
||||
uint32_t unknown2; //always 0xFFFFFFFF
|
||||
|
|
|
@ -848,7 +848,7 @@ uint16_t Core::Entity::Player::calculateEquippedGearItemLevel()
|
|||
it++;
|
||||
}
|
||||
|
||||
return std::max( static_cast< int32_t >( iLvlResult / 13 ), 9999 );
|
||||
return static_cast< uint16_t >( std::min( static_cast< int32_t >( iLvlResult / 13 ), 9999 ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ TYPE_FORWARD( Item );
|
|||
TYPE_FORWARD( ItemContainer );
|
||||
TYPE_FORWARD( Session );
|
||||
TYPE_FORWARD( ZonePosition );
|
||||
TYPE_FORWARD( Landset )
|
||||
TYPE_FORWARD( Land )
|
||||
|
||||
namespace StatusEffect {
|
||||
TYPE_FORWARD( StatusEffect );
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "Actor/Player.h"
|
||||
#include "Actor/Actor.h"
|
||||
#include "Landset.h"
|
||||
#include "Land.h"
|
||||
|
||||
#include "Forwards.h"
|
||||
#include "HousingZone.h"
|
||||
|
@ -21,13 +21,13 @@ using namespace Core::Common;
|
|||
using namespace Core::Network::Packets;
|
||||
using namespace Core::Network::Packets::Server;
|
||||
|
||||
Core::HousingZone::HousingZone( uint8_t wardNum,
|
||||
Core::HousingZone::HousingZone( uint8_t landSetId,
|
||||
uint16_t territoryId,
|
||||
uint32_t guId,
|
||||
const std::string& internalName,
|
||||
const std::string& contentName ) :
|
||||
Zone( territoryId, guId, internalName, contentName ),
|
||||
m_wardNum( wardNum ),
|
||||
m_landSetId( landSetId ),
|
||||
m_zoneId( territoryId )
|
||||
{
|
||||
|
||||
|
@ -35,12 +35,12 @@ Core::HousingZone::HousingZone( uint8_t wardNum,
|
|||
|
||||
bool Core::HousingZone::init()
|
||||
{
|
||||
uint32_t landsetId;
|
||||
for( landsetId = 0; landsetId < 60; landsetId++ )
|
||||
uint32_t landId;
|
||||
for( landId = 0; landId < 60; landId++ )
|
||||
{
|
||||
auto pObject = make_Landset( m_territoryId, getWardNum(), landsetId );
|
||||
auto pObject = make_Land( m_territoryId, getLandSetId(), landId );
|
||||
pObject->setHouseSize( 1 );
|
||||
m_landsetPtrMap[ landsetId ] = pObject;
|
||||
m_landPtrMap[ landId ] = pObject;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -64,7 +64,7 @@ void Core::HousingZone::onPlayerZoneIn(Entity::Player& player)
|
|||
|
||||
for( yardPacketNum = 0; yardPacketNum < yardPacketTotal; yardPacketNum++ )
|
||||
{
|
||||
auto landsetYardInitializePacket = makeZonePacket< FFXIVIpcLandsetYardInitialize >(player.getId());
|
||||
auto landsetYardInitializePacket = makeZonePacket< FFXIVIpcLandSetYardInitialize >( player.getId() );
|
||||
landsetYardInitializePacket->data().unknown1 = 0xFFFFFFFF;
|
||||
landsetYardInitializePacket->data().unknown2 = 0xFFFFFFFF;
|
||||
landsetYardInitializePacket->data().unknown3 = 0xFF;
|
||||
|
@ -80,9 +80,9 @@ void Core::HousingZone::onPlayerZoneIn(Entity::Player& player)
|
|||
|
||||
void Core::HousingZone::sendMap( Entity::Player& player )
|
||||
{
|
||||
auto landsetInitializePacket = makeZonePacket< FFXIVIpcLandsetInitialize >( player.getId() );
|
||||
auto landsetInitializePacket = makeZonePacket< FFXIVIpcLandSetInitialize >( player.getId() );
|
||||
|
||||
landsetInitializePacket->data().wardNum = m_wardNum;
|
||||
landsetInitializePacket->data().landSetId = m_landSetId;
|
||||
landsetInitializePacket->data().zoneId = m_territoryId;
|
||||
//TODO: get current WorldId
|
||||
landsetInitializePacket->data().worldId = 67;
|
||||
|
@ -92,8 +92,7 @@ void Core::HousingZone::sendMap( Entity::Player& player )
|
|||
uint8_t count = 0;
|
||||
for( uint8_t i = startIndex; i < ( startIndex + 30 ); i++ )
|
||||
{
|
||||
memcpy( &landsetInitializePacket->data().landset[ count ],
|
||||
&getLandset( i )->getLandset(), sizeof( Common::LandsetStruct ) );
|
||||
memcpy( &landsetInitializePacket->data().land[ count ], &getLand( i )->getLand(), sizeof( Common::LandStruct ) );
|
||||
count++;
|
||||
}
|
||||
|
||||
|
@ -109,19 +108,19 @@ void Core::HousingZone::onUpdate( uint32_t currTime )
|
|||
{
|
||||
for( uint8_t i = 0; i < 60; i++ )
|
||||
{
|
||||
getLandset( i )->Update( currTime );
|
||||
getLand( i )->Update( currTime );
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t Core::HousingZone::getWardNum() const
|
||||
uint8_t Core::HousingZone::getLandSetId() const
|
||||
{
|
||||
return m_wardNum;
|
||||
return m_landSetId;
|
||||
}
|
||||
|
||||
Core::LandsetPtr Core::HousingZone::getLandset( uint8_t id )
|
||||
Core::LandPtr Core::HousingZone::getLand( uint8_t id )
|
||||
{
|
||||
auto it = m_landsetPtrMap.find( id );
|
||||
if( it == m_landsetPtrMap.end() )
|
||||
auto it = m_landPtrMap.find( id );
|
||||
if( it == m_landPtrMap.end() )
|
||||
return nullptr;
|
||||
|
||||
return it->second;
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Core
|
|||
class HousingZone : public Zone
|
||||
{
|
||||
public:
|
||||
HousingZone( uint8_t wardNum,
|
||||
HousingZone( uint8_t landSetId,
|
||||
uint16_t territoryId,
|
||||
uint32_t guId,
|
||||
const std::string& internalName,
|
||||
|
@ -26,14 +26,14 @@ namespace Core
|
|||
bool isPlayerSubInstance( Entity::Player& player );
|
||||
|
||||
/* returns current ward number for this zone */
|
||||
uint8_t getWardNum() const;
|
||||
Core::LandsetPtr getLandset( uint8_t id );
|
||||
uint8_t getLandSetId() const;
|
||||
Core::LandPtr getLand( uint8_t id );
|
||||
|
||||
const uint32_t m_wardMaxNum = 18;
|
||||
private:
|
||||
using LandsetPtrMap = std::unordered_map< uint8_t, Core::LandsetPtr >;
|
||||
LandsetPtrMap m_landsetPtrMap;
|
||||
uint8_t m_wardNum;
|
||||
using LandPtrMap = std::unordered_map< uint8_t, Core::LandPtr >;
|
||||
LandPtrMap m_landPtrMap;
|
||||
uint8_t m_landSetId;
|
||||
uint32_t m_zoneId;
|
||||
};
|
||||
|
||||
|
|
346
src/servers/sapphire_zone/Zone/Land.cpp
Normal file
346
src/servers/sapphire_zone/Zone/Land.cpp
Normal file
|
@ -0,0 +1,346 @@
|
|||
#include <set>
|
||||
|
||||
#include <Common.h>
|
||||
#include <Logging/Logger.h>
|
||||
#include <Util/Util.h>
|
||||
#include <Util/UtilMath.h>
|
||||
#include <Exd/ExdDataGenerated.h>
|
||||
#include <Database/DatabaseDef.h>
|
||||
|
||||
#include <MySqlBase.h>
|
||||
#include <Connection.h>
|
||||
|
||||
#include <Network/GamePacketNew.h>
|
||||
#include <Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
|
||||
#include "Actor/Player.h"
|
||||
#include "Inventory/ItemContainer.h"
|
||||
#include "Inventory/Item.h"
|
||||
|
||||
#include "Forwards.h"
|
||||
#include "Land.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Framework g_fw;
|
||||
|
||||
using namespace Core::Common;
|
||||
|
||||
Core::Land::Land( uint16_t zoneId, uint8_t wardNum, uint8_t landId ) :
|
||||
m_zoneId( zoneId ),
|
||||
m_wardNum( wardNum ),
|
||||
m_landId( landId ),
|
||||
m_currentPrice( 0 ),
|
||||
m_nextDrop( 0 )
|
||||
{
|
||||
m_landKey = ( m_zoneId << 16 ) | ( m_wardNum << 8 ) | m_landId;
|
||||
memset( &m_land, 0x00, sizeof( LandStruct ) );
|
||||
load();
|
||||
}
|
||||
|
||||
Core::Land::~Land()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Core::Land::load()
|
||||
{
|
||||
/* auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
auto res = pDb->query( "SELECT * FROM land WHERE Id = " + std::to_string( m_landKey ) );
|
||||
if( !res->next() )
|
||||
{
|
||||
setHouseSize( HouseSizeType::smallHouse );//ToDo: get house site from ExD (Landset first 60 rows)
|
||||
m_currentPrice = m_initPrice;
|
||||
m_land.color[ 7 ] = 0xFF;
|
||||
m_ownerPlayerId = 0;
|
||||
m_nextDrop = 0;
|
||||
setState( HouseStateType::forSell );
|
||||
auto stmt = pDb->getPreparedStatement( Db::ZoneDbStatements::LAND_INS );
|
||||
stmt->setUInt( 1, m_landKey );
|
||||
pDb->directExecute( stmt );
|
||||
Init();
|
||||
}
|
||||
else
|
||||
{
|
||||
Init();
|
||||
if( getState() == HouseStateType::privateHouse || getState() == HouseStateType::sold )
|
||||
{
|
||||
m_ownerPlayerId = res->getUInt( "ownerPlayerId" );
|
||||
}
|
||||
else if( getState() == HouseStateType::forSell )
|
||||
{
|
||||
m_currentPrice = res->getUInt( "currentPrice" );
|
||||
m_nextDrop = res->getUInt( "nextDrop" );
|
||||
m_ownerPlayerId = 0;
|
||||
}
|
||||
}
|
||||
ItemsOutdoorContainer = make_ItemContainer( InventoryType::HousingOutdoorItems,
|
||||
m_maxItems,
|
||||
"housingoutdooritems", true );*/
|
||||
}
|
||||
|
||||
uint32_t Core::Land::convertItemIdToHousingItemId( uint32_t itemId )
|
||||
{
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto info = pExdData->get< Core::Data::Item >( itemId );
|
||||
return info->additionalData;
|
||||
}
|
||||
|
||||
void Core::Land::setPreset( uint32_t id )
|
||||
{
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto info = pExdData->get< Core::Data::HousingPreset >( convertItemIdToHousingItemId( id ) );
|
||||
setRoof( info->exteriorRoof );
|
||||
setWall( info->exteriorWall );
|
||||
setWindow( info->exteriorWindow );
|
||||
setBasementWall( info->basementWall );
|
||||
setFloorFlooring( info->otherFloorFlooring );
|
||||
setFloorWall( info->otherFloorWall );
|
||||
}
|
||||
|
||||
//Primary State
|
||||
void Core::Land::setHouseSize( uint8_t size )
|
||||
{
|
||||
m_land.houseSize = size;
|
||||
}
|
||||
|
||||
void Core::Land::setState( uint8_t state )
|
||||
{
|
||||
m_land.houseState = state;
|
||||
}
|
||||
|
||||
void Core::Land::setOwnership( uint8_t state )
|
||||
{
|
||||
m_land.iconColor = state;
|
||||
}
|
||||
|
||||
void Core::Land::setSharing( uint8_t state )
|
||||
{
|
||||
m_land.iconAddIcon = state;
|
||||
}
|
||||
|
||||
uint8_t Core::Land::getHouseSize()
|
||||
{
|
||||
return m_land.houseSize;
|
||||
}
|
||||
|
||||
uint8_t Core::Land::getState()
|
||||
{
|
||||
return m_land.houseState;
|
||||
}
|
||||
|
||||
uint8_t Core::Land::getOwnership()
|
||||
{
|
||||
return m_land.iconColor;
|
||||
}
|
||||
|
||||
uint8_t Core::Land::getSharing()
|
||||
{
|
||||
return m_land.iconAddIcon;
|
||||
}
|
||||
|
||||
//Free Comapny
|
||||
void Core::Land::setFreeCompany( uint32_t id, uint32_t icon, uint32_t color )
|
||||
{
|
||||
m_land.fcId = id;
|
||||
m_land.fcIcon = icon;
|
||||
m_land.fcIconColor = color; //RGBA
|
||||
}
|
||||
|
||||
uint32_t Core::Land::getFcId()
|
||||
{
|
||||
return m_land.fcIcon;
|
||||
}
|
||||
|
||||
uint32_t Core::Land::getFcIcon()
|
||||
{
|
||||
return m_land.fcIcon;
|
||||
}
|
||||
|
||||
uint32_t Core::Land::getFcColor()
|
||||
{
|
||||
return m_land.fcIconColor;
|
||||
}
|
||||
|
||||
//House Data
|
||||
void Core::Land::setRoof( uint16_t id )
|
||||
{
|
||||
m_land.exteriorRoof = convertItemIdToHousingItemId( id );
|
||||
}
|
||||
|
||||
void Core::Land::setFacade( uint16_t id )
|
||||
{
|
||||
m_land.exteriorWall = convertItemIdToHousingItemId( id );
|
||||
}
|
||||
|
||||
void Core::Land::setWindow( uint16_t id )
|
||||
{
|
||||
m_land.exteriorWindow = convertItemIdToHousingItemId( id );
|
||||
}
|
||||
|
||||
void Core::Land::setDoor( uint16_t id )
|
||||
{
|
||||
m_land.exteriorDoor = convertItemIdToHousingItemId( id );
|
||||
}
|
||||
|
||||
void Core::Land::setFloorWall( uint16_t id )
|
||||
{
|
||||
m_land.otherFloorWall = convertItemIdToHousingItemId( id );
|
||||
}
|
||||
|
||||
void Core::Land::setFloorFlooring( uint16_t id )
|
||||
{
|
||||
m_land.otherFloorFlooring = convertItemIdToHousingItemId( id );
|
||||
}
|
||||
|
||||
void Core::Land::setWall( uint16_t id )
|
||||
{
|
||||
m_land.exteriorWall = convertItemIdToHousingItemId( id );
|
||||
}
|
||||
|
||||
void Core::Land::setSign( uint16_t id )
|
||||
{
|
||||
m_land.gardenSign = convertItemIdToHousingItemId( id );
|
||||
}
|
||||
|
||||
void Core::Land::setBasementWall( uint16_t id )
|
||||
{
|
||||
m_land.basementWall = convertItemIdToHousingItemId( id );
|
||||
}
|
||||
|
||||
uint16_t Core::Land::getRoof()
|
||||
{
|
||||
return m_land.exteriorRoof;
|
||||
}
|
||||
|
||||
uint16_t Core::Land::getFacade()
|
||||
{
|
||||
return m_land.exteriorWall;
|
||||
}
|
||||
|
||||
uint16_t Core::Land::getWindow()
|
||||
{
|
||||
return m_land.exteriorWindow;
|
||||
}
|
||||
|
||||
uint16_t Core::Land::getDoor()
|
||||
{
|
||||
return m_land.exteriorDoor;
|
||||
}
|
||||
|
||||
uint16_t Core::Land::getSign()
|
||||
{
|
||||
return m_land.gardenSign;
|
||||
}
|
||||
|
||||
uint16_t Core::Land::getWall()
|
||||
{
|
||||
return m_land.basementWall;
|
||||
}
|
||||
|
||||
uint16_t Core::Land::getFloorWall()
|
||||
{
|
||||
return m_land.otherFloorFlooring;
|
||||
}
|
||||
|
||||
uint16_t Core::Land::getFloorFlooring()
|
||||
{
|
||||
return m_land.otherFloorFlooring;
|
||||
}
|
||||
|
||||
uint16_t Core::Land::getBasememtWall()
|
||||
{
|
||||
return m_land.basementWall;
|
||||
}
|
||||
|
||||
//Color
|
||||
void Core::Land::setColor( uint8_t slot, uint8_t color )
|
||||
{
|
||||
m_land.color[ slot ] = color;
|
||||
}
|
||||
|
||||
uint8_t Core::Land::getColor( uint8_t slot )
|
||||
{
|
||||
return m_land.color[ slot ];
|
||||
}
|
||||
|
||||
//Player
|
||||
void Core::Land::setPlayerOwner( uint32_t id )
|
||||
{
|
||||
m_ownerPlayerId = id;
|
||||
}
|
||||
|
||||
uint32_t Core::Land::getPlayerOwner()
|
||||
{
|
||||
return m_ownerPlayerId;
|
||||
}
|
||||
|
||||
uint32_t Core::Land::getLandKey()
|
||||
{
|
||||
return m_landKey;
|
||||
}
|
||||
|
||||
LandStruct Core::Land::getLand()
|
||||
{
|
||||
return m_land;
|
||||
}
|
||||
|
||||
uint32_t Core::Land::getMaxItems()
|
||||
{
|
||||
return m_maxItems;
|
||||
}
|
||||
|
||||
void Core::Land::Init()
|
||||
{
|
||||
|
||||
|
||||
switch( getHouseSize() )
|
||||
{
|
||||
case HouseSizeType::smallHouse:
|
||||
m_initPrice = 3750000;
|
||||
m_maxItems = 20;
|
||||
break;
|
||||
case HouseSizeType::mediumHouse:
|
||||
m_initPrice = 20000000;
|
||||
m_maxItems = 30;
|
||||
break;
|
||||
case HouseSizeType::bigHouse:
|
||||
m_initPrice = 50000000;
|
||||
m_maxItems = 40;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Core::Land::UpdateDatabase()
|
||||
{
|
||||
/*auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
std::string exec = "UPDATE land SET landset='" +
|
||||
std::string( reinterpret_cast< const char* >( &m_land ) ) + "', nextDrop=" +
|
||||
std::to_string( m_nextDrop ) + ", currentPrice=" +
|
||||
std::to_string( m_currentPrice ) +
|
||||
" WHERE Id =" + std::to_string( m_landKey );
|
||||
pDb->execute( exec );*/
|
||||
}
|
||||
|
||||
void Core::Land::Update( uint32_t currTime )
|
||||
{
|
||||
if( m_currentPrice == 0 && getState() == HouseStateType::forSale )
|
||||
{
|
||||
m_currentPrice = m_initPrice;
|
||||
m_nextDrop = 0;
|
||||
UpdateDatabase();
|
||||
}
|
||||
if( m_nextDrop < currTime && getState() == HouseStateType::forSale )
|
||||
{
|
||||
m_currentPrice = ( m_currentPrice / 100 ) * 90;
|
||||
m_nextDrop = currTime + 86400;
|
||||
UpdateDatabase();
|
||||
}
|
||||
onUpdate();
|
||||
}
|
||||
|
||||
void Core::Land::onUpdate()
|
||||
{
|
||||
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
#ifndef LANDSET_H_
|
||||
#define LANDSET_H_
|
||||
#ifndef LAND_H_
|
||||
#define LAND_H_
|
||||
#include <Common.h>
|
||||
#include "ForwardsZone.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class Landset
|
||||
class Land
|
||||
{
|
||||
public:
|
||||
enum HouseSizeType : uint8_t
|
||||
|
@ -19,7 +19,7 @@ namespace Core
|
|||
enum HouseStateType : uint8_t
|
||||
{
|
||||
none,
|
||||
forSell,
|
||||
forSale,
|
||||
sold,
|
||||
fcHouse,
|
||||
privateHouse
|
||||
|
@ -30,8 +30,8 @@ namespace Core
|
|||
heart = 0x06
|
||||
};
|
||||
|
||||
Landset( uint16_t zoneId, uint8_t wardNum, uint8_t landsetId );
|
||||
virtual ~Landset();
|
||||
Land( uint16_t zoneId, uint8_t wardNum, uint8_t landId );
|
||||
virtual ~Land();
|
||||
|
||||
void load();
|
||||
|
||||
|
@ -85,20 +85,20 @@ namespace Core
|
|||
void UpdateDatabase();
|
||||
void Update( uint32_t currTime );
|
||||
void onUpdate();
|
||||
uint32_t getLandsetKey();
|
||||
uint32_t getLandKey();
|
||||
|
||||
Common::LandsetStruct getLandset();
|
||||
Common::LandStruct getLand();
|
||||
uint32_t getMaxItems();
|
||||
|
||||
private:
|
||||
uint32_t convertItemIdToHousingItemId( uint32_t itemId );
|
||||
void Init();
|
||||
|
||||
uint32_t m_landsetKey;
|
||||
uint32_t m_landKey;
|
||||
uint8_t m_wardNum;
|
||||
uint8_t m_landsetId;
|
||||
uint8_t m_landId;
|
||||
uint16_t m_zoneId;
|
||||
Common::LandsetStruct m_landset;
|
||||
Common::LandStruct m_land;
|
||||
uint32_t m_ownerPlayerId;
|
||||
|
||||
|
|
@ -1,346 +0,0 @@
|
|||
#include <set>
|
||||
|
||||
#include <Common.h>
|
||||
#include <Logging/Logger.h>
|
||||
#include <Util/Util.h>
|
||||
#include <Util/UtilMath.h>
|
||||
#include <Exd/ExdDataGenerated.h>
|
||||
#include <Database/DatabaseDef.h>
|
||||
|
||||
#include <MySqlBase.h>
|
||||
#include <Connection.h>
|
||||
|
||||
#include <Network/GamePacketNew.h>
|
||||
#include <Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
|
||||
#include "Actor/Player.h"
|
||||
#include "Inventory/ItemContainer.h"
|
||||
#include "Inventory/Item.h"
|
||||
|
||||
#include "Forwards.h"
|
||||
#include "Landset.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Framework g_fw;
|
||||
|
||||
using namespace Core::Common;
|
||||
|
||||
Core::Landset::Landset( uint16_t zoneId, uint8_t wardNum, uint8_t landsetId ) :
|
||||
m_zoneId( zoneId ),
|
||||
m_wardNum( wardNum ),
|
||||
m_landsetId( landsetId ),
|
||||
m_currentPrice( 0 ),
|
||||
m_nextDrop( 0 )
|
||||
{
|
||||
m_landsetKey = ( m_zoneId << 16 ) | ( m_wardNum << 8 ) | m_landsetId;
|
||||
memset( &m_landset, 0x00, sizeof( LandsetStruct ) );
|
||||
load();
|
||||
}
|
||||
|
||||
Core::Landset::~Landset()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Core::Landset::load()
|
||||
{
|
||||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
auto res = pDb->query( "SELECT * FROM landset WHERE Id = " + std::to_string( m_landsetKey ) );
|
||||
if( !res->next() )
|
||||
{
|
||||
setHouseSize( HouseSizeType::smallHouse );//ToDo: get house site from ExD (Landset first 60 rows)
|
||||
m_currentPrice = m_initPrice;
|
||||
m_landset.color[ 7 ] = 0xFF;
|
||||
m_ownerPlayerId = 0;
|
||||
m_nextDrop = 0;
|
||||
setState( HouseStateType::forSell );
|
||||
auto stmt = pDb->getPreparedStatement( Db::ZoneDbStatements::LAND_INS );
|
||||
stmt->setUInt( 1, m_landsetKey );
|
||||
pDb->directExecute( stmt );
|
||||
Init();
|
||||
}
|
||||
else
|
||||
{
|
||||
Init();
|
||||
if( getState() == HouseStateType::privateHouse || getState() == HouseStateType::sold )
|
||||
{
|
||||
m_ownerPlayerId = res->getUInt( "ownerPlayerId" );
|
||||
}
|
||||
else if( getState() == HouseStateType::forSell )
|
||||
{
|
||||
m_currentPrice = res->getUInt( "currentPrice" );
|
||||
m_nextDrop = res->getUInt( "nextDrop" );
|
||||
m_ownerPlayerId = 0;
|
||||
}
|
||||
}
|
||||
ItemsOutdoorContainer = make_ItemContainer( InventoryType::HousingOutdoorItems,
|
||||
m_maxItems,
|
||||
"housingoutdooritems", true );
|
||||
}
|
||||
|
||||
uint32_t Core::Landset::convertItemIdToHousingItemId( uint32_t itemId )
|
||||
{
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto info = pExdData->get< Core::Data::Item >( itemId );
|
||||
return info->additionalData;
|
||||
}
|
||||
|
||||
void Core::Landset::setPreset( uint32_t id )
|
||||
{
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto info = pExdData->get< Core::Data::HousingPreset >( convertItemIdToHousingItemId( id ) );
|
||||
setRoof( info->exteriorRoof );
|
||||
setWall( info->exteriorWall );
|
||||
setWindow( info->exteriorWindow );
|
||||
setBasementWall( info->basementWall );
|
||||
setFloorFlooring( info->otherFloorFlooring );
|
||||
setFloorWall( info->otherFloorWall );
|
||||
}
|
||||
|
||||
//Primary State
|
||||
void Core::Landset::setHouseSize( uint8_t size )
|
||||
{
|
||||
m_landset.houseSize = size;
|
||||
}
|
||||
|
||||
void Core::Landset::setState( uint8_t state )
|
||||
{
|
||||
m_landset.houseState = state;
|
||||
}
|
||||
|
||||
void Core::Landset::setOwnership( uint8_t state )
|
||||
{
|
||||
m_landset.iconColor = state;
|
||||
}
|
||||
|
||||
void Core::Landset::setSharing( uint8_t state )
|
||||
{
|
||||
m_landset.iconAddIcon = state;
|
||||
}
|
||||
|
||||
uint8_t Core::Landset::getHouseSize()
|
||||
{
|
||||
return m_landset.houseSize;
|
||||
}
|
||||
|
||||
uint8_t Core::Landset::getState()
|
||||
{
|
||||
return m_landset.houseState;
|
||||
}
|
||||
|
||||
uint8_t Core::Landset::getOwnership()
|
||||
{
|
||||
return m_landset.iconColor;
|
||||
}
|
||||
|
||||
uint8_t Core::Landset::getSharing()
|
||||
{
|
||||
return m_landset.iconAddIcon;
|
||||
}
|
||||
|
||||
//Free Comapny
|
||||
void Core::Landset::setFreeCompany( uint32_t id, uint32_t icon, uint32_t color )
|
||||
{
|
||||
m_landset.fcId = id;
|
||||
m_landset.fcIcon = icon;
|
||||
m_landset.fcIconColor = color; //RGBA
|
||||
}
|
||||
|
||||
uint32_t Core::Landset::getFcId()
|
||||
{
|
||||
return m_landset.fcIcon;
|
||||
}
|
||||
|
||||
uint32_t Core::Landset::getFcIcon()
|
||||
{
|
||||
return m_landset.fcIcon;
|
||||
}
|
||||
|
||||
uint32_t Core::Landset::getFcColor()
|
||||
{
|
||||
return m_landset.fcIconColor;
|
||||
}
|
||||
|
||||
//House Data
|
||||
void Core::Landset::setRoof( uint16_t id )
|
||||
{
|
||||
m_landset.exteriorRoof = convertItemIdToHousingItemId( id );
|
||||
}
|
||||
|
||||
void Core::Landset::setFacade( uint16_t id )
|
||||
{
|
||||
m_landset.exteriorWall = convertItemIdToHousingItemId( id );
|
||||
}
|
||||
|
||||
void Core::Landset::setWindow( uint16_t id )
|
||||
{
|
||||
m_landset.exteriorWindow = convertItemIdToHousingItemId( id );
|
||||
}
|
||||
|
||||
void Core::Landset::setDoor( uint16_t id )
|
||||
{
|
||||
m_landset.exteriorDoor = convertItemIdToHousingItemId( id );
|
||||
}
|
||||
|
||||
void Core::Landset::setFloorWall( uint16_t id )
|
||||
{
|
||||
m_landset.otherFloorWall = convertItemIdToHousingItemId( id );
|
||||
}
|
||||
|
||||
void Core::Landset::setFloorFlooring( uint16_t id )
|
||||
{
|
||||
m_landset.otherFloorFlooring = convertItemIdToHousingItemId( id );
|
||||
}
|
||||
|
||||
void Core::Landset::setWall( uint16_t id )
|
||||
{
|
||||
m_landset.exteriorWall = convertItemIdToHousingItemId( id );
|
||||
}
|
||||
|
||||
void Core::Landset::setSign( uint16_t id )
|
||||
{
|
||||
m_landset.gardenSign = convertItemIdToHousingItemId( id );
|
||||
}
|
||||
|
||||
void Core::Landset::setBasementWall( uint16_t id )
|
||||
{
|
||||
m_landset.basementWall = convertItemIdToHousingItemId( id );
|
||||
}
|
||||
|
||||
uint16_t Core::Landset::getRoof()
|
||||
{
|
||||
return m_landset.exteriorRoof;
|
||||
}
|
||||
|
||||
uint16_t Core::Landset::getFacade()
|
||||
{
|
||||
return m_landset.exteriorWall;
|
||||
}
|
||||
|
||||
uint16_t Core::Landset::getWindow()
|
||||
{
|
||||
return m_landset.exteriorWindow;
|
||||
}
|
||||
|
||||
uint16_t Core::Landset::getDoor()
|
||||
{
|
||||
return m_landset.exteriorDoor;
|
||||
}
|
||||
|
||||
uint16_t Core::Landset::getSign()
|
||||
{
|
||||
return m_landset.gardenSign;
|
||||
}
|
||||
|
||||
uint16_t Core::Landset::getWall()
|
||||
{
|
||||
return m_landset.basementWall;
|
||||
}
|
||||
|
||||
uint16_t Core::Landset::getFloorWall()
|
||||
{
|
||||
return m_landset.otherFloorFlooring;
|
||||
}
|
||||
|
||||
uint16_t Core::Landset::getFloorFlooring()
|
||||
{
|
||||
return m_landset.otherFloorFlooring;
|
||||
}
|
||||
|
||||
uint16_t Core::Landset::getBasememtWall()
|
||||
{
|
||||
return m_landset.basementWall;
|
||||
}
|
||||
|
||||
//Color
|
||||
void Core::Landset::setColor( uint8_t slot, uint8_t color )
|
||||
{
|
||||
m_landset.color[ slot ] = color;
|
||||
}
|
||||
|
||||
uint8_t Core::Landset::getColor( uint8_t slot )
|
||||
{
|
||||
return m_landset.color[ slot ];
|
||||
}
|
||||
|
||||
//Player
|
||||
void Core::Landset::setPlayerOwner( uint32_t id )
|
||||
{
|
||||
m_ownerPlayerId = id;
|
||||
}
|
||||
|
||||
uint32_t Core::Landset::getPlayerOwner()
|
||||
{
|
||||
return m_ownerPlayerId;
|
||||
}
|
||||
|
||||
uint32_t Core::Landset::getLandsetKey()
|
||||
{
|
||||
return m_landsetKey;
|
||||
}
|
||||
|
||||
LandsetStruct Core::Landset::getLandset()
|
||||
{
|
||||
return m_landset;
|
||||
}
|
||||
|
||||
uint32_t Core::Landset::getMaxItems()
|
||||
{
|
||||
return m_maxItems;
|
||||
}
|
||||
|
||||
void Core::Landset::Init()
|
||||
{
|
||||
|
||||
|
||||
switch( getHouseSize() )
|
||||
{
|
||||
case HouseSizeType::smallHouse:
|
||||
m_initPrice = 3750000;
|
||||
m_maxItems = 20;
|
||||
break;
|
||||
case HouseSizeType::mediumHouse:
|
||||
m_initPrice = 20000000;
|
||||
m_maxItems = 30;
|
||||
break;
|
||||
case HouseSizeType::bigHouse:
|
||||
m_initPrice = 50000000;
|
||||
m_maxItems = 40;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Core::Landset::UpdateDatabase()
|
||||
{
|
||||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
std::string exec = "UPDATE land SET landset='" +
|
||||
std::string( reinterpret_cast< const char* >( &m_landset ) ) + "', nextDrop=" +
|
||||
std::to_string( m_nextDrop ) + ", currentPrice=" +
|
||||
std::to_string( m_currentPrice ) +
|
||||
" WHERE Id =" + std::to_string( m_landsetKey );
|
||||
pDb->execute( exec );
|
||||
}
|
||||
|
||||
void Core::Landset::Update( uint32_t currTime )
|
||||
{
|
||||
if( m_currentPrice == 0 && getState() == HouseStateType::forSell )
|
||||
{
|
||||
m_currentPrice = m_initPrice;
|
||||
m_nextDrop = 0;
|
||||
UpdateDatabase();
|
||||
}
|
||||
if( m_nextDrop < currTime && getState() == HouseStateType::forSell )
|
||||
{
|
||||
m_currentPrice = ( m_currentPrice / 100 ) * 90;
|
||||
m_nextDrop = currTime + 86400;
|
||||
UpdateDatabase();
|
||||
}
|
||||
onUpdate();
|
||||
}
|
||||
|
||||
void Core::Landset::onUpdate()
|
||||
{
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue