mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-23 18:17:46 +00:00
tempalted getters for db fields
This commit is contained in:
parent
350fc84947
commit
5cbdee5ac7
10 changed files with 120 additions and 195 deletions
|
@ -126,7 +126,7 @@ uint64_t Database::getNextUId()
|
|||
|
||||
Db::Field *field = res->fetch();
|
||||
|
||||
return field[0].getUInt64();
|
||||
return field[0].get< uint64_t >();
|
||||
}
|
||||
|
||||
DatabaseConnection * Database::getFreeConnection()
|
||||
|
@ -167,31 +167,6 @@ boost::shared_ptr<QueryResult> Database::query( const std::string& QueryString )
|
|||
return qResult;
|
||||
}
|
||||
|
||||
QueryResult * Database::queryNA( const char* QueryString )
|
||||
{
|
||||
// Send the query
|
||||
QueryResult * qResult = NULL;
|
||||
DatabaseConnection * con = getFreeConnection();
|
||||
|
||||
if( _SendQuery( con, QueryString, false ) )
|
||||
{
|
||||
qResult = _StoreQueryResult( con );
|
||||
}
|
||||
|
||||
con->lock.unlock();
|
||||
return qResult;
|
||||
}
|
||||
|
||||
QueryResult * Database::fQuery( const char * QueryString, DatabaseConnection * con ) {
|
||||
// Send the query
|
||||
QueryResult * qResult = NULL;
|
||||
if( _SendQuery( con, QueryString, false ) )
|
||||
{
|
||||
qResult = _StoreQueryResult( con );
|
||||
}
|
||||
|
||||
return qResult;
|
||||
}
|
||||
|
||||
bool Database::execute( const std::string& QueryString )
|
||||
{
|
||||
|
|
|
@ -61,40 +61,13 @@ namespace Core {
|
|||
return m_pValue ? atoi( m_pValue ) > 0 : false;
|
||||
}
|
||||
|
||||
// return as unsigned 8 bit integer
|
||||
__inline uint8_t getUInt8()
|
||||
template< class T >
|
||||
__inline T get()
|
||||
{
|
||||
return m_pValue ? static_cast< uint8_t >( atol( m_pValue ) ) : 0;
|
||||
}
|
||||
if( !m_pValue )
|
||||
return 0;
|
||||
|
||||
// return as signed 8 bit integer
|
||||
__inline int8_t getInt8()
|
||||
{
|
||||
return m_pValue ? static_cast< int8_t >( atol( m_pValue ) ) : 0;
|
||||
}
|
||||
|
||||
// return as unsigned 16 bit integer
|
||||
__inline uint16_t getUInt16()
|
||||
{
|
||||
return m_pValue ? static_cast< uint16_t >( atol( m_pValue ) ) : 0;
|
||||
}
|
||||
|
||||
// return as signed 16 bit integer
|
||||
__inline int16_t getInt16()
|
||||
{
|
||||
return m_pValue ? static_cast< int16_t >( atol( m_pValue ) ) : 0;
|
||||
}
|
||||
|
||||
// return as unsigned 32 bit integer
|
||||
__inline uint32_t getUInt32()
|
||||
{
|
||||
return m_pValue ? static_cast< uint32_t >( atol( m_pValue ) ) : 0;
|
||||
}
|
||||
|
||||
// return as signed 8 bit integer
|
||||
__inline int32_t getInt32()
|
||||
{
|
||||
return m_pValue ? static_cast< int32_t >( atol( m_pValue ) ) : 0;
|
||||
return static_cast< T >( atol( m_pValue ) );
|
||||
}
|
||||
|
||||
__inline uint32_t getLength()
|
||||
|
@ -102,25 +75,6 @@ namespace Core {
|
|||
return m_size;
|
||||
}
|
||||
|
||||
// return as unsigned 64 bit integer
|
||||
uint64_t getUInt64()
|
||||
{
|
||||
if( m_pValue )
|
||||
{
|
||||
#ifdef _WIN32
|
||||
uint64_t value;
|
||||
sscanf( m_pValue, "%I64d", &value );
|
||||
return value;
|
||||
#else
|
||||
uint64_t value;
|
||||
sscanf( m_pValue, "%Lu", &value );
|
||||
return value;
|
||||
|
||||
#endif
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
char *m_pValue;
|
||||
|
@ -191,14 +145,9 @@ namespace Core {
|
|||
void shutdown();
|
||||
|
||||
boost::shared_ptr<QueryResult> query( const std::string& QueryString );
|
||||
QueryResult* queryNA( const char* QueryString );
|
||||
QueryResult* fQuery( const char * QueryString, DatabaseConnection *con );
|
||||
void fWaitExecute( const char * QueryString, DatabaseConnection *con );
|
||||
bool waitExecute( const char* QueryString, ... );//Wait For Request Completion
|
||||
bool waitExecuteNA( const char* QueryString );//Wait For Request Completion
|
||||
bool execute( const char* QueryString, ... );
|
||||
bool execute( const std::string& QueryString );
|
||||
bool executeNA( const char* QueryString );
|
||||
|
||||
__inline const std::string& getHostName()
|
||||
{
|
||||
|
|
|
@ -282,8 +282,10 @@ void Core::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type )
|
|||
{
|
||||
auto data = g_exdData.getAetheryteInfo( aetheryteId );
|
||||
|
||||
if( data != nullptr )
|
||||
if( data == nullptr )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
setStateFlag( PlayerStateFlag::BetweenAreas );
|
||||
sendStateFlags();
|
||||
|
@ -302,7 +304,6 @@ void Core::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type )
|
|||
rot = z_pos->getTargetRotation();
|
||||
}
|
||||
|
||||
|
||||
sendDebug( "Teleport: " + data->placename + " " + data->placename_aethernet +
|
||||
"(" + std::to_string( data->levelId ) + ")" );
|
||||
|
||||
|
@ -328,7 +329,7 @@ void Core::Entity::Player::teleport( uint16_t aetheryteId, uint8_t type )
|
|||
|
||||
m_queuedZoneing = boost::make_shared< QueuedZoning >( data->target_zone, pos, Util::getTimeMs(), rot );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Core::Entity::Player::forceZoneing( uint32_t zoneId )
|
||||
|
|
|
@ -39,20 +39,20 @@ bool Core::Entity::Player::loadActiveQuests()
|
|||
|
||||
//g_log.debug( " QUEST_ID: " + std::to_string( field[index].getInt16() ) + " INDEX: " + std::to_string( index ) );
|
||||
|
||||
if( field[index].getInt16() != 0 )
|
||||
if( field[index].get< int16_t >() != 0 )
|
||||
{
|
||||
|
||||
boost::shared_ptr<QuestActive> pActiveQuest( new QuestActive() );
|
||||
pActiveQuest->c.questId = field[index].getInt16();
|
||||
pActiveQuest->c.sequence = field[index + 1].getUInt8();
|
||||
pActiveQuest->c.flags = field[index + 2].getUInt8();
|
||||
pActiveQuest->c.UI8A = field[index + 3].getUInt8();
|
||||
pActiveQuest->c.UI8B = field[index + 4].getUInt8();
|
||||
pActiveQuest->c.UI8C = field[index + 5].getUInt8();
|
||||
pActiveQuest->c.UI8D = field[index + 6].getUInt8();
|
||||
pActiveQuest->c.UI8E = field[index + 7].getUInt8();
|
||||
pActiveQuest->c.UI8F = field[index + 8].getUInt8();
|
||||
pActiveQuest->c.padding1 = field[index + 9].getUInt8();
|
||||
pActiveQuest->c.questId = field[index].get< int16_t >();
|
||||
pActiveQuest->c.sequence = field[index + 1].get< uint8_t >();
|
||||
pActiveQuest->c.flags = field[index + 2].get< uint8_t >();
|
||||
pActiveQuest->c.UI8A = field[index + 3].get< uint8_t >();
|
||||
pActiveQuest->c.UI8B = field[index + 4].get< uint8_t >();
|
||||
pActiveQuest->c.UI8C = field[index + 5].get< uint8_t >();
|
||||
pActiveQuest->c.UI8D = field[index + 6].get< uint8_t >();
|
||||
pActiveQuest->c.UI8E = field[index + 7].get< uint8_t >();
|
||||
pActiveQuest->c.UI8F = field[index + 8].get< uint8_t >();
|
||||
pActiveQuest->c.padding1 = field[index + 9].get< uint8_t >();
|
||||
m_activeQuests[i] = pActiveQuest;
|
||||
|
||||
m_questIdToQuestIdx[pActiveQuest->c.questId] = i;
|
||||
|
|
|
@ -99,13 +99,13 @@ bool Core::Entity::Player::load( uint32_t charId, Core::SessionPtr pSession )
|
|||
|
||||
strcpy( m_name, field[0].getString() );
|
||||
|
||||
ZonePtr pCurrZone = g_zoneMgr.getZone( field[1].getInt32() );
|
||||
m_zoneId = field[1].getInt32();
|
||||
ZonePtr pCurrZone = g_zoneMgr.getZone( field[1].get< int32_t >() );
|
||||
m_zoneId = field[1].get< int32_t >();
|
||||
|
||||
// see if a valid zone could be found for the character
|
||||
if( !pCurrZone )
|
||||
{
|
||||
g_log.error( "[" + char_id_str + "] Zone " + std::to_string( field[1].getInt32() ) + "not found!" );
|
||||
g_log.error( "[" + char_id_str + "] Zone " + std::to_string( field[1].get< int32_t >() ) + "not found!" );
|
||||
g_log.error( "[" + char_id_str + "] Setting default zone instead" );
|
||||
|
||||
// default to new gridania
|
||||
|
@ -118,9 +118,9 @@ bool Core::Entity::Player::load( uint32_t charId, Core::SessionPtr pSession )
|
|||
setRotation( 0.0f );
|
||||
}
|
||||
|
||||
m_hp = field[2].getUInt32();
|
||||
m_hp = field[2].get< uint16_t >();
|
||||
|
||||
m_mp = field[3].getUInt32();
|
||||
m_mp = field[3].get< uint16_t >();
|
||||
m_tp = 0;
|
||||
|
||||
m_pos.x = field[6].getFloat();
|
||||
|
@ -130,22 +130,22 @@ bool Core::Entity::Player::load( uint32_t charId, Core::SessionPtr pSession )
|
|||
|
||||
field[11].getBinary( reinterpret_cast< char* >( m_customize ), sizeof( m_customize ) );
|
||||
|
||||
m_modelMainWeapon = field[12].getUInt64();
|
||||
m_modelMainWeapon = field[12].get< uint64_t >();
|
||||
|
||||
field[14].getBinary( reinterpret_cast< char* >( m_modelEquip ), sizeof( m_modelEquip ) );
|
||||
|
||||
m_guardianDeity = field[15].getUInt8();
|
||||
m_birthDay = field[16].getUInt8();
|
||||
m_birthMonth = field[17].getUInt8();
|
||||
m_status = static_cast< ActorStatus >( field[18].getUInt8() );
|
||||
m_class = static_cast< ClassJob >( field[19].getUInt8() );
|
||||
m_homePoint = field[20].getUInt8();
|
||||
m_guardianDeity = field[15].get< uint8_t >();
|
||||
m_birthDay = field[16].get< uint8_t >();
|
||||
m_birthMonth = field[17].get< uint8_t >();
|
||||
m_status = static_cast< ActorStatus >( field[18].get< uint8_t >() );
|
||||
m_class = static_cast< ClassJob >( field[19].get< uint8_t >() );
|
||||
m_homePoint = field[20].get< uint8_t >();
|
||||
|
||||
field[21].getBinary( reinterpret_cast< char* >( m_howTo ), sizeof( m_howTo ) );
|
||||
|
||||
m_contentId = field[22].getUInt64();
|
||||
m_contentId = field[22].get< uint64_t >();
|
||||
|
||||
m_voice = field[23].getUInt32();
|
||||
m_voice = field[23].get< uint32_t >();
|
||||
|
||||
field[24].getBinary( reinterpret_cast< char* >( m_questCompleteFlags ), sizeof( m_questCompleteFlags ) );
|
||||
|
||||
|
@ -159,17 +159,17 @@ bool Core::Entity::Player::load( uint32_t charId, Core::SessionPtr pSession )
|
|||
|
||||
field[29].getBinary( reinterpret_cast< char* >( m_discovery ), sizeof( m_discovery ) );
|
||||
|
||||
m_startTown = field[30].getInt8();
|
||||
m_playTime = field[31].getUInt32();
|
||||
m_startTown = field[30].get< int8_t >();
|
||||
m_playTime = field[31].get< uint32_t >();
|
||||
|
||||
m_bNewAdventurer = field[32].getBool();
|
||||
|
||||
m_gc = field[33].getUInt8();
|
||||
m_gc = field[33].get< uint8_t >();
|
||||
field[34].getBinary( reinterpret_cast< char* >( m_gcRank ), sizeof( m_gcRank ) );
|
||||
|
||||
m_cfPenaltyUntil = field[35].getUInt32();
|
||||
m_cfPenaltyUntil = field[35].get< uint32_t >();
|
||||
|
||||
m_openingSequence = field[36].getUInt32();
|
||||
m_openingSequence = field[36].get< uint32_t >();
|
||||
|
||||
m_pCell = nullptr;
|
||||
|
||||
|
@ -240,8 +240,8 @@ bool Core::Entity::Player::loadClassData()
|
|||
for( uint8_t i = 0; i < 25; i++ )
|
||||
{
|
||||
uint8_t index = i * 2;
|
||||
m_classArray[i] = field[index].getUInt8();
|
||||
m_expArray[i] = field[index + 1].getUInt32();
|
||||
m_classArray[i] = field[index].get< uint8_t >();
|
||||
m_expArray[i] = field[index + 1].get< uint32_t >();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -256,8 +256,8 @@ bool Core::Entity::Player::loadSearchInfo()
|
|||
|
||||
Db::Field* field = pQR->fetch();
|
||||
|
||||
m_searchSelectClass = field[1].getUInt8();
|
||||
m_searchSelectRegion = field[2].getUInt8();
|
||||
m_searchSelectClass = field[1].get< uint8_t >();
|
||||
m_searchSelectRegion = field[2].get< uint8_t >();
|
||||
sprintf( m_searchMessage, field[3].getString() );
|
||||
|
||||
return true;
|
||||
|
|
|
@ -633,15 +633,15 @@ Core::ItemPtr Core::Inventory::loadItem( uint64_t uId )
|
|||
try
|
||||
{
|
||||
Db::Field *itemField = itemRes->fetch();
|
||||
auto itemInfo = g_exdData.getItemInfo( itemField[0].getUInt32() );
|
||||
bool isHq = itemField[2].getUInt8() == 1 ? true : false;
|
||||
auto itemInfo = g_exdData.getItemInfo( itemField[0].get< uint32_t >() );
|
||||
bool isHq = itemField[2].get< uint8_t >() == 1 ? true : false;
|
||||
ItemPtr pItem( new Item( uId,
|
||||
itemInfo->id,
|
||||
itemInfo->model_primary,
|
||||
itemInfo->model_secondary,
|
||||
static_cast< ItemCategory >( itemInfo->ui_category ),
|
||||
isHq ) );
|
||||
pItem->setStackSize( itemField[1].getUInt32() );
|
||||
pItem->setStackSize( itemField[1].get< uint32_t >() );
|
||||
|
||||
return pItem;
|
||||
}
|
||||
|
@ -669,11 +669,11 @@ bool Core::Inventory::load()
|
|||
|
||||
do
|
||||
{
|
||||
uint16_t storageId = field[0].getUInt16();
|
||||
uint16_t storageId = field[0].get< uint16_t >();
|
||||
|
||||
for( int32_t i = 1; i <= 14; i++ )
|
||||
{
|
||||
uint64_t uItemId = field[i].getUInt64();
|
||||
uint64_t uItemId = field[i].get< uint64_t >();
|
||||
if( uItemId == 0 )
|
||||
continue;
|
||||
|
||||
|
@ -707,10 +707,10 @@ bool Core::Inventory::load()
|
|||
|
||||
do
|
||||
{
|
||||
uint16_t storageId = bagField[0].getUInt16();
|
||||
uint16_t storageId = bagField[0].get< uint16_t >();
|
||||
for( int32_t i = 1; i <= 25; i++ )
|
||||
{
|
||||
uint64_t uItemId = bagField[i].getUInt64();
|
||||
uint64_t uItemId = bagField[i].get< uint64_t >();
|
||||
if( uItemId == 0 )
|
||||
continue;
|
||||
|
||||
|
@ -740,10 +740,10 @@ bool Core::Inventory::load()
|
|||
|
||||
do
|
||||
{
|
||||
uint16_t storageId = curField[0].getUInt16();
|
||||
uint16_t storageId = curField[0].get< uint16_t >();
|
||||
for( int32_t i = 1; i <= 12; i++ )
|
||||
{
|
||||
uint64_t uItemId = curField[i].getUInt64();
|
||||
uint64_t uItemId = curField[i].get< uint64_t >();
|
||||
if( uItemId == 0 )
|
||||
continue;
|
||||
|
||||
|
@ -774,10 +774,10 @@ bool Core::Inventory::load()
|
|||
|
||||
do
|
||||
{
|
||||
uint16_t storageId = crystalField[0].getUInt16();
|
||||
uint16_t storageId = crystalField[0].get< uint16_t >();
|
||||
for( int32_t i = 1; i <= 17; i++ )
|
||||
{
|
||||
uint64_t uItemId = crystalField[i].getUInt64();
|
||||
uint64_t uItemId = crystalField[i].get< uint64_t >();
|
||||
if( uItemId == 0 )
|
||||
continue;
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ bool Core::LinkshellMgr::loadLinkshells()
|
|||
|
||||
do
|
||||
{
|
||||
uint32_t linkshellId = field[0].getUInt32();
|
||||
uint32_t masterId = field[1].getUInt32();
|
||||
uint32_t linkshellId = field[0].get< uint32_t >();
|
||||
uint32_t masterId = field[1].get< uint32_t >();
|
||||
std::string name = field[3].getString();
|
||||
|
||||
auto func = []( std::set< uint64_t >& outList, Db::Field * pField )
|
||||
|
|
|
@ -350,13 +350,13 @@ void Core::Network::GameConnection::discoveryHandler( const Packets::GamePacket&
|
|||
Db::Field *field = pQR->fetch();
|
||||
|
||||
GamePacketNew< FFXIVIpcDiscovery, ServerZoneIpcType > discoveryPacket( pPlayer->getId() );
|
||||
discoveryPacket.data().map_id = field[1].getInt16();
|
||||
discoveryPacket.data().map_part_id = field[2].getInt16();
|
||||
discoveryPacket.data().map_id = field[1].get< int16_t >();
|
||||
discoveryPacket.data().map_part_id = field[2].get< int16_t >();
|
||||
|
||||
pPlayer->queuePacket( discoveryPacket );
|
||||
pPlayer->sendNotice( "Discovery ref pos ID: " + std::to_string( ref_position_id ) );
|
||||
|
||||
pPlayer->discover( field[1].getInt16(), field[2].getInt16() );
|
||||
pPlayer->discover( field[1].get< int16_t >(), field[2].get< int16_t >() );
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -162,24 +162,24 @@ void Zone::loadCellCache()
|
|||
do
|
||||
{
|
||||
Db::Field *field = pQR->fetch();
|
||||
uint32_t id = field[0].getUInt32();
|
||||
uint32_t targetZoneId = field[1].getUInt32();
|
||||
uint32_t nameId = field[2].getUInt32();
|
||||
uint32_t sizeId = field[3].getUInt32();
|
||||
uint32_t classJob = field[4].getUInt32();
|
||||
uint32_t displayFlags1 = field[5].getUInt32();
|
||||
uint32_t displayFlags2 = field[6].getUInt32();
|
||||
uint32_t level = field[7].getUInt32();
|
||||
uint32_t id = field[0].get< uint32_t >();
|
||||
uint32_t targetZoneId = field[1].get< uint32_t >();
|
||||
uint32_t nameId = field[2].get< uint32_t >();
|
||||
uint32_t sizeId = field[3].get< uint32_t >();
|
||||
uint32_t classJob = field[4].get< uint32_t >();
|
||||
uint32_t displayFlags1 = field[5].get< uint32_t >();
|
||||
uint32_t displayFlags2 = field[6].get< uint32_t >();
|
||||
uint32_t level = field[7].get< uint32_t >();
|
||||
float posX = field[8].getFloat();
|
||||
float posY = field[9].getFloat();
|
||||
float posZ = field[10].getFloat();
|
||||
uint32_t rotation = field[11].getUInt32();
|
||||
uint32_t mobType = field[12].getUInt32();
|
||||
uint32_t behaviour = field[13].getUInt32();
|
||||
uint64_t modelMainWeapon = field[14].getUInt32();
|
||||
uint64_t modelSubWeapon = field[15].getUInt32();
|
||||
uint32_t modelId = field[16].getUInt32();
|
||||
uint32_t type = field[17].getUInt32();
|
||||
uint32_t rotation = field[11].get< uint32_t >();
|
||||
uint32_t mobType = field[12].get< uint32_t >();
|
||||
uint32_t behaviour = field[13].get< uint32_t >();
|
||||
uint64_t modelMainWeapon = field[14].get< uint32_t >();
|
||||
uint64_t modelSubWeapon = field[15].get< uint32_t >();
|
||||
uint32_t modelId = field[16].get< uint32_t >();
|
||||
uint32_t type = field[17].get< uint32_t >();
|
||||
|
||||
|
||||
Common::FFXIVARR_POSITION3 pos;
|
||||
|
|
|
@ -34,14 +34,14 @@ namespace Core {
|
|||
do
|
||||
{
|
||||
Db::Field *field = pQR->fetch();
|
||||
uint32_t id = field[0].getUInt32();
|
||||
uint32_t targetZoneId = field[1].getUInt32();
|
||||
uint32_t id = field[0].get< uint32_t >();
|
||||
uint32_t targetZoneId = field[1].get< uint32_t >();
|
||||
Common::FFXIVARR_POSITION3 pos;
|
||||
pos.x = field[2].getFloat();
|
||||
pos.y = field[3].getFloat();
|
||||
pos.z = field[4].getFloat();
|
||||
float posO = field[5].getFloat();
|
||||
uint32_t radius = field[6].getUInt32();
|
||||
uint32_t radius = field[6].get< uint32_t >();
|
||||
|
||||
m_zonePositionMap[id] = ZonePositionPtr( new ZonePosition( id, targetZoneId, pos, radius, posO ) );
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue