mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-24 18:47:45 +00:00
refactor: Code updated to fmt::format
This commit is contained in:
parent
952bb6d7be
commit
741275d647
2 changed files with 9 additions and 10 deletions
|
@ -339,7 +339,7 @@ void Sapphire::Entity::Player::removeCurrency( Common::CurrencyType type, uint32
|
|||
currItem->setStackSize( 0 );
|
||||
else
|
||||
currItem->setStackSize( currentAmount - amount );
|
||||
writeCurrencyItem(type);
|
||||
writeCurrencyItem( type );
|
||||
|
||||
auto seq = getNextInventorySequence();
|
||||
|
||||
|
@ -563,11 +563,9 @@ void Sapphire::Entity::Player::writeCurrencyItem( CurrencyType type )
|
|||
|
||||
auto money = m_storageMap[ Currency ]->getItem( static_cast< uint16_t >( type ) - 1 )->getStackSize();
|
||||
|
||||
std::string query = "UPDATE charaitemcurrency SET ";
|
||||
|
||||
query += "container_" + std::to_string( static_cast< int16_t >( type ) - 1 ) + " = " + std::to_string( money );
|
||||
|
||||
query += " WHERE CharacterId = " + std::to_string( getCharacterId() ) + ";";
|
||||
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 );
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <Network/PacketContainer.h>
|
||||
#include <Database/DatabaseDef.h>
|
||||
#include <Service.h>
|
||||
#include <format>
|
||||
|
||||
#include "Network/PacketWrappers/PlayerSetupPacket.h"
|
||||
|
||||
|
@ -697,20 +698,20 @@ bool Sapphire::Entity::Player::loadInventory()
|
|||
}
|
||||
}
|
||||
|
||||
auto currencyRes = db.query("SELECT storageId, "
|
||||
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 = " + std::to_string(m_characterId) + " " \
|
||||
"ORDER BY storageId ASC;");
|
||||
"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 slot = static_cast< uint8_t >( static_cast< uint8_t >( CurrencyType::Gil ) - 1 );
|
||||
auto currItem = m_storageMap[ Currency ]->getItem( slot );
|
||||
|
||||
if ( !currItem )
|
||||
|
|
Loading…
Add table
Reference in a new issue