From 74d3192c2e8c9b8023a3fd7612c687be16be1fc5 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 19:46:23 -0700 Subject: [PATCH] NoRentExpired converted to QueryDatabase --- zone/zonedb.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index cf60969ea..f51074396 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -918,20 +918,19 @@ bool ZoneDatabase::GetCharacterInfoForLogin_result(MYSQL_RES* result, } bool ZoneDatabase::NoRentExpired(const char* name){ - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - if (RunQuery(query, MakeAnyLenString(&query, "Select (UNIX_TIMESTAMP(NOW())-timelaston) from character_ where name='%s'", name), errbuf, &result)) { - safe_delete_array(query); - if (mysql_num_rows(result) == 1) { - row = mysql_fetch_row(result); - uint32 seconds = atoi(row[0]); - mysql_free_result(result); - return (seconds>1800); - } - } - return false; + std::string query = StringFormat("SELECT (UNIX_TIMESTAMP(NOW())-timelaston) " + "FROM character_ WHERE name = '%s'", name); + auto results = QueryDatabase(query); + if (!results.Success()) + return false; + + if (results.RowCount() != 1) + return false; + + auto row = results.begin(); + uint32 seconds = atoi(row[0]); + + return (seconds>1800); } /* Searches npctable for matching id, and returns the item if found,