]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Load vehicles in the menu with the registry system
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 22 Aug 2015 04:02:49 +0000 (14:02 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 22 Aug 2015 04:02:49 +0000 (14:02 +1000)
12 files changed:
qcsrc/client/main.qc
qcsrc/client/progs.src
qcsrc/common/vehicles/all.qc
qcsrc/common/vehicles/all.qh
qcsrc/common/vehicles/unit/bumblebee.qc
qcsrc/common/vehicles/unit/racer.qc
qcsrc/common/vehicles/unit/raptor.qc
qcsrc/common/vehicles/unit/spiderbot.qc
qcsrc/common/vehicles/vehicle.qh [new file with mode: 0644]
qcsrc/menu/progs.src
qcsrc/server/g_world.qc
qcsrc/server/progs.src

index 84358c4f9bab1ef3c3139bc1f868b1d340f99246..752b518bac4cfe1dbb4c661cfae61424011ffdb0 100644 (file)
@@ -147,7 +147,6 @@ void CSQC_Init(void)
        CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
        CALL_ACCUMULATED_FUNCTION(RegisterHUD_Panels);
        CALL_ACCUMULATED_FUNCTION(RegisterEffects);
-       CALL_ACCUMULATED_FUNCTION(RegisterVehicles);
 
        WaypointSprite_Load();
 
index b80d787ca10c9c1d7f54206d6b71020d2b52a524..1c739ab76126c6ea1cb52998102255218b0c3f4b 100644 (file)
@@ -57,10 +57,9 @@ weapons/projectile.qc // TODO
 ../common/viewloc.qc
 
 ../common/items/all.qc
-
 ../common/monsters/all.qc
-
-../common/weapons/all.qc // TODO
+../common/vehicles/all.qc
+../common/weapons/all.qc
 
 ../common/triggers/include.qc
 
@@ -68,8 +67,6 @@ weapons/projectile.qc // TODO
 ../csqcmodellib/cl_player.qc
 ../csqcmodellib/interpolate.qc
 
-../common/vehicles/all.qc
-
 ../server/mutators/mutator_multijump.qc
 
 ../warpzonelib/anglestransform.qc
index 2c45308b4c9011f46aadc1981615b938322452dc..4923c1b0100db12c15ba38c9c5b14afd0d6f0fe3 100644 (file)
@@ -14,7 +14,6 @@
 #undef IMPLEMENTATION
 
 // VEHICLE PLUGIN SYSTEM
-entity vehicle_info[VEH_MAXCOUNT];
 entity dummy_vehicle_info;
 
 void vehicles_common_initialize()
@@ -48,10 +47,9 @@ void vehicles_common_initialize()
 #endif // SVQC
 }
 
