]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/g_world.qc
Argh I hate FTEQCC... Fix the bug and recommit from the revert (which was WRONG)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_world.qc
index 17b68d4f405960a0f1fd714a4e6b172fade71c24..224f6ce259763962b12b88230dbe4176eef34d14 100644 (file)
@@ -301,6 +301,7 @@ void cvar_changes_init()
                BADCVAR("g_domination_point_leadlimit");
                BADCVAR("g_forced_respawn");
                BADCVAR("g_keyhunt_point_leadlimit");
+               BADPREFIX("g_mod_");
                BADCVAR("g_nexball_goalleadlimit");
                BADCVAR("g_runematch_point_leadlimit");
                BADCVAR("leadlimit_and_fraglimit");
@@ -308,6 +309,7 @@ void cvar_changes_init()
                BADCVAR("pausable");
                BADCVAR("sv_allow_fullbright");
                BADCVAR("sv_checkforpacketsduringsleep");
+               BADCVAR("sv_fraginfo");
                BADCVAR("sv_timeout");
                BADPREFIX("sv_timeout_");
                BADCVAR("welcome_message_time");
@@ -346,7 +348,8 @@ void cvar_changes_init()
                BADCVAR("gametype");
                BADCVAR("g_antilag");
                BADCVAR("g_balance_teams");
-               BADCVAR("g_balance_teams_force");
+               BADCVAR("g_balance_teams_prevent_imbalance");
+               BADCVAR("g_balance_teams_scorefactor");
                BADCVAR("g_ban_sync_trusted_servers");
                BADCVAR("g_ban_sync_uri");
                BADCVAR("g_ctf_ignore_frags");
@@ -366,7 +369,6 @@ void cvar_changes_init()
                BADCVAR("g_maplist_votable_nodetail");
                BADCVAR("g_maplist_votable_suggestions");
                BADCVAR("g_maxplayers");
-               BADCVAR("g_minstagib");
                BADCVAR("g_mirrordamage");
                BADCVAR("g_nexball_goallimit");
                BADCVAR("g_powerups");
@@ -413,6 +415,11 @@ void cvar_changes_init()
                BADPREFIX("g_warmup_");
                BADPREFIX("sv_ready_restart_");
 
+               // mutators that announce themselves properly to the server browser
+               BADCVAR("g_minstagib");
+               BADCVAR("g_new_toys");
+               BADCVAR("g_nix");
+
                if(autocvar_g_minstagib)
                {
                        BADCVAR("g_grappling_hook");
@@ -632,6 +639,8 @@ void spawnfunc_worldspawn (void)
 
        Map_MarkAsRecent(mapname);
 
+       PlayerStats_Init(); // we need this to be initiated before InitGameplayMode
+
        precache_model ("null"); // we need this one before InitGameplayMode
        InitGameplayMode();
        readlevelcvars();
@@ -762,7 +771,7 @@ void spawnfunc_worldspawn (void)
 
        WeaponStats_Init();
 
-       addstat(STAT_WEAPONS, AS_INT, weapons);
+       WEPSET_ADDSTAT();
        addstat(STAT_SWITCHWEAPON, AS_INT, switchweapon);
        addstat(STAT_SWITCHINGWEAPON, AS_INT, switchingweapon);
        addstat(STAT_GAMESTARTTIME, AS_FLOAT, stat_game_starttime);
@@ -771,6 +780,7 @@ void spawnfunc_worldspawn (void)
 
        addstat(STAT_STRENGTH_FINISHED, AS_FLOAT, strength_finished);
        addstat(STAT_INVINCIBLE_FINISHED, AS_FLOAT, invincible_finished);
+       addstat(STAT_SUPERWEAPONS_FINISHED, AS_FLOAT, superweapons_finished);
        addstat(STAT_PRESSED_KEYS, AS_FLOAT, pressedkeys);
        addstat(STAT_FUEL, AS_INT, ammo_fuel);
        addstat(STAT_SHOTORG, AS_INT, stat_shotorg);
@@ -904,7 +914,27 @@ void spawnfunc_worldspawn (void)
                cvar_set("sv_curl_serverpackages", substring(s, 1, -1));
        }
 
