From: Mario Date: Fri, 3 Mar 2017 13:30:25 +0000 (+1000) Subject: Make vehicle auxiliary crosshairs spectatable X-Git-Tag: xonotic-v0.8.2~156 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=22b30e43e4e3bab3b82e66ec9eb694ec45b261b3;p=xonotic%2Fxonotic-data.pk3dir.git Make vehicle auxiliary crosshairs spectatable --- diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc index 82e1abf9f..8daa561a1 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qc +++ b/qcsrc/common/vehicles/sv_vehicles.qc @@ -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) diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 7f64c878b..f6e4c8391 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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)