]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/g_world.qc
try renaming charge_pool to chargepool to make the cvar name a bit shorter
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_world.qc
index ce7b8e2a15720eec91658e0c48b93faf9e832b8b..b898e147b9441d560211dabe48ef38efcee47993 100644 (file)
@@ -272,7 +272,21 @@ void cvar_changes_init()
                BADCVAR("bgmvolume");
 
                // private
+               BADCVAR("developer");
+               BADCVAR("g_banned_list");
+               BADCVAR("log_dest_udp");
+               BADCVAR("log_file");
+               BADCVAR("net_address");
+               BADCVAR("net_address_ipv6");
+               BADCVAR("port");
+               BADCVAR("savedgamecfg");
                BADCVAR("serverconfig");
+               BADCVAR("sv_heartbeatperiod");
+               BADCVAR("sv_vote_master_password");
+               BADCVAR("sys_colortranslation");
+               BADCVAR("sys_specialcharactertranslation");
+               BADCVAR("timestamps");
+               BADPREFIX("developer_");
                BADPREFIX("g_ban_");
                BADPREFIX("g_chat_flood_");
                BADPREFIX("g_voice_flood_");
@@ -284,26 +298,23 @@ void cvar_changes_init()
                BADPREFIX("sv_eventlog");
                BADPREFIX("sv_logscores_");
                BADPREFIX("sv_master");
-               BADCVAR("g_banned_list");
-               BADCVAR("log_dest_udp");
-               BADCVAR("log_file");
-               BADCVAR("net_address");
-               BADCVAR("port");
-               BADCVAR("savedgamecfg");
-               BADCVAR("sv_heartbeatperiod");
-               BADCVAR("sv_vote_master_password");
-               BADCVAR("sys_colortranslation");
-               BADCVAR("sys_specialcharactertranslation");
-               BADCVAR("timestamps");
-               BADCVAR("net_address");
-               BADCVAR("net_address_ipv6");
                BADPREFIX("sv_weaponstats_");
-               BADCVAR("developer");
-               BADPREFIX("developer_");
+
+               // these can contain player IDs, so better hide
+               BADCVAR("g_forced_team_red");
+               BADCVAR("g_forced_team_blue");
+               BADCVAR("g_forced_team_yellow");
+               BADCVAR("g_forced_team_pink");
 
                // mapinfo
                BADCVAR("timelimit");
                BADCVAR("fraglimit");
+               BADCVAR("leadlimit");
+               BADCVAR("g_tdm_teams");
+               BADCVAR("g_keyhunt_teams");
+               BADCVAR("g_domination_default_teams");
+               BADCVAR("g_race_qualifying_timelimit");
+               BADCVAR("g_lms");
                BADCVAR("g_arena");
                BADCVAR("g_ca");
                BADCVAR("g_assault");
@@ -318,6 +329,7 @@ void cvar_changes_init()
                BADCVAR("g_runematch");
                BADCVAR("g_tdm");
                BADCVAR("g_nexball");
+               BADCVAR("g_keepaway");
                BADCVAR("teamplay");
 
                // long
@@ -344,9 +356,21 @@ void cvar_changes_init()
                // now check if the changes are actually gameplay relevant
 
                // does nothing visible
-               BADPREFIX("prvm_");
+               BADCVAR("captureleadlimit_override");
+               BADCVAR("g_arena_point_leadlimit");
+               BADCVAR("g_ca_point_leadlimit");
+               BADCVAR("g_ctf_capture_leadlimit");
+               BADCVAR("g_domination_point_leadlimit");
+               BADCVAR("g_keyhunt_point_leadlimit");
+               BADCVAR("g_nexball_goalleadlimit");
+               BADCVAR("g_runematch_point_leadlimit");
+               BADCVAR("leadlimit_and_fraglimit");
+               BADCVAR("leadlimit_override");
+               BADCVAR("sv_checkforpacketsduringsleep");
                BADPREFIX("crypto_");
                BADPREFIX("g_chat_");
+               BADPREFIX("net_");
+               BADPREFIX("prvm_");
                BADPREFIX("sv_fragmessage_");
                BADPREFIX("sv_vote_");
                BADPREFIX("timelimit_");
@@ -386,6 +410,7 @@ void cvar_changes_init()
                BADCVAR("g_maplist_votable_abstain");
                BADCVAR("g_maplist_votable_nodetail");
                BADCVAR("g_maplist_votable_suggestions");
+               BADCVAR("g_minstagib");
                BADCVAR("g_nexball_goallimit");
                BADCVAR("g_runematch_point_limit");
                BADCVAR("g_start_delay");
@@ -399,13 +424,15 @@ void cvar_changes_init()
                BADCVAR("rcon_restricted_commands");
                BADCVAR("rcon_restricted_password");
                BADCVAR("skill");
+               BADCVAR("sv_adminnick");
                BADCVAR("sv_autoscreenshot");
                BADCVAR("sv_curl_defaulturl");
                BADCVAR("sv_defaultcharacter");
+               BADCVAR("sv_defaultplayercolors");
                BADCVAR("sv_defaultplayermodel");
                BADCVAR("sv_defaultplayerskin");
-               BADCVAR("sv_maxrate");
                BADCVAR("sv_maxidle");
+               BADCVAR("sv_maxrate");
                BADCVAR("sv_motd");
                BADCVAR("sv_public");
                BADCVAR("sv_ready_restart");
@@ -418,6 +445,12 @@ void cvar_changes_init()
                BADCVAR("sv_vote_master_password");
                BADCVAR("sv_vote_simple_majority_factor");
                BADCVAR("timelimit_override");
+
+               if(cvar("g_minstagib"))
+               {
+                       BADCVAR("g_grappling_hook");
+                       BADCVAR("g_jetpack");
+               }
 #undef BADPREFIX
 #undef BADCVAR
 
@@ -431,6 +464,12 @@ void cvar_changes_init()
                        }
                }
                ++cvar_purechanges_count;
+               // WARNING: this variable is used for the server list
+               // NEVER dare to skip this code!
+               // Hacks to intentionally appearing as "pure server" even though you DO have
+               // modified settings may be punished by removal from the server list.
+               // You can do to the variables cvar_changes and cvar_purechanges all you want,
+               // though.
        }
        buf_del(h);
        if(cvar_changes == "")
@@ -575,15 +614,6 @@ void spawnfunc_worldspawn (void)
 
        TemporaryDB = db_create();
 
-       /*
-       TODO sound pack system
-       // initialize sound pack system
-       soundpack = cvar_string("g_soundpack");
-       if(soundpack != "")
-               soundpack = strcat(soundpack, "/");
-       soundpack = strzone(soundpack);
-       */
-
        // 0 normal
        lightstyle(0, "m");
 
@@ -657,7 +687,7 @@ void spawnfunc_worldspawn (void)
        GameLogInit(); // prepare everything
        if(cvar("sv_eventlog"))
        {
-               s = strcat(cvar_string("sv_eventlog_files_counter"), ".");
+               s = strcat(ftos(cvar("sv_eventlog_files_counter")), ".");
                s = strcat(s, ftos(random()));
                matchid = strzone(s);
 
@@ -668,24 +698,34 @@ void spawnfunc_worldspawn (void)
                MUTATOR_CALLHOOK(BuildMutatorsString);
                s = ret_string;
 
+               // simple, probably not good in the mutator system
                if(cvar("g_grappling_hook"))
                        s = strcat(s, ":grappling_hook");
+
+               // initialiation stuff, not good in the mutator system
                if(!cvar("g_use_ammunition"))
                        s = strcat(s, ":no_use_ammunition");
+
+               // initialiation stuff, not good in the mutator system
                if(!cvar("g_pickup_items"))
                        s = strcat(s, ":no_pickup_items");
+
+               // initialiation stuff, not good in the mutator system
                if(cvar_string("g_weaponarena") != "0")
                        s = strcat(s, ":", cvar_string("g_weaponarena"), " arena");
-               if(cvar("g_vampire"))
-                       s = strcat(s, ":vampire");
-               if(cvar("g_laserguided_missile"))
-                       s = strcat(s, ":laserguided_missile");
+
+               // TODO to mutator system
                if(cvar("g_norecoil"))
                        s = strcat(s, ":norecoil");
+
+               // TODO to mutator system
                if(cvar("g_midair"))
                        s = strcat(s, ":midair");
+
+               // TODO to mutator system
                if(cvar("g_minstagib"))
                        s = strcat(s, ":minstagib");
+
                GameLogEcho(s);
                GameLogEcho(":gameinfo:end");
        }
@@ -753,22 +793,30 @@ void spawnfunc_worldspawn (void)
        addstat(STAT_INVINCIBLE_FINISHED, AS_FLOAT, invincible_finished);
        addstat(STAT_PRESSED_KEYS, AS_FLOAT, pressedkeys);
        addstat(STAT_FUEL, AS_INT, ammo_fuel);
-       addstat(STAT_DAMAGE_HITS, AS_INT, stat_hit);
-       addstat(STAT_DAMAGE_FIRED, AS_INT, stat_fired);
        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);
+       addstat(STAT_NEX_CHARGEPOOL, AS_FLOAT, nex_chargepool_ammo);
 
-       if(g_ca)
+       if(g_ca || g_freezetag)
        {
                addstat(STAT_REDALIVE, AS_INT, redalive_stat);
                addstat(STAT_BLUEALIVE, AS_INT, bluealive_stat);
+               addstat(STAT_YELLOWALIVE, AS_INT, yellowalive_stat);
+               addstat(STAT_PINKALIVE, AS_INT, pinkalive_stat);
+       }
+       if(g_freezetag)
+       {
+               addstat(STAT_FROZEN, AS_INT, freezetag_frozen);
+               addstat(STAT_REVIVE_PROGRESS, AS_FLOAT, freezetag_revive_progress);
        }
