this sounds good idea : more functionnality as no limit to WP count, and space saved as empty WP account for nothing. Using correct indexes could keep overhead to a minimum.
Also, it relieves the error prone 'what value for an empty waypoint ? is it NULL, " ", 0 ?'
unfortunatly, this can not be done without changing the code AFAIK, as you cant retrieve multiple lines data across a single line, what would leave the code untouched (but i may need SQL lessons)
example using a wp table :
create table wp (grid_id int(11),number int(4), x, float, y float, z float);
insert into wp values (1, 1, 7,8, 34.5, -5.0);
insert into wp values (1, 1, 8,9, 21.5, -5.1);
Code:
bool Database::GetWaypoints(int16 grid, int8 num, char* data) {
char *query = 0;
char errbuf[MYSQL_ERRMSG_SIZE];
MYSQL_RES *result;
MYSQL_ROW row;
if (RunQuery(query, MakeAnyLenString(&query,"SELECT type,type2,concat(x," ",y," ",z) from grid where id = %i and grid.id=wp.grid_id and wp.number=%i", grid,num),errbuf,&result)) {
safe_delete_array(query);
if (mysql_num_rows(result) == 1) {
row = mysql_fetch_row(result);
strcpy(data, row[2]);
mysql_free_result(result);
return true;
}
mysql_free_result(result);
}
else {
cerr << "Error in GetWaypoints query '" << query << "' " << errbuf << endl;
safe_delete_array(query);
}
return false;
}
did i get you right ?