-void register_vehicle(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)
+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)
 {
-       entity e;
-       vehicle_info[id - 1] = e = spawn();
+       vehicle_info[id - 1] = e;
        e.classname = "vehicle_info";
        e.vehicleid = id;
        e.netname = shortname;
@@ -72,7 +70,6 @@ void register_vehicle(float id, float(float) func, float vehicleflags, vector mi
        vehicles_common_initialize();
        #endif
 }
-float v_null(float dummy) { return 0; }
 void register_vehicles_done()
 {
        dummy_vehicle_info = spawn();
index 03be2127f9a222c17c697f31dac1a002b47e751f..dbb7b0e39178a60e750393d439c6643763c54d52 100644 (file)
@@ -65,38 +65,30 @@ entity get_vehicleinfo(float id);
 //  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();
-
+void RegisterVehicles();
 const int VEH_MAXCOUNT = 24;
-#define VEH_FIRST 1
+entity vehicle_info[VEH_MAXCOUNT], vehicle_info_first, vehicle_info_last;
 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)
-#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))
+#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)
+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"
 
-#undef REGISTER_VEHICLE
 ACCUMULATE_FUNCTION(RegisterVehicles, register_vehicles_done);
 
-#include "all.inc"
-
 #endif
index 859a89e133c5344d5c4f413c2f627ded6347c834..7d338d3e7c0346573fe192b4fbcfd693d1750d97 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef VEHICLE_BUMBLEBEE
 #define VEHICLE_BUMBLEBEE
 #include "bumblebee.qh"
-REGISTER_VEHICLE(
+REGISTER_VEHICLE_SIMPLE(
 /* VEH_##id   */ BUMBLEBEE,
 /* function   */ v_bumblebee,
 /* spawnflags */ VHF_DMGSHAKE,
index 6c1f30cc19fda79e24a0de29a90ad4b8a2020819..3549150d536b4ffb83415ca97d660bc6898c43e6 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef VEHICLE_RACER
 #define VEHICLE_RACER
-REGISTER_VEHICLE(
+REGISTER_VEHICLE_SIMPLE(
 /* VEH_##id   */ RACER,
 /* function   */ v_racer,
 /* spawnflags */ VHF_DMGSHAKE | VHF_DMGROLL,
@@ -859,9 +859,10 @@ bool v_racer(int req)
 
                        precache_model ("models/vhshield.md3");
                #endif
-
+               #ifndef MENUQC
                        precache_model ("models/vehicles/wakizashi.dpm");
                        precache_model ("models/vehicles/wakizashi_cockpit.dpm");
+               #endif
                        return true;
                }
        }
index 4624835a21555f25a2e936f20164bb4b0c120102..8eaa0c93c0849acca091209c5f4507f4d08347fe 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef VEHICLE_RAPTOR
 #define VEHICLE_RAPTOR
 #include "raptor.qh"
-REGISTER_VEHICLE(
+REGISTER_VEHICLE_SIMPLE(
 /* VEH_##id   */ RAPTOR,
 /* function   */ v_raptor,
 /* spawnflags */ VHF_DMGSHAKE | VHF_DMGROLL,
index 511f9964ab3f767c743d542e2441db30b21134a2..7c23205ece8c59851ba656d796b772a7d5ce7c75 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef VEHICLE_SPIDERBOT
 #define VEHICLE_SPIDERBOT
-REGISTER_VEHICLE(
+REGISTER_VEHICLE_SIMPLE(
 /* VEH_##id   */ SPIDERBOT,
 /* function   */ v_spiderbot,
 /* spawnflags */ VHF_DMGSHAKE,
diff --git a/qcsrc/common/vehicles/vehicle.qh b/qcsrc/common/vehicles/vehicle.qh
new file mode 100644 (file)
index 0000000..65b1397
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef VEHICLE_H
+#define VEHICLE_H
+
+int v_null(int) { return 0; }
+
+CLASS(Vehicle, Object)
+    ATTRIB(Vehicle, m_id, int, 0)
+ENDCLASS(Vehicle)
+
+#endif
index 64f12478ddeb9bff3fe171e50bf8f5e2480f5aa8..2bde451f8dc381aa80209319872bda56b69427be 100644 (file)
@@ -23,10 +23,9 @@ xonotic/util.qc
 ../common/util.qc
 
 ../common/items/all.qc
-
 ../common/monsters/all.qc
-
-../common/weapons/all.qc // TODO
+../common/vehicles/all.qc
+../common/weapons/all.qc
 
 ../warpzonelib/mathlib.qc
 
index 0a3462dca47400203b92f8b666cc2f58c5f9bb6f..2df126d4ba0d392be9ffea8d8953d6bebc3fbe68 100644 (file)
@@ -565,7 +565,6 @@ void spawnfunc___init_dedicated_server(void)
        CALL_ACCUMULATED_FUNCTION(RegisterNotifications);
        CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
        CALL_ACCUMULATED_FUNCTION(RegisterEffects);
-       CALL_ACCUMULATED_FUNCTION(RegisterVehicles);
 
        MapInfo_Enumerate();
        MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
@@ -614,7 +613,6 @@ void spawnfunc_worldspawn (void)
        CALL_ACCUMULATED_FUNCTION(RegisterNotifications);
        CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
        CALL_ACCUMULATED_FUNCTION(RegisterEffects);
-       CALL_ACCUMULATED_FUNCTION(RegisterVehicles);
 
        ServerProgsDB = db_load(strcat("server.db", autocvar_sessionid));
 
index cda751fa7c01918057b4a6cfe47094ebc70a3765..e13a760cbf4df64f2603d1119bcf30b7220445fe 100644 (file)
@@ -87,7 +87,6 @@ weapons/weaponsystem.qc
 ../common/campaign_setup.qc
 ../common/effects.qc
 ../common/mapinfo.qc
-../common/monsters/all.qc
 ../common/monsters/spawn.qc
 ../common/monsters/sv_monsters.qc
 ../common/movetypes/include.qc
@@ -102,12 +101,13 @@ weapons/weaponsystem.qc
 ../common/triggers/include.qc
 ../common/urllib.qc
 ../common/util.qc
-../common/vehicles/all.qc
 
 ../common/items/all.qc
+../common/monsters/all.qc
+../common/vehicles/all.qc
+../common/weapons/all.qc // TODO
 
 ../common/weapons/config.qc
-../common/weapons/all.qc // TODO
 
 ../csqcmodellib/sv_model.qc