mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 01:11:29 +00:00
GetAccountName converted to QueryDatabase
This commit is contained in:
parent
20e80ebb92
commit
5ef05d1bb6
@ -837,28 +837,29 @@ uint32 Database::GetAccountIDByName(const char* accname, int16* status, uint32*
|
||||
}
|
||||
|
||||
void Database::GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
char *query = nullptr;
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT name, lsaccount_id FROM account WHERE id='%i'", accountid), errbuf, &result)) {
|
||||
auto results = QueryDatabase(query, MakeAnyLenString(&query, "SELECT name, lsaccount_id FROM account WHERE id='%i'", accountid));
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in GetAccountName query '" << query << "' " << errbuf << std::endl;
|
||||
safe_delete_array(query);
|
||||
if (mysql_num_rows(result) == 1) {
|
||||
row = mysql_fetch_row(result);
|
||||
return;
|
||||
}
|
||||
|
||||
safe_delete_array(query);
|
||||
|
||||
if (results.RowCount() != 1)
|
||||
return;
|
||||
|
||||
auto row = results.begin();
|
||||
|
||||
strcpy(name, row[0]);
|
||||
if (row[1] && oLSAccountID) {
|
||||
*oLSAccountID = atoi(row[1]);
|
||||
}
|
||||
}
|
||||
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else {
|
||||
safe_delete_array(query);
|
||||
std::cerr << "Error in GetAccountName query '" << query << "' " << errbuf << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void Database::GetCharName(uint32 char_id, char* name) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user