]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/g_world.qc
beginning of "pure server" checking... the rule is simple: only settings in the offic...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_world.qc
index 90a1e744f923a1701da7d93c1eef474c4ad5d199..061b4a11740922b3bcb96662a77455d5502c01db 100644 (file)
@@ -213,16 +213,23 @@ void cvar_changes_init()
 {
        float h;
        string k, v, d;
-       float n, i;
+       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;
+       cvar_purechanges_count = 0;
 
        h = buf_create();
        buf_cvarlist(h, "", "_"); // exclude all _ cvars as they are temporary
        n = buf_getsize(h);
 
+       adding = TRUE;
+       pureadding = TRUE;
+
        for(i = 0; i < n; ++i)
        {
                k = bufstr_get(h, i);
@@ -236,6 +243,7 @@ void cvar_changes_init()
                BADCVAR("g_configversion");
                BADCVAR("g_maplist_index");
                BADCVAR("halflifebsp");
+               BADPREFIX("sv_world");
 
                // client
                BADPREFIX("cl_");
@@ -279,6 +287,9 @@ void cvar_changes_init()
                BADCVAR("sys_colortranslation");
                BADCVAR("sys_specialcharactertranslation");
                BADCVAR("timestamps");
+               BADCVAR("net_address");
+               BADCVAR("net_address_ipv6");
+               BADPREFIX("sv_weaponstats_");
 
                // mapinfo
                BADCVAR("timelimit");
@@ -304,27 +315,128 @@ void cvar_changes_init()
                BADCVAR("g_maplist");
                BADCVAR("g_maplist_mostrecent");
                BADCVAR("sv_motd");
-#undef BADPREFIX
-#undef BADCVAR
 
                v = cvar_string(k);
                d = cvar_defstring(k);
-               if(v != d)
+               if(v == d)
+                       continue;
+
+               if(adding)
                {
                        cvar_changes = strcat(cvar_changes, k, " \"", v, "\" // \"", d, "\"\n");
                        if(strlen(cvar_changes) > 16384)
                        {
                                cvar_changes = "// too many settings have been changed to show them here\n";
-                               break;
+                               adding = 0;
                        }
                }
+
+               // now check if the changes are actually gameplay relevant
+
+               // does nothing visible
+               BADPREFIX("prvm_");
+               BADCVAR("bot_prefix");
+               BADCVAR("bot_suffix");
+
+               // allowed changes to server admins (please sync this to server.cfg)
+               // vi commands:
+               //   :g!,^\/\/[^ /],d
+               //   :%s,//\([^ ]*\).*,BADCVAR("\1");,
+               //   :%!sort
+               // yes, this does contain some redundant stuff, don't really care
+               BADCVAR("bot_number");
+               BADCVAR("bot_prefix");
+               BADCVAR("bot_suffix");
+               BADCVAR("capturelimit_override");
+               BADCVAR("fraglimit_override");
+               BADCVAR("gametype");
+               BADCVAR("g_antilag");
+               BADCVAR("g_balance_teams");
+               BADCVAR("g_balance_teams_force");
+               BADCVAR("g_ban_sync_trusted_servers");
+               BADCVAR("g_ban_sync_uri");
+               BADCVAR("g_cloaked");
+               BADCVAR("g_ctf_capture_limit");
+               BADCVAR("g_ctf_ignore_frags");
+               BADCVAR("g_ctf_win_mode");
+               BADCVAR("g_domination_point_limit");
+               BADCVAR("g_footsteps");
+               BADCVAR("g_fullbrightitems");
+               BADCVAR("g_fullbrightplayers");
+               BADCVAR("g_grappling_hook");
+               BADCVAR("g_keyhunt_point_limit");
+               BADCVAR("g_keyhunt_teams_override");
+               BADCVAR("g_laserguided_missile");
+               BADCVAR("g_lms_lives_override");
+               BADCVAR("g_maplist");
+               BADCVAR("g_maplist_check_waypoints");
+               BADCVAR("g_maplist_mostrecent_count");
+               BADCVAR("g_maplist_shuffle");
+               BADCVAR("g_maplist_votable");
+               BADCVAR("g_maplist_votable_abstain");
+               BADCVAR("g_maplist_votable_nodetail");
+               BADCVAR("g_maplist_votable_suggestions");
+               BADCVAR("g_midair");
+               BADCVAR("g_minstagib");
+               BADCVAR("g_nexball_goallimit");
+               BADCVAR("g_nixnex");
+               BADCVAR("g_nixnex_with_laser");
+               BADCVAR("g_runematch_point_limit");
+               BADCVAR("g_vampire");
+               BADCVAR("hostname");
+               BADCVAR("log_file");
+               BADCVAR("maxplayers");
+               BADCVAR("minplayers");
+               BADCVAR("net_address");
+               BADCVAR("port");
+               BADCVAR("rcon_password");
+               BADCVAR("rcon_restricted_commands");
+               BADCVAR("rcon_restricted_password");
+               BADCVAR("skill");
+               BADCVAR("sv_autoscreenshot");
+               BADCVAR("sv_curl_defaulturl");
+               BADCVAR("sv_defaultcharacter");
+               BADCVAR("sv_defaultplayermodel");
+               BADCVAR("sv_defaultplayerskin");
+               BADCVAR("sv_gravity");
+               BADCVAR("sv_maxrate");
+               BADCVAR("sv_motd");
+               BADCVAR("sv_public");
+               BADCVAR("sv_ready_restart");
+               BADCVAR("sv_status_privacy");
+               BADCVAR("sv_vote_call");
+               BADCVAR("sv_vote_commands");
+               BADCVAR("sv_vote_majority_factor");
+               BADCVAR("sv_vote_master");
+               BADCVAR("sv_vote_master_commands");
+               BADCVAR("sv_vote_master_password");
+               BADCVAR("sv_vote_simple_majority_factor");
+               BADCVAR("timelimit_override");
+#undef BADPREFIX
+#undef BADCVAR
+
+               if(pureadding)
+               {
+                       cvar_purechanges = strcat(cvar_purechanges, k, " \"", v, "\" // \"", d, "\"\n");
+                       if(strlen(cvar_purechanges) > 16384)
+                       {
+                               cvar_purechanges = "// too many settings have been changed to show them here\n";
+                               pureadding = 0;
+                       }
+               }
+               ++cvar_purechanges_count;
        }
        buf_del(h);
        if(cvar_changes == "")
-               cvar_changes = "// this server runs at default settings\n";
+               cvar_changes = "// this server runs at default server settings\n";
        else
-               cvar_changes = strcat("// this server runs at modified settings:\n", cvar_changes);
+               cvar_changes = strcat("// this server runs at modified server settings:\n", cvar_changes);
        cvar_changes = strzone(cvar_changes);
+       if(cvar_purechanges == "")
+               cvar_purechanges = "// this server runs at default gameplay settings\n";
+       else
+               cvar_purechanges = strcat("// this server runs at modified gameplay settings:\n", cvar_purechanges);
+       cvar_purechanges = strzone(cvar_purechanges);
 }
 
 void detect_maptype()
@@ -435,8 +547,12 @@ void spawnfunc_worldspawn (void)
 
        check_unacceptable_compiler_bugs();
 
+       cvar_changes_init(); // do this very early now so it REALLY matches the server config
+
        compressShortVector_init();
 
+       allowed_to_spawn = TRUE;
+
        local entity head;
        head = nextent(world);
        maxclients = 0;
@@ -512,6 +628,8 @@ void spawnfunc_worldspawn (void)
        InitGameplayMode();
        readlevelcvars();
        GrappleHookInit();
+       ElectroInit();
+       LaserInit();
 
        player_count = 0;
        bot_waypoints_for_items = cvar("g_waypoints_for_items");
@@ -634,14 +752,21 @@ void spawnfunc_worldspawn (void)
        addstat(STAT_SHOTORG, AS_INT, stat_shotorg);
        addstat(STAT_LEADLIMIT, AS_FLOAT, stat_leadlimit);
        addstat(STAT_BULLETS_LOADED, AS_INT, campingrifle_bulletcounter);
+       addstat(STAT_LAST_PICKUP, AS_FLOAT, last_pickup);
 
+       addstat(STAT_NEX_CHARGE, AS_FLOAT, nex_charge);
+
+       if(g_ca)
+       {
+               addstat(STAT_REDALIVE, AS_INT, redalive_stat);
+               addstat(STAT_BLUEALIVE, AS_INT, bluealive_stat);
+       }
        // g_movementspeed hack
        addstat(STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW, AS_FLOAT, stat_sv_airspeedlimit_nonqw);
        addstat(STAT_MOVEVARS_AIRACCEL_QW, AS_FLOAT, stat_sv_airaccel_qw);
        addstat(STAT_MOVEVARS_AIRSTRAFEACCEL_QW, AS_FLOAT, stat_sv_airstrafeaccel_qw);
 
        next_pingtime = time + 5;
