From 8d909ea8e279faa5abd652a3f049daac0a2e3ebb Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 17:58:51 -0700 Subject: [PATCH] LoadByGlobalContext converted to QueryDatabase --- zone/QGlobals.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/zone/QGlobals.cpp b/zone/QGlobals.cpp index 24fd4119c..7bd09d8f7 100644 --- a/zone/QGlobals.cpp +++ b/zone/QGlobals.cpp @@ -177,19 +177,12 @@ void QGlobalCache::LoadByZoneID(uint32 zoneID) void QGlobalCache::LoadByGlobalContext() { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; + std::string query = "SELECT name, charid, npcid, zoneid, value, expdate " + "FROM quest_globals WHERE zoneid = 0 && npcid = 0 && charid = 0"; + auto results = database.QueryDatabase(query); + if (!results.Success()) + return; - if (database.RunQuery(query, MakeAnyLenString(&query, "select name, charid, npcid, zoneid, value, expdate from quest_globals" - " where zoneid = 0 && npcid = 0 && charid = 0"), errbuf, &result)) - { - while((row = mysql_fetch_row(result))) - { - AddGlobal(0, QGlobal(std::string(row[0]), atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5]?atoi(row[5]):0xFFFFFFFF)); - } - mysql_free_result(result); - } - safe_delete_array(query); + for (auto row = results.begin(); row != results.end(); ++row) + AddGlobal(0, QGlobal(std::string(row[0]), atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5]? atoi(row[5]): 0xFFFFFFFF)); }