-       PlayerStats_Init();
+       // MOD AUTHORS: change this, and possibly remove a few of the blocks below to ignore certain changes
+       modname = "Xonotic";
+       // physics/balance/config changes that count as mod
+       if(cvar_string("g_mod_physics") != cvar_defstring("g_mod_physics"))
+               modname = cvar_string("g_mod_physics");
+       if(cvar_string("g_mod_balance") != cvar_defstring("g_mod_balance"))
+               modname = cvar_string("g_mod_balance");
+       if(cvar_string("g_mod_config") != cvar_defstring("g_mod_config"))
+               modname = cvar_string("g_mod_config");
+       // weird mutators that deserve to count as mod
+       if(autocvar_g_minstagib)
+               modname = "MinstaGib";
+       // extra mutators that deserve to count as mod
+       MUTATOR_CALLHOOK(SetModname);
+       // weird game types that deserve to count as mod
+       if(g_cts)
+               modname = "CTS";
+       // save it for later
+       modname = strzone(modname);
+
+       WinningConditionHelper(); // set worldstatus
 
        world_initialized = 1;
 }
@@ -1226,7 +1256,7 @@ float DoNextMapOverride(float reinit)
                alreadychangedlevel = TRUE;
                return TRUE;
        }
-       if (autocvar_samelevel) // if samelevel is set, stay on same level
+       if (!reinit && autocvar_samelevel) // if samelevel is set, stay on same level
        {
                localcmd("restart\n");
                alreadychangedlevel = TRUE;
@@ -1240,7 +1270,7 @@ float DoNextMapOverride(float reinit)
                        alreadychangedlevel = TRUE;
                        return TRUE;
                }
