]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/view.qc
Merge branch 'terencehill/camera_spectator_2' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / view.qc
index 828853243f3049bc8756a9b1521d3789ad6f31c3..200bcfde715373d44105d516894ad72745de8778 100644 (file)
@@ -447,7 +447,7 @@ vector GetCurrentFov(float fov)
                        zoomspeed = 3.5;
 
        zoomdir = button_zoom;
-       if(hud == HUD_NORMAL)
+       if(hud == HUD_NORMAL && !spectatee_status)
        if(switchweapon == activeweapon)
        if((activeweapon == WEP_VORTEX && !WEP_CVAR(vortex, secondary)) || (activeweapon == WEP_RIFLE && !WEP_CVAR(rifle, secondary))) // do NOT use switchweapon here
                zoomdir += button_attack2;
@@ -766,12 +766,12 @@ bool WantEventchase(entity this)
        return false;
 }
 
-void HUD_Crosshair_Vehicle()
+void HUD_Crosshair_Vehicle(entity this)
 {
        if(hud != HUD_BUMBLEBEE_GUN)
        {
                Vehicle info = Vehicles_from(hud);
-               info.vr_crosshair(info);
+               info.vr_crosshair(info, this);
        }
 }
 
@@ -836,7 +836,7 @@ void HitSound()
                        // 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, SND(HIT), VOL_BASE, ATTN_NONE, pitch_shift * 100, 0);
+                       sound7(NULL, CH_INFO, SND(HIT), VOL_BASE, ATTN_NONE, pitch_shift * 100, 0);
                }
                unaccounted_damage = 0;
                hitsound_time_prev = time;
@@ -846,7 +846,7 @@ void HitSound()
        float typehit_time = STAT(TYPEHIT_TIME);
        if (COMPARE_INCREASING(typehit_time, typehit_time_prev) > autocvar_cl_hitsound_antispam_time)
        {
-               sound(world, CH_INFO, SND_TYPEHIT, VOL_BASE, ATTN_NONE);
+               sound(NULL, CH_INFO, SND_TYPEHIT, VOL_BASE, ATTN_NONE);
                typehit_time_prev = typehit_time;
        }
 }
@@ -860,7 +860,7 @@ vector crosshair_getcolor(entity this, float health_stat)
        {
                case 1: // crosshair_color_per_weapon
                {
-                       if(this)
+                       if(this != WEP_Null)
                        {
                                wcross_color = this.wpcolor;
                                break;
@@ -942,9 +942,12 @@ void HUD_Crosshair(entity this)
                if (!autocvar_crosshair_enabled) // main toggle for crosshair rendering
                        return;
 
+               if (spectatee_status > 0 && STAT(CAMERA_SPECTATOR) == 2)
+                       return;
+
                if (hud != HUD_NORMAL)
                {
-                       HUD_Crosshair_Vehicle();
+                       HUD_Crosshair_Vehicle(this);
                        return;
                }
 
@@ -989,7 +992,7 @@ void HUD_Crosshair(entity this)
                string wcross_name = "";
                float wcross_scale, wcross_blur;
 
-        entity e = this; // wtf?
+        entity e = WEP_Null;
                if(autocvar_crosshair_per_weapon || (autocvar_crosshair_color_special == 1))
                {
                        e = switchingweapon;
@@ -1369,9 +1372,8 @@ float prev_myteam;
 int lasthud;
 float vh_notice_time;
 void WaypointSprite_Load();
-void CSQC_UpdateView(float w, float h)
+void CSQC_UpdateView(entity this, float w, float h)
 {
-    SELFPARAM(); // needed for engine functions
     TC(int, w); TC(int, h);
        entity e;
        float fov;
@@ -1460,9 +1462,28 @@ void CSQC_UpdateView(float w, float h)
        // event chase camera
        if(autocvar_chase_active <= 0) // greater than 0 means it's enabled manually, and this code is skipped
        {
+               if(STAT(CAMERA_SPECTATOR))
+               {
+                       if(spectatee_status > 0)
+                       {
+                               if(!autocvar_chase_active)
+                               {
+                                       cvar_set("chase_active", "-2");
+                                       goto skip_eventchase_death;
+                               }
+                       }
+                       else if(autocvar_chase_active == -2)
+                               cvar_set("chase_active", "0");
+
+                       if(autocvar_chase_active == -2)
+                               goto skip_eventchase_death;
+               }
+               else if(autocvar_chase_active == -2)
+                       cvar_set("chase_active", "0");
+
                float vehicle_chase = (hud != HUD_NORMAL && (autocvar_cl_eventchase_vehicle || spectatee_status > 0));
                float ons_roundlost = (gametype == MAPINFO_TYPE_ONSLAUGHT && STAT(ROUNDLOST));
-               entity gen = world;
+               entity gen = NULL;
 
                float vehicle_viewdist = 0;
                vector vehicle_viewofs = '0 0 0';
@@ -1570,6 +1591,8 @@ void CSQC_UpdateView(float w, float h)
                eventchase_current_distance = 0;
        }
 
+       LABEL(skip_eventchase_death);
+
        // 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 || QuickMenu_IsOpened())))
        {
@@ -1848,7 +1871,10 @@ void CSQC_UpdateView(float w, float h)
           mousepos = mousepos*0.5 + getmousepos();
         */
 
-       FOREACH_ENTITY(it.draw, it.draw(it));
+       FOREACH_ENTITY_FLOAT(pure_data, false,
+       {
+               if(it.draw) { it.draw(it); }
+       });
 
        addentities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
        renderscene();
@@ -2178,13 +2204,16 @@ void CSQC_UpdateView(float w, float h)
          } else */
 
        // draw 2D entities
-       FOREACH_ENTITY(it.draw2d, it.draw2d(it));
+       FOREACH_ENTITY_FLOAT(pure_data, false,
+       {
+               if(it.draw2d) { it.draw2d(it); }
+       });
        Draw_ShowNames_All();
        Debug_Draw();
 
        scoreboard_active = HUD_WouldDrawScoreboard();
 
-       HUD_Draw(this);
+       HUD_Draw(this); // this parameter for deep vehicle function
 
        if(NextFrameCommand)
        {