+
        // g_movementspeed hack
        addstat(STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW, AS_FLOAT, stat_sv_airspeedlimit_nonqw);
+       addstat(STAT_MOVEVARS_MAXSPEED, AS_FLOAT, stat_sv_maxspeed);
        addstat(STAT_MOVEVARS_AIRACCEL_QW, AS_FLOAT, stat_sv_airaccel_qw);
        addstat(STAT_MOVEVARS_AIRSTRAFEACCEL_QW, AS_FLOAT, stat_sv_airstrafeaccel_qw);
 
@@ -849,6 +897,8 @@ void spawnfunc_worldspawn (void)
                cvar_set("sv_curl_serverpackages", substring(s, 1, -1));
        }
 
+       PlayerStats_Init();
+
        world_initialized = 1;
 }
 
@@ -1349,12 +1399,13 @@ RULES
 
 void DumpStats(float final)
 {
-       local float file;
-       local string s;
-       local float to_console;
-       local float to_eventlog;
-       local float to_file;
-       local float i;
+       float file;
+       string s;
+       float to_console;
+       float to_eventlog;
+       float to_file;
+       float i;
+       entity e;
 
        to_console = cvar("sv_logscores_console");
        to_eventlog = cvar("sv_eventlog");
@@ -1449,6 +1500,11 @@ void DumpStats(float final)
                fputs(file, ":end\n");
                fclose(file);
        }
+
+       // send statistics
+       FOR_EACH_CLIENT(e)
+               PlayerStats_AddGlobalInfo(e);
+       PlayerStats_Shutdown();
 }
 
 void FixIntermissionClient(entity e)
@@ -1494,8 +1550,6 @@ only called if a time or frag limit has expired
 */
 void NextLevel()
 {
-       float i;
-
        gameover = TRUE;
 
        intermission_running = 1;
@@ -1524,52 +1578,10 @@ void NextLevel()
 
        GameLogClose();
 
-// TO DO
-
-// save the stats to a text file on the client
-// stuffcmd(other, log_stats "stats/file_name");
-// bprint stats
-// stuffcmd(other, log_stats "");
-// use a filename similar to the demo name
-       // string file_name;
-       // file_name = strcat("\nlog_file \"stats/", strftime(TRUE, "%Y-%m-%d_%H-%M"), "_", mapname, ".txt\"");  // open the log file
-
-// write a stats parser for the menu
-
-       if(cvar("sv_accuracy_data_send")) {
-               string stats_to_send;
-
-               FOR_EACH_CLIENT(other) {  // make the string to send
-                       FixIntermissionClient(other);
-
-                       if(other.cvar_cl_accuracy_data_share) {
-                               stats_to_send = strcat(stats_to_send, ":hits:", other.netname);
-
-                               for(i = WEP_FIRST; i <= WEP_LAST; ++i)
-                                       stats_to_send = strcat(stats_to_send, ":", ftos(other.stats_hit[i-1]));
-
-                               stats_to_send = strcat(stats_to_send, "\n:fired:", other.netname);
-
-                               for(i = WEP_FIRST; i <= WEP_LAST; ++i)
-                                       stats_to_send = strcat(stats_to_send, ":", ftos(other.stats_fired[i-1]));
-
-                               stats_to_send = strcat(stats_to_send, "\n");
-                       }
-               }
-
-               FOR_EACH_REALCLIENT(other) {  // only spam humans
-                       Score_NicePrint(other);  // print the score
-
-                       if(other.cvar_cl_accuracy_data_receive)  // send the stats string to all the willing clients
-                               bprint(stats_to_send);
-               }
-       } else { // ye olde message
-               FOR_EACH_PLAYER(other) {
-                       FixIntermissionClient(other);
-
-                       if(other.winning)
-                               bprint(other.netname, " ^7wins.\n");
-               }
+       FOR_EACH_PLAYER(other) {
+               FixIntermissionClient(other);
+               if(other.winning)
+                       bprint(other.netname, " ^7wins.\n");
        }
 
        if(cvar("g_campaign"))
@@ -2714,6 +2726,10 @@ void MapVote_Start()
        if(mapvote_run)
                return;
 
+       // wait for stats to be sent first
+       if(!playerstats_waitforme)
+               return;
+
        MapInfo_Enumerate();
        if(MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 1))
                mapvote_run = TRUE;
@@ -2888,6 +2904,8 @@ void RestoreGame()
 
 void SV_Shutdown()
 {
+       entity e;
+
        if(gameover > 1) // shutting down already?
                return;
 
@@ -2898,6 +2916,11 @@ void SV_Shutdown()
                world_initialized = 0;
                print("Saving persistent data...\n");
                Ban_SaveBans();
+
+               FOR_EACH_CLIENT(e)
+                       PlayerStats_AddGlobalInfo(e);
+               PlayerStats_Shutdown();
+
                if(!cheatcount_total)
                {
                        if(cvar("sv_db_saveasdump"))