mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-24 13:47:46 +00:00
Improved Persistence (#822)
* persistant money * removed hardcoding and fixed debug console spam * refactor: fix coding system inconsistencies * refactor: fix coding style inconsistencies in loading * refactor: Missed some inconsistents * refactor: Missed some more inconsistents * quest: Introduced marauder quest (can get class, but no cutscenes yet) * refactor: Code updated to fmt::format * Delete ClsMar999.cpp * Delete ClsMar998.cpp * script-loader fix * script-loader formatting * build-error: removed broken dep
This commit is contained in:
parent
68a249792c
commit
f71230809b
5 changed files with 52 additions and 5 deletions
1
deps/ffxiv-actions
vendored
Submodule
1
deps/ffxiv-actions
vendored
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit dde9b5bbfc7c0197de0b0b49b982a0ee9fe761ab
|
|
@ -322,11 +322,13 @@ void Player::calculateStats()
|
||||||
uint8_t tribe = getLookAt( Common::CharaLook::Tribe );
|
uint8_t tribe = getLookAt( Common::CharaLook::Tribe );
|
||||||
uint8_t level = getLevel();
|
uint8_t level = getLevel();
|
||||||
auto job = static_cast< uint8_t >( getClass() );
|
auto job = static_cast< uint8_t >( getClass() );
|
||||||
|
auto deity = getGuardianDeity();
|
||||||
|
|
||||||
auto& exdData = Common::Service< Data::ExdData >::ref();
|
auto& exdData = Common::Service< Data::ExdData >::ref();
|
||||||
|
|
||||||
auto classInfo = exdData.getRow< Excel::ClassJob >( job );
|
auto classInfo = exdData.getRow< Excel::ClassJob >( job );
|
||||||
auto tribeInfo = exdData.getRow< Excel::Tribe >( tribe );
|
auto tribeInfo = exdData.getRow< Excel::Tribe >( tribe );
|
||||||
|
auto deityInfo = exdData.getRow< Excel::GuardianDeity >( deity );
|
||||||
auto paramGrowthInfo = exdData.getRow< Excel::ParamGrow >( level );
|
auto paramGrowthInfo = exdData.getRow< Excel::ParamGrow >( level );
|
||||||
|
|
||||||
float base = Math::CalcStats::calculateBaseStat( *this );
|
float base = Math::CalcStats::calculateBaseStat( *this );
|
||||||
|
@ -374,6 +376,8 @@ void Player::calculateStats()
|
||||||
setStatValue( BaseParam::AttackMagicPotency, inte );
|
setStatValue( BaseParam::AttackMagicPotency, inte );
|
||||||
setStatValue( BaseParam::HealingMagicPotency, mnd );
|
setStatValue( BaseParam::HealingMagicPotency, mnd );
|
||||||
|
|
||||||
|
setStatValue( BaseParam::PiercingResistance, 0 );
|
||||||
|
|
||||||
max_mp = Math::CalcStats::calculateMaxMp( *this );
|
max_mp = Math::CalcStats::calculateMaxMp( *this );
|
||||||
|
|
||||||
max_hp = Math::CalcStats::calculateMaxHp( *this );
|
max_hp = Math::CalcStats::calculateMaxHp( *this );
|
||||||
|
|
|
@ -736,6 +736,8 @@ namespace Sapphire::Entity
|
||||||
|
|
||||||
void writeItem( ItemPtr pItem ) const;
|
void writeItem( ItemPtr pItem ) const;
|
||||||
|
|
||||||
|
void writeCurrencyItem( Common::CurrencyType type );
|
||||||
|
|
||||||
void deleteItemDb( ItemPtr pItem ) const;
|
void deleteItemDb( ItemPtr pItem ) const;
|
||||||
|
|
||||||
/*! return the crystal amount of currency of type */
|
/*! return the crystal amount of currency of type */
|
||||||
|
|
|
@ -301,7 +301,7 @@ void Sapphire::Entity::Player::addCurrency( CurrencyType type, uint32_t amount )
|
||||||
|
|
||||||
uint32_t currentAmount = currItem->getStackSize();
|
uint32_t currentAmount = currItem->getStackSize();
|
||||||
currItem->setStackSize( currentAmount + amount );
|
currItem->setStackSize( currentAmount + amount );
|
||||||
writeItem( currItem );
|
writeCurrencyItem( type );
|
||||||
|
|
||||||
updateContainer( Currency, slot, currItem );
|
updateContainer( Currency, slot, currItem );
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ void Sapphire::Entity::Player::removeCurrency( Common::CurrencyType type, uint32
|
||||||
currItem->setStackSize( 0 );
|
currItem->setStackSize( 0 );
|
||||||
else
|
else
|
||||||
currItem->setStackSize( currentAmount - amount );
|
currItem->setStackSize( currentAmount - amount );
|
||||||
writeItem( currItem );
|
writeCurrencyItem( type );
|
||||||
|
|
||||||
auto seq = getNextInventorySequence();
|
auto seq = getNextInventorySequence();
|
||||||
|
|
||||||
|
@ -557,6 +557,19 @@ void Sapphire::Entity::Player::writeItem( Sapphire::ItemPtr pItem ) const
|
||||||
db.directExecute( stmt );
|
db.directExecute( stmt );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sapphire::Entity::Player::writeCurrencyItem( CurrencyType type )
|
||||||
|
{
|
||||||
|
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||||
|
|
||||||
|
auto money = m_storageMap[ Currency ]->getItem( static_cast< uint16_t >( type ) - 1 )->getStackSize();
|
||||||
|
|
||||||
|
std::string query = fmt::format(
|
||||||
|
"UPDATE charaitemcurrency SET container_{0} = {1} WHERE CharacterId = {2};",
|
||||||
|
std::to_string( static_cast< int16_t >( type ) - 1 ), std::to_string( money ), std::to_string( getCharacterId() ) );
|
||||||
|
|
||||||
|
db.execute( query );
|
||||||
|
}
|
||||||
|
|
||||||
void Sapphire::Entity::Player::deleteItemDb( Sapphire::ItemPtr item ) const
|
void Sapphire::Entity::Player::deleteItemDb( Sapphire::ItemPtr item ) const
|
||||||
{
|
{
|
||||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||||
|
|
|
@ -152,7 +152,7 @@ bool Sapphire::Entity::Player::loadFromDb( uint64_t characterId )
|
||||||
// Stats
|
// Stats
|
||||||
m_hp = res->getUInt( "Hp" );
|
m_hp = res->getUInt( "Hp" );
|
||||||
m_mp = res->getUInt( "Mp" );
|
m_mp = res->getUInt( "Mp" );
|
||||||
m_tp = 0;
|
m_tp = res->getUInt( "Tp" );
|
||||||
m_maxHp = getMaxHp();
|
m_maxHp = getMaxHp();
|
||||||
m_maxMp = getMaxMp();
|
m_maxMp = getMaxMp();
|
||||||
|
|
||||||
|
@ -168,6 +168,7 @@ bool Sapphire::Entity::Player::loadFromDb( uint64_t characterId )
|
||||||
m_bNewGame = false;
|
m_bNewGame = false;
|
||||||
m_hp = getMaxHp();
|
m_hp = getMaxHp();
|
||||||
m_mp = getMaxMp();
|
m_mp = getMaxMp();
|
||||||
|
m_tp = 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_hp == 0 )
|
if( m_hp == 0 )
|
||||||
|
@ -323,7 +324,7 @@ void Sapphire::Entity::Player::updateDbChara() const
|
||||||
|
|
||||||
stmt->setInt( 1, getHp() );
|
stmt->setInt( 1, getHp() );
|
||||||
stmt->setInt( 2, getMp() );
|
stmt->setInt( 2, getMp() );
|
||||||
stmt->setInt( 3, 0 ); // TP
|
stmt->setInt( 3, getTp() ); // TP
|
||||||
stmt->setInt( 4, 0 ); // GP
|
stmt->setInt( 4, 0 ); // GP
|
||||||
stmt->setInt( 5, 0 ); // Mode
|
stmt->setInt( 5, 0 ); // Mode
|
||||||
stmt->setUInt( 6, m_mount ); // Mount
|
stmt->setUInt( 6, m_mount ); // Mount
|
||||||
|
@ -696,6 +697,32 @@ bool Sapphire::Entity::Player::loadInventory()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto currencyRes = db.query(fmt::format("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 = {0} " \
|
||||||
|
"ORDER BY storageId ASC;", std::to_string(m_characterId)));
|
||||||
|
|
||||||
|
while ( currencyRes->next() )
|
||||||
|
{
|
||||||
|
uint16_t storageId = currencyRes->getUInt16( 1 );
|
||||||
|
uint32_t money = currencyRes->getUInt64( 2 );
|
||||||
|
|
||||||
|
auto slot = static_cast< uint8_t >( static_cast< uint8_t >( CurrencyType::Gil ) - 1 );
|
||||||
|
auto currItem = m_storageMap[ Currency ]->getItem( slot );
|
||||||
|
|
||||||
|
if ( !currItem )
|
||||||
|
{
|
||||||
|
// TODO: map currency type to itemid
|
||||||
|
currItem = createItem( 1 );
|
||||||
|
m_storageMap[ Currency ]->setItem( slot, currItem );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_storageMap[ Currency ]->getItem( slot )->setStackSize( money );
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue