From 2ae8ccf2a62ca386ecf5c5627a4bc8fe8b4f2708 Mon Sep 17 00:00:00 2001 From: TimePath Date: Sat, 22 Aug 2015 21:45:07 +1000 Subject: [PATCH] Fix auxiliary crosshairs --- qcsrc/common/vehicles/all.qc | 12 ++++-------- qcsrc/common/vehicles/sv_vehicles.qc | 10 ++++------ qcsrc/common/vehicles/sv_vehicles.qh | 2 +- qcsrc/common/vehicles/unit/bumblebee.qc | 2 +- qcsrc/common/vehicles/unit/racer.qc | 2 +- qcsrc/common/vehicles/unit/raptor.qc | 2 +- qcsrc/common/vehicles/unit/spiderbot.qc | 2 +- 7 files changed, 13 insertions(+), 19 deletions(-) diff --git a/qcsrc/common/vehicles/all.qc b/qcsrc/common/vehicles/all.qc index d90e0696b..f0316ab1f 100644 --- a/qcsrc/common/vehicles/all.qc +++ b/qcsrc/common/vehicles/all.qc @@ -46,15 +46,11 @@ STATIC_INIT(vehicles_common_initialize) } #endif -entity get_vehicleinfo(float id) +entity get_vehicleinfo(int id) { - entity m; - if(id < VEH_FIRST || id > VEH_LAST) - return VEH_NULL; - m = vehicle_info[id - 1]; - if(m) - return m; - return VEH_NULL; + if (id < VEH_FIRST || id > VEH_LAST) return VEH_NULL; + entity m = vehicle_info[id]; + return m ? m : VEH_NULL; } #endif diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc index c21b0a5cf..79f59018d 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qc +++ b/qcsrc/common/vehicles/sv_vehicles.qc @@ -1183,17 +1183,15 @@ void vehicles_spawn() CSQCMODEL_AUTOINIT(); } -bool vehicle_initialize(int vehicle_id, bool nodrop) +bool vehicle_initialize(entity veh, bool nodrop) { if(!autocvar_g_vehicles) return false; - entity veh = get_vehicleinfo(vehicle_id); - if(!veh.vehicleid) return false; - if(!veh.tur_head) { VEH_ACTION(vehicle_id, VR_PRECACHE); } + if(!veh.tur_head) { VEH_ACTION(veh.vehicleid, VR_PRECACHE); } if(self.targetname && self.targetname != "") { @@ -1238,7 +1236,7 @@ bool vehicle_initialize(int vehicle_id, bool nodrop) self.iscreature = true; self.teleportable = false; // no teleporting for vehicles, too buggy self.damagedbycontents = true; - self.vehicleid = vehicle_id; + self.vehicleid = veh.vehicleid; self.PlayerPhysplug = veh.PlayerPhysplug; self.event_damage = func_null; self.touch = vehicles_touch; @@ -1286,7 +1284,7 @@ bool vehicle_initialize(int vehicle_id, bool nodrop) self.pos2 = self.angles; self.tur_head.team = self.team; - VEH_ACTION(vehicle_id, VR_SETUP); + VEH_ACTION(veh.vehicleid, VR_SETUP); if(self.active == ACTIVE_NOT) self.nextthink = 0; // wait until activated diff --git a/qcsrc/common/vehicles/sv_vehicles.qh b/qcsrc/common/vehicles/sv_vehicles.qh index c02ccddb5..b1921371e 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qh +++ b/qcsrc/common/vehicles/sv_vehicles.qh @@ -100,7 +100,7 @@ float vehicles_exit_running; .float vehicle_enter_delay; // prevent players jumping to and from vehicles instantly void vehicles_exit(float eject); -float vehicle_initialize(float vehicle_id, float nodrop); +float vehicle_initialize(entity vehicle, float nodrop); bool vehicle_impulse(int imp); bool vehicles_crushable(entity e); diff --git a/qcsrc/common/vehicles/unit/bumblebee.qc b/qcsrc/common/vehicles/unit/bumblebee.qc index 3d8eff20e..ba0db541a 100644 --- a/qcsrc/common/vehicles/unit/bumblebee.qc +++ b/qcsrc/common/vehicles/unit/bumblebee.qc @@ -767,7 +767,7 @@ float bumble_raygun_send(entity to, float sf) void spawnfunc_vehicle_bumblebee() { if(!autocvar_g_vehicle_bumblebee) { remove(self); return; } - if(!vehicle_initialize(VEH_BUMBLEBEE.vehicleid, false)) { remove(self); return; } + if(!vehicle_initialize(VEH_BUMBLEBEE, false)) { remove(self); return; } } float v_bumblebee(float req) diff --git a/qcsrc/common/vehicles/unit/racer.qc b/qcsrc/common/vehicles/unit/racer.qc index 3cf6215be..41a0b12ff 100644 --- a/qcsrc/common/vehicles/unit/racer.qc +++ b/qcsrc/common/vehicles/unit/racer.qc @@ -666,7 +666,7 @@ void racer_deadtouch() void spawnfunc_vehicle_racer() { if(!autocvar_g_vehicle_racer) { remove(self); return; } - if(!vehicle_initialize(VEH_RACER.vehicleid, false)) { remove(self); return; } + if(!vehicle_initialize(VEH_RACER, false)) { remove(self); return; } } #endif // SVQC diff --git a/qcsrc/common/vehicles/unit/raptor.qc b/qcsrc/common/vehicles/unit/raptor.qc index 1e92fa195..2ea89491b 100644 --- a/qcsrc/common/vehicles/unit/raptor.qc +++ b/qcsrc/common/vehicles/unit/raptor.qc @@ -788,7 +788,7 @@ float raptor_impulse(float _imp) void spawnfunc_vehicle_raptor() { if(!autocvar_g_vehicle_raptor) { remove(self); return; } - if(!vehicle_initialize(VEH_RAPTOR.vehicleid, false)) { remove(self); return; } + if(!vehicle_initialize(VEH_RAPTOR, false)) { remove(self); return; } } float v_raptor(float req) diff --git a/qcsrc/common/vehicles/unit/spiderbot.qc b/qcsrc/common/vehicles/unit/spiderbot.qc index 0c134acd4..939dd28a6 100644 --- a/qcsrc/common/vehicles/unit/spiderbot.qc +++ b/qcsrc/common/vehicles/unit/spiderbot.qc @@ -810,7 +810,7 @@ bool spiderbot_impulse(int _imp) void spawnfunc_vehicle_spiderbot() { if(!autocvar_g_vehicle_spiderbot) { remove(self); return; } - if(!vehicle_initialize(VEH_SPIDERBOT.vehicleid, false)) { remove(self); return; } + if(!vehicle_initialize(VEH_SPIDERBOT, false)) { remove(self); return; } } float v_spiderbot(float req) -- 2.39.2