From: TimePath Date: Tue, 6 Oct 2015 09:50:37 +0000 (+1100) Subject: Vehicles: rename registry globals X-Git-Tag: xonotic-v0.8.2~1872 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=debcc4abaf44b9663f32d7663b5c690e3b8bdcf9;p=xonotic%2Fxonotic-data.pk3dir.git Vehicles: rename registry globals --- 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