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