2017-08-08 13:53:47 +02:00
|
|
|
#include "PlayerMinimal.h"
|
|
|
|
|
2018-03-06 22:22:19 +01:00
|
|
|
#include <Common.h>
|
2021-11-27 00:53:57 +01:00
|
|
|
#include <Exd/ExdData.h>
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-03-06 22:22:19 +01:00
|
|
|
#include <Database/DatabaseDef.h>
|
2017-10-07 23:10:13 +02:00
|
|
|
|
2019-07-16 14:40:35 +10:00
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
extern Sapphire::Data::ExdData g_exdData;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2019-06-07 18:12:35 +10:00
|
|
|
namespace Sapphire::Api {
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
using namespace Common;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
// player constructor
|
2019-07-20 22:13:24 +10:00
|
|
|
PlayerMinimal::PlayerMinimal() :
|
2021-11-27 00:53:57 +01:00
|
|
|
m_characterId( 0 )
|
2018-08-29 21:40:59 +02:00
|
|
|
{
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// load player from the db
|
|
|
|
// TODO change void CPlayer::load to bool, we want to know if something went wrong
|
2021-11-27 00:53:57 +01:00
|
|
|
void PlayerMinimal::load( uint64_t charId )
|
2018-08-29 21:40:59 +02:00
|
|
|
{
|
|
|
|
|
2018-09-09 23:56:22 +02:00
|
|
|
auto stmt = g_charaDb.getPreparedStatement( Db::ZoneDbStatements::CHARA_SEL_MINIMAL );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
stmt->setUInt64( 1, charId );
|
2018-08-29 21:40:59 +02:00
|
|
|
auto res = g_charaDb.query( stmt );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
if( !res->next() )
|
|
|
|
return;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
m_characterId = charId;
|
|
|
|
m_id = res->getUInt64( "EntityId" );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
memset( m_name, 0, 32 );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
strcpy( m_name, res->getString( "Name" ).c_str() );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
auto customize = res->getBlobVector( "Customize" );
|
|
|
|
memcpy( ( char* ) m_look, customize.data(), customize.size() );
|
|
|
|
for( int32_t i = 0; i < 26; i++ )
|
|
|
|
{
|
|
|
|
m_lookMap[ i ] = m_look[ i ];
|
|
|
|
}
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
auto modelEquip = res->getBlobVector( "ModelEquip" );
|
|
|
|
memcpy( ( char* ) m_modelEquip, modelEquip.data(), modelEquip.size() );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-09-21 01:59:45 +10:00
|
|
|
m_modelMainWeapon = res->getUInt64( "ModelMainWeapon" );
|
|
|
|
m_modelSubWeapon = res->getUInt64( "ModelSubWeapon" );
|
|
|
|
m_equipDisplayFlags = res->getUInt8( "EquipDisplayFlags" );
|
|
|
|
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
setBirthDay( res->getUInt8( "BirthDay" ), res->getUInt8( "BirthMonth" ) );
|
|
|
|
m_guardianDeity = res->getUInt8( "GuardianDeity" );
|
|
|
|
m_class = res->getUInt8( "Class" );
|
2018-12-02 15:32:22 +11:00
|
|
|
m_territoryTypeId = res->getUInt16( "TerritoryType" );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-09-21 03:26:02 +10:00
|
|
|
res.reset();
|
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
// SELECT ClassIdx, Exp, Lvl
|
2018-09-21 03:26:02 +10:00
|
|
|
auto stmtClass = g_charaDb.getPreparedStatement( Db::ZoneDbStatements::CHARA_CLASS_SEL );
|
2021-11-27 00:53:57 +01:00
|
|
|
stmtClass->setUInt64( 1, m_characterId );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-09-21 03:26:02 +10:00
|
|
|
auto resClass = g_charaDb.query( stmtClass );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
|
|
|
while( resClass->next() )
|
|
|
|
{
|
2018-09-21 03:26:02 +10:00
|
|
|
auto classIdx = resClass->getUInt( 1 );
|
|
|
|
auto lvl = resClass->getUInt( 3 );
|
|
|
|
|
|
|
|
m_classMap[ classIdx ] = lvl;
|
|
|
|
m_classLevel = getClassLevel();
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
}
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
std::string PlayerMinimal::getInfoJson()
|
|
|
|
{
|
2019-07-20 21:42:21 +10:00
|
|
|
auto payload = nlohmann::json();
|
|
|
|
auto& c = payload["content"];
|
|
|
|
|
2019-07-22 00:29:00 +10:00
|
|
|
// DisplayName
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( getName() );
|
|
|
|
|
|
|
|
// class levels
|
|
|
|
auto levelsArray = nlohmann::json();
|
|
|
|
for( int i = 0; i < Common::CLASSJOB_SLOTS; ++i )
|
|
|
|
{
|
|
|
|
// these must be strings
|
|
|
|
levelsArray.push_back( std::to_string( m_classMap[ i ] ) );
|
|
|
|
}
|
|
|
|
|
2019-07-22 00:29:00 +10:00
|
|
|
// ClassLv
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( levelsArray );
|
|
|
|
|
2019-07-22 00:29:00 +10:00
|
|
|
// Race
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( "0" );
|
2019-07-22 00:29:00 +10:00
|
|
|
// Tribe
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( "0" );
|
2019-07-22 00:29:00 +10:00
|
|
|
// Sex
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( "0" );
|
|
|
|
|
2019-07-22 00:29:00 +10:00
|
|
|
// BirthMonth
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( std::to_string( getBirthMonth() ) );
|
2019-07-22 00:29:00 +10:00
|
|
|
// Birthday
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( std::to_string( getBirthDay() ) );
|
2019-07-22 00:29:00 +10:00
|
|
|
// GuardianDeity
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( std::to_string( getGuardianDeity() ) );
|
|
|
|
|
2019-07-22 00:29:00 +10:00
|
|
|
// Class
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( std::to_string( m_class ) );
|
|
|
|
|
2019-07-22 00:29:00 +10:00
|
|
|
// ZoneId
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( "0" );
|
|
|
|
|
2019-07-22 00:29:00 +10:00
|
|
|
// TerritoryType
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( std::to_string( getZoneId() ) );
|
|
|
|
|
2019-07-22 00:29:00 +10:00
|
|
|
// ContentFinderCondition
|
2021-11-27 00:53:57 +01:00
|
|
|
//c.push_back( "0" );
|
2019-07-20 21:42:21 +10:00
|
|
|
|
|
|
|
// look map
|
|
|
|
auto lookArray = nlohmann::json();
|
|
|
|
for( auto& it : m_lookMap )
|
|
|
|
{
|
|
|
|
lookArray.push_back( std::to_string( it.second ) );
|
|
|
|
}
|
2019-07-22 00:29:00 +10:00
|
|
|
// Customize
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( lookArray );
|
|
|
|
|
2019-07-22 00:29:00 +10:00
|
|
|
// ModelMainWeapon
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( std::to_string( m_modelMainWeapon ) );
|
2019-07-22 00:29:00 +10:00
|
|
|
// ModelSubWeapon
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( std::to_string( m_modelSubWeapon ) );
|
|
|
|
|
|
|
|
// model
|
|
|
|
auto modelArray = nlohmann::json();
|
|
|
|
for( auto i : m_modelEquip )
|
|
|
|
{
|
|
|
|
modelArray.push_back( std::to_string( i ) );
|
|
|
|
}
|
2019-07-22 00:29:00 +10:00
|
|
|
// ModelEquip
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( modelArray );
|
|
|
|
|
2019-07-22 00:29:00 +10:00
|
|
|
// MainWeapon
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( "1" );
|
2019-07-22 00:29:00 +10:00
|
|
|
// SubWeapon
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( "0" );
|
2019-07-22 00:29:00 +10:00
|
|
|
// JobStone
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( "0" );
|
2019-07-22 00:29:00 +10:00
|
|
|
|
|
|
|
// RemakeFlag
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( "0" );
|
|
|
|
|
2019-07-22 00:29:00 +10:00
|
|
|
// ConfigFlags
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( std::to_string( m_equipDisplayFlags ) );
|
|
|
|
|
2019-07-22 00:29:00 +10:00
|
|
|
// Voice
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( "0" );
|
2019-07-22 00:29:00 +10:00
|
|
|
// WorldName
|
2019-07-21 21:40:16 +10:00
|
|
|
c.push_back( "" );
|
2019-07-22 00:29:00 +10:00
|
|
|
// LoginStatus
|
2019-07-20 21:42:21 +10:00
|
|
|
c.push_back( "0" );
|
2019-07-22 00:29:00 +10:00
|
|
|
// IsOutTerritory
|
2021-11-27 00:53:57 +01:00
|
|
|
//c.push_back( "0" );
|
2019-07-20 21:42:21 +10:00
|
|
|
|
|
|
|
|
|
|
|
payload["classname"] = "ClientSelectData";
|
|
|
|
payload["classid"] = 116;
|
|
|
|
|
|
|
|
return payload.dump();
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-09-21 03:26:02 +10:00
|
|
|
uint8_t PlayerMinimal::getClassLevel()
|
2018-09-21 01:59:45 +10:00
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
uint8_t classJobIndex = g_exdData.getRow< Component::Excel::ClassJob >( m_class )->data().WorkIndex;
|
2018-09-21 03:26:02 +10:00
|
|
|
return static_cast< uint8_t >( m_classMap[ classJobIndex ] );
|
2018-09-21 01:59:45 +10:00
|
|
|
}
|
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
void PlayerMinimal::saveAsNew()
|
|
|
|
{
|
|
|
|
|
|
|
|
std::vector< uint8_t > customize( 26 );
|
|
|
|
std::vector< uint8_t > howTo( 33 );
|
|
|
|
std::vector< uint8_t > aetherytes( 16 );
|
|
|
|
std::vector< uint8_t > discovery( 421 );
|
2019-03-26 09:30:30 +01:00
|
|
|
std::vector< uint8_t > questComplete( 476 );
|
2018-08-29 21:40:59 +02:00
|
|
|
std::vector< uint8_t > unlocks( 64 );
|
|
|
|
std::vector< uint8_t > mountGuide( 15 );
|
|
|
|
std::vector< uint8_t > orchestrion( 40 );
|
|
|
|
std::vector< uint8_t > modelEquip( 40 );
|
|
|
|
std::vector< uint8_t > questTracking8( 10 );
|
2019-03-24 23:49:52 +01:00
|
|
|
std::vector< uint8_t > monsterNote( 41 );
|
2018-08-29 21:40:59 +02:00
|
|
|
std::vector< int16_t > questTracking = { -1, -1, -1, -1, -1 };
|
|
|
|
|
|
|
|
memset( questComplete.data(), 0, questComplete.size() );
|
|
|
|
|
|
|
|
memcpy( questTracking8.data(), questTracking.data(), questTracking8.size() );
|
|
|
|
|
|
|
|
for( uint32_t i = 0; i < m_lookMap.size(); i++ )
|
|
|
|
{
|
|
|
|
customize[ i ] = m_lookMap[ i ];
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t equipModel[10];
|
|
|
|
memset( equipModel, 0, 40 );
|
|
|
|
|
|
|
|
uint32_t startZone;
|
|
|
|
float x, y, z, o;
|
|
|
|
int32_t startTown = 0;
|
2019-03-16 23:52:50 +01:00
|
|
|
int32_t homePoint = 0;
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
switch( static_cast< Sapphire::Common::ClassJob >( m_class ) )
|
2018-08-29 21:40:59 +02:00
|
|
|
{
|
2018-11-29 16:55:48 +01:00
|
|
|
case Sapphire::Common::ClassJob::Conjurer:
|
|
|
|
case Sapphire::Common::ClassJob::Lancer:
|
|
|
|
case Sapphire::Common::ClassJob::Archer:
|
2018-08-29 21:40:59 +02:00
|
|
|
x = 127.0f;
|
|
|
|
y = -13.0f;
|
|
|
|
z = 147.0f;
|
|
|
|
o = -2.1f;
|
|
|
|
startZone = 183;
|
|
|
|
startTown = 2;
|
2019-03-16 23:52:50 +01:00
|
|
|
homePoint = 2;
|
2018-08-29 21:40:59 +02:00
|
|
|
break;
|
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
case Sapphire::Common::ClassJob::Marauder:
|
|
|
|
case Sapphire::Common::ClassJob::Arcanist:
|
2018-08-29 21:40:59 +02:00
|
|
|
x = -53.0f;
|
|
|
|
y = 18.0f;
|
|
|
|
z = 0.0f;
|
|
|
|
o = 1.5f;
|
|
|
|
startTown = 1;
|
|
|
|
startZone = 181;
|
2019-03-16 23:52:50 +01:00
|
|
|
homePoint = 8;
|
2018-08-29 21:40:59 +02:00
|
|
|
break;
|
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
case Sapphire::Common::ClassJob::Thaumaturge:
|
|
|
|
case Sapphire::Common::ClassJob::Pugilist:
|
|
|
|
case Sapphire::Common::ClassJob::Gladiator:
|
2018-08-29 21:40:59 +02:00
|
|
|
x = 42.0f;
|
|
|
|
y = 4.0f;
|
|
|
|
z = -157.6f;
|
|
|
|
o = -0.3f;
|
|
|
|
startTown = 3;
|
|
|
|
startZone = 182;
|
2019-03-16 23:52:50 +01:00
|
|
|
homePoint = 9;
|
2018-08-29 21:40:59 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-12-07 00:06:59 +01:00
|
|
|
// CharacterId, ClassIdx, Exp, Lvl
|
|
|
|
auto stmtClass = g_charaDb.getPreparedStatement( Db::ZoneDbStatements::CHARA_CLASS_INS );
|
2021-11-27 00:53:57 +01:00
|
|
|
stmtClass->setUInt64( 1, m_characterId );
|
|
|
|
stmtClass->setInt( 2, g_exdData.getRow< Component::Excel::ClassJob >( m_class )->data().WorkIndex );
|
2018-12-07 00:06:59 +01:00
|
|
|
stmtClass->setInt( 3, 0 );
|
|
|
|
stmtClass->setInt( 4, 1 );
|
|
|
|
g_charaDb.directExecute( stmtClass );
|
|
|
|
|
2018-09-09 23:56:22 +02:00
|
|
|
auto stmtSearchInfo = g_charaDb.getPreparedStatement( Db::ZoneDbStatements::CHARA_SEARCHINFO_INS );
|
2021-11-27 00:53:57 +01:00
|
|
|
stmtSearchInfo->setUInt64( 1, m_characterId );
|
2018-08-29 21:40:59 +02:00
|
|
|
g_charaDb.directExecute( stmtSearchInfo );
|
|
|
|
|
2021-12-01 21:30:12 -03:00
|
|
|
// Friend list related
|
|
|
|
auto stmtFriendList = g_charaDb.getPreparedStatement( Db::ZoneDbStatements::CHARA_FRIENDLIST_INS );
|
|
|
|
std::vector< uint8_t > friendIds( 1600, 0 );
|
|
|
|
std::vector< uint8_t > inviteIds( 1600, 0 );
|
|
|
|
|
|
|
|
stmtFriendList->setUInt64( 1, m_characterId );
|
|
|
|
stmtFriendList->setBinary( 2, friendIds );
|
|
|
|
stmtFriendList->setBinary( 3, inviteIds );
|
|
|
|
g_charaDb.directExecute( stmtFriendList );
|
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
/// SET UP INVENTORIES
|
|
|
|
createInvDbContainer( InventoryType::Bag0 );
|
|
|
|
createInvDbContainer( InventoryType::Bag1 );
|
|
|
|
createInvDbContainer( InventoryType::Bag2 );
|
|
|
|
createInvDbContainer( InventoryType::Bag3 );
|
|
|
|
|
|
|
|
createInvDbContainer( InventoryType::ArmoryOff );
|
|
|
|
|
|
|
|
createInvDbContainer( InventoryType::ArmoryHead );
|
|
|
|
createInvDbContainer( InventoryType::ArmoryBody );
|
|
|
|
createInvDbContainer( InventoryType::ArmoryHand );
|
|
|
|
createInvDbContainer( InventoryType::ArmoryWaist );
|
|
|
|
createInvDbContainer( InventoryType::ArmoryLegs );
|
|
|
|
createInvDbContainer( InventoryType::ArmoryFeet );
|
|
|
|
|
|
|
|
createInvDbContainer( InventoryType::ArmoryNeck );
|
|
|
|
createInvDbContainer( InventoryType::ArmoryEar );
|
|
|
|
createInvDbContainer( InventoryType::ArmoryWrist );
|
|
|
|
createInvDbContainer( InventoryType::ArmoryRing );
|
|
|
|
createInvDbContainer( InventoryType::ArmoryMain );
|
2018-10-16 20:06:30 +03:00
|
|
|
createInvDbContainer( InventoryType::ArmorySoulCrystal );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
|
|
|
createInvDbContainer( InventoryType::Currency );
|
|
|
|
createInvDbContainer( InventoryType::Crystal );
|
|
|
|
|
2019-03-24 23:49:52 +01:00
|
|
|
auto stmtMonsterNote = g_charaDb.getPreparedStatement( Db::ZoneDbStatements::CHARA_MONSTERNOTE_INS );
|
2021-11-27 00:53:57 +01:00
|
|
|
stmtMonsterNote->setUInt64( 1, m_characterId );
|
2019-03-24 23:49:52 +01:00
|
|
|
for( uint8_t i = 1; i <= 12; ++i )
|
|
|
|
stmtMonsterNote->setBinary( i + 1, monsterNote );
|
|
|
|
g_charaDb.directExecute( stmtMonsterNote );
|
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
/// SETUP EQUIPMENT / STARTING GEAR
|
2021-11-27 00:53:57 +01:00
|
|
|
auto classJobInfo = g_exdData.getRow< Component::Excel::ClassJob >( m_class );
|
2021-11-28 23:56:36 +01:00
|
|
|
uint32_t weaponId = classJobInfo->data().InitWeapon[ 0 ];
|
2018-08-29 21:40:59 +02:00
|
|
|
uint64_t uniqueId = getNextUId64();
|
|
|
|
|
|
|
|
uint8_t race = customize[ CharaLook::Race ];
|
|
|
|
uint8_t gender = customize[ CharaLook::Gender ];
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
auto raceInfo = g_exdData.getRow< Component::Excel::Race >( race );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
|
|
|
uint32_t body;
|
|
|
|
uint32_t hands;
|
|
|
|
uint32_t legs;
|
|
|
|
uint32_t feet;
|
|
|
|
uint64_t bodyUid = getNextUId64();
|
|
|
|
uint64_t handsUid = getNextUId64();
|
|
|
|
uint64_t legsUid = getNextUId64();
|
|
|
|
uint64_t feetUid = getNextUId64();
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
body = raceInfo->data().Body[ gender ];
|
|
|
|
hands = raceInfo->data().Hand[ gender ];
|
|
|
|
legs = raceInfo->data().Leg[ gender ];
|
|
|
|
feet = raceInfo->data().Foot[ gender ];
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2021-11-28 23:56:36 +01:00
|
|
|
auto mainWeaponInfo = g_exdData.getRow< Component::Excel::Item >( weaponId );
|
|
|
|
auto bodyInfo = g_exdData.getRow< Component::Excel::Item >( body );
|
|
|
|
auto handsInfo = g_exdData.getRow< Component::Excel::Item >( hands );
|
|
|
|
auto legsInfo = g_exdData.getRow< Component::Excel::Item >( legs );
|
|
|
|
auto feetInfo = g_exdData.getRow< Component::Excel::Item >( feet );
|
|
|
|
|
|
|
|
uint64_t modelMainWeapon = mainWeaponInfo->data().ModelId;
|
|
|
|
|
|
|
|
equipModel[ GearModelSlot::ModelBody ] = static_cast< uint32_t >( bodyInfo->data().ModelId );
|
|
|
|
equipModel[ GearModelSlot::ModelHands ] = static_cast< uint32_t >( handsInfo->data().ModelId );
|
|
|
|
equipModel[ GearModelSlot::ModelLegs ] = static_cast< uint32_t >( legsInfo->data().ModelId );
|
|
|
|
equipModel[ GearModelSlot::ModelFeet ] = static_cast< uint32_t >( feetInfo->data().ModelId );
|
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
insertDbGlobalItem( weaponId, uniqueId );
|
|
|
|
insertDbGlobalItem( body, bodyUid );
|
|
|
|
insertDbGlobalItem( hands, handsUid );
|
|
|
|
insertDbGlobalItem( legs, legsUid );
|
|
|
|
insertDbGlobalItem( feet, feetUid );
|
|
|
|
|
|
|
|
|
|
|
|
g_charaDb.execute( "INSERT INTO charaitemgearset (storageId, CharacterId, "
|
|
|
|
"container_" + std::to_string( GearSetSlot::MainHand ) + ", "
|
2018-09-17 23:26:56 +02:00
|
|
|
"container_" + std::to_string( GearSetSlot::Body ) + ", "
|
|
|
|
"container_" + std::to_string( GearSetSlot::Hands ) + ", "
|
|
|
|
"container_" + std::to_string( GearSetSlot::Legs ) + ", "
|
|
|
|
"container_" + std::to_string( GearSetSlot::Feet ) + ", "
|
|
|
|
"container_" + std::to_string( GearSetSlot::Neck ) + ", "
|
|
|
|
"container_" + std::to_string( GearSetSlot::Ear ) + ", "
|
|
|
|
"container_" + std::to_string( GearSetSlot::Wrist ) + ", "
|
|
|
|
"container_" + std::to_string( GearSetSlot::Ring1 ) + ", UPDATE_DATE ) "
|
|
|
|
"VALUES ( " +
|
|
|
|
std::to_string( InventoryType::GearSet0 ) + ", " +
|
2021-11-27 00:53:57 +01:00
|
|
|
std::to_string( m_characterId ) + ", " +
|
2018-08-29 21:40:59 +02:00
|
|
|
std::to_string( uniqueId ) + ", " +
|
|
|
|
std::to_string( bodyUid ) + ", " +
|
|
|
|
std::to_string( handsUid ) + ", " +
|
|
|
|
std::to_string( legsUid ) + ", " +
|
|
|
|
std::to_string( feetUid ) + ", " +
|
2021-11-27 00:53:57 +01:00
|
|
|
std::to_string( 0 ) + ", " +
|
|
|
|
std::to_string( 0 ) + ", " +
|
|
|
|
std::to_string( 0 ) + ", " +
|
|
|
|
std::to_string( 0 ) + ", NOW());" );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2021-11-28 23:56:36 +01:00
|
|
|
// "(AccountId, CharacterId, EntityId, Name, Hp, Mp, "
|
|
|
|
// "Customize, Voice, IsNewGame, TerritoryType, PosX, PosY, PosZ, PosR, ModelEquip, "
|
|
|
|
// "IsNewAdventurer, GuardianDeity, Birthday, BirthMonth, Class, Status, FirstClass, "
|
|
|
|
// "HomePoint, StartTown, Discovery, HowTo, QuestCompleteFlags, Unlocks, QuestTracking, "
|
|
|
|
// "Aetheryte, GMRank, UPDATE_DATE )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memcpy( modelEquip.data(), equipModel, modelEquip.size() );
|
|
|
|
auto stmt = g_charaDb.getPreparedStatement( Db::ZoneDbStatements::CHARA_INS );
|
|
|
|
stmt->set( 1, m_accountId );
|
|
|
|
stmt->set( 2, m_characterId );
|
|
|
|
stmt->set( 3, m_id );
|
|
|
|
|
|
|
|
stmt->setString( 4, std::string( m_name ) );
|
|
|
|
stmt->setInt( 5, 100 );
|
|
|
|
stmt->setInt( 6, 100 );
|
|
|
|
stmt->setBinary( 7, customize );
|
|
|
|
stmt->setInt( 8, m_voice );
|
|
|
|
stmt->setInt( 9, 1 );
|
|
|
|
stmt->setInt( 10, startZone );
|
|
|
|
stmt->setDouble( 11, x );
|
|
|
|
stmt->setDouble( 12, y );
|
|
|
|
stmt->setDouble( 13, z );
|
|
|
|
stmt->setDouble( 14, o );
|
|
|
|
stmt->setBinary( 15, modelEquip );
|
|
|
|
stmt->setInt( 16, 1 );
|
|
|
|
stmt->setInt( 17, m_guardianDeity );
|
|
|
|
stmt->setInt( 18, m_birthDay );
|
|
|
|
stmt->setInt( 19, m_birthMonth );
|
|
|
|
stmt->setInt( 20, m_class );
|
|
|
|
stmt->setInt( 21, 1 );
|
|
|
|
stmt->setInt( 22, m_class );
|
|
|
|
stmt->setInt( 23, homePoint );
|
|
|
|
stmt->setInt( 24, startTown );
|
|
|
|
stmt->setBinary( 25, discovery );
|
|
|
|
stmt->setBinary( 26, howTo );
|
|
|
|
stmt->setBinary( 27, questComplete );
|
|
|
|
stmt->setBinary( 28, unlocks );
|
|
|
|
stmt->setBinary( 29, questTracking8 );
|
|
|
|
stmt->setBinary( 30, aetherytes );
|
|
|
|
stmt->setInt( 31, m_gmRank );
|
|
|
|
stmt->setBinary( 32, mountGuide );
|
|
|
|
stmt->setBinary( 33, orchestrion );
|
|
|
|
stmt->set( 34, modelMainWeapon );
|
|
|
|
g_charaDb.directExecute( stmt );
|
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void PlayerMinimal::insertDbGlobalItem( uint32_t itemId, uint64_t uniqueId ) const
|
|
|
|
{
|
|
|
|
auto stmtItemGlobal = g_charaDb.getPreparedStatement( Db::CHARA_ITEMGLOBAL_INS );
|
2021-11-27 00:53:57 +01:00
|
|
|
stmtItemGlobal->setUInt64( 1, m_characterId );
|
2018-08-29 21:40:59 +02:00
|
|
|
stmtItemGlobal->setInt64( 2, uniqueId );
|
|
|
|
stmtItemGlobal->setInt( 3, itemId );
|
2018-12-25 20:11:59 +11:00
|
|
|
stmtItemGlobal->setInt( 4, 1 ); // stack of 1
|
2018-08-29 21:40:59 +02:00
|
|
|
g_charaDb.directExecute( stmtItemGlobal );
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlayerMinimal::createInvDbContainer( uint16_t slot ) const
|
|
|
|
{
|
|
|
|
auto stmtCreateInv = g_charaDb.getPreparedStatement( Db::CHARA_ITEMINV_INS );
|
2021-11-27 00:53:57 +01:00
|
|
|
stmtCreateInv->setUInt64( 1, m_characterId );
|
2018-08-29 21:40:59 +02:00
|
|
|
stmtCreateInv->setInt( 2, slot );
|
|
|
|
g_charaDb.directExecute( stmtCreateInv );
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t PlayerMinimal::getNextUId64() const
|
|
|
|
{
|
|
|
|
g_charaDb.directExecute( std::string( "INSERT INTO uniqueiddata( IdName ) VALUES( 'NOT_SET' );" ) );
|
|
|
|
auto res = g_charaDb.query( "SELECT LAST_INSERT_ID();" );
|
|
|
|
|
|
|
|
if( !res->next() )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return res->getUInt64( 1 );
|
|
|
|
}
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|