GetLootDropInfo converted to QueryDatabase

This commit is contained in:
Arthur Ice 2014-10-04 14:20:46 -07:00
parent 81b9d9a57e
commit aa9601352d

View File

@ -1707,42 +1707,43 @@ void SharedDatabase::GetLootTableInfo(uint32 &loot_table_count, uint32 &max_loot
loot_table_count = 0; loot_table_count = 0;
max_loot_table = 0; max_loot_table = 0;
loot_table_entries = 0; loot_table_entries = 0;
const char *query = "SELECT COUNT(*), MAX(id), (SELECT COUNT(*) FROM loottable_entries) FROM loottable"; const std::string query = "SELECT COUNT(*), MAX(id), (SELECT COUNT(*) FROM loottable_entries) FROM loottable";
char errbuf[MYSQL_ERRMSG_SIZE]; auto results = QueryDatabase(query);
MYSQL_RES *result; if (!results.Success()) {
MYSQL_ROW row; LogFile->write(EQEMuLog::Error, "Error getting loot table info from database: %s, %s", query.c_str(), results.ErrorMessage().c_str());
return;
}
if(RunQuery(query, strlen(query), errbuf, &result)) { if (results.RowCount() == 0)
if(row = mysql_fetch_row(result)) { return;
loot_table_count = static_cast<uint32>(atoul(row[0]));
max_loot_table = static_cast<uint32>(atoul(row[1])); auto row = results.begin();
loot_table_entries = static_cast<uint32>(atoul(row[2]));
} loot_table_count = static_cast<uint32>(atoul(row[0]));
mysql_free_result(result); max_loot_table = static_cast<uint32>(atoul(row[1]));
} else { loot_table_entries = static_cast<uint32>(atoul(row[2]));
LogFile->write(EQEMuLog::Error, "Error getting loot table info from database: %s, %s", query, errbuf);
}
} }
void SharedDatabase::GetLootDropInfo(uint32 &loot_drop_count, uint32 &max_loot_drop, uint32 &loot_drop_entries) { void SharedDatabase::GetLootDropInfo(uint32 &loot_drop_count, uint32 &max_loot_drop, uint32 &loot_drop_entries) {
loot_drop_count = 0; loot_drop_count = 0;
max_loot_drop = 0; max_loot_drop = 0;
loot_drop_entries = 0; loot_drop_entries = 0;
const char *query = "SELECT COUNT(*), MAX(id), (SELECT COUNT(*) FROM lootdrop_entries) FROM lootdrop";
char errbuf[MYSQL_ERRMSG_SIZE];
MYSQL_RES *result;
MYSQL_ROW row;
if(RunQuery(query, strlen(query), errbuf, &result)) { const std::string query = "SELECT COUNT(*), MAX(id), (SELECT COUNT(*) FROM lootdrop_entries) FROM lootdrop";
if(row = mysql_fetch_row(result)) { auto results = QueryDatabase(query);
loot_drop_count = static_cast<uint32>(atoul(row[0])); if (!results.Success()) {
max_loot_drop = static_cast<uint32>(atoul(row[1])); LogFile->write(EQEMuLog::Error, "Error getting loot table info from database: %s, %s", query.c_str(), results.ErrorMessage().c_str());
loot_drop_entries = static_cast<uint32>(atoul(row[2])); return;
} }
mysql_free_result(result);
} else { if (results.RowCount() == 0)
LogFile->write(EQEMuLog::Error, "Error getting loot table info from database: %s, %s", query, errbuf); return;
}
auto row =results.begin();
loot_drop_count = static_cast<uint32>(atoul(row[0]));
max_loot_drop = static_cast<uint32>(atoul(row[1]));
loot_drop_entries = static_cast<uint32>(atoul(row[2]));
} }
void SharedDatabase::LoadLootTables(void *data, uint32 size) { void SharedDatabase::LoadLootTables(void *data, uint32 size) {