mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 06:47:45 +00:00
Almost done porting...
This commit is contained in:
parent
dff1a5a28e
commit
db5cf9c45c
7 changed files with 191 additions and 181 deletions
|
@ -12,10 +12,7 @@
|
|||
|
||||
#include <time.h>
|
||||
|
||||
#include <Server_Common/Database/DbLoader.h>
|
||||
#include <Server_Common/Database/CharaDbConnection.h>
|
||||
#include <Server_Common/Database/DbWorkerPool.h>
|
||||
#include <Server_Common/Database/PreparedStatement.h>
|
||||
|
||||
#include <servers/Server_Common/Common.h>
|
||||
|
||||
#include "Player.h"
|
||||
|
@ -32,14 +29,18 @@
|
|||
#include "src/servers/Server_Zone/StatusEffect/StatusEffectContainer.h"
|
||||
#include "src/servers/Server_Zone/Inventory/Inventory.h"
|
||||
|
||||
#include <Server_Common/Database/DbLoader.h>
|
||||
#include <Server_Common/Database/CharaDbConnection.h>
|
||||
#include <Server_Common/Database/DbWorkerPool.h>
|
||||
#include <Server_Common/Database/PreparedStatement.h>
|
||||
#include "src/libraries/sapphire/mysqlConnector/MySqlConnector.h"
|
||||
|
||||
|
||||
extern Core::Db::DbWorkerPool< Core::Db::CharaDbConnection > g_charaDb;
|
||||
extern Core::Logger g_log;
|
||||
extern Core::ServerZone g_serverZone;
|
||||
extern Core::ZoneMgr g_zoneMgr;
|
||||
extern Core::Data::ExdData g_exdData;
|
||||
extern Core::Db::DbWorkerPool< Core::Db::CharaDbConnection > g_charaDb;
|
||||
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network::Packets;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include <src/servers/Server_Common/Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
#include <src/servers/Server_Common/Database/Database.h>
|
||||
#include <src/servers/Server_Common/Common.h>
|
||||
#include <src/servers/Server_Common/Exd/ExdData.h>
|
||||
#include <src/servers/Server_Common/Logging/Logger.h>
|
||||
|
@ -18,8 +17,14 @@
|
|||
#include "src/servers/Server_Zone/Forwards.h"
|
||||
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket143.h"
|
||||
|
||||
#include <Server_Common/Database/DbLoader.h>
|
||||
#include <Server_Common/Database/CharaDbConnection.h>
|
||||
#include <Server_Common/Database/DbWorkerPool.h>
|
||||
#include <Server_Common/Database/PreparedStatement.h>
|
||||
#include "src/libraries/sapphire/mysqlConnector/MySqlConnector.h"
|
||||
|
||||
extern Core::Db::DbWorkerPool< Core::Db::CharaDbConnection > g_charaDb;
|
||||
extern Core::Logger g_log;
|
||||
extern Core::Db::Database g_database;
|
||||
extern Core::Data::ExdData g_exdData;
|
||||
|
||||
using namespace Core::Common;
|
||||
|
@ -139,9 +144,7 @@ Core::ItemPtr Core::Inventory::createItem( uint32_t catalogId, uint8_t quantity
|
|||
uint8_t itemAmount = quantity;
|
||||
|
||||
if( itemInfo->stack_size == 1 )
|
||||
{
|
||||
itemAmount = 1;
|
||||
}
|
||||
|
||||
if( !itemInfo )
|
||||
return nullptr;
|
||||
|
@ -153,16 +156,16 @@ Core::ItemPtr Core::Inventory::createItem( uint32_t catalogId, uint8_t quantity
|
|||
ItemPtr pItem( new Item( catalogId ) );
|
||||
|
||||
pItem->setStackSize( itemAmount );
|
||||
pItem->setUId( g_database.getNextUId() );
|
||||
pItem->setUId( getNextUId() );
|
||||
pItem->setModelIds( itemInfo->model_primary, itemInfo->model_secondary );
|
||||
pItem->setCategory( static_cast< ItemCategory >( itemInfo->ui_category ) );
|
||||
|
||||
g_database.query( " INSERT INTO charaglobalitem ( CharacterId, itemId, catalogId, stack, flags ) VALUES ( " +
|
||||
std::to_string( m_pOwner->getId() ) + ", " +
|
||||
std::to_string( pItem->getUId() ) + ", " +
|
||||
std::to_string( pItem->getId() ) + ", " +
|
||||
std::to_string( itemAmount ) + ", " +
|
||||
std::to_string( flags ) + ");" );
|
||||
g_charaDb.execute( "INSERT INTO charaglobalitem ( CharacterId, itemId, catalogId, stack, flags ) VALUES ( " +
|
||||
std::to_string( m_pOwner->getId() ) + ", " +
|
||||
std::to_string( pItem->getUId() ) + ", " +
|
||||
std::to_string( pItem->getId() ) + ", " +
|
||||
std::to_string( itemAmount ) + ", " +
|
||||
std::to_string( flags ) + ");" );
|
||||
|
||||
return pItem;
|
||||
|
||||
|
@ -260,7 +263,7 @@ void Core::Inventory::updateCurrencyDb()
|
|||
|
||||
query += " WHERE CharacterId = " + std::to_string( m_pOwner->getId() );
|
||||
|
||||
auto curRes = g_database.query( query );
|
||||
g_charaDb.execute( query );
|
||||
}
|
||||
|
||||
|
||||
|
@ -287,7 +290,7 @@ void Core::Inventory::updateCrystalDb()
|
|||
|
||||
query += " WHERE CharacterId = " + std::to_string( m_pOwner->getId() );
|
||||
|
||||
auto curRes = g_database.query( query );
|
||||
g_charaDb.execute( query );
|
||||
}
|
||||
|
||||
void Core::Inventory::updateBagDb( InventoryType type )
|
||||
|
@ -307,7 +310,7 @@ void Core::Inventory::updateBagDb( InventoryType type )
|
|||
query += " WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) +
|
||||
" AND storageId = " + std::to_string( static_cast< uint16_t >( type ) );
|
||||
|
||||
auto curRes = g_database.query( query );
|
||||
g_charaDb.execute( query );
|
||||
}
|
||||
|
||||
bool Core::Inventory::isArmory( uint16_t containerId )
|
||||
|
@ -391,13 +394,13 @@ void Core::Inventory::updateMannequinDb( InventoryType type )
|
|||
" AND storageId = " + std::to_string( static_cast< uint16_t >( type ) );
|
||||
|
||||
g_log.Log( LoggingSeverity::debug, query );
|
||||
auto curRes = g_database.query( query );
|
||||
g_charaDb.execute( query );
|
||||
}
|
||||
|
||||
|
||||
void Core::Inventory::updateItemDb( Core::ItemPtr pItem ) const
|
||||
{
|
||||
g_database.query( "UPDATE charaglobalitem SET stack = " + std::to_string( pItem->getStackSize() ) + " " +
|
||||
g_charaDb.execute( "UPDATE charaglobalitem SET stack = " + std::to_string( pItem->getStackSize() ) + " " +
|
||||
// TODO: add other attributes
|
||||
" WHERE itemId = " + std::to_string( pItem->getUId() ) );
|
||||
}
|
||||
|
@ -482,9 +485,9 @@ int16_t Core::Inventory::addItem( uint16_t inventoryId, int8_t slotId, uint32_t
|
|||
|
||||
m_inventoryMap[inventoryId]->setItem( rSlotId, item );
|
||||
|
||||
g_database.query( "UPDATE charaiteminventory SET container_" + std::to_string( rSlotId ) + " = " + std::to_string( item->getUId() ) +
|
||||
" WHERE storageId = " + std::to_string( inventoryId ) +
|
||||
" AND CharacterId = " + std::to_string( m_pOwner->getId() ) );
|
||||
g_charaDb.execute( "UPDATE charaiteminventory SET container_" + std::to_string( rSlotId ) + " = " + std::to_string( item->getUId() ) +
|
||||
" WHERE storageId = " + std::to_string( inventoryId ) +
|
||||
" AND CharacterId = " + std::to_string( m_pOwner->getId() ) );
|
||||
|
||||
GamePacketNew< FFXIVIpcUpdateInventorySlot, ServerZoneIpcType > invUpPacket( m_pOwner->getId() );
|
||||
invUpPacket.data().containerId = inventoryId;
|
||||
|
@ -626,22 +629,21 @@ void Core::Inventory::discardItem( uint16_t fromInventoryId, uint8_t fromSlotId
|
|||
Core::ItemPtr Core::Inventory::loadItem( uint64_t uId )
|
||||
{
|
||||
// load actual item
|
||||
auto itemRes = g_database.query( "SELECT catalogId, stack, flags FROM charaglobalitem WHERE itemId = " + std::to_string( uId ) + ";" );
|
||||
if( !itemRes )
|
||||
auto itemRes = g_charaDb.query( "SELECT catalogId, stack, flags FROM charaglobalitem WHERE itemId = " + std::to_string( uId ) + ";" );
|
||||
if( !itemRes->next() )
|
||||
return nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
Db::Field *itemField = itemRes->fetch();
|
||||
auto itemInfo = g_exdData.getItemInfo( itemField[0].get< uint32_t >() );
|
||||
bool isHq = itemField[2].get< uint8_t >() == 1 ? true : false;
|
||||
auto itemInfo = g_exdData.getItemInfo( itemRes->getUInt( 1 ) );
|
||||
bool isHq = itemRes->getUInt( 3 ) == 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].get< uint32_t >() );
|
||||
pItem->setStackSize( itemRes->getUInt( 2 ) );
|
||||
|
||||
return pItem;
|
||||
}
|
||||
|
@ -655,25 +657,21 @@ bool Core::Inventory::load()
|
|||
{
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// load active gearset
|
||||
auto res = g_database.query( "SELECT storageId, container_0, container_1, container_2, container_3, "
|
||||
"container_4, container_5, container_6, container_7, "
|
||||
"container_8, container_9, container_10, container_11, "
|
||||
"container_12, container_13 "
|
||||
"FROM charaitemgearset " \
|
||||
"WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) + " " \
|
||||
"ORDER BY storageId ASC;" );
|
||||
if( !res )
|
||||
return false;
|
||||
auto res = g_charaDb.query( "SELECT storageId, container_0, container_1, container_2, container_3, "
|
||||
"container_4, container_5, container_6, container_7, "
|
||||
"container_8, container_9, container_10, container_11, "
|
||||
"container_12, container_13 "
|
||||
"FROM charaitemgearset " \
|
||||
"WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) + " " \
|
||||
"ORDER BY storageId ASC;" );
|
||||
|
||||
Db::Field *field = res->fetch();
|
||||
|
||||
do
|
||||
while( res->next() )
|
||||
{
|
||||
uint16_t storageId = field[0].get< uint16_t >();
|
||||
uint16_t storageId = res->getUInt16( 1 );
|
||||
|
||||
for( int32_t i = 1; i <= 14; i++ )
|
||||
for( uint32_t i = 1; i <= 14; i++ )
|
||||
{
|
||||
uint64_t uItemId = field[i].getUInt64();
|
||||
uint64_t uItemId = res->getUInt64( i + 1 );
|
||||
if( uItemId == 0 )
|
||||
continue;
|
||||
|
||||
|
@ -685,32 +683,28 @@ bool Core::Inventory::load()
|
|||
m_inventoryMap[storageId]->getItemMap()[i - 1] = pItem;
|
||||
m_pOwner->equipItem( static_cast< EquipSlot >( i - 1 ), pItem, false );
|
||||
}
|
||||
} while( res->nextRow() );
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Load Bags
|
||||
auto bagRes = g_database.query( "SELECT storageId, "
|
||||
"container_0, container_1, container_2, container_3, container_4, "
|
||||
"container_5, container_6, container_7, container_8, container_9, "
|
||||
"container_10, container_11, container_12, container_13, container_14, "
|
||||
"container_15, container_16, container_17, container_18, container_19, "
|
||||
"container_20, container_21, container_22, container_23, container_24, "
|
||||
"container_25, container_26, container_27, container_28, container_29, "
|
||||
"container_30, container_31, container_32, container_33, container_34 "
|
||||
"FROM charaiteminventory " \
|
||||
"WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) + " " \
|
||||
"ORDER BY storageId ASC;" );
|
||||
if( !bagRes )
|
||||
return false;
|
||||
auto bagRes = g_charaDb.query( "SELECT storageId, "
|
||||
"container_0, container_1, container_2, container_3, container_4, "
|
||||
"container_5, container_6, container_7, container_8, container_9, "
|
||||
"container_10, container_11, container_12, container_13, container_14, "
|
||||
"container_15, container_16, container_17, container_18, container_19, "
|
||||
"container_20, container_21, container_22, container_23, container_24, "
|
||||
"container_25, container_26, container_27, container_28, container_29, "
|
||||
"container_30, container_31, container_32, container_33, container_34 "
|
||||
"FROM charaiteminventory " \
|
||||
"WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) + " " \
|
||||
"ORDER BY storageId ASC;" );
|
||||
|
||||
Db::Field *bagField = bagRes->fetch();
|
||||
|
||||
do
|
||||
while( bagRes->next() )
|
||||
{
|
||||
uint16_t storageId = bagField[0].get< uint16_t >();
|
||||
for( int32_t i = 1; i <= 25; i++ )
|
||||
uint16_t storageId = bagRes->getUInt16( 1 );
|
||||
for( uint32_t i = 1; i <= 25; i++ )
|
||||
{
|
||||
uint64_t uItemId = bagField[i].getUInt64();
|
||||
uint64_t uItemId = bagRes->getUInt64( i + 1 );
|
||||
if( uItemId == 0 )
|
||||
continue;
|
||||
|
||||
|
@ -721,29 +715,25 @@ bool Core::Inventory::load()
|
|||
|
||||
m_inventoryMap[storageId]->getItemMap()[i - 1] = pItem;
|
||||
}
|
||||
} while( bagRes->nextRow() );
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Load Currency
|
||||
auto curRes = g_database.query( "SELECT storageId, "
|
||||
"container_0, container_1, container_2, container_3, container_4, "
|
||||
"container_5, container_6, container_7, container_8, container_9, "
|
||||
"container_10, container_11 "
|
||||
"FROM charaitemcurrency " \
|
||||
"WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) + " " \
|
||||
"ORDER BY storageId ASC;" );
|
||||
if( !curRes )
|
||||
return false;
|
||||
auto curRes = g_charaDb.query( "SELECT storageId, "
|
||||
"container_0, container_1, container_2, container_3, container_4, "
|
||||
"container_5, container_6, container_7, container_8, container_9, "
|
||||
"container_10, container_11 "
|
||||
"FROM charaitemcurrency " \
|
||||
"WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) + " " \
|
||||
"ORDER BY storageId ASC;" );
|
||||
|
||||
Db::Field *curField = curRes->fetch();
|
||||
|
||||
do
|
||||
while( curRes->next() )
|
||||
{
|
||||
uint16_t storageId = curField[0].get< uint16_t >();
|
||||
for( int32_t i = 1; i <= 12; i++ )
|
||||
uint16_t storageId = curRes->getUInt16( 1 );
|
||||
for( uint32_t i = 1; i <= 12; i++ )
|
||||
{
|
||||
uint64_t uItemId = curField[i].getUInt64();
|
||||
uint64_t uItemId = curRes->getUInt64( i + 1 );
|
||||
if( uItemId == 0 )
|
||||
continue;
|
||||
|
||||
|
@ -754,30 +744,26 @@ bool Core::Inventory::load()
|
|||
|
||||
m_inventoryMap[storageId]->getItemMap()[i - 1] = pItem;
|
||||
}
|
||||
} while( curRes->nextRow() );
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Load Crystals
|
||||
auto crystalRes = g_database.query( "SELECT storageId, "
|
||||
"container_0, container_1, container_2, container_3, container_4, "
|
||||
"container_5, container_6, container_7, container_8, container_9, "
|
||||
"container_10, container_11, container_12, container_13, container_14, "
|
||||
"container_15, container_16, container_17 "
|
||||
"FROM charaitemcrystal " \
|
||||
"WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) + " " \
|
||||
"ORDER BY storageId ASC;" );
|
||||
if( !crystalRes )
|
||||
return false;
|
||||
auto crystalRes = g_charaDb.query( "SELECT storageId, "
|
||||
"container_0, container_1, container_2, container_3, container_4, "
|
||||
"container_5, container_6, container_7, container_8, container_9, "
|
||||
"container_10, container_11, container_12, container_13, container_14, "
|
||||
"container_15, container_16, container_17 "
|
||||
"FROM charaitemcrystal " \
|
||||
"WHERE CharacterId = " + std::to_string( m_pOwner->getId() ) + " " \
|
||||
"ORDER BY storageId ASC;" );
|
||||
|
||||
Db::Field *crystalField = crystalRes->fetch();
|
||||
|
||||
do
|
||||
while( crystalRes->next() )
|
||||
{
|
||||
uint16_t storageId = crystalField[0].get< uint16_t >();
|
||||
uint16_t storageId = crystalRes->getUInt16( 1 );
|
||||
for( int32_t i = 1; i <= 17; i++ )
|
||||
{
|
||||
uint64_t uItemId = crystalField[i].getUInt64();
|
||||
uint64_t uItemId = crystalRes->getUInt64( i + 1 );
|
||||
if( uItemId == 0 )
|
||||
continue;
|
||||
|
||||
|
@ -788,7 +774,7 @@ bool Core::Inventory::load()
|
|||
|
||||
m_inventoryMap[storageId]->getItemMap()[i - 1] = pItem;
|
||||
}
|
||||
} while( crystalRes->nextRow() );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -881,3 +867,19 @@ Core::Inventory::ContainerType Core::Inventory::getContainerType( uint32_t conta
|
|||
return Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t Core::Inventory::getNextUId()
|
||||
{
|
||||
uint32_t charId = 0;
|
||||
|
||||
auto pQR = g_charaDb.query( "SELECT MAX(ItemId) FROM charaglobalitem" );
|
||||
|
||||
if( !pQR->next() )
|
||||
return 0x00500001;
|
||||
|
||||
charId = pQR->getUInt( 1 ) + 1;
|
||||
if( charId < 0x00500001 )
|
||||
return 0x00500001;
|
||||
|
||||
return charId;
|
||||
}
|
||||
|
|
|
@ -187,6 +187,9 @@ public:
|
|||
|
||||
ContainerType getContainerType( uint32_t containerId );
|
||||
|
||||
uint32_t getNextUId();
|
||||
|
||||
|
||||
private:
|
||||
Entity::PlayerPtr m_pOwner;
|
||||
InventoryMap m_inventoryMap;
|
||||
|
|
|
@ -3,14 +3,19 @@
|
|||
|
||||
#include <src/servers/Server_Common/Common.h>
|
||||
#include <src/servers/Server_Common/Logging/Logger.h>
|
||||
#include <src/servers/Server_Common/Database/Database.h>
|
||||
|
||||
#include "src/servers/Server_Zone/Actor/Player.h"
|
||||
|
||||
#include "Item.h"
|
||||
|
||||
#include <Server_Common/Database/DbLoader.h>
|
||||
#include <Server_Common/Database/CharaDbConnection.h>
|
||||
#include <Server_Common/Database/DbWorkerPool.h>
|
||||
#include <Server_Common/Database/PreparedStatement.h>
|
||||
#include "src/libraries/sapphire/mysqlConnector/MySqlConnector.h"
|
||||
|
||||
extern Core::Db::DbWorkerPool< Core::Db::CharaDbConnection > g_charaDb;
|
||||
extern Core::Logger g_log;
|
||||
extern Core::Db::Database g_database;
|
||||
|
||||
Core::ItemContainer::ItemContainer( uint16_t locationId ) :
|
||||
m_id( locationId ),
|
||||
|
@ -40,10 +45,7 @@ void Core::ItemContainer::removeItem( uint8_t slotId )
|
|||
|
||||
if( it != m_itemMap.end() )
|
||||
{
|
||||
|
||||
|
||||
g_database.execute( "DELETE FROM charaglobalitem WHERE itemId = " +
|
||||
std::to_string( it->second->getUId() ) );
|
||||
g_charaDb.execute( "DELETE FROM charaglobalitem WHERE itemId = " + std::to_string( it->second->getUId() ) );
|
||||
|
||||
m_itemMap.erase( it );
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include <src/servers/Server_Common/Common.h>
|
||||
#include <src/servers/Server_Common/Network/CommonNetwork.h>
|
||||
#include <src/servers/Server_Common/Database/Database.h>
|
||||
#include <src/servers/Server_Common/Network/GamePacketNew.h>
|
||||
#include <src/servers/Server_Common/Logging/Logger.h>
|
||||
#include <src/servers/Server_Common/Exd/ExdData.h>
|
||||
|
@ -38,8 +37,14 @@
|
|||
#include "src/servers/Server_Zone/Action/Action.h"
|
||||
#include "src/servers/Server_Zone/Action/ActionTeleport.h"
|
||||
|
||||
#include <Server_Common/Database/DbLoader.h>
|
||||
#include <Server_Common/Database/CharaDbConnection.h>
|
||||
#include <Server_Common/Database/DbWorkerPool.h>
|
||||
#include <Server_Common/Database/PreparedStatement.h>
|
||||
#include "src/libraries/sapphire/mysqlConnector/MySqlConnector.h"
|
||||
|
||||
extern Core::Db::DbWorkerPool< Core::Db::CharaDbConnection > g_charaDb;
|
||||
extern Core::Logger g_log;
|
||||
extern Core::Db::Database g_database;
|
||||
extern Core::ServerZone g_serverZone;
|
||||
extern Core::ZoneMgr g_zoneMgr;
|
||||
extern Core::Data::ExdData g_exdData;
|
||||
|
@ -337,26 +342,24 @@ void Core::Network::GameConnection::discoveryHandler( const Packets::GamePacket&
|
|||
{
|
||||
uint32_t ref_position_id = inPacket.getValAt< uint32_t >( 0x20 );
|
||||
|
||||
auto pQR = g_database.query( "SELECT id, map_id, discover_id "
|
||||
"FROM discoveryinfo "
|
||||
"WHERE id = " + std::to_string( ref_position_id ) + ";" );
|
||||
auto pQR = g_charaDb.query( "SELECT id, map_id, discover_id "
|
||||
"FROM discoveryinfo "
|
||||
"WHERE id = " + std::to_string( ref_position_id ) + ";" );
|
||||
|
||||
if( !pQR )
|
||||
if( !pQR->next() )
|
||||
{
|
||||
pPlayer->sendNotice( "Discovery ref pos ID: " + std::to_string( ref_position_id ) + " not found. " );
|
||||
return;
|
||||
}
|
||||
|
||||
Db::Field *field = pQR->fetch();
|
||||
|
||||
GamePacketNew< FFXIVIpcDiscovery, ServerZoneIpcType > discoveryPacket( pPlayer->getId() );
|
||||
discoveryPacket.data().map_id = field[1].get< int16_t >();
|
||||
discoveryPacket.data().map_part_id = field[2].get< int16_t >();
|
||||
discoveryPacket.data().map_id = pQR->getUInt( 2 );
|
||||
discoveryPacket.data().map_part_id = pQR->getUInt( 3 );
|
||||
|
||||
pPlayer->queuePacket( discoveryPacket );
|
||||
pPlayer->sendNotice( "Discovery ref pos ID: " + std::to_string( ref_position_id ) );
|
||||
|
||||
pPlayer->discover( field[1].get< int16_t >(), field[2].get< int16_t >() );
|
||||
pPlayer->discover( pQR->getUInt16( 2 ), pQR->getUInt16( 3 ) );
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,14 @@
|
|||
|
||||
#include <time.h>
|
||||
|
||||
#include <Server_Common/Database/DbLoader.h>
|
||||
#include <Server_Common/Database/CharaDbConnection.h>
|
||||
#include <Server_Common/Database/DbWorkerPool.h>
|
||||
#include <Server_Common/Database/PreparedStatement.h>
|
||||
#include "src/libraries/sapphire/mysqlConnector/MySqlConnector.h"
|
||||
|
||||
extern Core::Db::DbWorkerPool< Core::Db::CharaDbConnection > g_charaDb;
|
||||
extern Core::Logger g_log;
|
||||
extern Core::Db::Database g_database;
|
||||
extern Core::ServerZone g_serverZone;
|
||||
extern Core::Data::ExdData g_exdData;
|
||||
extern Core::Scripting::ScriptManager g_scriptMgr;
|
||||
|
@ -132,55 +138,50 @@ CellCache* Zone::getCellCacheAndCreate( uint32_t cellx, uint32_t celly )
|
|||
|
||||
void Zone::loadCellCache()
|
||||
{
|
||||
auto pQR = g_database.query( "SELECT Id,"
|
||||
"Zoneid,"
|
||||
"NameId,"
|
||||
"SizeId,"
|
||||
"ClassJob,"
|
||||
"DisplayFlags1,"
|
||||
"DisplayFlags2,"
|
||||
"Level,"
|
||||
"Pos_0_0,"
|
||||
"Pos_0_1,"
|
||||
"Pos_0_2,"
|
||||
"Rotation,"
|
||||
"MobType,"
|
||||
"Behaviour,"
|
||||
"ModelMainWeapon,"
|
||||
"ModelSubWeapon,"
|
||||
"ModelId,"
|
||||
"Look,"
|
||||
"Models,"
|
||||
"type "
|
||||
"FROM battlenpc WHERE ZoneId = " + std::to_string( getId() ) + ";" );
|
||||
|
||||
if( !pQR )
|
||||
return;
|
||||
auto pQR = g_charaDb.query( "SELECT Id,"
|
||||
"Zoneid,"
|
||||
"NameId,"
|
||||
"SizeId,"
|
||||
"ClassJob,"
|
||||
"DisplayFlags1,"
|
||||
"DisplayFlags2,"
|
||||
"Level,"
|
||||
"Pos_0_0,"
|
||||
"Pos_0_1,"
|
||||
"Pos_0_2,"
|
||||
"Rotation,"
|
||||
"MobType,"
|
||||
"Behaviour,"
|
||||
"ModelMainWeapon,"
|
||||
"ModelSubWeapon,"
|
||||
"ModelId,"
|
||||
"Look,"
|
||||
"Models,"
|
||||
"type "
|
||||
"FROM battlenpc WHERE ZoneId = " + std::to_string( getId() ) + ";" );
|
||||
|
||||
std::vector< Entity::BattleNpcPtr > cache;
|
||||
|
||||
do
|
||||
while( pQR->next() )
|
||||
{
|
||||
Db::Field *field = pQR->fetch();
|
||||
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].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 >();
|
||||
|
||||
uint32_t id = pQR->getUInt( 1 );
|
||||
uint32_t targetZoneId = pQR->getUInt( 2 );
|
||||
uint32_t nameId = pQR->getUInt( 3 );
|
||||
uint32_t sizeId = pQR->getUInt( 4 );
|
||||
uint32_t classJob = pQR->getUInt( 5 );
|
||||
uint32_t displayFlags1 = pQR->getUInt( 6 );
|
||||
uint32_t displayFlags2 = pQR->getUInt( 7 );
|
||||
uint32_t level = pQR->getUInt( 8 );
|
||||
float posX = pQR->getFloat( 9 );
|
||||
float posY = pQR->getFloat( 10 );
|
||||
float posZ = pQR->getFloat( 11 );
|
||||
uint32_t rotation = pQR->getUInt( 12 );
|
||||
uint32_t mobType = pQR->getUInt( 13 );
|
||||
uint32_t behaviour = pQR->getUInt( 14 );
|
||||
uint64_t modelMainWeapon = pQR->getUInt( 15 );
|
||||
uint64_t modelSubWeapon = pQR->getUInt( 16 );
|
||||
uint32_t modelId = pQR->getUInt( 17 );
|
||||
uint32_t type = pQR->getUInt( 18 );
|
||||
|
||||
Common::FFXIVARR_POSITION3 pos;
|
||||
pos.x = posX;
|
||||
|
@ -196,7 +197,7 @@ void Zone::loadCellCache()
|
|||
|
||||
//m_zonePositionMap[id] = ZonePositionPtr( new ZonePosition( id, targetZoneId, Position( posX, posY, posZ, posO ), radius ) );
|
||||
|
||||
} while( pQR->nextRow() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include <src/servers/Server_Common/Logging/Logger.h>
|
||||
#include <src/servers/Server_Common/Database/Database.h>
|
||||
#include <src/servers/Server_Common/Exd/ExdData.h>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
|
@ -8,9 +7,14 @@
|
|||
|
||||
#include "ZonePosition.h"
|
||||
|
||||
#include <Server_Common/Database/DbLoader.h>
|
||||
#include <Server_Common/Database/CharaDbConnection.h>
|
||||
#include <Server_Common/Database/DbWorkerPool.h>
|
||||
#include <Server_Common/Database/PreparedStatement.h>
|
||||
#include "src/libraries/sapphire/mysqlConnector/MySqlConnector.h"
|
||||
|
||||
extern Core::Db::DbWorkerPool< Core::Db::CharaDbConnection > g_charaDb;
|
||||
extern Core::Logger g_log;
|
||||
extern Core::Db::Database g_database;
|
||||
extern Core::Data::ExdData g_exdData;
|
||||
|
||||
namespace Core {
|
||||
|
@ -25,27 +29,21 @@ namespace Core {
|
|||
|
||||
void ZoneMgr::loadZonePositionMap()
|
||||
{
|
||||
auto pQR = g_database.query( "SELECT id, target_zone_id, pos_x, pos_y, pos_z, pos_o, radius " \
|
||||
"FROM zonepositions;" );
|
||||
auto pQR = g_charaDb.query( "SELECT id, target_zone_id, pos_x, pos_y, pos_z, pos_o, radius FROM zonepositions;" );
|
||||
|
||||
if( !pQR )
|
||||
return;
|
||||
|
||||
do
|
||||
while( pQR->next() )
|
||||
{
|
||||
Db::Field *field = pQR->fetch();
|
||||
uint32_t id = field[0].get< uint32_t >();
|
||||
uint32_t targetZoneId = field[1].get< uint32_t >();
|
||||
uint32_t id = pQR->getUInt( 1 );
|
||||
uint32_t targetZoneId = pQR->getUInt( 2 );
|
||||
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].get< uint32_t >();
|
||||
pos.x = pQR->getFloat( 3 );
|
||||
pos.y = pQR->getFloat( 4 );
|
||||
pos.z = pQR->getFloat( 5 );
|
||||
float posO = pQR->getFloat( 6 );
|
||||
uint32_t radius = pQR->getUInt( 7 );
|
||||
|
||||
m_zonePositionMap[id] = ZonePositionPtr( new ZonePosition( id, targetZoneId, pos, radius, posO ) );
|
||||
|
||||
} while( pQR->nextRow() );
|
||||
}
|
||||
}
|
||||
|
||||
ZonePositionPtr ZoneMgr::getZonePosition( uint32_t zonePositionId )
|
||||
|
|
Loading…
Add table
Reference in a new issue