1
Fork 0
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:
Matthe815 2023-01-06 21:21:19 -05:00
parent 952bb6d7be
commit 741275d647
No known key found for this signature in database
GPG key ID: 6B963FE816B1DC39
2 changed files with 9 additions and 10 deletions

View file

@ -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 );
}

View file

@ -6,6 +6,7 @@
#include <Network/PacketContainer.h>
#include <Database/DatabaseDef.h>
#include <Service.h>
#include <format>
#include "Network/PacketWrappers/PlayerSetupPacket.h"
@ -697,13 +698,13 @@ 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() )
{