From dee58f9a91a9773f56fd4c9fd9c11c2ccc7fe340 Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Mon, 1 Sep 2025 21:39:24 -0400 Subject: [PATCH] [Repositories] Convert Shared Bank Platinum to Repositories (#5006) --- common/shareddb.cpp | 25 +++++++++---------------- common/shareddb.h | 2 +- zone/client_process.cpp | 2 +- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 89c48daa1..4039551fd 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -448,27 +448,20 @@ bool SharedDatabase::DeleteSharedBankSlot(uint32 char_id, int16 slot_id) ); } - int32 SharedDatabase::GetSharedPlatinum(uint32 account_id) { - const auto query = fmt::format("SELECT sharedplat FROM account WHERE id = {}", account_id); - auto results = QueryDatabase(query); - if (!results.Success() || !results.RowCount()) { - return 0; - } - - auto row = results.begin(); - return Strings::ToInt(row[0]); + const auto& e = AccountRepository::FindOne(*this, account_id); + + return e.sharedplat; } -bool SharedDatabase::SetSharedPlatinum(uint32 account_id, int32 amount_to_add) { - const std::string query = StringFormat("UPDATE account SET sharedplat = sharedplat + %i WHERE id = %i", amount_to_add, account_id); - const auto results = QueryDatabase(query); - if (!results.Success()) { - return false; - } +bool SharedDatabase::AddSharedPlatinum(uint32 account_id, int amount) +{ + auto e = AccountRepository::FindOne(*this, account_id); - return true; + e.sharedplat += amount; + + return AccountRepository::UpdateOne(*this, e); } bool SharedDatabase::SetStartingItems( diff --git a/common/shareddb.h b/common/shareddb.h index 873b8e1a0..fa86f859e 100644 --- a/common/shareddb.h +++ b/common/shareddb.h @@ -104,7 +104,7 @@ public: bool VerifyInventory(uint32 account_id, int16 slot_id, const EQ::ItemInstance *inst); bool GetSharedBank(uint32 id, EQ::InventoryProfile *inv, bool is_charid); int32 GetSharedPlatinum(uint32 account_id); - bool SetSharedPlatinum(uint32 account_id, int32 amount_to_add); + bool AddSharedPlatinum(uint32 account_id, int amount); bool GetInventory(Client* c); bool GetInventory(uint32 account_id, char *name, EQ::InventoryProfile *inv); // deprecated std::map GetItemRecastTimestamps(uint32 char_id); diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 71144db89..e14985763 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -1571,7 +1571,7 @@ void Client::OPMoveCoin(const EQApplicationPacket* app) if (from_bucket == &m_pp.platinum_shared) amount_to_add = 0 - amount_to_take; - database.SetSharedPlatinum(AccountID(),amount_to_add); + database.AddSharedPlatinum(AccountID(),amount_to_add); } } else{