From b2bd202ed7103fbe4391560bd8c8b1549b499b8e Mon Sep 17 00:00:00 2001 From: Matthe815 Date: Fri, 6 Jan 2023 10:07:21 -0500 Subject: [PATCH] refactor: fix coding style inconsistencies in loading --- src/world/Actor/PlayerInventory.cpp | 4 ++-- src/world/Actor/PlayerSql.cpp | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/world/Actor/PlayerInventory.cpp b/src/world/Actor/PlayerInventory.cpp index f09049ce..a8eb6a4c 100644 --- a/src/world/Actor/PlayerInventory.cpp +++ b/src/world/Actor/PlayerInventory.cpp @@ -301,7 +301,7 @@ void Sapphire::Entity::Player::addCurrency( CurrencyType type, uint32_t amount ) uint32_t currentAmount = currItem->getStackSize(); currItem->setStackSize( currentAmount + amount ); - writeMoney( type ); + writeCurrencyItem( type ); updateContainer( Currency, slot, currItem ); @@ -339,7 +339,7 @@ void Sapphire::Entity::Player::removeCurrency( Common::CurrencyType type, uint32 currItem->setStackSize( 0 ); else currItem->setStackSize( currentAmount - amount ); - writeItem( currItem ); + writeCurrencyItem(type); auto seq = getNextInventorySequence(); diff --git a/src/world/Actor/PlayerSql.cpp b/src/world/Actor/PlayerSql.cpp index 3ad465ac..737de670 100644 --- a/src/world/Actor/PlayerSql.cpp +++ b/src/world/Actor/PlayerSql.cpp @@ -696,7 +696,7 @@ bool Sapphire::Entity::Player::loadInventory() } } - auto moneyRes = db.query("SELECT storageId, " + auto currencyRes = 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 " @@ -704,22 +704,22 @@ bool Sapphire::Entity::Player::loadInventory() "WHERE CharacterId = " + std::to_string(m_characterId) + " " \ "ORDER BY storageId ASC;"); - while ( moneyRes->next() ) + while ( currencyRes->next() ) { - uint16_t storageId = moneyRes->getUInt16( 1 ); - uint32_t money = moneyRes->getUInt64(2); + uint16_t storageId = currencyRes->getUInt16( 1 ); + uint32_t money = currencyRes->getUInt64( 2 ); - auto slot = static_cast(static_cast(CurrencyType::Gil) - 1); - auto currItem = m_storageMap[Currency]->getItem(slot); + auto slot = static_cast< uint8_t >( static_cast( CurrencyType::Gil ) - 1 ); + auto currItem = m_storageMap[ Currency ]->getItem( slot ); - if (!currItem) + if ( !currItem ) { // TODO: map currency type to itemid - currItem = createItem(1); - m_storageMap[Currency]->setItem(slot, currItem); + currItem = createItem( 1 ); + m_storageMap[ Currency ]->setItem( slot, currItem ); } - m_storageMap[Currency]->getItem(slot)->setStackSize(money); + m_storageMap[ Currency ]->getItem( slot )->setStackSize( money ); } return true;