From 00689ad6591308724140e4e1eff110c0ac347871 Mon Sep 17 00:00:00 2001 From: TimePath Date: Sat, 22 Aug 2015 14:47:43 +1000 Subject: [PATCH] Move common vehicle entity fields into the vehicle class --- qcsrc/common/vehicles/all.qh | 30 +------------------------ qcsrc/common/vehicles/unit/bumblebee.qc | 6 +++-- qcsrc/common/vehicles/unit/racer.qc | 6 +++-- qcsrc/common/vehicles/unit/raptor.qc | 6 +++-- qcsrc/common/vehicles/unit/spiderbot.qc | 6 +++-- qcsrc/common/vehicles/vehicle.qh | 30 +++++++++++++++++++++++++ 6 files changed, 47 insertions(+), 37 deletions(-) diff --git a/qcsrc/common/vehicles/all.qh b/qcsrc/common/vehicles/all.qh index 08a3020c7..ccb3a0564 100644 --- a/qcsrc/common/vehicles/all.qh +++ b/qcsrc/common/vehicles/all.qh @@ -41,22 +41,6 @@ entity get_vehicleinfo(float id); .entity tur_head; -// 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 - // other useful macros #define VEH_ACTION(vehicletype,mrequest) (get_vehicleinfo(vehicletype)).vehicle_func(mrequest) #define VEH_NAME(vehicletype) (get_vehicleinfo(vehicletype)).vehicle_name @@ -93,19 +77,7 @@ const int VEH_FIRST = 1; REGISTER_INIT(VEH, id) REGISTER_REGISTRY(RegisterVehicles) - -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 = ""; -} +REGISTER_VEHICLE(NULL, Vehicle); #include "all.inc" diff --git a/qcsrc/common/vehicles/unit/bumblebee.qc b/qcsrc/common/vehicles/unit/bumblebee.qc index b4686d63c..3d8eff20e 100644 --- a/qcsrc/common/vehicles/unit/bumblebee.qc +++ b/qcsrc/common/vehicles/unit/bumblebee.qc @@ -13,7 +13,9 @@ REGISTER_VEHICLE_SIMPLE( /* tags */ "", "", "tag_viewport", /* netname */ "bumblebee", /* fullname */ _("Bumblebee") -); +) { + this.m_icon = "vehicle_bumble"; +} #endif #ifdef IMPLEMENTATION @@ -1101,7 +1103,7 @@ float v_bumblebee(float req) { case VR_HUD: { - Vehicles_drawHUD("vehicle_bumble", "vehicle_bumble_weapon1", "vehicle_bumble_weapon2", + Vehicles_drawHUD(VEH_BUMBLEBEE.m_icon, "vehicle_bumble_weapon1", "vehicle_bumble_weapon2", "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color, "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color, vCROSS_HEAL); diff --git a/qcsrc/common/vehicles/unit/racer.qc b/qcsrc/common/vehicles/unit/racer.qc index afcb131e9..3cf6215be 100644 --- a/qcsrc/common/vehicles/unit/racer.qc +++ b/qcsrc/common/vehicles/unit/racer.qc @@ -12,7 +12,9 @@ REGISTER_VEHICLE_SIMPLE( /* tags */ "", "", "tag_viewport", /* netname */ "racer", /* fullname */ _("Racer") -); +) { + this.m_icon = "vehicle_racer"; +} #endif #ifdef IMPLEMENTATION @@ -808,7 +810,7 @@ bool v_racer(int req) #ifdef CSQC case VR_HUD: { - Vehicles_drawHUD("vehicle_racer", "vehicle_racer_weapon1", "vehicle_racer_weapon2", + Vehicles_drawHUD(VEH_RACER.m_icon, "vehicle_racer_weapon1", "vehicle_racer_weapon2", "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color, "vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color, vCROSS_GUIDE); diff --git a/qcsrc/common/vehicles/unit/raptor.qc b/qcsrc/common/vehicles/unit/raptor.qc index 12bc40589..1e92fa195 100644 --- a/qcsrc/common/vehicles/unit/raptor.qc +++ b/qcsrc/common/vehicles/unit/raptor.qc @@ -13,7 +13,9 @@ REGISTER_VEHICLE_SIMPLE( /* tags */ "", "tag_hud", "tag_camera", /* netname */ "raptor", /* fullname */ _("Raptor") -); +) { + this.m_icon = "vehicle_raptor"; +} #endif #ifdef IMPLEMENTATION @@ -1043,7 +1045,7 @@ float v_raptor(float req) default: crosshair = vCROSS_BURST; } - Vehicles_drawHUD("vehicle_raptor", "vehicle_raptor_weapon1", "vehicle_raptor_weapon2", + Vehicles_drawHUD(VEH_RAPTOR.m_icon, "vehicle_raptor_weapon1", "vehicle_raptor_weapon2", "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color, "vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color, crosshair); diff --git a/qcsrc/common/vehicles/unit/spiderbot.qc b/qcsrc/common/vehicles/unit/spiderbot.qc index de3cdbb7a..0c134acd4 100644 --- a/qcsrc/common/vehicles/unit/spiderbot.qc +++ b/qcsrc/common/vehicles/unit/spiderbot.qc @@ -12,7 +12,9 @@ REGISTER_VEHICLE_SIMPLE( /* tags */ "tag_head", "tag_hud", "", /* netname */ "spiderbot", /* fullname */ _("Spiderbot") -); +) { + this.m_icon = "vehicle_spider"; +} #endif #ifdef IMPLEMENTATION @@ -963,7 +965,7 @@ float v_spiderbot(float req) default: crosshair = vCROSS_BURST; } - Vehicles_drawHUD("vehicle_spider", "vehicle_spider_weapon1", "vehicle_spider_weapon2", + Vehicles_drawHUD(VEH_SPIDERBOT.m_icon, "vehicle_spider_weapon1", "vehicle_spider_weapon2", "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color, "vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color, crosshair); diff --git a/qcsrc/common/vehicles/vehicle.qh b/qcsrc/common/vehicles/vehicle.qh index b085a248b..7df34206f 100644 --- a/qcsrc/common/vehicles/vehicle.qh +++ b/qcsrc/common/vehicles/vehicle.qh @@ -5,6 +5,36 @@ int v_null(int) { return 0; } CLASS(Vehicle, Object) ATTRIB(Vehicle, vehicleid, int, 0) + /** hud icon */ + ATTRIB(Vehicle, m_icon, string, string_null) + /** short name */ + ATTRIB(Vehicle, netname, string, "") + /** human readable name */ + ATTRIB(Vehicle, vehicle_name, string, "Vehicle") + /** */ + ATTRIB(Vehicle, vehicle_func, int(int), v_null) + /** full name of model */ + ATTRIB(Vehicle, model, string, "") + /** currently a copy of the model */ + ATTRIB(Vehicle, mdl, string, "") + /** full name of tur_head model */ + ATTRIB(Vehicle, head_model, string, "") + /** cockpit model */ + ATTRIB(Vehicle, hud_model, string, "") + /** tur_head model tag */ + ATTRIB(Vehicle, tag_head, string, string_null) + /** hud model tag */ + ATTRIB(Vehicle, tag_hud, string, string_null) + /** cockpit model tag */ + ATTRIB(Vehicle, tag_view, string, string_null) + /** player physics mod */ + ATTRIB(Vehicle, PlayerPhysplug, int(), func_null) + /** */ + ATTRIB(Vehicle, spawnflags, int, 0) + /** vehicle hitbox size */ + ATTRIB(Vehicle, mins, vector, '-0 -0 -0') + /** vehicle hitbox size */ + ATTRIB(Vehicle, maxs, vector, '0 0 0') ENDCLASS(Vehicle) #endif -- 2.39.2