mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-23 19:02:25 +00:00
GetSharedPlatinum converted to QueryDatabase
This commit is contained in:
parent
a3347579e6
commit
cbce5e5eb6
@ -318,34 +318,19 @@ bool SharedDatabase::DeleteSharedBankSlot(uint32 char_id, int16 slot_id) {
|
|||||||
|
|
||||||
int32 SharedDatabase::GetSharedPlatinum(uint32 account_id)
|
int32 SharedDatabase::GetSharedPlatinum(uint32 account_id)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string query = StringFormat("SELECT sharedplat 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 GetSharedPlatinum query '" << query << "' " << results.ErrorMessage().c_str() << std::endl;
|
||||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT sharedplat FROM account WHERE id='%i'", account_id), errbuf, &result)) {
|
|
||||||
safe_delete_array(query);
|
|
||||||
if (mysql_num_rows(result) == 1)
|
|
||||||
{
|
|
||||||
row = mysql_fetch_row(result);
|
|
||||||
uint32 shared_platinum = atoi(row[0]);
|
|
||||||
mysql_free_result(result);
|
|
||||||
return shared_platinum;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mysql_free_result(result);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
mysql_free_result(result);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cerr << "Error in GetSharedPlatinum query '" << query << "' " << errbuf << std::endl;
|
|
||||||
safe_delete_array(query);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
if (results.RowCount() != 1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
|
||||||
|
return atoi(row[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SharedDatabase::SetSharedPlatinum(uint32 account_id, int32 amount_to_add) {
|
bool SharedDatabase::SetSharedPlatinum(uint32 account_id, int32 amount_to_add) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user