server: remove _all
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 5 Aug 2017 14:07:45 +0000 (00:07 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 5 Aug 2017 15:50:41 +0000 (01:50 +1000)
Added REGISTRY_DEPENDS

67 files changed:
qcsrc/common/items/all.qh
qcsrc/common/sounds/all.qc
qcsrc/common/stats.qh
qcsrc/common/t_items.qh
qcsrc/common/turrets/sv_turrets.qh
qcsrc/lib/registry.qh
qcsrc/server/_all.inc [deleted file]
qcsrc/server/_all.qh [deleted file]
qcsrc/server/_mod.inc
qcsrc/server/_mod.qh
qcsrc/server/antilag.qc
qcsrc/server/bot/api.qh
qcsrc/server/bot/default/aim.qc
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/havocbot/roles.qc
qcsrc/server/bot/default/navigation.qc
qcsrc/server/bot/default/scripting.qc
qcsrc/server/bot/default/waypoints.qc
qcsrc/server/campaign.qc
qcsrc/server/cheats.qc
qcsrc/server/client.qc
qcsrc/server/client.qh
qcsrc/server/command/banning.qc
qcsrc/server/command/cmd.qc
qcsrc/server/command/common.qc
qcsrc/server/command/getreplies.qc
qcsrc/server/command/sv_cmd.qc
qcsrc/server/command/vote.qc
qcsrc/server/compat/quake.qc
qcsrc/server/compat/quake3.qc
qcsrc/server/compat/wop.qc
qcsrc/server/g_damage.qc
qcsrc/server/g_damage.qh
qcsrc/server/g_hook.qc
qcsrc/server/g_lights.qc
qcsrc/server/g_models.qc
qcsrc/server/g_subs.qc
qcsrc/server/ipban.qc
qcsrc/server/mapvoting.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/miscfunctions.qh
qcsrc/server/mutators/gamemode.qh
qcsrc/server/mutators/loader.qc
qcsrc/server/mutators/mutator/gamemode_ctf.qc
qcsrc/server/mutators/mutator/gamemode_keepaway.qc
qcsrc/server/pathlib/main.qc
qcsrc/server/pathlib/movenode.qc
qcsrc/server/pathlib/utility.qc
qcsrc/server/player.qc
qcsrc/server/portals.qc
qcsrc/server/progs.inc
qcsrc/server/race.qc
qcsrc/server/round_handler.qc
qcsrc/server/scores_rules.qc
qcsrc/server/tests.qh
qcsrc/server/utils.qh [new file with mode: 0644]
qcsrc/server/weapons/accuracy.qh
qcsrc/server/weapons/common.qc
qcsrc/server/weapons/csqcprojectile.qc
qcsrc/server/weapons/hitplot.qc
qcsrc/server/weapons/selection.qh
qcsrc/server/weapons/spawning.qh
qcsrc/server/weapons/throwing.qh
qcsrc/server/weapons/tracing.qc
qcsrc/server/weapons/tracing.qh
qcsrc/server/weapons/weaponstats.qc
qcsrc/server/weapons/weaponsystem.qh

index dc8cf21..14c5a34 100644 (file)
@@ -6,6 +6,9 @@
 
 REGISTRY(Items, BITS(7))
 #define Items_from(i) _Items_from(i, NULL)
+#ifdef GAMEQC
+REGISTRY_DEPENDS(Items, Models)
+#endif
 REGISTER_REGISTRY(Items)
 #define REGISTER_ITEM(id, class) REGISTER(Items, ITEM, id, m_id, NEW(class))
 
index 203b643..328486d 100644 (file)
@@ -1,6 +1,8 @@
 #include "all.qh"
 #ifdef SVQC
 
+#include <server/utils.qh>
+
 bool autocvar_bot_sound_monopoly;
 
 .entity realowner;
index c1503ca..c452b11 100644 (file)
@@ -1,6 +1,7 @@
 #pragma once
 
 #ifdef SVQC
+#include <server/autocvars.qh>
 #include <server/client.qh>
 #endif
 
index 1b2293b..e52604d 100644 (file)
@@ -1,5 +1,9 @@
 #pragma once
 
+#ifdef SVQC
+#include <server/defs.qh>
+#endif
+
 const int AMMO_COUNT = 4; // amount of ammo types to show in the inventory panel
 
 // item networking
index edd06bd..41a7bd9 100644 (file)
@@ -1,5 +1,7 @@
 #pragma once
 
+#include <server/miscfunctions.qh>
+
 entity turret_projectile(entity actor, Sound _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim);
 void turret_projectile_explode(entity this);
 float turret_validate_target(entity e_turret, entity e_target, float validate_flags);
index a3282a0..8ca07b4 100644 (file)
  */
 #define REGISTRY(id, max) \
        void Register##id(); \
+       [[accumulate]] void REGISTRY_DEPENDS_(id) {} \
        [[accumulate]] REGISTRY_BEGIN(id) {} \
        [[accumulate]] REGISTRY_END(id) {} \
        void _Register##id() {} \
-       void Register##id() { REGISTRY_BEGIN_(id); _Register##id(); REGISTRY_END_(id); } \
+       int id##_state = 0; \
+       void Register##id() { if (id##_state) return; id##_state = 1; REGISTRY_DEPENDS_(id); REGISTRY_BEGIN_(id); _Register##id(); id##_state = 2; REGISTRY_END_(id); } \
        const int id##_MAX = max; \
        int id##_COUNT; \
        noref entity id##_first, id##_last; \
        SHUTDOWN(id) { _R_DEL(_##id); } \
        entity _##id##_from(int i, entity null) { if (i >= 0 && i < id##_COUNT) { entity e = _R_GET(_##id, i); if (e) return e; } return null; }
 
+/** Add registry dependencies to a registry */
+#define REGISTRY_DEPENDS(id, dep) void Register##dep(); void REGISTRY_DEPENDS_(id) { Register##dep(); }
+#define REGISTRY_DEPENDS_(id) Register##id##_Depends()
+
 /** Called before initializing a registry. */
 #define REGISTRY_BEGIN(id) [[accumulate]] void REGISTRY_BEGIN_(id) { noref void() f = Register##id; } void REGISTRY_BEGIN_(id)
 #define REGISTRY_BEGIN_(id) Register##id##_First()
@@ -189,5 +195,6 @@ void Registry_send(string id, string hash);
        ENDCLASS(id##Registry) \
        REGISTER(Registries, REGISTRY, id, m_id, NEW(id##Registry)); \
        METHOD(id##Registry, m_reload, void()) { \
+           id##_state = 0; \
                Register##id(); \
        }
diff --git a/qcsrc/server/_all.inc b/qcsrc/server/_all.inc
deleted file mode 100644 (file)
index 95bf715..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <server/_all.qh>
-#include "_mod.inc"
-
-#include "bot/_mod.inc"
-#include "command/_mod.inc"
-#include "compat/_mod.inc"
-#include "mutators/_mod.inc"
-#include "pathlib/_mod.inc"
-#include "weapons/_mod.inc"
-
-#include <common/_all.inc>
-#include <common/effects/qc/all.qc>
-
-#include <lib/csqcmodel/sv_model.qc>
-
-#include <lib/warpzone/anglestransform.qc>
-#include <lib/warpzone/common.qc>
-#include <lib/warpzone/server.qc>
-#include <lib/warpzone/util_server.qc>
diff --git a/qcsrc/server/_all.qh b/qcsrc/server/_all.qh
deleted file mode 100644 (file)
index 1c0382c..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-#pragma once
-
-int maxclients;
-
-const string STR_PLAYER = "player";
-const string STR_SPECTATOR = "spectator";
-const string STR_OBSERVER = "observer";
-
-#define IS_PLAYER(v) ((v).classname == STR_PLAYER)
-#define IS_SPEC(v) ((v).classname == STR_SPECTATOR)
-#define IS_OBSERVER(v) ((v).classname == STR_OBSERVER)
-
-#define IS_CLIENT(v) (v.flags & FL_CLIENT)
-/** want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v)) */
-#define IS_BOT_CLIENT(v) (clienttype(v) == CLIENTTYPE_BOT)
-#define IS_FAKE_CLIENT(v) (clienttype(v) == CLIENTTYPE_NOTACLIENT)
-#define IS_REAL_CLIENT(v) (clienttype(v) == CLIENTTYPE_REAL)
-/** was: (clienttype(v) == CLIENTTYPE_NOTACLIENT) */
-#define IS_NOT_A_CLIENT(v) (!IS_CLIENT(v))
-
-#define IS_MONSTER(v) (v.flags & FL_MONSTER)
-#define IS_VEHICLE(v) (v.vehicle_flags & VHF_ISVEHICLE)
-#define IS_TURRET(v) (v.turret_flags & TUR_FLAG_ISTURRET)
-
-// NOTE: FOR_EACH_CLIENTSLOT deprecated! Use the following instead: FOREACH_CLIENTSLOT(true, { code; });
-// NOTE: FOR_EACH_CLIENT deprecated! Use the following instead: FOREACH_CLIENT(true, { code; });
-// NOTE: FOR_EACH_REALCLIENT deprecated! Use the following instead: FOREACH_CLIENT(IS_REAL_CLIENT(it), { code; });
-
-// NOTE: FOR_EACH_PLAYER deprecated! Use the following instead: FOREACH_CLIENT(IS_PLAYER(it), { code; });
-// NOTE: FOR_EACH_SPEC deprecated! Use the following instead: FOREACH_CLIENT(IS_SPEC(it), { code; });
-// NOTE: FOR_EACH_OBSERVER deprecated! Use the following instead: FOREACH_CLIENT(IS_OBSERVER(it), { code; });
-// NOTE: FOR_EACH_REALPLAYER deprecated! Use the following instead: FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), { code; });
-
-#define FOREACH_CLIENTSLOT(cond, body) \
-       MACRO_BEGIN { \
-               for(int _i = 1; _i <= maxclients; ++_i) \
-               { \
-                       const noref int i = _i; \
-                       ITER_CONST noref entity it = ftoe(i); \
-                       if(cond) { LAMBDA(body) } \
-               } \
-       } MACRO_END
-
-#define FOREACH_CLIENT(cond, body) FOREACH_CLIENTSLOT(IS_CLIENT(it) && (cond), body)
-
-// using the "inside out" version of knuth-fisher-yates shuffle
-// https://en.wikipedia.org/wiki/Fisher–Yates_shuffle
-entity _FCR_clients[255];
-bool _FCR_entered = false;
-#define FOREACH_CLIENT_RANDOM(cond, body) \
-       MACRO_BEGIN { \
-               if (_FCR_entered) LOG_FATAL("FOREACH_CLIENT_RANDOM must not be nested"); \
-               _FCR_entered = true; \
-               int _cnt = 0; \
-               FOREACH_CLIENT(cond, { \
-            int _j = floor(random() * (_cnt + 1)); \
-            if (_j == _cnt) \
-            { \
-                _FCR_clients[_cnt] = it; \
-            } \
-            else \
-            { \
-                _FCR_clients[_cnt] = _FCR_clients[_j]; \
-                _FCR_clients[_j] = it; \
-            } \
-            _cnt++; \
-        }); \
-               for (int _i = 0; _i < _cnt; ++_i) \
-               { \
-                       const noref int i = _i; \
-                       ITER_CONST noref entity it = _FCR_clients[i]; \
-                       if (cond) { LAMBDA(body) } \
-               } \
-               _FCR_entered = false; \
-       } MACRO_END
-
-// NOTE: FOR_EACH_MONSTER deprecated! Use the following instead: IL_EACH(g_monsters, true, { code; });
-
-#include <common/effects/all.qh>
-#include <common/models/all.qh>
-#include <common/sounds/all.qh>
-
-#include "autocvars.qh"
-#include "constants.qh"
-#include "defs.qh"
-#include "miscfunctions.qh"
index eb74529..87a8d56 100644 (file)
 #endif
 #include <server/teamplay.qc>
 #include <server/tests.qc>
+
+#include <server/bot/_mod.inc>
+#include <server/command/_mod.inc>
+#include <server/compat/_mod.inc>
+#include <server/mutators/_mod.inc>
+#include <server/pathlib/_mod.inc>
+#include <server/weapons/_mod.inc>
index a0d160d..2967c11 100644 (file)
 #endif
 #include <server/teamplay.qh>
 #include <server/tests.qh>
+
+#include <server/bot/_mod.qh>
+#include <server/command/_mod.qh>
+#include <server/compat/_mod.qh>
+#include <server/mutators/_mod.qh>
+#include <server/pathlib/_mod.qh>
+#include <server/weapons/_mod.qh>
index d5f8e39..46c8718 100644 (file)
@@ -2,6 +2,7 @@
 #if defined(CSQC)
 #elif defined(MENUQC)
 #elif defined(SVQC)
+    #include <server/defs.qh>
     #include <common/state.qh>
     #include <common/vehicles/all.qh>
     #include "antilag.qh"
index d488213..f33cc4f 100644 (file)
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <server/defs.qh>
 #include <common/weapons/_all.qh>
 
 const int WAYPOINTFLAG_GENERATED = BIT(23);
index d0ba633..feb19af 100644 (file)
@@ -1,5 +1,7 @@
 #include "aim.qh"
 
+#include <server/defs.qh>
+
 #include "cvars.qh"
 
 #include "bot.qh"
index 5d31c7e..46acf88 100644 (file)
@@ -1,5 +1,7 @@
 #include "havocbot.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include "../cvars.qh"
 
 #include "../aim.qh"
index 22f444f..94aed9c 100644 (file)
@@ -1,5 +1,7 @@
 #include "roles.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include "havocbot.qh"
 
 #include "../cvars.qh"
index fc97931..d0061b9 100644 (file)
@@ -1,5 +1,7 @@
 #include "navigation.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include "cvars.qh"
 
 #include "bot.qh"
index ca74965..badf943 100644 (file)
@@ -1,5 +1,7 @@
 #include "scripting.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include "cvars.qh"
 
 #include <common/state.qh>
index 65cc69f..c8a958d 100644 (file)
@@ -1,5 +1,7 @@
 #include "waypoints.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include "cvars.qh"
 
 #include "bot.qh"
index b39f82a..ec8990d 100644 (file)
@@ -1,4 +1,7 @@
 #include "campaign.qh"
+
+#include "defs.qh"
+
 #include "cheats.qh"
 #include "miscfunctions.qh"
 #include "g_world.qh"
index 78c5912..ee1e767 100644 (file)
@@ -1,5 +1,9 @@
 #include "cheats.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+#include <common/effects/all.qh>
+
 #include "g_damage.qh"
 #include "race.qh"
 #include "../common/triggers/teleporters.qh"
index 14b854b..a8e2ef3 100644 (file)
@@ -1,5 +1,8 @@
 #include "client.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+#include <common/effects/all.qh>
 #include "anticheat.qh"
 #include "impulse.qh"
 #include "player.qh"
index ee00c60..383383a 100644 (file)
@@ -1,5 +1,8 @@
 #pragma once
 
+#include "utils.qh"
+#include <common/sounds/all.qh>
+
 void ClientState_attach(entity this);
 
 IntrusiveList g_players;
index fa1be75..d90b372 100644 (file)
@@ -1,4 +1,7 @@
 #include "banning.qh"
+
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include <common/state.qh>
 #include <common/command/_mod.qh>
 #include "banning.qh"
index 03f484d..d1d7998 100644 (file)
@@ -1,4 +1,8 @@
 #include "cmd.qh"
+
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
 #include <common/command/_mod.qh>
 
 #include "common.qh"
index 77c3930..d8bc3ac 100644 (file)
@@ -1,4 +1,8 @@
 #include "common.qh"
+
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
 #include <common/command/_mod.qh>
 #include "common.qh"
 
index cfcadf4..e67625a 100644 (file)
@@ -1,4 +1,8 @@
 #include "getreplies.qh"
+
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
 #include <common/command/_mod.qh>
 #include "getreplies.qh"
 
index 0bc47c0..49bee36 100644 (file)
@@ -1,6 +1,8 @@
 #include "sv_cmd.qh"
 #include "_mod.qh"
 
+#include <common/effects/all.qh>
+
 #include "banning.qh"
 #include "cmd.qh"
 #include "common.qh"
index 2db503c..ed17ed0 100644 (file)
@@ -1,4 +1,8 @@
 #include "vote.qh"
+
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
 #include <common/command/_mod.qh>
 #include "vote.qh"
 
index 539042d..126a0f6 100644 (file)
@@ -1,5 +1,7 @@
 #include "quake.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include <common/weapons/_all.qh>
 
 spawnfunc(weapon_electro);
index 905523b..532428d 100644 (file)
@@ -1,5 +1,7 @@
 #include "quake3.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include <common/weapons/_all.qh>
 
 spawnfunc(weapon_crylink);
index f6b2f26..6c69859 100644 (file)
@@ -1,5 +1,7 @@
 #include "wop.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include <common/weapons/_all.qh>
 // #include <server/mutators/gamemode.qh>
 
index 61d0480..d96c28b 100644 (file)
@@ -1,5 +1,6 @@
 #include "g_damage.qh"
 
+#include <common/effects/all.qh>
 #include "bot/api.qh"
 #include "g_hook.qh"
 #include "mutators/_mod.qh"
index e242de4..aee4a93 100644 (file)
@@ -3,6 +3,8 @@
 #if defined(CSQC)
 #elif defined(MENUQC)
 #elif defined(SVQC)
+    #include <server/defs.qh>
+    #include <server/miscfunctions.qh>
     #include <lib/warpzone/common.qh>
     #include <common/constants.qh>
     #include <common/teams.qh>
index 2081b68..0fc60b2 100644 (file)
@@ -1,5 +1,8 @@
 #include "g_hook.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+#include <common/effects/all.qh>
 #include "weapons/common.qh"
 #include "weapons/csqcprojectile.qh"
 #include "weapons/weaponsystem.qh"
index 425716d..852f1ef 100644 (file)
@@ -1,5 +1,8 @@
 #include "g_lights.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
 void train_next(entity this);
 
 const float LOOP = 1;
index d3f56f5..539522f 100644 (file)
@@ -1,5 +1,7 @@
 #include "g_models.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include "g_subs.qh"
 #include <common/net_linked.qh>
 #include "../common/triggers/subs.qh"
index 33f471e..8c39f88 100644 (file)
@@ -1,5 +1,7 @@
 #include "g_subs.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include "antilag.qh"
 #include "command/common.qh"
 #include "../common/state.qh"
index 50c258f..6211362 100644 (file)
@@ -1,5 +1,7 @@
 #include "ipban.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include "autocvars.qh"
 #include "command/banning.qh"
 #include "defs.qh"
index 53cf1cd..209ac7a 100644 (file)
@@ -1,5 +1,7 @@
 #include "mapvoting.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include "g_world.qh"
 #include "command/cmd.qh"
 #include "command/getreplies.qh"
index 652ef65..ffc0e9e 100644 (file)
@@ -1,4 +1,5 @@
 #include "miscfunctions.qh"
+
 #include "antilag.qh"
 #include "command/common.qh"
 #include "constants.qh"
index 789ba93..abe8cd7 100644 (file)
@@ -1,5 +1,7 @@
 #pragma once
 
+#include <server/defs.qh>
+
 #include <common/t_items.qh>
 
 #include "mutators/events.qh"
index 84094df..ac87465 100644 (file)
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <server/miscfunctions.qh>
 #include <server/g_world.qh>
 #include <server/round_handler.qh>
 #include <server/scores.qh>
index 43c668e..7c20b37 100644 (file)
@@ -1,5 +1,8 @@
 #include "loader.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
 STATIC_INIT_LATE(Gametype) {
     Gametype g = MapInfo_CurrentGametype();
     if (g) {
index 23bbeaa..c1698c5 100644 (file)
@@ -1,6 +1,7 @@
 #include "gamemode_ctf.qh"
 
 #ifndef CSQC
+#include <common/effects/all.qh>
 void ctf_Initialize();
 
 REGISTER_MUTATOR(ctf, false)
index 0b4bd54..c28fd5e 100644 (file)
@@ -1,5 +1,7 @@
 #include "gamemode_keepaway.qh"
 
+#include <common/effects/all.qh>
+
 int autocvar_g_keepaway_ballcarrier_effects;
 float autocvar_g_keepaway_ballcarrier_damage;
 float autocvar_g_keepaway_ballcarrier_force;
index 706e10d..c2f3326 100644 (file)
@@ -1,5 +1,7 @@
 #include "main.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include "pathlib.qh"
 #include "utility.qh"
 #include "../command/common.qh"
index f27ab48..cbcfe3d 100644 (file)
@@ -1,5 +1,7 @@
 #include "movenode.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include "pathlib.qh"
 #include "utility.qh"
 
index da64db6..151fb44 100644 (file)
@@ -1,5 +1,7 @@
 #include "utility.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include "pathlib.qh"
 
 bool location_isok(vector point, bool waterok, bool air_isok)
index d70210f..827c86a 100644 (file)
@@ -1,5 +1,6 @@
 #include "player.qh"
 
+#include <common/effects/all.qh>
 #include "bot/api.qh"
 #include "cheats.qh"
 #include "g_damage.qh"
index 260e035..6de3e0a 100644 (file)
@@ -1,5 +1,6 @@
 #include "portals.qh"
 
+#include <common/effects/all.qh>
 #include "g_hook.qh"
 #include "mutators/_mod.qh"
 #include "../common/constants.qh"
index 1a8ada4..f72ff85 100644 (file)
@@ -1,7 +1,18 @@
 #include <lib/_all.inc>
 
 #if XONOTIC
-#include <server/_all.inc>
+
+#include <server/_mod.inc>
+
+#include <common/_all.inc>
+#include <common/effects/qc/all.qc>
+
+#include <lib/csqcmodel/sv_model.qc>
+
+#include <lib/warpzone/anglestransform.qc>
+#include <lib/warpzone/common.qc>
+#include <lib/warpzone/server.qc>
+#include <lib/warpzone/util_server.qc>
 
 #include <ecs/_mod.inc>
 #endif
index 0a3e2e8..7f2aaaa 100644 (file)
@@ -1,5 +1,7 @@
 #include "race.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include "client.qh"
 #include "portals.qh"
 #include "scores.qh"
index 16564cd..ae64e74 100644 (file)
@@ -1,5 +1,7 @@
 #include "round_handler.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include "campaign.qh"
 #include "command/vote.qh"
 #include "../common/util.qh"
index 9c41647..97e8040 100644 (file)
@@ -1,5 +1,7 @@
 #include "scores_rules.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include "client.qh"
 #include "scores.qh"
 
index e6d6f66..ad40da4 100644 (file)
@@ -1,5 +1,7 @@
 #pragma once
 
+#include "defs.qh"
+#include "miscfunctions.qh"
 #include "autocvars.qh"
 #include "client.qh"
 #include "command/_mod.qh"
diff --git a/qcsrc/server/utils.qh b/qcsrc/server/utils.qh
new file mode 100644 (file)
index 0000000..da5c7a5
--- /dev/null
@@ -0,0 +1,77 @@
+#pragma once
+
+int maxclients;
+
+const string STR_PLAYER = "player";
+const string STR_SPECTATOR = "spectator";
+const string STR_OBSERVER = "observer";
+
+#define IS_PLAYER(v) ((v).classname == STR_PLAYER)
+#define IS_SPEC(v) ((v).classname == STR_SPECTATOR)
+#define IS_OBSERVER(v) ((v).classname == STR_OBSERVER)
+
+#define IS_CLIENT(v) (v.flags & FL_CLIENT)
+/** want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v)) */
+#define IS_BOT_CLIENT(v) (clienttype(v) == CLIENTTYPE_BOT)
+#define IS_FAKE_CLIENT(v) (clienttype(v) == CLIENTTYPE_NOTACLIENT)
+#define IS_REAL_CLIENT(v) (clienttype(v) == CLIENTTYPE_REAL)
+/** was: (clienttype(v) == CLIENTTYPE_NOTACLIENT) */
+#define IS_NOT_A_CLIENT(v) (!IS_CLIENT(v))
+
+#define IS_MONSTER(v) (v.flags & FL_MONSTER)
+#define IS_VEHICLE(v) (v.vehicle_flags & VHF_ISVEHICLE)
+#define IS_TURRET(v) (v.turret_flags & TUR_FLAG_ISTURRET)
+
+// NOTE: FOR_EACH_CLIENTSLOT deprecated! Use the following instead: FOREACH_CLIENTSLOT(true, { code; });
+// NOTE: FOR_EACH_CLIENT deprecated! Use the following instead: FOREACH_CLIENT(true, { code; });
+// NOTE: FOR_EACH_REALCLIENT deprecated! Use the following instead: FOREACH_CLIENT(IS_REAL_CLIENT(it), { code; });
+
+// NOTE: FOR_EACH_PLAYER deprecated! Use the following instead: FOREACH_CLIENT(IS_PLAYER(it), { code; });
+// NOTE: FOR_EACH_SPEC deprecated! Use the following instead: FOREACH_CLIENT(IS_SPEC(it), { code; });
+// NOTE: FOR_EACH_OBSERVER deprecated! Use the following instead: FOREACH_CLIENT(IS_OBSERVER(it), { code; });
+// NOTE: FOR_EACH_REALPLAYER deprecated! Use the following instead: FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), { code; });
+
+#define FOREACH_CLIENTSLOT(cond, body) \
+       MACRO_BEGIN { \
+               for(int _i = 1; _i <= maxclients; ++_i) \
+               { \
+                       const noref int i = _i; \
+                       ITER_CONST noref entity it = ftoe(i); \
+                       if(cond) { LAMBDA(body) } \
+               } \
+       } MACRO_END
+
+#define FOREACH_CLIENT(cond, body) FOREACH_CLIENTSLOT(IS_CLIENT(it) && (cond), body)
+
+// using the "inside out" version of knuth-fisher-yates shuffle
+// https://en.wikipedia.org/wiki/Fisher–Yates_shuffle
+entity _FCR_clients[255];
+bool _FCR_entered = false;
+#define FOREACH_CLIENT_RANDOM(cond, body) \
+       MACRO_BEGIN { \
+               if (_FCR_entered) LOG_FATAL("FOREACH_CLIENT_RANDOM must not be nested"); \
+               _FCR_entered = true; \
+               int _cnt = 0; \
+               FOREACH_CLIENT(cond, { \
+            int _j = floor(random() * (_cnt + 1)); \
+            if (_j == _cnt) \
+            { \
+                _FCR_clients[_cnt] = it; \
+            } \
+            else \
+            { \
+                _FCR_clients[_cnt] = _FCR_clients[_j]; \
+                _FCR_clients[_j] = it; \
+            } \
+            _cnt++; \
+        }); \
+               for (int _i = 0; _i < _cnt; ++_i) \
+               { \
+                       const noref int i = _i; \
+                       ITER_CONST noref entity it = _FCR_clients[i]; \
+                       if (cond) { LAMBDA(body) } \
+               } \
+               _FCR_entered = false; \
+       } MACRO_END
+
+// NOTE: FOR_EACH_MONSTER deprecated! Use the following instead: IL_EACH(g_monsters, true, { code; });
index 35b0174..d24ee1c 100644 (file)
@@ -1,5 +1,8 @@
 #pragma once
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
 .bool cvar_cl_accuracy_data_share;
 REPLICATE(cvar_cl_accuracy_data_share, bool, "cl_accuracy_data_share");
 .bool cvar_cl_accuracy_data_receive;
index fb57d92..b94b253 100644 (file)
@@ -1,5 +1,7 @@
 #include "common.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include <common/t_items.qh>
 #include <common/constants.qh>
 #include <common/net_linked.qh>
index 42bff7c..d426e2f 100644 (file)
@@ -1,5 +1,7 @@
 #include "csqcprojectile.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include <common/t_items.qh>
 
 #include "../command/common.qh"
index 89cec6a..fb13bd1 100644 (file)
@@ -1,5 +1,7 @@
 #include "hitplot.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include "../antilag.qh"
 #include "../g_subs.qh"
 #include <common/weapons/_all.qh>
index 071a0fe..ea580e9 100644 (file)
@@ -1,5 +1,8 @@
 #pragma once
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
 // switch between weapons
 void Send_WeaponComplain(entity e, float wpn, float type);
 
index 9ce5ca3..d435002 100644 (file)
@@ -1,5 +1,8 @@
 #pragma once
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
 string W_Apply_Weaponreplace(string in);
 
 void weapon_defaultspawnfunc(entity this, Weapon e);
index 1b62b64..9ea5e5c 100644 (file)
@@ -1,5 +1,8 @@
 #pragma once
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
 .float savenextthink;
 void thrown_wep_think(entity this);
 
index d6c9fdf..6497266 100644 (file)
@@ -1,5 +1,7 @@
 #include "tracing.qh"
 
+#include <common/effects/all.qh>
+
 #include "accuracy.qh"
 #include "common.qh"
 #include "hitplot.qh"
index 0c17e19..3fa16d6 100644 (file)
@@ -1,5 +1,8 @@
 #pragma once
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
 vector w_shotorg;
 vector w_shotdir;
 vector w_shotend;
index 2ffb1c1..a71abe7 100644 (file)
@@ -1,5 +1,7 @@
 #include "weaponstats.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include "../g_world.qh"
 
 #include <common/weapons/_all.qh>
index 2fb0f99..4ddf5a5 100644 (file)
@@ -1,5 +1,8 @@
 #pragma once
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
 float internalteam;
 float weaponswapping;
 entity weapon_dropevent_item;