]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/Main.qc
Merge branch 'master' into terencehill/cursormode
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / Main.qc
index 4e54f811c91ef963d7e3351d5d475510441d58b9..2f7eb3d62d1509a76ed4cc771a3b114635bafeba 100644 (file)
@@ -25,24 +25,23 @@ void cvar_clientsettemp_restore()
                        cvar_set(e.netname, e.message);
 }
 
-void() menu_show_error =
+void menu_show_error()
 {
        drawstring('0 200 0', _("ERROR - MENU IS VISIBLE BUT NO MENU WAS DEFINED!"), '8 8 0', '1 0 0', 1, 0);
-};
+}
 
 // CSQC_Init : Called every time the CSQC code is initialized (essentially at map load)
 // Useful for precaching things
 
-void() menu_sub_null =
+void menu_sub_null()
 {
-};
+}
 
 #ifdef USE_FTE
 float __engine_check;
 #endif
 
 string forcefog;
-string cl_announcer_prev;
 void WaypointSprite_Load();
 void CSQC_Init(void)
 {
@@ -83,10 +82,6 @@ void CSQC_Init(void)
                        break;
        maxclients = i;
 
-       //ctf_temp_1 = "";
-       // localcmd("alias order \"cmd order $*\""); enable if ctf-command thingy is used
-       //registercmd("ctf_menu");
-       registercmd("ons_map");
        registercmd("hud_configure");
        registercmd("hud_save");
        //registercmd("menu_action");
@@ -140,18 +135,16 @@ void CSQC_Init(void)
        Casings_Precache();
        DamageInfo_Precache();
        Vehicles_Precache();
-
-       if(autocvar_cl_announcer != cl_announcer_prev) {
-               Announcer_Precache();
-               if(cl_announcer_prev)
-                       strunzone(cl_announcer_prev);
-               cl_announcer_prev = strzone(autocvar_cl_announcer);
-       }
+       turrets_precache();
+  Announcer_Precache();
        Tuba_Precache();
-
-       if(autocvar_cl_reticle_item_normal) precache_pic("gfx/reticle_normal");
-       if(autocvar_cl_reticle_item_nex) precache_pic("gfx/reticle_nex");
-
+       
+       if(autocvar_cl_reticle)
+       {
+               if(autocvar_cl_reticle_item_normal) { precache_pic("gfx/reticle_normal"); }
+               if(autocvar_cl_reticle_item_nex) { precache_pic("gfx/reticle_nex"); }
+       }
+       
        get_mi_min_max_texcoords(1); // try the CLEVER way first
        minimapname = strcat("gfx/", mi_shortname, "_radar.tga");
        shortmapname = mi_shortname;
@@ -353,11 +346,10 @@ float CSQC_ConsoleCommand(string strMessage)
 {
        float argc;
        // Tokenize String
-       //argc = tokenize(strMessage);
        argc = tokenize_console(strMessage);
 
        // Acquire Command
-       local string strCmd;
+       string strCmd;
        strCmd = argv(0);
 
        if(strCmd == "hud_configure") { // config hud
@@ -506,6 +498,13 @@ void GameCommand(string msg)
        if(cmd == "mv_download") {
                Cmd_MapVote_MapDownload(argc);
        }
+       else if(cmd == "hud_panel_radar_maximized")
+       {
+               if(argc == 1)
+                       hud_panel_radar_maximized = !hud_panel_radar_maximized;
+               else
+                       hud_panel_radar_maximized = (stof(argv(1)) != 0);
+       }
        else if(cmd == "settemp") {
                cvar_clientsettemp(argv(1), argv(2));
        }
@@ -594,7 +593,7 @@ void GameCommand(string msg)
         {
             vote_active = 0; // force the panel to disappear right as we have selected the value (to prevent it from fading out in the normal vote panel pos)
             vote_prev = 0;
-            cvar_set("cl_allow_uid2name", "1");
+            localcmd("setreport cl_allow_uid2name 1\n");
             vote_change = -9999;
                        uid2name_dialog = 0;
         }
@@ -609,7 +608,7 @@ void GameCommand(string msg)
         {
             vote_active = 0;
             vote_prev = 0;
-            cvar_set("cl_allow_uid2name", "0");
+            localcmd("setreport cl_allow_uid2name 0\n");
             vote_change = -9999;
                        uid2name_dialog = 0;
         }
@@ -630,12 +629,13 @@ void GameCommand(string msg)
 // CSQC_InputEvent : Used to perform actions based on any key pressed, key released and mouse on the client.
 // Return value should be 1 if CSQC handled the input, otherwise return 0 to have the input passed to the engine.
 // All keys are in ascii.
-// bInputType = 0 is key pressed, 1 is key released, 2 is mouse input.
+// bInputType = 0 is key pressed, 1 is key released, 2 and 3 are mouse input.
 // In the case of keyboard input, nPrimary is the ascii code, and nSecondary is 0.
 // In the case of mouse input, nPrimary is xdelta, nSecondary is ydelta.
+// In the case of mouse input after a setcursormode(1) call, nPrimary is xpos, nSecondary is ypos.
 float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
 {
-       local float bSkipKey;
+       float bSkipKey;
        bSkipKey = false;
 
        if (HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary))
@@ -826,8 +826,6 @@ void Ent_ClientData()
 
        if(newspectatee_status != spectatee_status)
        {
-               float i;
-
                // clear race stuff
                race_laptime = 0;
                race_checkpointtime = 0;
@@ -848,13 +846,26 @@ void Ent_Nagger()
 {
        float nags, i, j, b, f;
 
-       nags = ReadByte();
+       nags = ReadByte(); // NAGS NAGS NAGS NAGS NAGS NAGS NADZ NAGS NAGS NAGS
 
        if(!(nags & 4))
        {
                if(vote_called_vote)
                        strunzone(vote_called_vote);
                vote_called_vote = string_null;
+               vote_active = 0;
+       }
+       else
+       {
+               vote_active = 1;
+       }
+
+       if(nags & 64)
+       {
+               vote_yescount = ReadByte();
+               vote_nocount = ReadByte();
+               vote_needed = ReadByte();
+               vote_highlighted = ReadChar();
        }
 
        if(nags & 128)
@@ -925,7 +936,7 @@ void Ent_ReadAccuracy(void)
 void Ent_RadarLink();
 void Ent_Init();
 void Ent_ScoresInfo();
-void(float bIsNewEntity) CSQC_Ent_Update =
+void CSQC_Ent_Update(float bIsNewEntity)
 {
        float t;
        float savetime;
@@ -946,13 +957,23 @@ void(float bIsNewEntity) CSQC_Ent_Update =
 
 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
        if(self.enttype)
-               if(t != self.enttype)
+       {
+               if(t != self.enttype || bIsNewEntity)
                {
                        //print(_("A CSQC entity changed its type!\n"));
-                       print(sprintf(_("A CSQC entity changed its type! (edict: %d, classname: %s)\n"), num_for_edict(self), self.classname));
+                       print(sprintf(_("A CSQC entity changed its type! (edict: %d, server: %d, type: %d -> %d)\n"), num_for_edict(self), self.entnum, self.enttype, t));
                        Ent_Remove();
                        bIsNewEntity = 1;
                }
+       }
+       else
+       {
+               if(!bIsNewEntity)
+               {
+                       print(sprintf(_("A CSQC entity appeared out of nowhere! (edict: %d, server: %d, type: %d)\n"), num_for_edict(self), self.entnum, t));
+                       bIsNewEntity = 1;
+               }
+       }
 #endif
        self.enttype = t;
        switch(t)
@@ -987,6 +1008,7 @@ void(float bIsNewEntity) CSQC_Ent_Update =
                case ENT_CLIENT_GAUNTLET: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_GAUNTLET); break;
                case ENT_CLIENT_ACCURACY: Ent_ReadAccuracy(); break;
                case ENT_CLIENT_AUXILIARYXHAIR: Net_AuXair2(bIsNewEntity); break;
+               case ENT_CLIENT_TURRET: ent_turret(); break; 
                default:
                        //error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), self.enttype));
                        error(sprintf(_("Unknown entity type in CSQC_Ent_Update (enttype: %d, edict: %d, classname: %s)\n"), self.enttype, num_for_edict(self), self.classname));
@@ -994,7 +1016,7 @@ void(float bIsNewEntity) CSQC_Ent_Update =
        }
 
        time = savetime;
-};
+}
 // Destructor, but does NOT deallocate the entity by calling remove(). Also
 // used when an entity changes its type. For an entity that someone interacts
 // with others, make sure it can no longer do so.
@@ -1300,36 +1322,6 @@ void Net_ReadPingPLReport()
        playerslots[e].ping_movementloss = ml / 255.0;
 }
 
-void Net_VoteDialog(float highlight) {
-       if(highlight) {
-               vote_highlighted = ReadByte();
-               return;
-       }
-
-       vote_yescount = ReadByte();
-       vote_nocount = ReadByte();
-       vote_needed = ReadByte();
-       vote_active = 1;
-}
-
-void Net_VoteDialogReset() {
-       vote_active = 0;
-}
-
-void Net_Notify() {
-       float type;
-       type = ReadByte();
-
-       if(type == CSQC_KILLNOTIFY)
-       {
-               HUD_KillNotify(ReadString(), ReadString(), ReadString(), ReadShort(), ReadByte());
-       }
-       else if(type == CSQC_CENTERPRINT)
-       {
-               HUD_Centerprint(ReadString(), ReadString(), ReadShort(), ReadByte());
-       }
-}
-
 void Net_WeaponComplain() {
        complain_weapon = ReadByte();
 
@@ -1348,10 +1340,10 @@ void Net_WeaponComplain() {
 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
 float CSQC_Parse_TempEntity()
 {
-       local float bHandled;
+       float bHandled;
                bHandled  = true;
        // Acquire TE ID
-       local float nTEID;
+       float nTEID;
                nTEID = ReadByte();
 
                // NOTE: Could just do return instead of break...
@@ -1385,14 +1377,6 @@ float CSQC_Parse_TempEntity()
                        Net_TeamNagger();
                        bHandled = true;
                        break;
-               case TE_CSQC_VOTE:
-                       Net_VoteDialog(ReadByte());
-                       bHandled = true;
-                       break;
-               case TE_CSQC_VOTERESET:
-                       Net_VoteDialogReset();
-                       bHandled = true;
-                       break;
                case TE_CSQC_LIGHTNINGARC:
                        Net_ReadLightningarc();
                        bHandled = true;
@@ -1402,21 +1386,36 @@ float CSQC_Parse_TempEntity()
                        bHandled = true;
                        break;
                case TE_CSQC_ANNOUNCE:
-                       announce_snd = strzone(ReadString());
+                       Announcer_Play(ReadString());
                        bHandled = true;
                        break;
-               case TE_CSQC_NOTIFY:
-                       Net_Notify();
+               case TE_CSQC_KILLNOTIFY:
+                       HUD_KillNotify(ReadString(), ReadString(), ReadString(), ReadShort(), ReadByte());
+                       bHandled = true;
+                       break;
+               case TE_CSQC_KILLCENTERPRINT:
+                       HUD_KillCenterprint(ReadString(), ReadString(), ReadShort(), ReadByte());
+                       bHandled = true;
+                       break;
+               case TE_CSQC_CENTERPRINT_GENERIC:
+                       float id;
+                       string s;
+                       id = ReadByte();
+                       s = ReadString();
+                       if (id != 0 && s != "")
+                               centerprint_generic(id, s, ReadByte(), ReadByte());
+                       else
+                               centerprint_generic(id, s, 0, 0);
                        bHandled = true;
                        break;
                case TE_CSQC_WEAPONCOMPLAIN:
                        Net_WeaponComplain();
                        bHandled = true;
                        break;
-        case TE_CSQC_VEHICLESETUP:
-            Net_VehicleSetup();
-            bHandled = true;
-            break;
+               case TE_CSQC_VEHICLESETUP:
+                       Net_VehicleSetup();
+                       bHandled = true;
+                       break;
                default:
                        // No special logic for this temporary entity; return 0 so the engine can handle it
                        bHandled = false;