mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-17 22:51:30 +00:00
GetGMSpeed converted to QueryDatabase
This commit is contained in:
parent
b379bdd36e
commit
edc2567b10
@ -60,37 +60,19 @@ bool SharedDatabase::SetHideMe(uint32 account_id, uint8 hideme)
|
|||||||
|
|
||||||
uint8 SharedDatabase::GetGMSpeed(uint32 account_id)
|
uint8 SharedDatabase::GetGMSpeed(uint32 account_id)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string query = StringFormat("SELECT gmspeed FROM account WHERE id = '%i'", account_id);
|
||||||
char *query = 0;
|
auto results = QueryDatabase(query);
|
||||||
MYSQL_RES *result;
|
if (!results.Success()) {
|
||||||
MYSQL_ROW row;
|
std::cerr << "Error in GetGMSpeed query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT gmspeed FROM account where id='%i'", account_id), errbuf, &result)) {
|
return 0;
|
||||||
safe_delete_array(query);
|
|
||||||
if (mysql_num_rows(result) == 1)
|
|
||||||
{
|
|
||||||
row = mysql_fetch_row(result);
|
|
||||||
uint8 gmspeed = atoi(row[0]);
|
|
||||||
mysql_free_result(result);
|
|
||||||
return gmspeed;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mysql_free_result(result);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
mysql_free_result(result);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
std::cerr << "Error in GetGMSpeed query '" << query << "' " << errbuf << std::endl;
|
|
||||||
safe_delete_array(query);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
if (results.RowCount() != 1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
|
||||||
|
return atoi(row[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SharedDatabase::SetGMSpeed(uint32 account_id, uint8 gmspeed)
|
bool SharedDatabase::SetGMSpeed(uint32 account_id, uint8 gmspeed)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user