X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fg_world.qc;h=a613edc14c7861581e16833dc0278413caf96f68;hb=93d199789e02f894ce801e815810d706d909a93d;hp=64aa03b5026d5b62f0e24df6fc731389a8b637e9;hpb=98b2c4213abe04f3ec96a95471ba5fe5fe57e008;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 64aa03b50..a613edc14 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(); @@ -253,6 +249,7 @@ void cvar_changes_init() // these can contain player IDs, so better hide BADPREFIX("g_forced_team_"); BADCVAR("sv_muteban_list"); + BADCVAR("sv_voteban_list"); BADCVAR("sv_allow_customplayermodels_idlist"); BADCVAR("sv_allow_customplayermodels_speciallist"); @@ -521,7 +518,7 @@ void detect_maptype() o.y += random() * (world.maxs.y - world.mins.y); o.z += random() * (world.maxs.z - world.mins.z); - tracebox(o, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), o - '0 0 32768', MOVE_WORLDONLY, NULL); + tracebox(o, STAT(PL_MIN), STAT(PL_MAX), o - '0 0 32768', MOVE_WORLDONLY, NULL); if(trace_fraction == 1) continue; @@ -580,7 +577,15 @@ spawnfunc(__init_dedicated_server) e = new(info_player_deathmatch); // safeguard against player joining - this.classname = "worldspawn"; // safeguard against various stuff ;) + // assign reflectively to avoid "assignment to world" warning + for (int i = 0, n = numentityfields(); i < n; ++i) { + string k = entityfieldname(i); + if (k == "classname") { + // safeguard against various stuff ;) + putentityfieldstring(i, this, "worldspawn"); + break; + } + } // needs to be done so early because of the constants they create static_init(); @@ -597,6 +602,14 @@ void __init_dedicated_server_shutdown() { MapInfo_Shutdown(); } +STATIC_INIT_EARLY(maxclients) +{ + maxclients = 0; + for (entity head = nextent(NULL); head; head = nextent(head)) { + ++maxclients; + } +} + void Map_MarkAsRecent(string m); float world_already_spawned; void Nagger_Init(); @@ -680,12 +693,6 @@ spawnfunc(worldspawn) cvar_changes_init(); // do this very early now so it REALLY matches the server config - maxclients = 0; - for (entity head = nextent(NULL); head; head = nextent(head)) - { - ++maxclients; - } - // needs to be done so early because of the constants they create static_init(); @@ -936,6 +943,7 @@ spawnfunc(worldspawn) WinningConditionHelper(this); // set worldstatus world_initialized = 1; + __spawnfunc_spawn_all(); } spawnfunc(light) @@ -979,45 +987,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; } @@ -1190,9 +1196,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 } @@ -2058,12 +2062,12 @@ void EndFrame() FOREACH_CLIENT(IS_REAL_CLIENT(it), { entity e = IS_SPEC(it) ? it.enemy : it; if (e.typehitsound) { - it.typehit_time = time; + STAT(TYPEHIT_TIME, it) = time; } else if (e.killsound) { - it.kill_time = time; + STAT(KILL_TIME, it) = time; } else if (e.damage_dealt) { - it.hit_time = time; - it.damage_dealt_total += ceil(e.damage_dealt); + STAT(HIT_TIME, it) = time; + STAT(DAMAGE_DEALT_TOTAL, it) += ceil(e.damage_dealt); } }); // add 1 frametime because after this, engine SV_Physics @@ -2082,6 +2086,10 @@ void EndFrame() { antilag_record(it, it, altime); }); + IL_EACH(g_projectiles, it.classname == "nade", + { + antilag_record(it, it, altime); + }); systems_update(); IL_ENDFRAME(); }