mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-15 20:51:29 +00:00
[Commands] Cleanup #acceptrules Command (#3716)
# Note - Cleanup messages and logic. - Utilize repositories in database methods.
This commit is contained in:
parent
93ddffa57f
commit
f9f45eedcd
@ -29,6 +29,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../common/repositories/account_repository.h"
|
||||
|
||||
// Disgrace: for windows compile
|
||||
#ifdef _WINDOWS
|
||||
#include <windows.h>
|
||||
@ -1643,25 +1645,20 @@ void Database::ClearGroupLeader(uint32 gid) {
|
||||
std::cout << "Unable to clear group leader: " << results.ErrorMessage() << std::endl;
|
||||
}
|
||||
|
||||
uint8 Database::GetAgreementFlag(uint32 acctid) {
|
||||
|
||||
std::string query = StringFormat("SELECT rulesflag FROM account WHERE id=%i",acctid);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
uint8 Database::GetAgreementFlag(uint32 account_id)
|
||||
{
|
||||
const auto& e = AccountRepository::FindOne(*this, account_id);
|
||||
if (!e.id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (results.RowCount() != 1)
|
||||
return 0;
|
||||
|
||||
auto row = results.begin();
|
||||
|
||||
return Strings::ToUnsignedInt(row[0]);
|
||||
return e.rulesflag;
|
||||
}
|
||||
|
||||
void Database::SetAgreementFlag(uint32 acctid) {
|
||||
std::string query = StringFormat("UPDATE account SET rulesflag=1 where id=%i", acctid);
|
||||
QueryDatabase(query);
|
||||
void Database::SetAgreementFlag(uint32 account_id) {
|
||||
auto e = AccountRepository::FindOne(*this, account_id);
|
||||
e.rulesflag = 1;
|
||||
AccountRepository::UpdateOne(*this, e);
|
||||
}
|
||||
|
||||
void Database::ClearRaid(uint32 rid) {
|
||||
|
||||
@ -188,10 +188,10 @@ public:
|
||||
uint32 CheckLogin(const char* name, const char* password, const char *loginserver, int16* oStatus = 0);
|
||||
uint32 CreateAccount(const char* name, const char* password, int16 status, const char* loginserver, uint32 lsaccount_id);
|
||||
uint32 GetAccountIDFromLSID(const std::string& in_loginserver_id, uint32 in_loginserver_account_id, char* in_account_name = 0, int16* in_status = 0);
|
||||
uint8 GetAgreementFlag(uint32 acctid);
|
||||
uint8 GetAgreementFlag(uint32 account_id);
|
||||
|
||||
void GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus);
|
||||
void SetAgreementFlag(uint32 acctid);
|
||||
void SetAgreementFlag(uint32 account_id);
|
||||
|
||||
int GetIPExemption(std::string account_ip);
|
||||
void SetIPExemption(std::string account_ip, int exemption_amount);
|
||||
|
||||
@ -2,10 +2,12 @@
|
||||
|
||||
void command_acceptrules(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (!database.GetAgreementFlag(c->AccountID())) {
|
||||
if (database.GetAgreementFlag(c->AccountID())) {
|
||||
c->Message(Chat::White, "You have already agreed to the rules.");
|
||||
return;
|
||||
}
|
||||
|
||||
database.SetAgreementFlag(c->AccountID());
|
||||
c->SendAppearancePacket(AT_Anim, ANIM_STAND);
|
||||
c->Message(Chat::White, "It is recorded you have agreed to the rules.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user