-       InitializeEntity(self, cvar_changes_init, INITPRIO_CVARS);
 
        detect_maptype();
 
@@ -699,7 +824,22 @@ void spawnfunc_worldspawn (void)
 
        CheatInit();
 
-       localcmd("\n_sv_hook_gamestart ", GetGametype(), ";");
+       localcmd("\n_sv_hook_gamestart ", GetGametype(), "\n");
+
+       // fill sv_curl_serverpackages from .serverpackage files
+       if(cvar("sv_curl_serverpackages_auto"))
+       {
+               fd = search_begin("*.serverpackage", TRUE, FALSE);
+               s = "";
+               if(fd >= 0)
+               {
+                       j = search_getsize(fd);
+                       for(i = 0; i < j; ++i)
+                               s = strcat(s, " ", search_getfilename(fd, i));
+                       search_end(fd);
+               }
+               cvar_set("sv_curl_serverpackages", substring(s, 1, -1));
+       }
 
        world_initialized = 1;
 }
@@ -1427,7 +1567,7 @@ void NextLevel()
        if(cvar("g_campaign"))
                CampaignPreIntermission();
 
-       localcmd("\nsv_hook_gameend;");
+       localcmd("\nsv_hook_gameend\n");
 }
 
 /*
@@ -1507,16 +1647,23 @@ void InitiateOvertime() // ONLY call this if InitiateSuddenDeath returned true
 
 float GetWinningCode(float fraglimitreached, float equality)
 {
-       if(equality)
-               if(fraglimitreached)
-                       return WINNING_STARTSUDDENDEATHOVERTIME;
-               else
-                       return WINNING_NEVER;
-       else
+       if(cvar("g_campaign") == 1)
                if(fraglimitreached)
                        return WINNING_YES;
                else
                        return WINNING_NO;
+
+       else
+               if(equality)
+                       if(fraglimitreached)
+                               return WINNING_STARTSUDDENDEATHOVERTIME;
+                       else
+                               return WINNING_NEVER;
+               else
+                       if(fraglimitreached)
+                               return WINNING_YES;
+                       else
+                               return WINNING_NO;
 }
 
 // set the .winning flag for exactly those players with a given field value
@@ -1635,7 +1782,7 @@ float WinningCondition_Assault()
 
                        TeamScore_AddToTeam(assault_attacker_team, ST_ASSAULT_OBJECTIVES, 666 - TeamScore_AddToTeam(assault_attacker_team, ST_ASSAULT_OBJECTIVES, 0));
 
-                       if(ent.cnt == 1) // this was the second round
+                       if(ent.cnt == 1 || cvar("g_campaign")) // this was the second round
                        {
                                status = WINNING_YES;
                        }
@@ -2744,9 +2891,19 @@ void SV_Shutdown()
                print("Saving persistent data...\n");
                Ban_SaveBans();
                if(!cheatcount_total)
-                       db_save(ServerProgsDB, "server.db");
+               {
+                       if(cvar("sv_db_saveasdump"))
+                               db_dump(ServerProgsDB, "server.db");
+                       else
+                               db_save(ServerProgsDB, "server.db");
+               }
                if(cvar("developer"))
-                       db_save(TemporaryDB, "server-temp.db");
+               {
+                       if(cvar("sv_db_saveasdump"))
+                               db_dump(TemporaryDB, "server-temp.db");
+                       else
+                               db_save(TemporaryDB, "server-temp.db");
+               }
                CheatShutdown(); // must be after cheatcount check
                db_close(ServerProgsDB);
                db_close(TemporaryDB);