]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Make vehicle auxiliary crosshairs spectatable
authorMario <mario@smbclan.net>
Fri, 3 Mar 2017 13:30:25 +0000 (23:30 +1000)
committerMario <mario@smbclan.net>
Fri, 3 Mar 2017 13:30:43 +0000 (23:30 +1000)
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/server/client.qc

index 82e1abf9f16bfa941eb97500f2a6587d1e3bcb01..8daa561a10b83d0df3e8aca1c8d253cc6fb91235 100644 (file)
@@ -24,6 +24,13 @@ bool SendAuxiliaryXhair(entity this, entity to, int sf)
        return true;
 }
 
+bool AuxiliaryXhair_customize(entity this, entity client)
+{
+       //entity e = WaypointSprite_getviewentity(client);
+       entity axh = client.(AuxiliaryXhair[this.cnt]);
+       return axh.owner == this.owner; // cheaply check if the client's axh owner is the same as our real owner
+}
+
 .vector axh_prevorigin;
 .vector axh_prevcolors;
 
@@ -39,7 +46,8 @@ void UpdateAuxiliaryXhair(entity own, vector loc, vector clr, int axh_id)
        {
                axh = new(auxiliary_xhair);
                axh.cnt = axh_id;
-               axh.drawonlytoclient = own;
+               //axh.drawonlytoclient = own; // not spectatable
+               setcefc(axh, AuxiliaryXhair_customize);
                axh.owner = own;
                Net_LinkEntity(axh, false, 0, SendAuxiliaryXhair);
        }
@@ -68,6 +76,18 @@ void CSQCVehicleSetup(entity own, int vehicle_id)
 
        WriteHeader(MSG_ONE, TE_CSQC_VEHICLESETUP);
        WriteByte(MSG_ONE, vehicle_id);
+
+       if(vehicle_id == 0 || vehicle_id == HUD_NORMAL)
+       {
+               for(int i = 0; i < MAX_AXH; ++i)
+               {
+                       entity axh = own.(AuxiliaryXhair[i]);
+                       own.(AuxiliaryXhair[i]) = NULL;
+
+                       if(axh.owner == own && axh != NULL && !wasfreed(axh))
+                               delete(axh);
+               }
+       }
 }
 
 void vehicles_locktarget(entity this, float incr, float decr, float _lock_time)
index 7f64c878bc7a5ebe104b1c484b8e20e293520142..f6e4c8391d4413d97105b0477cd9a2170d75f710 100644 (file)
@@ -354,6 +354,15 @@ void PutObserverInServer(entity this)
        this.oldvelocity = this.velocity;
        this.fire_endtime = -1;
        this.event_damage = func_null;
+
+       for(int slot = 0; slot < MAX_AXH; ++slot)
+       {
+               entity axh = this.(AuxiliaryXhair[slot]);
+               this.(AuxiliaryXhair[slot]) = NULL;
+
+               if(axh.owner == this && axh != NULL && !wasfreed(axh))
+                       delete(axh);
+       }
 }
 
 int player_getspecies(entity this)
@@ -1705,6 +1714,11 @@ void SpectateCopy(entity this, entity spectatee)
                this.(weaponentity) = spectatee.(weaponentity);
        }
 
+       for(int slot = 0; slot < MAX_AXH; ++slot)
+       {
+               this.(AuxiliaryXhair[slot]) = spectatee.(AuxiliaryXhair[slot]);
+       }
+
     anticheat_spectatecopy(this, spectatee);
        this.hud = spectatee.hud;
        if(spectatee.vehicle)