]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/main.qc
Register the ranking cvar in CSQC so it has a default value on older clients
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / main.qc
index 863905a3d32fd4fb5ec1b4c9ae9e2d2dbf45df31..b61f425aa6da44b8d9d4f073a7929275f54a5685 100644 (file)
@@ -140,6 +140,11 @@ void CSQC_Init()
 
        registercvar("cl_spawn_near_teammate", "1");
 
+       registercvar("cl_weapon_switch_reload", "1");
+       registercvar("cl_weapon_switch_fallback_to_impulse", "1");
+
+       registercvar("cl_allow_uidranking", "1");
+
        if(autocvar_cl_lockview)
                cvar_set("cl_lockview", "0");
 
@@ -223,12 +228,16 @@ void Shutdown()
 
        localcmd("\ncl_hook_shutdown\n");
 
+       localcmd("\n-button12\n");
+
        deactivate_minigame();
        HUD_MinigameMenu_Close(NULL, NULL, NULL);
+
+       ReplicateVars(true); // destroy
 }
 
 .float has_team;
-float SetTeam(entity o, int Team)
+bool SetTeam(entity o, int Team)
 {
        TC(int, Team);
        devassert_once(Team);
@@ -303,7 +312,7 @@ float SetTeam(entity o, int Team)
 
 void Playerchecker_Think(entity this)
 {
-    int i;
+       int i;
        entity e;
        for(i = 0; i < maxclients; ++i)
        {
@@ -363,20 +372,21 @@ void PostInit()
 // In the case of mouse input after a setcursormode(1) call, nPrimary is xpos, nSecondary is ypos.
 float CSQC_InputEvent(int bInputType, float nPrimary, float nSecondary)
 {
-    TC(int, bInputType);
-       if (HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary))
+       TC(int, bInputType);
+       bool override = false;
+       override |= HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary);
+       if (override)
                return true;
 
-       if (QuickMenu_InputEvent(bInputType, nPrimary, nSecondary))
-               return true;
+       override |= QuickMenu_InputEvent(bInputType, nPrimary, nSecondary);
 
-       if (HUD_Radar_InputEvent(bInputType, nPrimary, nSecondary))
-               return true;
+       override |= HUD_Radar_InputEvent(bInputType, nPrimary, nSecondary);
 
-       if (MapVote_InputEvent(bInputType, nPrimary, nSecondary))
-               return true;
+       override |= MapVote_InputEvent(bInputType, nPrimary, nSecondary);
+
+       override |= HUD_Minigame_InputEvent(bInputType, nPrimary, nSecondary);
 
-       if (HUD_Minigame_InputEvent(bInputType, nPrimary, nSecondary))
+       if(override)
                return true;
 
        return false;
@@ -528,6 +538,7 @@ NET_HANDLE(ENT_CLIENT_CLIENTDATA, bool isnew)
                race_laptime = 0;
                race_checkpointtime = 0;
                hud_dynamic_shake_factor = -1;
+               spectatee_status_changed_time = time;
        }
        if (autocvar_hud_panel_healtharmor_progressbar_gfx)
        {
@@ -577,14 +588,14 @@ NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew)
        {
                for(j = 0; j < maxclients; ++j)
                        if(playerslots[j])
-                               playerslots[j].ready = 1;
+                               playerslots[j].ready = true;
                for(i = 1; i <= maxclients; i += 8)
                {
                        f = ReadByte();
                        for(j = i-1, b = BIT(0); b < BIT(8); b <<= 1, ++j)
                                if (!(f & b))
                                        if(playerslots[j])
-                                               playerslots[j].ready = 0;
+                                               playerslots[j].ready = false;
                }
        }
 
@@ -605,7 +616,7 @@ NET_HANDLE(ENT_CLIENT_ELIMINATEDPLAYERS, bool isnew)
        if (sf & 1) {
                for (int j = 0; j < maxclients; ++j) {
                        if (playerslots[j]) {
-                               playerslots[j].eliminated = 1;
+                               playerslots[j].eliminated = true;
                        }
                }
                for (int i = 1; i <= maxclients; i += 8) {
@@ -615,7 +626,7 @@ NET_HANDLE(ENT_CLIENT_ELIMINATEDPLAYERS, bool isnew)
                                if (f & BIT(b)) continue;
                                int j = i - 1 + b;
                                if (playerslots[j]) {
-                                       playerslots[j].eliminated = 0;
+                                       playerslots[j].eliminated = false;
                                }
                        }
                }
@@ -794,7 +805,7 @@ NET_HANDLE(ENT_CLIENT_SPAWNEVENT, bool is_new)
 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
 void CSQC_Ent_Update(entity this, bool isnew)
 {
-       this.sourceLoc = __FILE__ ":" STR(__LINE__);
+       this.sourceLoc = __FILE__":"STR(__LINE__);
        int t = ReadByte();
 
        // set up the "time" global for received entities to be correct for interpolation purposes
@@ -1114,17 +1125,15 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew)
                        break;
 
                case RACE_NET_PENALTY_RACE:
-                       race_penaltyeventtime = time;
-                       race_penaltytime = ReadShort();
-                       //race_penaltyaccumulator += race_penaltytime;
-                       strcpy(race_penaltyreason, ReadString());
-                       break;
-
                case RACE_NET_PENALTY_QUALIFYING:
                        race_penaltyeventtime = time;
                        race_penaltytime = ReadShort();
-                       race_penaltyaccumulator += race_penaltytime;
-                       strcpy(race_penaltyreason, ReadString());
+                       string reason = ReadString();
+                       if (reason == "missing a checkpoint")
+                               reason = _("missing a checkpoint");
+                       strcpy(race_penaltyreason, reason);
+                       if (b == RACE_NET_PENALTY_QUALIFYING)
+                               race_penaltyaccumulator += race_penaltytime;
                        break;
 
                case RACE_NET_SERVER_RECORD:
@@ -1145,12 +1154,12 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew)
                        break;
                case RACE_NET_SERVER_RANKINGS:
                        float prevpos, del;
-            int pos = ReadShort();
+                       int pos = ReadShort();
                        prevpos = ReadShort();
                        del = ReadShort();
 
                        // move other rankings out of the way
-            int i;
+                       int i;
                        if (prevpos) {
                                int m = min(prevpos, RANKINGS_DISPLAY_CNT);
                                for (i=m-1; i>pos-1; --i) {
@@ -1254,6 +1263,8 @@ string _getcommandkey(string cmd_name, string command, bool forcename)
                                if(!joy_active && substring(key, 0, 3) == "JOY")
                                        continue;
 
+                               key = translate_key(key);
+
                                if (keys == "")
                                        keys = key;
                                else