mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 14:37:44 +00:00
PlayerMinimal almost completely ported
This commit is contained in:
parent
d73246a4c9
commit
d7b54b5b6d
4 changed files with 47 additions and 31 deletions
|
@ -130,5 +130,10 @@ void Core::Db::CharaDbConnection::doPrepareStatements()
|
||||||
/// INVENTORY INFO
|
/// INVENTORY INFO
|
||||||
prepareStatement( CHARA_ITEMINV_INS, "INSERT INTO charaiteminventory ( CharacterId, storageId, UPDATE_DATE ) VALUES ( ?, ?, NOW() );", CONNECTION_BOTH );
|
prepareStatement( CHARA_ITEMINV_INS, "INSERT INTO charaiteminventory ( CharacterId, storageId, UPDATE_DATE ) VALUES ( ?, ?, NOW() );", CONNECTION_BOTH );
|
||||||
|
|
||||||
|
/// ITEM GLOBAL
|
||||||
|
prepareStatement( CHARA_ITEMGLOBAL_INS, "INSERT INTO charaglobalitem ( CharacterId, ItemId, catalogId, UPDATE_DATE ) VALUES ( ?, ?, ?, NOW() );", CONNECTION_BOTH );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -73,6 +73,8 @@ enum CharaDbStatements : uint32_t
|
||||||
|
|
||||||
CHARA_ITEMINV_INS,
|
CHARA_ITEMINV_INS,
|
||||||
|
|
||||||
|
CHARA_ITEMGLOBAL_INS,
|
||||||
|
|
||||||
MAX_STATEMENTS
|
MAX_STATEMENTS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -169,8 +169,6 @@ namespace Core {
|
||||||
|
|
||||||
memcpy( questTracking8.data(), questTracking.data(), questTracking8.size() );
|
memcpy( questTracking8.data(), questTracking.data(), questTracking8.size() );
|
||||||
|
|
||||||
uint16_t size = static_cast< uint16_t >( m_lookMap.size() );
|
|
||||||
|
|
||||||
for( uint32_t i = 0; i < m_lookMap.size(); i++ )
|
for( uint32_t i = 0; i < m_lookMap.size(); i++ )
|
||||||
{
|
{
|
||||||
customize[i] = m_lookMap[i];
|
customize[i] = m_lookMap[i];
|
||||||
|
@ -273,7 +271,6 @@ namespace Core {
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// SET UP INVENTORIES
|
/// SET UP INVENTORIES
|
||||||
|
|
||||||
createInvDbContainer( InventoryType::Bag0 );
|
createInvDbContainer( InventoryType::Bag0 );
|
||||||
createInvDbContainer( InventoryType::Bag1 );
|
createInvDbContainer( InventoryType::Bag1 );
|
||||||
createInvDbContainer( InventoryType::Bag2 );
|
createInvDbContainer( InventoryType::Bag2 );
|
||||||
|
@ -297,26 +294,25 @@ namespace Core {
|
||||||
createInvDbContainer( InventoryType::Currency );
|
createInvDbContainer( InventoryType::Currency );
|
||||||
createInvDbContainer( InventoryType::Crystal );
|
createInvDbContainer( InventoryType::Crystal );
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// SETUP EQUIPMENT / STARTING GEAR
|
/// SETUP EQUIPMENT / STARTING GEAR
|
||||||
auto classJobInfo = g_exdData.m_classJobInfoMap[m_class];
|
auto classJobInfo = g_exdData.m_classJobInfoMap[m_class];
|
||||||
uint32_t weaponId = classJobInfo.start_weapon_id;
|
uint32_t weaponId = classJobInfo.start_weapon_id;
|
||||||
uint64_t uniqueId = g_database.getNextUId();
|
uint64_t uniqueId = getNextUId64();
|
||||||
|
|
||||||
uint8_t race = customize[CharaLook::Race];
|
uint8_t race = customize[CharaLook::Race];
|
||||||
uint8_t gender = customize[CharaLook::Gender];
|
uint8_t gender = customize[CharaLook::Gender];
|
||||||
|
|
||||||
auto raceInfo = g_exdData.getRaceInfo( race );
|
auto raceInfo = g_exdData.getRaceInfo( race );
|
||||||
|
|
||||||
int32_t body;
|
uint32_t body;
|
||||||
int32_t hands;
|
uint32_t hands;
|
||||||
int32_t legs;
|
uint32_t legs;
|
||||||
int32_t feet;
|
uint32_t feet;
|
||||||
uint64_t bodyUid = g_database.getNextUId();
|
uint64_t bodyUid = getNextUId64();
|
||||||
uint64_t handsUid = g_database.getNextUId();
|
uint64_t handsUid = getNextUId64();
|
||||||
uint64_t legsUid = g_database.getNextUId();
|
uint64_t legsUid = getNextUId64();
|
||||||
uint64_t feetUid = g_database.getNextUId();
|
uint64_t feetUid = getNextUId64();
|
||||||
|
|
||||||
if( gender == 0 )
|
if( gender == 0 )
|
||||||
{
|
{
|
||||||
|
@ -333,21 +329,11 @@ namespace Core {
|
||||||
feet = raceInfo->female_feet;
|
feet = raceInfo->female_feet;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_charaDb.execute( "INSERT INTO charaglobalitem (CharacterId, ItemId, catalogId, UPDATE_DATE ) "
|
insertDbGlobalItem( weaponId, uniqueId );
|
||||||
"VALUES ( " + std::to_string( m_id ) + ", " + std::to_string( uniqueId ) + ", " +
|
insertDbGlobalItem( body, bodyUid );
|
||||||
std::to_string( weaponId ) + ", NOW());" );
|
insertDbGlobalItem( hands, handsUid );
|
||||||
g_charaDb.execute( "INSERT INTO charaglobalitem (CharacterId, ItemId, catalogId, UPDATE_DATE ) "
|
insertDbGlobalItem( legs, legsUid );
|
||||||
"VALUES ( " + std::to_string( m_id ) + ", " + std::to_string( bodyUid ) + ", " +
|
insertDbGlobalItem( feet, feetUid );
|
||||||
std::to_string( body ) + ", NOW());" );
|
|
||||||
g_charaDb.execute( "INSERT INTO charaglobalitem (CharacterId, ItemId, catalogId, UPDATE_DATE ) "
|
|
||||||
"VALUES ( " + std::to_string( m_id ) + ", " + std::to_string( handsUid ) + ", " +
|
|
||||||
std::to_string( hands ) + ", NOW());" );
|
|
||||||
g_charaDb.execute( "INSERT INTO charaglobalitem (CharacterId, ItemId, catalogId, UPDATE_DATE ) "
|
|
||||||
"VALUES ( " + std::to_string( m_id ) + ", " + std::to_string( legsUid ) + ", " +
|
|
||||||
std::to_string( legs ) + ", NOW());" );
|
|
||||||
g_charaDb.execute( "INSERT INTO charaglobalitem (CharacterId, ItemId, catalogId, UPDATE_DATE ) "
|
|
||||||
"VALUES ( " + std::to_string( m_id ) + ", " + std::to_string( feetUid ) + ", " +
|
|
||||||
std::to_string( feet ) + ", NOW());" );
|
|
||||||
|
|
||||||
g_charaDb.execute( "INSERT INTO charaitemgearset (storageId, CharacterId, "
|
g_charaDb.execute( "INSERT INTO charaitemgearset (storageId, CharacterId, "
|
||||||
"container_" + std::to_string( EquipSlot::MainHand ) + ", "
|
"container_" + std::to_string( EquipSlot::MainHand ) + ", "
|
||||||
|
@ -365,6 +351,15 @@ namespace Core {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlayerMinimal::insertDbGlobalItem( uint32_t weaponId, uint64_t uniqueId ) const
|
||||||
|
{
|
||||||
|
auto stmtItemGlobal = g_charaDb.getPreparedStatement(Db::CHARA_ITEMGLOBAL_INS );
|
||||||
|
stmtItemGlobal->setInt(1, m_id);
|
||||||
|
stmtItemGlobal->setInt64( 2, uniqueId );
|
||||||
|
stmtItemGlobal->setInt( 3, weaponId );
|
||||||
|
g_charaDb.directExecute( stmtItemGlobal );
|
||||||
|
}
|
||||||
|
|
||||||
void PlayerMinimal::createInvDbContainer( uint8_t slot ) const
|
void PlayerMinimal::createInvDbContainer( uint8_t slot ) const
|
||||||
{
|
{
|
||||||
auto stmtCreateInv = g_charaDb.getPreparedStatement( Db::CHARA_ITEMINV_INS );
|
auto stmtCreateInv = g_charaDb.getPreparedStatement( Db::CHARA_ITEMINV_INS );
|
||||||
|
@ -372,4 +367,15 @@ namespace Core {
|
||||||
stmtCreateInv->setInt( 2, slot );
|
stmtCreateInv->setInt( 2, slot );
|
||||||
g_charaDb.directExecute( stmtCreateInv );
|
g_charaDb.directExecute( stmtCreateInv );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t PlayerMinimal::getNextUId64() const
|
||||||
|
{
|
||||||
|
g_charaDb.execute( std::string( "INSERT INTO uniqueiddata( IdName ) VALUES( 'NOT_SET' );" ) );
|
||||||
|
auto res = g_charaDb.query( "SELECT LAST_INSERT_ID();" );
|
||||||
|
|
||||||
|
if( !res )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return res->getUInt64( 1 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,6 +154,8 @@ namespace Core {
|
||||||
|
|
||||||
uint32_t m_modelEquip[10];
|
uint32_t m_modelEquip[10];
|
||||||
|
|
||||||
|
uint64_t getNextUId64() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t m_accountId;
|
uint32_t m_accountId;
|
||||||
uint32_t m_id;
|
uint32_t m_id;
|
||||||
|
@ -170,7 +172,7 @@ namespace Core {
|
||||||
|
|
||||||
uint16_t m_zoneId;
|
uint16_t m_zoneId;
|
||||||
|
|
||||||
std::map< uint8_t, uint32_t > m_lookMap;
|
std::map< uint8_t, uint8_t > m_lookMap;
|
||||||
std::map< uint8_t, uint16_t > m_classMap;
|
std::map< uint8_t, uint16_t > m_classMap;
|
||||||
uint8_t m_look[26];
|
uint8_t m_look[26];
|
||||||
|
|
||||||
|
@ -178,6 +180,7 @@ namespace Core {
|
||||||
|
|
||||||
char m_name[34];
|
char m_name[34];
|
||||||
|
|
||||||
|
void insertDbGlobalItem( uint32_t weaponId, uint64_t uniqueId ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue