X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fg_world.qc;h=b9c62643163739a9badeb1d2390a458c543c8a28;hp=16303bd39f8a1092df21f37ef3bda62a8b950408;hb=3cfa3eaf6856fe76f7fd8c945fbfab2e9e28014c;hpb=6e4c0c69ce16c05cdc8ce97c5287c848acfc3b1f diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 16303bd39..b9c626431 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -145,12 +145,8 @@ void cvar_changes_init() string k, v, d; float n, i, adding, pureadding; - if(cvar_changes) - strunzone(cvar_changes); - cvar_changes = string_null; - if(cvar_purechanges) - strunzone(cvar_purechanges); - cvar_purechanges = string_null; + strfree(cvar_changes); + strfree(cvar_purechanges); cvar_purechanges_count = 0; h = buf_create(); @@ -990,45 +986,43 @@ float GetMaplistPosition() return idx; } -float MapHasRightSize(string map) +bool MapHasRightSize(string map) { - float fh; if(currentbots || autocvar_bot_number || player_count < autocvar_minplayers) if(autocvar_g_maplist_check_waypoints) { - LOG_TRACE("checkwp "); LOG_TRACE(map); + string checkwp_msg = strcat("checkwp ", map); if(!fexists(strcat("maps/", map, ".waypoints"))) { - LOG_TRACE(": no waypoints"); + LOG_TRACE(checkwp_msg, ": no waypoints"); return false; } - LOG_TRACE(": has waypoints"); + LOG_TRACE(checkwp_msg, ": has waypoints"); } // open map size restriction file - LOG_TRACE("opensize "); LOG_TRACE(map); - fh = fopen(strcat("maps/", map, ".sizes"), FILE_READ); + string opensize_msg = strcat("opensize ", map); + float fh = fopen(strcat("maps/", map, ".sizes"), FILE_READ); if(fh >= 0) { - float mapmin, mapmax; - LOG_TRACE(": ok, "); - mapmin = stof(fgets(fh)); - mapmax = stof(fgets(fh)); + opensize_msg = strcat(opensize_msg, ": ok, "); + int mapmin = stoi(fgets(fh)); + int mapmax = stoi(fgets(fh)); fclose(fh); if(player_count < mapmin) { - LOG_TRACE("not enough"); + LOG_TRACE(opensize_msg, "not enough"); return false; } - if(player_count > mapmax) + if(mapmax && player_count > mapmax) { - LOG_TRACE("too many"); + LOG_TRACE(opensize_msg, "too many"); return false; } - LOG_TRACE("right size"); + LOG_TRACE(opensize_msg, "right size"); return true; } - LOG_TRACE(": not found"); + LOG_TRACE(opensize_msg, ": not found"); return true; } @@ -1201,9 +1195,7 @@ void Maplist_Init() error("empty maplist, cannot select a new map"); Map_Current = bound(0, GetMaplistPosition(), Map_Count - 1); - if(Map_Current_Name) - strunzone(Map_Current_Name); - Map_Current_Name = strzone(argv(Map_Current)); // will be automatically freed on exit thanks to DP + strcpy(Map_Current_Name, argv(Map_Current)); // will be automatically freed on exit thanks to DP // this may or may not be correct, but who cares, in the worst case a map // isn't chosen in the first pass that should have been }