-       if(autocvar_lastlevel)
+       if(!reinit && autocvar_lastlevel)
        {
                cvar_settemp_restore();
                localcmd("set lastlevel 0\ntogglemenu 1\n");
@@ -1301,12 +1331,15 @@ float mapvote_initialized;
 void IntermissionThink()
 {
        FixIntermissionClient(self);
-
-       if( (autocvar_sv_autoscreenshot || self.cvar_cl_autoscreenshot)
+       
+       float server_screenshot = (autocvar_sv_autoscreenshot && self.cvar_cl_autoscreenshot);
+       float client_screenshot = (self.cvar_cl_autoscreenshot == 2);
+       
+       if( (server_screenshot || client_screenshot)
                && ((self.autoscreenshot > 0) && (time > self.autoscreenshot)) )
        {
                self.autoscreenshot = -1;
-               if(clienttype(self) == CLIENTTYPE_REAL) { stuffcmd(self, sprintf("\nautoscreenshot \"%s\" \"%s\"\n", GetMapname(), strftime(FALSE, "%s"))); }
+               if(clienttype(self) == CLIENTTYPE_REAL) { stuffcmd(self, sprintf("\nscreenshot screenshots/autoscreenshot/%s-%s.jpg; echo \"^5A screenshot has been taken at request of the server.\"", GetMapname(), strftime(FALSE, "%s"))); }
                return;
        }
 
@@ -1409,6 +1442,8 @@ void DumpStats(float final)
                print(s, "\n");
        if(to_eventlog)
                GameLogEcho(s);
+
+       file = -1;
        if(to_file)
        {
                file = fopen(autocvar_sv_logscores_filename, FILE_APPEND);
@@ -1509,7 +1544,7 @@ void FixIntermissionClient(entity e)
        }
 }
 
-
+void minstagib_stop_countdown(entity e);
 /*
 go to the next level for deathmatch
 only called if a time or frag limit has expired
@@ -1553,6 +1588,7 @@ void NextLevel()
        GameLogClose();
 
        FOR_EACH_PLAYER(other) {
+               minstagib_stop_countdown(other);
                FixIntermissionClient(other);
                if(other.winning)
                        bprint(other.netname, " ^7wins.\n");
@@ -1599,7 +1635,7 @@ float InitiateSuddenDeath()
        // - for this timelimit_overtime needs to be >0 of course
        // - also check the winning condition calculated in the previous frame and only add normal overtime
        //   again, if at the point at which timelimit would be extended again, still no winner was found
-       if ((checkrules_overtimesadded >= 0) && (checkrules_overtimesadded < autocvar_timelimit_overtimes) && autocvar_timelimit_overtime && !(g_race && !g_race_qualifying))
+       if (!autocvar_g_campaign && (checkrules_overtimesadded >= 0) && (checkrules_overtimesadded < autocvar_timelimit_overtimes) && autocvar_timelimit_overtime && !(g_race && !g_race_qualifying))
        {
                return 1; // need to call InitiateOvertime later
        }
@@ -1607,7 +1643,10 @@ float InitiateSuddenDeath()
        {
                if(!checkrules_suddendeathend)
                {
-                       checkrules_suddendeathend = time + 60 * autocvar_timelimit_suddendeath;
+                       if(autocvar_g_campaign)
+                               checkrules_suddendeathend = time; // no suddendeath in campaign
+                       else
+                               checkrules_suddendeathend = time + 60 * autocvar_timelimit_suddendeath;
                        if(g_race && !g_race_qualifying)
                                race_StartCompleting();
                }
@@ -1941,6 +1980,9 @@ float WinningCondition_Scores(float limit, float leadlimit)
                        limitreached = (limitreached || leadlimitreached);
        }
 
+       if(limit)
+               game_completion_ratio = max(game_completion_ratio, bound(0, WinningConditionHelper_topscore / limit, 1));
+
        return GetWinningCode(
                WinningConditionHelper_topscore && limitreached,
                WinningConditionHelper_equality
@@ -2036,10 +2078,14 @@ float WinningCondition_RanOutOfSpawns()
        else if(team1_score + team2_score + team3_score + team4_score == 1)
        {
                float t, i;
-               if(team1_score) t = COLOR_TEAM1;
-               if(team2_score) t = COLOR_TEAM2;
-               if(team3_score) t = COLOR_TEAM3;
-               if(team4_score) t = COLOR_TEAM4;
+               if(team1_score)
+                       t = COLOR_TEAM1;
+               else if(team2_score)
+                       t = COLOR_TEAM2;
+               else if(team3_score)
+                       t = COLOR_TEAM3;
+               else // if(team4_score)
+                       t = COLOR_TEAM4;
                CheckAllowedTeams(world);
                for(i = 0; i < MAX_TEAMSCORE; ++i)
                {
@@ -2108,9 +2154,6 @@ void CheckRules_World()
                leadlimit = 0; // no leadlimit for now
        }
 
-       if(g_onslaught)
-               timelimit = 0; // ONS has its own overtime rule
-
        if(timelimit > 0)
        {
                timelimit += game_starttime;
@@ -2122,9 +2165,17 @@ void CheckRules_World()
                return;
        }
 
+       if(g_onslaught)
+               timelimit = 0; // ONS has its own overtime rule
+
        float wantovertime;
        wantovertime = 0;
 
+       if(timelimit > game_starttime)
+               game_completion_ratio = (time - game_starttime) / (timelimit - game_starttime);
+       else
+               game_completion_ratio = 0;
+
        if(checkrules_suddendeathend)
        {
                if(!checkrules_suddendeathwarning)
@@ -2327,6 +2378,7 @@ void MapVote_AddVotable(string nextMap, float isSuggestion)
        mapvote_maps[mapvote_count] = strzone(nextMap);
        mapvote_maps_suggested[mapvote_count] = isSuggestion;
 
+       pakfile = string_null;
        for(i = 0; i < mapvote_screenshot_dirs_count; ++i)
        {
                mapfile = strcat(mapvote_screenshot_dirs[i], "/", mapvote_maps[i]);
@@ -2832,11 +2884,12 @@ float RedirectionThink()
        clients_found = 0;
        FOR_EACH_REALCLIENT(self)
        {
+               // TODO add timer
                print("Redirecting: sending connect command to ", self.netname, "\n");
                if(redirection_target == "self")
-                       stuffcmd(self, "\ndisconnect; reconnect\n");
+                       stuffcmd(self, "\ndisconnect; defer ", ftos(autocvar_quit_and_redirect_timer), " reconnect\n");
                else
-                       stuffcmd(self, strcat("\ndisconnect; connect ", redirection_target, "\n"));
+                       stuffcmd(self, strcat("\ndisconnect; defer ", ftos(autocvar_quit_and_redirect_timer), " \"connect ", redirection_target, "\"\n"));
                ++clients_found;
        }