From debcc4abaf44b9663f32d7663b5c690e3b8bdcf9 Mon Sep 17 00:00:00 2001 From: TimePath Date: Tue, 6 Oct 2015 20:50:37 +1100 Subject: [PATCH] Vehicles: rename registry globals --- qcsrc/common/vehicles/all.qc | 7 ------- qcsrc/common/vehicles/all.qh | 22 ++++++++++++++-------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/qcsrc/common/vehicles/all.qc b/qcsrc/common/vehicles/all.qc index b071cf5a7..72d72d29d 100644 --- a/qcsrc/common/vehicles/all.qc +++ b/qcsrc/common/vehicles/all.qc @@ -23,13 +23,6 @@ STATIC_INIT(vehicles_common_initialize) } #endif -entity get_vehicleinfo(int id) -{ - if (id < VEH_FIRST || id > VEH_LAST) return VEH_Null; - entity m = vehicle_info[id]; - return m ? m : VEH_Null; -} - #if defined(SVQC) #include "sv_vehicles.qc" #elif defined(CSQC) diff --git a/qcsrc/common/vehicles/all.qh b/qcsrc/common/vehicles/all.qh index 351c267a2..706585597 100644 --- a/qcsrc/common/vehicles/all.qh +++ b/qcsrc/common/vehicles/all.qh @@ -3,16 +3,13 @@ #include "vehicle.qh" -void RegisterVehicles(); -const int VEH_MAXCOUNT = 24; -entity vehicle_info[VEH_MAXCOUNT], vehicle_info_first, vehicle_info_last; -Vehicle get_vehicleinfo(int id); -int VEH_COUNT; +REGISTRY(Vehicles, 24) +REGISTER_REGISTRY(RegisterVehicles) const int VEH_FIRST = 1; -#define VEH_LAST (VEH_FIRST + VEH_COUNT - 1) +#define VEH_LAST (Vehicles_COUNT - 1) + /** If you register a new vehicle, make sure to add it to all.inc */ -#define REGISTER_VEHICLE(id, inst) REGISTER(RegisterVehicles, VEH, vehicle_info, VEH_COUNT, id, vehicleid, inst) -REGISTER_REGISTRY(RegisterVehicles) +#define REGISTER_VEHICLE(id, inst) REGISTER(RegisterVehicles, VEH, Vehicles, Vehicles_COUNT, id, vehicleid, inst) #if defined(SVQC) #include "sv_vehicles.qh" @@ -22,6 +19,15 @@ REGISTER_REGISTRY(RegisterVehicles) REGISTER_VEHICLE(Null, NEW(Vehicle)); +Vehicle get_vehicleinfo(int id) +{ + if (id >= VEH_FIRST && id <= VEH_LAST) { + Vehicle v = Vehicles[id]; + if (v) return v; + } + return VEH_Null; +} + #include "all.inc" #endif -- 2.39.2