diff --git a/src/world/Actor/Player.h b/src/world/Actor/Player.h index 3078b8e6..27173b82 100644 --- a/src/world/Actor/Player.h +++ b/src/world/Actor/Player.h @@ -736,7 +736,7 @@ namespace Sapphire::Entity void writeItem( ItemPtr pItem ) const; - void writeMoney(Common::CurrencyType type); + void writeCurrencyItem( Common::CurrencyType type ); void deleteItemDb( ItemPtr pItem ) const; diff --git a/src/world/Actor/PlayerInventory.cpp b/src/world/Actor/PlayerInventory.cpp index 8be59df6..f09049ce 100644 --- a/src/world/Actor/PlayerInventory.cpp +++ b/src/world/Actor/PlayerInventory.cpp @@ -531,7 +531,7 @@ void Sapphire::Entity::Player::writeInventory( InventoryType type ) if( i > 0 ) query += ", "; - query += "container_" + std::to_string( i ) + " = " + std::to_string( currItem ? currItem->getUId() : 0 ); + query += "container_" + std::to_string( i ) + " = " + std::to_string( currItem ? currItem->getUId() : 0 ); } query += " WHERE CharacterId = " + std::to_string( getCharacterId() ); @@ -557,13 +557,16 @@ void Sapphire::Entity::Player::writeItem( Sapphire::ItemPtr pItem ) const db.directExecute( stmt ); } -void Sapphire::Entity::Player::writeMoney(CurrencyType type) +void Sapphire::Entity::Player::writeCurrencyItem( 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(type) - 1)->getStackSize(); + std::string query = "UPDATE charaitemcurrency SET "; + query += "container_" + std::to_string(static_cast(type) - 1) + " = " + std::to_string(money); + query += " WHERE CharacterId = " + std::to_string(getCharacterId()) + ";"; db.execute(query); diff --git a/src/world/Actor/PlayerSql.cpp b/src/world/Actor/PlayerSql.cpp index 6e097a5d..3ad465ac 100644 --- a/src/world/Actor/PlayerSql.cpp +++ b/src/world/Actor/PlayerSql.cpp @@ -323,7 +323,7 @@ void Sapphire::Entity::Player::updateDbChara() const stmt->setInt( 1, getHp() ); stmt->setInt( 2, getMp() ); - stmt->setInt( 3, 0 ); // TP + stmt->setInt( 3, getTp() ); // TP stmt->setInt( 4, 0 ); // GP stmt->setInt( 5, 0 ); // Mode stmt->setUInt( 6, m_mount ); // Mount