GetWaypoints converted to QueryDatabase

This commit is contained in:
Arthur Ice 2014-08-20 14:08:43 -07:00
parent b654729383
commit 5f2db0d1cb

View File

@ -1048,31 +1048,29 @@ uint8 ZoneDatabase::GetGridType2(uint32 grid, uint16 zoneid) {
} }
bool ZoneDatabase::GetWaypoints(uint32 grid, uint16 zoneid, uint32 num, wplist* wp) { bool ZoneDatabase::GetWaypoints(uint32 grid, uint16 zoneid, uint32 num, wplist* wp) {
char *query = 0;
char errbuff[MYSQL_ERRMSG_SIZE]; std::string query = StringFormat("SELECT x, y, z, pause, heading FROM grid_entries "
MYSQL_RES *result; "WHERE gridid = %i AND number = %i AND zoneid = %i", grid, num, zoneid);
MYSQL_ROW row; auto results = QueryDatabase(query);
if (RunQuery(query, MakeAnyLenString(&query,"SELECT x, y, z, pause, heading from grid_entries where gridid = %i and number = %i and zoneid = %i",grid,num,zoneid),errbuff,&result)) { if (!results.Success()) {
safe_delete_array(query); LogFile->write(EQEMuLog::Error, "Error in GetWaypoints query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
if (mysql_num_rows(result) == 1) { return false;
row = mysql_fetch_row(result); }
if ( wp ) {
if (results.RowCount() != 1)
return false;
auto row = results.begin();
if (wp) {
wp->x = atof( row[0] ); wp->x = atof( row[0] );
wp->y = atof( row[1] ); wp->y = atof( row[1] );
wp->z = atof( row[2] ); wp->z = atof( row[2] );
wp->pause = atoi( row[3] ); wp->pause = atoi( row[3] );
wp->heading = atof( row[4] ); wp->heading = atof( row[4] );
} }
mysql_free_result(result);
return true; return true;
}
mysql_free_result(result);
}
else {
LogFile->write(EQEMuLog::Error, "Error in GetWaypoints query '%s': %s", query, errbuff);
safe_delete_array(query);
}
return false;
} }
void ZoneDatabase::AssignGrid(Client *client, float x, float y, uint32 grid) void ZoneDatabase::AssignGrid(Client *client, float x, float y, uint32 grid)