mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-24 18:47:45 +00:00
persistant money
This commit is contained in:
parent
3b272d3053
commit
bcb6c2b404
5 changed files with 50 additions and 2 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 level = getLevel();
|
||||
auto job = static_cast< uint8_t >( getClass() );
|
||||
auto deity = getGuardianDeity();
|
||||
|
||||
auto& exdData = Common::Service< Data::ExdData >::ref();
|
||||
|
||||
auto classInfo = exdData.getRow< Excel::ClassJob >( job );
|
||||
auto tribeInfo = exdData.getRow< Excel::Tribe >( tribe );
|
||||
auto deityInfo = exdData.getRow< Excel::GuardianDeity >( deity );
|
||||
auto paramGrowthInfo = exdData.getRow< Excel::ParamGrow >( level );
|
||||
|
||||
float base = Math::CalcStats::calculateBaseStat( *this );
|
||||
|
@ -374,6 +376,8 @@ void Player::calculateStats()
|
|||
setStatValue( BaseParam::AttackMagicPotency, inte );
|
||||
setStatValue( BaseParam::HealingMagicPotency, mnd );
|
||||
|
||||
setStatValue( BaseParam::PiercingResistance, 0 );
|
||||
|
||||
max_mp = Math::CalcStats::calculateMaxMp( *this );
|
||||
|
||||
max_hp = Math::CalcStats::calculateMaxHp( *this );
|
||||
|
|
|
@ -736,6 +736,8 @@ namespace Sapphire::Entity
|
|||
|
||||
void writeItem( ItemPtr pItem ) const;
|
||||
|
||||
void writeMoney(Common::CurrencyType type);
|
||||
|
||||
void deleteItemDb( ItemPtr pItem ) const;
|
||||
|
||||
/*! 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();
|
||||
currItem->setStackSize( currentAmount + amount );
|
||||
writeItem( currItem );
|
||||
writeMoney( CurrencyType::Gil );
|
||||
|
||||
updateContainer( Currency, slot, currItem );
|
||||
|
||||
|
@ -557,6 +557,18 @@ void Sapphire::Entity::Player::writeItem( Sapphire::ItemPtr pItem ) const
|
|||
db.directExecute( stmt );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::writeMoney(CurrencyType type)
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
std::string query = "UPDATE charaitemcurrency SET ";
|
||||
auto money = m_storageMap[Currency]->getItem(static_cast<uint16_t>(type) - 1)->getStackSize();
|
||||
|
||||
query += "container_0 = " + std::to_string(money);
|
||||
query += " WHERE CharacterId = " + std::to_string(getCharacterId()) + ";";
|
||||
|
||||
db.execute(query);
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::deleteItemDb( Sapphire::ItemPtr item ) const
|
||||
{
|
||||
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
||||
|
|
|
@ -152,7 +152,7 @@ bool Sapphire::Entity::Player::loadFromDb( uint64_t characterId )
|
|||
// Stats
|
||||
m_hp = res->getUInt( "Hp" );
|
||||
m_mp = res->getUInt( "Mp" );
|
||||
m_tp = 0;
|
||||
m_tp = res->getUInt("Tp");
|
||||
m_maxHp = getMaxHp();
|
||||
m_maxMp = getMaxMp();
|
||||
|
||||
|
@ -680,6 +680,7 @@ bool Sapphire::Entity::Player::loadInventory()
|
|||
|
||||
while( bagRes->next() )
|
||||
{
|
||||
Logger::info("Loaded items");
|
||||
uint16_t storageId = bagRes->getUInt16( 1 );
|
||||
for( uint32_t i = 1; i <= m_storageMap[ storageId ]->getMaxSize(); i++ )
|
||||
{
|
||||
|
@ -696,6 +697,34 @@ bool Sapphire::Entity::Player::loadInventory()
|
|||
}
|
||||
}
|
||||
|
||||
Logger::info(std::to_string(m_characterId));
|
||||
|
||||
auto moneyRes = db.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_characterId) + " " \
|
||||
"ORDER BY storageId ASC;");
|
||||
|
||||
while ( moneyRes->next() )
|
||||
{
|
||||
uint16_t storageId = moneyRes->getUInt16( 1 );
|
||||
uint32_t money = moneyRes->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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue