mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 01:11:29 +00:00
GetAccountStatus converted to QueryDatabase
This commit is contained in:
parent
16d47a2c47
commit
a568a6f194
@ -102,41 +102,34 @@ Database::~Database()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::GetAccountStatus(Client *c) {
|
void Database::GetAccountStatus(Client *client) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char* query = 0;
|
|
||||||
MYSQL_RES *result;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
|
|
||||||
if (!RunQuery(query,MakeAnyLenString(&query, "select `status`, `hideme`, `karma`, `revoked` from `account` where `id`='%i' limit 1",
|
|
||||||
c->GetAccountID()),errbuf,&result)){
|
|
||||||
|
|
||||||
_log(UCS__ERROR, "Unable to get account status for character %s, error %s", c->GetName().c_str(), errbuf);
|
|
||||||
|
|
||||||
safe_delete_array(query);
|
|
||||||
|
|
||||||
|
std::string query = StringFormat("SELECT `status`, `hideme`, `karma`, `revoked` "
|
||||||
|
"FROM `account` WHERE `id` = '%i' LIMIT 1",
|
||||||
|
client->GetAccountID());
|
||||||
|
auto results = QueryDatabase(query);
|
||||||
|
if (!results.Success()) {
|
||||||
|
_log(UCS__ERROR, "Unable to get account status for character %s, error %s", client->GetName().c_str(), results.ErrorMessage().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_log(UCS__TRACE, "GetAccountStatus Query: %s", query);
|
|
||||||
safe_delete_array(query);
|
|
||||||
|
|
||||||
if(mysql_num_rows(result) != 1)
|
_log(UCS__TRACE, "GetAccountStatus Query: %s", query.c_str());
|
||||||
|
|
||||||
|
if(results.RowCount() != 1)
|
||||||
{
|
{
|
||||||
_log(UCS__ERROR, "Error in GetAccountStatus");
|
_log(UCS__ERROR, "Error in GetAccountStatus");
|
||||||
mysql_free_result(result);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
row = mysql_fetch_row(result);
|
auto row = results.begin();
|
||||||
|
|
||||||
c->SetAccountStatus(atoi(row[0]));
|
client->SetAccountStatus(atoi(row[0]));
|
||||||
c->SetHideMe(atoi(row[1]) != 0);
|
client->SetHideMe(atoi(row[1]) != 0);
|
||||||
c->SetKarma(atoi(row[2]));
|
client->SetKarma(atoi(row[2]));
|
||||||
c->SetRevoked((atoi(row[3])==1?true:false));
|
client->SetRevoked((atoi(row[3])==1?true:false));
|
||||||
|
|
||||||
|
_log(UCS__TRACE, "Set account status to %i, hideme to %i and karma to %i for %s", client->GetAccountStatus(), client->GetHideMe(), client->GetKarma(), client->GetName().c_str());
|
||||||
|
|
||||||
_log(UCS__TRACE, "Set account status to %i, hideme to %i and karma to %i for %s", c->GetAccountStatus(), c->GetHideMe(), c->GetKarma(), c->GetName().c_str());
|
|
||||||
mysql_free_result(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Database::FindAccount(const char *CharacterName, Client *c) {
|
int Database::FindAccount(const char *CharacterName, Client *c) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user