]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/view.qc
Nades: rename registry globals
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / view.qc
index 7cf7af5f7e4502491e48bab6ee8915067b0f9f52..9c20747fbac1bd8c6d50de065ba6343fc57b9397 100644 (file)
@@ -12,7 +12,7 @@
 
 #include "../common/constants.qh"
 #include "../common/mapinfo.qh"
-#include "../common/nades.qh"
+#include "../common/nades/all.qh"
 #include "../common/stats.qh"
 #include "../common/triggers/target/music.qh"
 #include "../common/teams.qh"
@@ -131,6 +131,7 @@ vector GetCurrentFov(float fov)
 
        zoomdir = button_zoom;
        if(hud == HUD_NORMAL)
+       if(switchweapon == activeweapon)
        if((activeweapon == WEP_VORTEX.m_id && vortex_scope) || (activeweapon == WEP_RIFLE.m_id && rifle_scope)) // do NOT use switchweapon here
                zoomdir += button_attack2;
        if(spectatee_status > 0 || isdemo())
@@ -320,6 +321,7 @@ float TrueAimCheck()
        {
                case WEP_TUBA.m_id: // no aim
                case WEP_PORTO.m_id: // shoots from eye
+               case WEP_NEXBALL.m_id: // shoots from eye
                case WEP_HOOK.m_id: // no trueaim
                case WEP_MORTAR.m_id: // toss curve
                        return SHOTTYPE_HITWORLD;
@@ -426,7 +428,7 @@ vector liquidcolor_prev;
 float eventchase_current_distance;
 float eventchase_running;
 bool WantEventchase()
-{
+{SELFPARAM();
        if(autocvar_cl_orthoview)
                return false;
        if(intermission)
@@ -439,7 +441,7 @@ bool WantEventchase()
                        return true;
                if(MUTATOR_CALLHOOK(WantEventchase, self))
                        return true;
-               if(autocvar_cl_eventchase_nexball && gametype == MAPINFO_TYPE_NEXBALL && !(WepSet_GetFromStat() & WepSet_FromWeapon(WEP_PORTO.m_id)))
+               if(autocvar_cl_eventchase_nexball && gametype == MAPINFO_TYPE_NEXBALL && !(WepSet_GetFromStat() & WepSet_FromWeapon(WEP_NEXBALL.m_id)))
                        return true;
                if(autocvar_cl_eventchase_death && (getstati(STAT_HEALTH) <= 0))
                {
@@ -516,7 +518,7 @@ void UpdateHitsound()
                        // todo: avoid very long and very short sounds from wave stretching using different sound files? seems unnecessary
                        // todo: normalize sound pressure levels? seems unnecessary
 
-                       sound7(world, CH_INFO, "misc/hit.wav", VOL_BASE, ATTN_NONE, pitch_shift * 100, 0);
+                       sound7(world, CH_INFO, SND(HIT), VOL_BASE, ATTN_NONE, pitch_shift * 100, 0);
                }
                unaccounted_damage = 0;
                hitsound_time_prev = time;
@@ -526,13 +528,13 @@ void UpdateHitsound()
        float typehit_time = getstatf(STAT_TYPEHIT_TIME);
        if (COMPARE_INCREASING(typehit_time, typehit_time_prev) > autocvar_cl_hitsound_antispam_time)
        {
-               sound(world, CH_INFO, "misc/typehit.wav", VOL_BASE, ATTN_NONE);
+               sound(world, CH_INFO, SND_TYPEHIT, VOL_BASE, ATTN_NONE);
                typehit_time_prev = typehit_time;
        }
 }
 
 void UpdateCrosshair()
-{
+{SELFPARAM();
        static float rainbow_last_flicker;
     static vector rainbow_prev_color;
        entity e = self;
@@ -559,7 +561,7 @@ void UpdateCrosshair()
                        CSQC_common_hud();
 
        // crosshair goes VERY LAST
-       if(!scoreboard_active && !camera_active && intermission != 2 && 
+       if(!scoreboard_active && !camera_active && intermission != 2 &&
                spectatee_status != -1 && hud == HUD_NORMAL && !csqcplayer.viewloc &&
                !HUD_MinigameMenu_IsOpened() )
        {
@@ -1005,6 +1007,14 @@ void UpdateCrosshair()
        }
 }
 
+bool ov_enabled;
+float oldr_nearclip;
+float oldr_farclip_base;
+float oldr_farclip_world;
+float oldr_novis;
+float oldr_useportalculling;
+float oldr_useinfinitefarclip;
+
 const int BUTTON_3 = 4;
 const int BUTTON_4 = 8;
 float cl_notice_run();
@@ -1013,7 +1023,7 @@ int lasthud;
 float vh_notice_time;
 void WaypointSprite_Load();
 void CSQC_UpdateView(float w, float h)
-{
+{SELFPARAM();
        entity e;
        float fov;
        float f;
@@ -1183,7 +1193,7 @@ void CSQC_UpdateView(float w, float h)
        }
 
        // do lockview after event chase camera so that it still applies whenever necessary.
-       if(autocvar_cl_lockview || (!autocvar_hud_cursormode && (autocvar__hud_configure && spectatee_status <= 0 || intermission > 1)))
+       if(autocvar_cl_lockview || (!autocvar_hud_cursormode && (autocvar__hud_configure && spectatee_status <= 0 || intermission > 1 || QuickMenu_IsOpened())))
        {
                setproperty(VF_ORIGIN, freeze_org);
                setproperty(VF_ANGLES, freeze_ang);
@@ -1231,6 +1241,16 @@ void CSQC_UpdateView(float w, float h)
                if((dist = vlen(vec3(ov_worldmax.x, ov_worldmin.y, ov_worldmax.z) - ov_org)) > ov_furthest) { ov_furthest = dist; }
                if((dist = vlen(vec3(ov_worldmax.x, ov_worldmax.y, ov_worldmax.z) - ov_org)) > ov_furthest) { ov_furthest = dist; }
 
+               if(!ov_enabled)
+               {
+                       oldr_nearclip = cvar("r_nearclip");
+                       oldr_farclip_base = cvar("r_farclip_base");
+                       oldr_farclip_world = cvar("r_farclip_world");
+                       oldr_novis = cvar("r_novis");
+                       oldr_useportalculling = cvar("r_useportalculling");
+                       oldr_useinfinitefarclip = cvar("r_useinfinitefarclip");
+               }
+
                cvar_settemp("r_nearclip", ftos(ov_nearest));
                cvar_settemp("r_farclip_base", ftos(ov_furthest));
                cvar_settemp("r_farclip_world", "0");
@@ -1241,6 +1261,8 @@ void CSQC_UpdateView(float w, float h)
                setproperty(VF_ORIGIN, ov_org);
                setproperty(VF_ANGLES, '90 0 0');
 
+               ov_enabled = true;
+
                #if 0
                LOG_INFOF("OrthoView: org = %s, angles = %s, distance = %f, nearest = %f, furthest = %f\n",
                        vtos(ov_org),
@@ -1250,6 +1272,19 @@ void CSQC_UpdateView(float w, float h)
                        ov_furthest);
                #endif
        }
+       else
+       {
+               if(ov_enabled)
+               {
+                       cvar_set("r_nearclip", ftos(oldr_nearclip));
+                       cvar_set("r_farclip_base", ftos(oldr_farclip_base));
+                       cvar_set("r_farclip_world", ftos(oldr_farclip_world));
+                       cvar_set("r_novis", ftos(oldr_novis));
+                       cvar_set("r_useportalculling", ftos(oldr_useportalculling));
+                       cvar_set("r_useinfinitefarclip", ftos(oldr_useinfinitefarclip));
+               }
+               ov_enabled = false;
+       }
 
        // Render the Scene
        view_origin = getpropertyvec(VF_ORIGIN);
@@ -1432,11 +1467,9 @@ void CSQC_UpdateView(float w, float h)
           mousepos = mousepos*0.5 + getmousepos();
         */
 
-       e = self;
-       for(self = world; (self = nextent(self)); )
-               if(self.draw)
-                       self.draw();
-       self = e;
+       for(entity e = NULL; (e = nextent(e)); ) if (e.draw) {
+               WITH(entity, self, e, e.draw());
+       }
 
        addentities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
        renderscene();
@@ -1499,6 +1532,7 @@ void CSQC_UpdateView(float w, float h)
 
        if(autocvar_cl_reticle)
        {
+               Weapon wep = get_weaponinfo(activeweapon);
                // Draw the aiming reticle for weapons that use it
                // reticle_type is changed to the item we are zooming / aiming with, to decide which reticle to use
                // It must be a persisted float for fading out to work properly (you let go of the zoom button for
@@ -1508,7 +1542,7 @@ void CSQC_UpdateView(float w, float h)
                        // no zoom reticle while dead
                        reticle_type = 0;
                }
-               else if(WEP_ACTION(activeweapon, WR_ZOOMRETICLE) && autocvar_cl_reticle_weapon)
+               else if(wep.wr_zoomreticle(wep) && autocvar_cl_reticle_weapon)
                {
                        if(reticle_image != "") { reticle_type = 2; }
                        else { reticle_type = 0; }
@@ -1771,11 +1805,9 @@ void CSQC_UpdateView(float w, float h)
          } else */
 
        // draw 2D entities
-       e = self;
-       for(self = world; (self = nextent(self)); )
-               if(self.draw2d)
-                       self.draw2d();
-       self = e;
+       for (entity e = NULL; (e = nextent(e)); ) if (e.draw2d) {
+               WITH(entity, self, e, e.draw2d());
+       }
        Draw_ShowNames_All();
 
        scoreboard_active = HUD_WouldDrawScoreboard();
@@ -1821,14 +1853,18 @@ void CSQC_UpdateView(float w, float h)
                HUD_Panel_Mouse();
        else if ( HUD_MinigameMenu_IsOpened() || minigame_isactive() )
                HUD_Minigame_Mouse();
+       else if(QuickMenu_IsOpened())
+               QuickMenu_Mouse();
        else
                HUD_Radar_Mouse();
 
     if(hud && !intermission)
     if(hud == HUD_BUMBLEBEE_GUN)
        CSQC_BUMBLE_GUN_HUD();
-    else
-               VEH_ACTION(hud, VR_HUD);
+    else {
+       Vehicle info = get_vehicleinfo(hud);
+               info.vr_hud(info);
+       }
 
        cl_notice_run();