mirror of
https://github.com/EQEmu/Server.git
synced 2026-09-04 02:06:50 +00:00
[Account] Convert Get/Update Account Karma to Repositories (#3858)
* [Account] Convert Get/Update Account Karma to Repositories - Convert `GetKarma` and `UpdateKarma` to repositories. * Update zonedb.cpp
This commit is contained in:
+13
-13
@@ -36,6 +36,7 @@
|
||||
#include "../common/repositories/character_auras_repository.h"
|
||||
#include "../common/repositories/character_alt_currency_repository.h"
|
||||
#include "../common/repositories/character_item_recast_repository.h"
|
||||
#include "../common/repositories/account_repository.h"
|
||||
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
@@ -2748,24 +2749,23 @@ int ZoneDatabase::getZoneShutDownDelay(uint32 zoneID, uint32 version)
|
||||
return z ? z->shutdowndelay : RuleI(Zone, AutoShutdownDelay);
|
||||
}
|
||||
|
||||
uint32 ZoneDatabase::GetKarma(uint32 acct_id)
|
||||
uint32 ZoneDatabase::GetKarma(uint32 account_id)
|
||||
{
|
||||
std::string query = StringFormat("SELECT `karma` FROM `account` WHERE `id` = '%i' LIMIT 1", acct_id);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
return 0;
|
||||
const auto& e = AccountRepository::FindOne(*this, account_id);
|
||||
|
||||
for (auto& row = results.begin(); row != results.end(); ++row) {
|
||||
return Strings::ToInt(row[0]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return !e.id ? 0 : e.karma;
|
||||
}
|
||||
|
||||
void ZoneDatabase::UpdateKarma(uint32 acct_id, uint32 amount)
|
||||
void ZoneDatabase::UpdateKarma(uint32 account_id, uint32 amount)
|
||||
{
|
||||
std::string query = StringFormat("UPDATE account SET karma = %i WHERE id = %i", amount, acct_id);
|
||||
QueryDatabase(query);
|
||||
auto e = AccountRepository::FindOne(*this, account_id);
|
||||
if (!e.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.karma = amount;
|
||||
|
||||
AccountRepository::UpdateOne(*this, e);
|
||||
}
|
||||
|
||||
void ZoneDatabase::ListAllInstances(Client* client, uint32 character_id)
|
||||
|
||||
+2
-2
@@ -653,8 +653,8 @@ public:
|
||||
* PLEASE DO NOT ADD TO THIS COLLECTION OF CRAP UNLESS YOUR METHOD
|
||||
* REALLY HAS NO BETTER SECTION
|
||||
*/
|
||||
uint32 GetKarma(uint32 acct_id);
|
||||
void UpdateKarma(uint32 acct_id, uint32 amount);
|
||||
uint32 GetKarma(uint32 account_id);
|
||||
void UpdateKarma(uint32 account_id, uint32 amount);
|
||||
|
||||
// bot database add-on to eliminate the need for a second database connection
|
||||
BotDatabase botdb;
|
||||
|
||||
Reference in New Issue
Block a user