1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 22:57:45 +00:00
sapphire/src/servers/sapphire_zone/Zone/House.cpp

91 lines
1.9 KiB
C++
Raw Normal View History

2018-11-19 09:40:44 +01:00
#include <set>
2018-11-19 10:04:54 +01:00
#include <string.h>
2018-11-19 09:40:44 +01:00
#include <Logging/Logger.h>
#include <Exd/ExdDataGenerated.h>
2018-11-25 01:55:53 +11:00
#include <Database/DatabaseDef.h>
2018-11-19 09:40:44 +01:00
#include "House.h"
#include <unordered_map>
#include "Framework.h"
extern Core::Framework g_fw;
2018-11-19 10:32:58 +01:00
Core::House::House( uint32_t houseId, uint32_t landSetId, uint8_t landId, uint8_t wardNum, uint16_t territoryTypeId ) :
2018-11-19 09:40:44 +01:00
m_houseId( houseId ),
m_landSetId( landSetId ),
m_landId( landId ),
m_wardNum( wardNum ),
2018-11-19 10:32:58 +01:00
m_territoryTypeId( territoryTypeId )
2018-11-19 09:40:44 +01:00
{
2018-11-19 10:35:48 +01:00
memset( &m_houseParts, 0x00, sizeof( m_houseParts ) );
2018-11-19 11:56:53 +01:00
memset( &m_commentMsg, 0x00, sizeof( m_commentMsg ) );
2018-11-25 01:55:53 +11:00
auto pDB = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
auto res = pDB->query("SELECT * FROM house WHERE HouseId = " + std::to_string( houseId ) );
if( !res->next() )
{
pDB->directExecute("INSERT INTO house ( LandSetId, HouseId ) VALUES ( " + std::to_string( m_landSetId ) + ", " + std::to_string( m_houseId ) + " )" );
}
else
{
// todo
}
2018-11-19 09:40:44 +01:00
}
Core::House::~House()
{
}
2018-11-19 10:32:58 +01:00
uint32_t Core::House::getLandSetId() const
2018-11-19 09:40:44 +01:00
{
return m_landSetId;
}
2018-11-19 10:32:58 +01:00
uint8_t Core::House::getLandId() const
2018-11-19 09:40:44 +01:00
{
return m_landId;
}
2018-11-19 10:32:58 +01:00
uint8_t Core::House::getWardNum() const
2018-11-19 09:40:44 +01:00
{
return m_wardNum;
}
2018-11-19 10:32:58 +01:00
uint16_t Core::House::getTerritoryTypeId() const
{
return m_territoryTypeId;
}
uint32_t Core::House::getHouseId() const
2018-11-19 09:40:44 +01:00
{
return m_houseId;
}
2018-11-19 10:32:58 +01:00
uint8_t Core::House::getHousePartColor( Common::HousePartSlot slot ) const
2018-11-19 09:40:44 +01:00
{
return std::get< 1 >( m_houseParts[ slot ] );
2018-11-19 09:40:44 +01:00
}
void Core::House::setHousePart( Common::HousePartSlot slot, uint32_t id )
{
std::get< 0 >( m_houseParts[ slot ] ) = id;
2018-11-19 09:40:44 +01:00
}
void Core::House::setHousePartColor( Common::HousePartSlot slot, uint32_t id )
{
std::get< 1 >( m_houseParts[ slot ] ) = id;
2018-11-19 09:40:44 +01:00
}
2018-11-19 10:32:58 +01:00
uint32_t Core::House::getHousePart( Common::HousePartSlot slot ) const
2018-11-19 09:40:44 +01:00
{
return std::get< 0 >( m_houseParts[ slot ] );
}
Core::House::HousePartsArray const& Core::House::getHouseParts() const
{
return m_houseParts;
2018-11-25 01:55:53 +11:00
}