From 929e1154b5b07c0d00f44b2c0449913a553ad91f Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 2 Jun 2020 23:08:50 +1000 Subject: [PATCH] Store the vehicle definition into a field so that it doesn't need to be pulled from the buffer every time it's accessed --- qcsrc/common/vehicles/sv_vehicles.qc | 13 +++++++------ qcsrc/common/vehicles/vehicle.qh | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc index cc2e13e22..7273f5a64 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qc +++ b/qcsrc/common/vehicles/sv_vehicles.qc @@ -450,7 +450,7 @@ void vehicles_reset_colors(entity this, entity player) this.velocity = '0 0 0'; this.effects = eff; - Vehicle info = REGISTRY_GET(Vehicles, this.vehicleid); + Vehicle info = this.vehicledef; //REGISTRY_GET(Vehicles, this.vehicleid); info.vr_setcolors(info, this); } @@ -741,7 +741,7 @@ void vehicles_damage(entity this, entity inflictor, entity attacker, float damag antilag_clear(this, this); - Vehicle info = REGISTRY_GET(Vehicles, this.vehicleid); + Vehicle info = this.vehicledef; //REGISTRY_GET(Vehicles, this.vehicleid); info.vr_death(info, this); vehicles_setreturn(this); } @@ -931,7 +931,7 @@ void vehicles_touch(entity this, entity toucher) } if(this.play_time < time) { - Vehicle info = REGISTRY_GET(Vehicles, this.vehicleid); + Vehicle info = this.vehicledef; //REGISTRY_GET(Vehicles, this.vehicleid); info.vr_impact(info, this); } @@ -976,7 +976,7 @@ void vehicles_enter(entity pl, entity veh) || (pl.vehicle) ) { return; } - Vehicle info = REGISTRY_GET(Vehicles, veh.vehicleid); + Vehicle info = veh.vehicledef; //REGISTRY_GET(Vehicles, veh.vehicleid); if(autocvar_g_vehicles_enter) // vehicle's touch function should handle this if entering via use key is disabled (TODO) if(veh.vehicle_flags & VHF_MULTISLOT) @@ -1115,7 +1115,7 @@ void vehicles_think(entity this) if(this.owner) STAT(VEHICLESTAT_W2MODE, this.owner) = STAT(VEHICLESTAT_W2MODE, this); - Vehicle info = REGISTRY_GET(Vehicles, this.vehicleid); + Vehicle info = this.vehicledef; //REGISTRY_GET(Vehicles, this.vehicleid); info.vr_think(info, this); vehicles_painframe(this); @@ -1188,7 +1188,7 @@ void vehicles_spawn(entity this) }); - Vehicle info = REGISTRY_GET(Vehicles, this.vehicleid); + Vehicle info = this.vehicledef; //REGISTRY_GET(Vehicles, this.vehicleid); info.vr_spawn(info, this); vehicles_reset_colors(this, NULL); @@ -1256,6 +1256,7 @@ bool vehicle_initialize(entity this, Vehicle info, bool nodrop) this.damagedbycontents = true; IL_PUSH(g_damagedbycontents, this); this.vehicleid = info.vehicleid; + this.vehicledef = info; this.PlayerPhysplug = info.PlayerPhysplug; this.event_damage = func_null; this.event_heal = func_null; diff --git a/qcsrc/common/vehicles/vehicle.qh b/qcsrc/common/vehicles/vehicle.qh index 5b30b845e..8da44a459 100644 --- a/qcsrc/common/vehicles/vehicle.qh +++ b/qcsrc/common/vehicles/vehicle.qh @@ -77,3 +77,4 @@ const int VHF_PLAYERSLOT = BIT(14); /// This ent is a player slot on a multi-pe // fields: .entity tur_head; +.entity vehicledef; -- 2.39.2