-#ifndef VEHICLES_ALL_H
-#define VEHICLES_ALL_H
+#pragma once
-#if defined(SVQC)
- #include "sv_vehicles.qh"
-#elif defined(CSQC)
- #include "cl_vehicles.qh"
-#endif
-
-
-// vehicle requests
-const int VR_SETUP = 1; // (BOTH) setup vehicle data
-const int VR_THINK = 2; // (SERVER) logic to run every frame
-const int VR_DEATH = 3; // (SERVER) called when vehicle dies
-const int VR_PRECACHE = 4; // (BOTH) precaches models/sounds used by this vehicle
-const int VR_ENTER = 5; // (SERVER) called when a player enters this vehicle
-const int VR_SPAWN = 6; // (SERVER) called when the vehicle re-spawns
-const int VR_IMPACT = 7; // (SERVER) called when a vehicle hits something
-const int VR_HUD = 8; // (CLIENT) logic to run every frame
-
-// vehicle spawn flags (need them here for common registrations)
-const int VHF_ISVEHICLE = 2; /// Indicates vehicle
-const int VHF_HASSHIELD = 4; /// Vehicle has shileding
-const int VHF_SHIELDREGEN = 8; /// Vehicles shield regenerates
-const int VHF_HEALTHREGEN = 16; /// Vehicles health regenerates
-const int VHF_ENERGYREGEN = 32; /// Vehicles energy regenerates
-const int VHF_DEATHEJECT = 64; /// Vehicle ejects pilot upon fatal damage
-const int VHF_MOVE_GROUND = 128; /// Vehicle moves on gound
-const int VHF_MOVE_HOVER = 256; /// Vehicle hover close to gound
-const int VHF_MOVE_FLY = 512; /// Vehicle is airborn
-const int VHF_DMGSHAKE = 1024; /// Add random velocity each frame if health < 50%
-const int VHF_DMGROLL = 2048; /// Add random angles each frame if health < 50%
-const int VHF_DMGHEADROLL = 4096; /// Add random head angles each frame if health < 50%
-const int VHF_MULTISLOT = 8192; /// Vehicle has multiple player slots
-const int VHF_PLAYERSLOT = 16384; /// This ent is a player slot on a multi-person vehicle
-
-// functions:
-entity get_vehicleinfo(float id);
-
-// fields:
-.entity tur_head;
+#include "vehicle.qh"
+REGISTRY(Vehicles, BITS(4))
+#define Vehicles_from(i) _Vehicles_from(i, VEH_Null)
+REGISTER_REGISTRY(Vehicles)
+REGISTRY_CHECK(Vehicles)
-// entity properties of vehicleinfo:
-.int vehicleid; // VEH_...
-.string netname; // short name
-.string vehicle_name; // human readable name
-.int(int) vehicle_func; // v_...
-.string mdl; // currently a copy of the model
-.string model; // full name of model
-.string head_model; // full name of tur_head model
-.string hud_model; // cockpit model
-.string tag_head; // tur_head model tag
-.string tag_hud; // hud model tag
-.string tag_view; // cockpit model tag
-.int() PlayerPhysplug; // player physics mod
-.int spawnflags;
-.vector mins, maxs; // vehicle hitbox size
+const int VEH_FIRST = 1;
+#define VEH_LAST (Vehicles_COUNT - 1)
-// other useful macros
-#define VEH_ACTION(vehicletype,mrequest) (get_vehicleinfo(vehicletype)).vehicle_func(mrequest)
-#define VEH_NAME(vehicletype) (get_vehicleinfo(vehicletype)).vehicle_name
+#define REGISTER_VEHICLE(id, inst) REGISTER(Vehicles, VEH, id, vehicleid, inst)
-// =====================
-// Vehicle Registration
-// =====================
-
-int v_null(int dummy);
-void register_vehicle(int id, int(int) func, float vehicleflags, vector min_s, vector max_s, string modelname, string headmodelname, string hudmodelname, string headtag, string hudtag, string viewtag, string shortname, string vname);
-void register_vehicles_done();
-
-const int VEH_MAXCOUNT = 24;
-#define VEH_FIRST 1
-int VEH_COUNT;
-int VEH_LAST;
-
-#define REGISTER_VEHICLE_2(id,func,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname) \
- int id; \
- int func(int); \
- void RegisterVehicles_##id() \
- { \
- VEH_LAST = (id = VEH_FIRST + VEH_COUNT); \
- ++VEH_COUNT; \
- register_vehicle(id,func,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname); \
- } \
- ACCUMULATE_FUNCTION(RegisterVehicles, RegisterVehicles_##id)
-#ifdef MENUQC
-#define REGISTER_VEHICLE(id,func,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname) \
- REGISTER_VEHICLE_2(VEH_##id,v_null,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname)
-#else
-#define REGISTER_VEHICLE(id,func,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname) \
- REGISTER_VEHICLE_2(VEH_##id,func,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname)
+#if defined(SVQC)
+ #include "sv_vehicles.qh"
+#elif defined(CSQC)
+ #include "cl_vehicles.qh"
#endif
-#include "all.inc"
-
-#undef REGISTER_VEHICLE
-ACCUMULATE_FUNCTION(RegisterVehicles, register_vehicles_done);
+REGISTER_VEHICLE(Null, NEW(Vehicle));
-#include "all.inc"
-
-#endif
+#include "vehicle/_mod.inc"