}
#endif
-entity get_vehicleinfo(float id)
+entity get_vehicleinfo(int id)
{
- entity m;
- if(id < VEH_FIRST || id > VEH_LAST)
- return VEH_NULL;
- m = vehicle_info[id - 1];
- if(m)
- return m;
- return VEH_NULL;
+ if (id < VEH_FIRST || id > VEH_LAST) return VEH_NULL;
+ entity m = vehicle_info[id];
+ return m ? m : VEH_NULL;
}
#endif
CSQCMODEL_AUTOINIT();
}
-bool vehicle_initialize(int vehicle_id, bool nodrop)
+bool vehicle_initialize(entity veh, bool nodrop)
{
if(!autocvar_g_vehicles)
return false;
- entity veh = get_vehicleinfo(vehicle_id);
-
if(!veh.vehicleid)
return false;
- if(!veh.tur_head) { VEH_ACTION(vehicle_id, VR_PRECACHE); }
+ if(!veh.tur_head) { VEH_ACTION(veh.vehicleid, VR_PRECACHE); }
if(self.targetname && self.targetname != "")
{
self.iscreature = true;
self.teleportable = false; // no teleporting for vehicles, too buggy
self.damagedbycontents = true;
- self.vehicleid = vehicle_id;
+ self.vehicleid = veh.vehicleid;
self.PlayerPhysplug = veh.PlayerPhysplug;
self.event_damage = func_null;
self.touch = vehicles_touch;
self.pos2 = self.angles;
self.tur_head.team = self.team;
- VEH_ACTION(vehicle_id, VR_SETUP);
+ VEH_ACTION(veh.vehicleid, VR_SETUP);
if(self.active == ACTIVE_NOT)
self.nextthink = 0; // wait until activated
.float vehicle_enter_delay; // prevent players jumping to and from vehicles instantly
void vehicles_exit(float eject);
-float vehicle_initialize(float vehicle_id, float nodrop);
+float vehicle_initialize(entity vehicle, float nodrop);
bool vehicle_impulse(int imp);
bool vehicles_crushable(entity e);
void spawnfunc_vehicle_bumblebee()
{
if(!autocvar_g_vehicle_bumblebee) { remove(self); return; }
- if(!vehicle_initialize(VEH_BUMBLEBEE.vehicleid, false)) { remove(self); return; }
+ if(!vehicle_initialize(VEH_BUMBLEBEE, false)) { remove(self); return; }
}
float v_bumblebee(float req)
void spawnfunc_vehicle_racer()
{
if(!autocvar_g_vehicle_racer) { remove(self); return; }
- if(!vehicle_initialize(VEH_RACER.vehicleid, false)) { remove(self); return; }
+ if(!vehicle_initialize(VEH_RACER, false)) { remove(self); return; }
}
#endif // SVQC
void spawnfunc_vehicle_raptor()
{
if(!autocvar_g_vehicle_raptor) { remove(self); return; }
- if(!vehicle_initialize(VEH_RAPTOR.vehicleid, false)) { remove(self); return; }
+ if(!vehicle_initialize(VEH_RAPTOR, false)) { remove(self); return; }
}
float v_raptor(float req)
void spawnfunc_vehicle_spiderbot()
{
if(!autocvar_g_vehicle_spiderbot) { remove(self); return; }
- if(!vehicle_initialize(VEH_SPIDERBOT.vehicleid, false)) { remove(self); return; }
+ if(!vehicle_initialize(VEH_SPIDERBOT, false)) { remove(self); return; }
}
float v_spiderbot(float req)