#include "all.inc"
#undef IMPLEMENTATION
-// VEHICLE PLUGIN SYSTEM
-entity dummy_vehicle_info;
-
-void vehicles_common_initialize()
+#ifndef MENUQC
+STATIC_INIT(vehicles_common_initialize)
{
#ifdef CSQC
precache_model("models/vehicles/bomblet.md3");
addstat(STAT_VEHICLESTAT_RELOAD2, AS_INT, vehicle_reload2);
#endif // SVQC
}
+#endif
-void register_vehicle(entity e, float id, float(float) 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)
-{
- vehicle_info[id - 1] = e;
- e.classname = "vehicle_info";
- e.vehicleid = id;
- e.netname = shortname;
- e.vehicle_name = vname;
- e.vehicle_func = func;
- e.mdl = modelname;
- e.spawnflags = vehicleflags;
- e.mins = min_s;
- e.maxs = max_s;
- e.model = modelname;
- e.head_model = headmodelname;
- e.hud_model = hudmodelname;
- e.tag_head = headtag;
- e.tag_hud = hudtag;
- e.tag_view = viewtag;
-
- #ifndef MENUQC
- vehicles_common_initialize();
- #endif
-}
-void register_vehicles_done()
-{
- dummy_vehicle_info = spawn();
- dummy_vehicle_info.classname = "vehicle_info";
- dummy_vehicle_info.vehicleid = 0; // you can recognize dummies by this
- dummy_vehicle_info.netname = "";
- dummy_vehicle_info.vehicle_name = "Vehicle";
- dummy_vehicle_info.vehicle_func = v_null;
- dummy_vehicle_info.mdl = "";
- dummy_vehicle_info.mins = '-0 -0 -0';
- dummy_vehicle_info.maxs = '0 0 0';
- dummy_vehicle_info.model = "";
- dummy_vehicle_info.head_model = "";
- dummy_vehicle_info.hud_model = "";
-}
entity get_vehicleinfo(float id)
{
entity m;
if(id < VEH_FIRST || id > VEH_LAST)
- return dummy_vehicle_info;
+ return VEH_NULL;
m = vehicle_info[id - 1];
if(m)
return m;
- return dummy_vehicle_info;
+ return VEH_NULL;
}
#endif
const int VEH_FIRST = 1;
#define VEH_LAST (VEH_FIRST + VEH_COUNT - 1)
/** If you register a new vehicle, make sure to add it to all.inc */
-#define REGISTER_VEHICLE(id, class) REGISTER(RegisterVehicles, vehicle_info, vehicle_info, VEH_COUNT, id, m_id, NEW(class))
+#define REGISTER_VEHICLE(id, class) REGISTER(RegisterVehicles, VEH, vehicle_info, VEH_COUNT, id, vehicleid, NEW(class))
#include "vehicle.qh"
-#define REGISTER_VEHICLE_SIMPLE(id,func,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname) \
- int VEH_##id; \
- int func(int); \
- REGISTER_VEHICLE(id, Vehicle) { \
- VEH_##id = VEH_LAST; \
- register_vehicle(this,VEH_##id,func,vehicleflags,min_s,max_s,modelname,headmodelname,hudmodelname,headtag,hudtag,viewtag,shortname,vname); \
- } \
- REGISTER_INIT(vehicle_info, id)
+#define REGISTER_VEHICLE_SIMPLE(id, func, vehicleflags, min_s, max_s, modelname, headmodelname, hudmodelname, headtag, hudtag, viewtag, shortname, vname) \
+ REGISTER_VEHICLE(id, Vehicle) { \
+ this.netname = shortname; \
+ this.vehicle_name = vname; \
+ this.vehicle_func = func; \
+ this.mdl = modelname; \
+ this.spawnflags = vehicleflags; \
+ this.mins = min_s; \
+ this.maxs = max_s; \
+ this.model = modelname; \
+ this.head_model = headmodelname; \
+ this.hud_model = hudmodelname; \
+ this.tag_head = headtag; \
+ this.tag_hud = hudtag; \
+ this.tag_view = viewtag; \
+ } \
+ REGISTER_INIT(VEH, id)
REGISTER_REGISTRY(RegisterVehicles)
-void register_vehicle(entity e, 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();
-#include "all.inc"
+REGISTER_VEHICLE(NULL, Vehicle) {
+ this.vehicleid = 0; // you can recognize dummies by this
+ this.netname = "";
+ this.vehicle_name = "Vehicle";
+ this.vehicle_func = v_null;
+ this.mdl = "";
+ this.mins = '-0 -0 -0';
+ this.maxs = '0 0 0';
+ this.model = "";
+ this.head_model = "";
+ this.hud_model = "";
+}
-ACCUMULATE_FUNCTION(RegisterVehicles, register_vehicles_done);
+#include "all.inc"
#endif
}
// Bumblebee gunner crosshairs
- if(hud == VEH_BUMBLEBEE)
+ if(hud == VEH_BUMBLEBEE.vehicleid)
{
tmpSize = '1 1 1' * hud_fontsize;
tmpPos.x = hudPos.x + hudSize.x * (520/768);
}
// Raptor bomb crosshair
- if(hud == VEH_RAPTOR && weapon2mode != RSM_FLARE)
+ if(hud == VEH_RAPTOR.vehicleid && weapon2mode != RSM_FLARE)
{
vector where;
#ifndef VEHICLE_BUMBLEBEE
#define VEHICLE_BUMBLEBEE
#include "bumblebee.qh"
+int v_bumblebee(int);
REGISTER_VEHICLE_SIMPLE(
/* VEH_##id */ BUMBLEBEE,
/* function */ v_bumblebee,
void bumblebee_exit(float eject)
{
- if(self.owner.vehicleid == VEH_BUMBLEBEE)
+ if(self.owner.vehicleid == VEH_BUMBLEBEE.vehicleid)
{
bumblebee_gunner_exit(eject);
return;
void spawnfunc_vehicle_bumblebee()
{
if(!autocvar_g_vehicle_bumblebee) { remove(self); return; }
- if(!vehicle_initialize(VEH_BUMBLEBEE, false)) { remove(self); return; }
+ if(!vehicle_initialize(VEH_BUMBLEBEE.vehicleid, false)) { remove(self); return; }
}
float v_bumblebee(float req)
#ifndef VEHICLE_RACER
#define VEHICLE_RACER
+int v_racer(int);
REGISTER_VEHICLE_SIMPLE(
/* VEH_##id */ RACER,
/* function */ v_racer,
void spawnfunc_vehicle_racer()
{
if(!autocvar_g_vehicle_racer) { remove(self); return; }
- if(!vehicle_initialize(VEH_RACER, false)) { remove(self); return; }
+ if(!vehicle_initialize(VEH_RACER.vehicleid, false)) { remove(self); return; }
}
#endif // SVQC
#ifndef VEHICLE_RAPTOR
#define VEHICLE_RAPTOR
#include "raptor.qh"
+int v_raptor(int);
REGISTER_VEHICLE_SIMPLE(
/* VEH_##id */ RAPTOR,
/* function */ v_raptor,
void spawnfunc_vehicle_raptor()
{
if(!autocvar_g_vehicle_raptor) { remove(self); return; }
- if(!vehicle_initialize(VEH_RAPTOR, false)) { remove(self); return; }
+ if(!vehicle_initialize(VEH_RAPTOR.vehicleid, false)) { remove(self); return; }
}
float v_raptor(float req)
#ifndef VEHICLE_SPIDERBOT
#define VEHICLE_SPIDERBOT
+int v_spiderbot(int);
REGISTER_VEHICLE_SIMPLE(
/* VEH_##id */ SPIDERBOT,
/* function */ v_spiderbot,
void spawnfunc_vehicle_spiderbot()
{
if(!autocvar_g_vehicle_spiderbot) { remove(self); return; }
- if(!vehicle_initialize(VEH_SPIDERBOT, false)) { remove(self); return; }
+ if(!vehicle_initialize(VEH_SPIDERBOT.vehicleid, false)) { remove(self); return; }
}
float v_spiderbot(float req)
int v_null(int) { return 0; }
CLASS(Vehicle, Object)
- ATTRIB(Vehicle, m_id, int, 0)
+ ATTRIB(Vehicle, vehicleid, int, 0)
ENDCLASS(Vehicle)
#endif