From: TimePath Date: Sat, 5 Aug 2017 14:07:45 +0000 (+1000) Subject: server: remove _all X-Git-Tag: xonotic-v0.8.5~2537 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b283d314c0c619a12b54c6094ade99ed69daed67;p=xonotic%2Fxonotic-data.pk3dir.git server: remove _all Added REGISTRY_DEPENDS --- diff --git a/qcsrc/common/items/all.qh b/qcsrc/common/items/all.qh index dc8cf21c0..14c5a347a 100644 --- a/qcsrc/common/items/all.qh +++ b/qcsrc/common/items/all.qh @@ -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)) diff --git a/qcsrc/common/sounds/all.qc b/qcsrc/common/sounds/all.qc index 203b64385..328486d35 100644 --- a/qcsrc/common/sounds/all.qc +++ b/qcsrc/common/sounds/all.qc @@ -1,6 +1,8 @@ #include "all.qh" #ifdef SVQC +#include + bool autocvar_bot_sound_monopoly; .entity realowner; diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index c1503ca68..c452b1128 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -1,6 +1,7 @@ #pragma once #ifdef SVQC +#include #include #endif diff --git a/qcsrc/common/t_items.qh b/qcsrc/common/t_items.qh index 1b2293bcf..e52604d99 100644 --- a/qcsrc/common/t_items.qh +++ b/qcsrc/common/t_items.qh @@ -1,5 +1,9 @@ #pragma once +#ifdef SVQC +#include +#endif + const int AMMO_COUNT = 4; // amount of ammo types to show in the inventory panel // item networking diff --git a/qcsrc/common/turrets/sv_turrets.qh b/qcsrc/common/turrets/sv_turrets.qh index edd06bd6d..41a7bd962 100644 --- a/qcsrc/common/turrets/sv_turrets.qh +++ b/qcsrc/common/turrets/sv_turrets.qh @@ -1,5 +1,7 @@ #pragma once +#include + 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); diff --git a/qcsrc/lib/registry.qh b/qcsrc/lib/registry.qh index a3282a0ab..8ca07b43f 100644 --- a/qcsrc/lib/registry.qh +++ b/qcsrc/lib/registry.qh @@ -22,10 +22,12 @@ */ #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; \ @@ -33,6 +35,10 @@ 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 index 95bf71531..000000000 --- a/qcsrc/server/_all.inc +++ /dev/null @@ -1,19 +0,0 @@ -#include -#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 -#include - -#include - -#include -#include -#include -#include diff --git a/qcsrc/server/_all.qh b/qcsrc/server/_all.qh deleted file mode 100644 index 1c0382cae..000000000 --- a/qcsrc/server/_all.qh +++ /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 -#include -#include - -#include "autocvars.qh" -#include "constants.qh" -#include "defs.qh" -#include "miscfunctions.qh" diff --git a/qcsrc/server/_mod.inc b/qcsrc/server/_mod.inc index eb74529a6..87a8d5689 100644 --- a/qcsrc/server/_mod.inc +++ b/qcsrc/server/_mod.inc @@ -30,3 +30,10 @@ #endif #include #include + +#include +#include +#include +#include +#include +#include diff --git a/qcsrc/server/_mod.qh b/qcsrc/server/_mod.qh index a0d160d57..2967c110c 100644 --- a/qcsrc/server/_mod.qh +++ b/qcsrc/server/_mod.qh @@ -30,3 +30,10 @@ #endif #include #include + +#include +#include +#include +#include +#include +#include diff --git a/qcsrc/server/antilag.qc b/qcsrc/server/antilag.qc index d5f8e39f7..46c871876 100644 --- a/qcsrc/server/antilag.qc +++ b/qcsrc/server/antilag.qc @@ -2,6 +2,7 @@ #if defined(CSQC) #elif defined(MENUQC) #elif defined(SVQC) + #include #include #include #include "antilag.qh" diff --git a/qcsrc/server/bot/api.qh b/qcsrc/server/bot/api.qh index d48821357..f33cc4f26 100644 --- a/qcsrc/server/bot/api.qh +++ b/qcsrc/server/bot/api.qh @@ -1,5 +1,6 @@ #pragma once +#include #include const int WAYPOINTFLAG_GENERATED = BIT(23); diff --git a/qcsrc/server/bot/default/aim.qc b/qcsrc/server/bot/default/aim.qc index d0ba63365..feb19afe1 100644 --- a/qcsrc/server/bot/default/aim.qc +++ b/qcsrc/server/bot/default/aim.qc @@ -1,5 +1,7 @@ #include "aim.qh" +#include + #include "cvars.qh" #include "bot.qh" diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 5d31c7ee9..46acf8828 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -1,5 +1,7 @@ #include "havocbot.qh" +#include +#include #include "../cvars.qh" #include "../aim.qh" diff --git a/qcsrc/server/bot/default/havocbot/roles.qc b/qcsrc/server/bot/default/havocbot/roles.qc index 22f444fd1..94aed9c96 100644 --- a/qcsrc/server/bot/default/havocbot/roles.qc +++ b/qcsrc/server/bot/default/havocbot/roles.qc @@ -1,5 +1,7 @@ #include "roles.qh" +#include +#include #include "havocbot.qh" #include "../cvars.qh" diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index fc9793154..d0061b900 100644 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@ -1,5 +1,7 @@ #include "navigation.qh" +#include +#include #include "cvars.qh" #include "bot.qh" diff --git a/qcsrc/server/bot/default/scripting.qc b/qcsrc/server/bot/default/scripting.qc index ca74965be..badf9437e 100644 --- a/qcsrc/server/bot/default/scripting.qc +++ b/qcsrc/server/bot/default/scripting.qc @@ -1,5 +1,7 @@ #include "scripting.qh" +#include +#include #include "cvars.qh" #include diff --git a/qcsrc/server/bot/default/waypoints.qc b/qcsrc/server/bot/default/waypoints.qc index 65cc69f66..c8a958ddb 100644 --- a/qcsrc/server/bot/default/waypoints.qc +++ b/qcsrc/server/bot/default/waypoints.qc @@ -1,5 +1,7 @@ #include "waypoints.qh" +#include +#include #include "cvars.qh" #include "bot.qh" diff --git a/qcsrc/server/campaign.qc b/qcsrc/server/campaign.qc index b39f82a10..ec8990de2 100644 --- a/qcsrc/server/campaign.qc +++ b/qcsrc/server/campaign.qc @@ -1,4 +1,7 @@ #include "campaign.qh" + +#include "defs.qh" + #include "cheats.qh" #include "miscfunctions.qh" #include "g_world.qh" diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index 78c591264..ee1e76760 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -1,5 +1,9 @@ #include "cheats.qh" +#include +#include +#include + #include "g_damage.qh" #include "race.qh" #include "../common/triggers/teleporters.qh" diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 14b854bc6..a8e2ef348 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -1,5 +1,8 @@ #include "client.qh" +#include +#include +#include #include "anticheat.qh" #include "impulse.qh" #include "player.qh" diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index ee00c60ca..383383ad7 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -1,5 +1,8 @@ #pragma once +#include "utils.qh" +#include + void ClientState_attach(entity this); IntrusiveList g_players; diff --git a/qcsrc/server/command/banning.qc b/qcsrc/server/command/banning.qc index fa1be7511..d90b372bb 100644 --- a/qcsrc/server/command/banning.qc +++ b/qcsrc/server/command/banning.qc @@ -1,4 +1,7 @@ #include "banning.qh" + +#include +#include #include #include #include "banning.qh" diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index 03f484d2e..d1d799811 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -1,4 +1,8 @@ #include "cmd.qh" + +#include +#include + #include #include "common.qh" diff --git a/qcsrc/server/command/common.qc b/qcsrc/server/command/common.qc index 77c393025..d8bc3ac8b 100644 --- a/qcsrc/server/command/common.qc +++ b/qcsrc/server/command/common.qc @@ -1,4 +1,8 @@ #include "common.qh" + +#include +#include + #include #include "common.qh" diff --git a/qcsrc/server/command/getreplies.qc b/qcsrc/server/command/getreplies.qc index cfcadf445..e67625a30 100644 --- a/qcsrc/server/command/getreplies.qc +++ b/qcsrc/server/command/getreplies.qc @@ -1,4 +1,8 @@ #include "getreplies.qh" + +#include +#include + #include #include "getreplies.qh" diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index 0bc47c0ac..49bee362e 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -1,6 +1,8 @@ #include "sv_cmd.qh" #include "_mod.qh" +#include + #include "banning.qh" #include "cmd.qh" #include "common.qh" diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index 2db503ca2..ed17ed0b8 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -1,4 +1,8 @@ #include "vote.qh" + +#include +#include + #include #include "vote.qh" diff --git a/qcsrc/server/compat/quake.qc b/qcsrc/server/compat/quake.qc index 539042d63..126a0f6f6 100644 --- a/qcsrc/server/compat/quake.qc +++ b/qcsrc/server/compat/quake.qc @@ -1,5 +1,7 @@ #include "quake.qh" +#include +#include #include spawnfunc(weapon_electro); diff --git a/qcsrc/server/compat/quake3.qc b/qcsrc/server/compat/quake3.qc index 905523bfb..532428dd0 100644 --- a/qcsrc/server/compat/quake3.qc +++ b/qcsrc/server/compat/quake3.qc @@ -1,5 +1,7 @@ #include "quake3.qh" +#include +#include #include spawnfunc(weapon_crylink); diff --git a/qcsrc/server/compat/wop.qc b/qcsrc/server/compat/wop.qc index f6b2f2621..6c69859fd 100644 --- a/qcsrc/server/compat/wop.qc +++ b/qcsrc/server/compat/wop.qc @@ -1,5 +1,7 @@ #include "wop.qh" +#include +#include #include // #include diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index 61d04801b..d96c28bf1 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -1,5 +1,6 @@ #include "g_damage.qh" +#include #include "bot/api.qh" #include "g_hook.qh" #include "mutators/_mod.qh" diff --git a/qcsrc/server/g_damage.qh b/qcsrc/server/g_damage.qh index e242de4a8..aee4a93df 100644 --- a/qcsrc/server/g_damage.qh +++ b/qcsrc/server/g_damage.qh @@ -3,6 +3,8 @@ #if defined(CSQC) #elif defined(MENUQC) #elif defined(SVQC) + #include + #include #include #include #include diff --git a/qcsrc/server/g_hook.qc b/qcsrc/server/g_hook.qc index 2081b688d..0fc60b2cd 100644 --- a/qcsrc/server/g_hook.qc +++ b/qcsrc/server/g_hook.qc @@ -1,5 +1,8 @@ #include "g_hook.qh" +#include +#include +#include #include "weapons/common.qh" #include "weapons/csqcprojectile.qh" #include "weapons/weaponsystem.qh" diff --git a/qcsrc/server/g_lights.qc b/qcsrc/server/g_lights.qc index 425716d2d..852f1efc0 100644 --- a/qcsrc/server/g_lights.qc +++ b/qcsrc/server/g_lights.qc @@ -1,5 +1,8 @@ #include "g_lights.qh" +#include +#include + void train_next(entity this); const float LOOP = 1; diff --git a/qcsrc/server/g_models.qc b/qcsrc/server/g_models.qc index d3f56f5f0..539522f2d 100644 --- a/qcsrc/server/g_models.qc +++ b/qcsrc/server/g_models.qc @@ -1,5 +1,7 @@ #include "g_models.qh" +#include +#include #include "g_subs.qh" #include #include "../common/triggers/subs.qh" diff --git a/qcsrc/server/g_subs.qc b/qcsrc/server/g_subs.qc index 33f471eb4..8c39f88c9 100644 --- a/qcsrc/server/g_subs.qc +++ b/qcsrc/server/g_subs.qc @@ -1,5 +1,7 @@ #include "g_subs.qh" +#include +#include #include "antilag.qh" #include "command/common.qh" #include "../common/state.qh" diff --git a/qcsrc/server/ipban.qc b/qcsrc/server/ipban.qc index 50c258f92..6211362ac 100644 --- a/qcsrc/server/ipban.qc +++ b/qcsrc/server/ipban.qc @@ -1,5 +1,7 @@ #include "ipban.qh" +#include +#include #include "autocvars.qh" #include "command/banning.qh" #include "defs.qh" diff --git a/qcsrc/server/mapvoting.qc b/qcsrc/server/mapvoting.qc index 53cf1cdba..209ac7af9 100644 --- a/qcsrc/server/mapvoting.qc +++ b/qcsrc/server/mapvoting.qc @@ -1,5 +1,7 @@ #include "mapvoting.qh" +#include +#include #include "g_world.qh" #include "command/cmd.qh" #include "command/getreplies.qh" diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 652ef656b..ffc0e9ea5 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -1,4 +1,5 @@ #include "miscfunctions.qh" + #include "antilag.qh" #include "command/common.qh" #include "constants.qh" diff --git a/qcsrc/server/miscfunctions.qh b/qcsrc/server/miscfunctions.qh index 789ba9381..abe8cd74a 100644 --- a/qcsrc/server/miscfunctions.qh +++ b/qcsrc/server/miscfunctions.qh @@ -1,5 +1,7 @@ #pragma once +#include + #include #include "mutators/events.qh" diff --git a/qcsrc/server/mutators/gamemode.qh b/qcsrc/server/mutators/gamemode.qh index 84094df6b..ac8746516 100644 --- a/qcsrc/server/mutators/gamemode.qh +++ b/qcsrc/server/mutators/gamemode.qh @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include diff --git a/qcsrc/server/mutators/loader.qc b/qcsrc/server/mutators/loader.qc index 43c668edd..7c20b3729 100644 --- a/qcsrc/server/mutators/loader.qc +++ b/qcsrc/server/mutators/loader.qc @@ -1,5 +1,8 @@ #include "loader.qh" +#include +#include + STATIC_INIT_LATE(Gametype) { Gametype g = MapInfo_CurrentGametype(); if (g) { diff --git a/qcsrc/server/mutators/mutator/gamemode_ctf.qc b/qcsrc/server/mutators/mutator/gamemode_ctf.qc index 23bbeaae2..c1698c554 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ctf.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ctf.qc @@ -1,6 +1,7 @@ #include "gamemode_ctf.qh" #ifndef CSQC +#include void ctf_Initialize(); REGISTER_MUTATOR(ctf, false) diff --git a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc index 0b4bd54aa..c28fd5eb8 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc +++ b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc @@ -1,5 +1,7 @@ #include "gamemode_keepaway.qh" +#include + int autocvar_g_keepaway_ballcarrier_effects; float autocvar_g_keepaway_ballcarrier_damage; float autocvar_g_keepaway_ballcarrier_force; diff --git a/qcsrc/server/pathlib/main.qc b/qcsrc/server/pathlib/main.qc index 706e10d9e..c2f332603 100644 --- a/qcsrc/server/pathlib/main.qc +++ b/qcsrc/server/pathlib/main.qc @@ -1,5 +1,7 @@ #include "main.qh" +#include +#include #include "pathlib.qh" #include "utility.qh" #include "../command/common.qh" diff --git a/qcsrc/server/pathlib/movenode.qc b/qcsrc/server/pathlib/movenode.qc index f27ab4879..cbcfe3d4c 100644 --- a/qcsrc/server/pathlib/movenode.qc +++ b/qcsrc/server/pathlib/movenode.qc @@ -1,5 +1,7 @@ #include "movenode.qh" +#include +#include #include "pathlib.qh" #include "utility.qh" diff --git a/qcsrc/server/pathlib/utility.qc b/qcsrc/server/pathlib/utility.qc index da64db697..151fb44b5 100644 --- a/qcsrc/server/pathlib/utility.qc +++ b/qcsrc/server/pathlib/utility.qc @@ -1,5 +1,7 @@ #include "utility.qh" +#include +#include #include "pathlib.qh" bool location_isok(vector point, bool waterok, bool air_isok) diff --git a/qcsrc/server/player.qc b/qcsrc/server/player.qc index d70210fea..827c86ae4 100644 --- a/qcsrc/server/player.qc +++ b/qcsrc/server/player.qc @@ -1,5 +1,6 @@ #include "player.qh" +#include #include "bot/api.qh" #include "cheats.qh" #include "g_damage.qh" diff --git a/qcsrc/server/portals.qc b/qcsrc/server/portals.qc index 260e035b5..6de3e0af3 100644 --- a/qcsrc/server/portals.qc +++ b/qcsrc/server/portals.qc @@ -1,5 +1,6 @@ #include "portals.qh" +#include #include "g_hook.qh" #include "mutators/_mod.qh" #include "../common/constants.qh" diff --git a/qcsrc/server/progs.inc b/qcsrc/server/progs.inc index 1a8ada45f..f72ff8533 100644 --- a/qcsrc/server/progs.inc +++ b/qcsrc/server/progs.inc @@ -1,7 +1,18 @@ #include #if XONOTIC -#include + +#include + +#include +#include + +#include + +#include +#include +#include +#include #include #endif diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index 0a3e2e8fa..7f2aaaaf5 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -1,5 +1,7 @@ #include "race.qh" +#include +#include #include "client.qh" #include "portals.qh" #include "scores.qh" diff --git a/qcsrc/server/round_handler.qc b/qcsrc/server/round_handler.qc index 16564cd39..ae64e74e4 100644 --- a/qcsrc/server/round_handler.qc +++ b/qcsrc/server/round_handler.qc @@ -1,5 +1,7 @@ #include "round_handler.qh" +#include +#include #include "campaign.qh" #include "command/vote.qh" #include "../common/util.qh" diff --git a/qcsrc/server/scores_rules.qc b/qcsrc/server/scores_rules.qc index 9c416472f..97e80409c 100644 --- a/qcsrc/server/scores_rules.qc +++ b/qcsrc/server/scores_rules.qc @@ -1,5 +1,7 @@ #include "scores_rules.qh" +#include +#include #include "client.qh" #include "scores.qh" diff --git a/qcsrc/server/tests.qh b/qcsrc/server/tests.qh index e6d6f66a0..ad40da4dd 100644 --- a/qcsrc/server/tests.qh +++ b/qcsrc/server/tests.qh @@ -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 index 000000000..da5c7a56a --- /dev/null +++ b/qcsrc/server/utils.qh @@ -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; }); diff --git a/qcsrc/server/weapons/accuracy.qh b/qcsrc/server/weapons/accuracy.qh index 35b0174ec..d24ee1cf5 100644 --- a/qcsrc/server/weapons/accuracy.qh +++ b/qcsrc/server/weapons/accuracy.qh @@ -1,5 +1,8 @@ #pragma once +#include +#include + .bool cvar_cl_accuracy_data_share; REPLICATE(cvar_cl_accuracy_data_share, bool, "cl_accuracy_data_share"); .bool cvar_cl_accuracy_data_receive; diff --git a/qcsrc/server/weapons/common.qc b/qcsrc/server/weapons/common.qc index fb57d9277..b94b2533f 100644 --- a/qcsrc/server/weapons/common.qc +++ b/qcsrc/server/weapons/common.qc @@ -1,5 +1,7 @@ #include "common.qh" +#include +#include #include #include #include diff --git a/qcsrc/server/weapons/csqcprojectile.qc b/qcsrc/server/weapons/csqcprojectile.qc index 42bff7c0e..d426e2f61 100644 --- a/qcsrc/server/weapons/csqcprojectile.qc +++ b/qcsrc/server/weapons/csqcprojectile.qc @@ -1,5 +1,7 @@ #include "csqcprojectile.qh" +#include +#include #include #include "../command/common.qh" diff --git a/qcsrc/server/weapons/hitplot.qc b/qcsrc/server/weapons/hitplot.qc index 89cec6aea..fb13bd1b9 100644 --- a/qcsrc/server/weapons/hitplot.qc +++ b/qcsrc/server/weapons/hitplot.qc @@ -1,5 +1,7 @@ #include "hitplot.qh" +#include +#include #include "../antilag.qh" #include "../g_subs.qh" #include diff --git a/qcsrc/server/weapons/selection.qh b/qcsrc/server/weapons/selection.qh index 071a0fea8..ea580e911 100644 --- a/qcsrc/server/weapons/selection.qh +++ b/qcsrc/server/weapons/selection.qh @@ -1,5 +1,8 @@ #pragma once +#include +#include + // switch between weapons void Send_WeaponComplain(entity e, float wpn, float type); diff --git a/qcsrc/server/weapons/spawning.qh b/qcsrc/server/weapons/spawning.qh index 9ce5ca30e..d435002ad 100644 --- a/qcsrc/server/weapons/spawning.qh +++ b/qcsrc/server/weapons/spawning.qh @@ -1,5 +1,8 @@ #pragma once +#include +#include + string W_Apply_Weaponreplace(string in); void weapon_defaultspawnfunc(entity this, Weapon e); diff --git a/qcsrc/server/weapons/throwing.qh b/qcsrc/server/weapons/throwing.qh index 1b62b64c8..9ea5e5cb8 100644 --- a/qcsrc/server/weapons/throwing.qh +++ b/qcsrc/server/weapons/throwing.qh @@ -1,5 +1,8 @@ #pragma once +#include +#include + .float savenextthink; void thrown_wep_think(entity this); diff --git a/qcsrc/server/weapons/tracing.qc b/qcsrc/server/weapons/tracing.qc index d6c9fdfff..649726658 100644 --- a/qcsrc/server/weapons/tracing.qc +++ b/qcsrc/server/weapons/tracing.qc @@ -1,5 +1,7 @@ #include "tracing.qh" +#include + #include "accuracy.qh" #include "common.qh" #include "hitplot.qh" diff --git a/qcsrc/server/weapons/tracing.qh b/qcsrc/server/weapons/tracing.qh index 0c17e1974..3fa16d654 100644 --- a/qcsrc/server/weapons/tracing.qh +++ b/qcsrc/server/weapons/tracing.qh @@ -1,5 +1,8 @@ #pragma once +#include +#include + vector w_shotorg; vector w_shotdir; vector w_shotend; diff --git a/qcsrc/server/weapons/weaponstats.qc b/qcsrc/server/weapons/weaponstats.qc index 2ffb1c1ec..a71abe70f 100644 --- a/qcsrc/server/weapons/weaponstats.qc +++ b/qcsrc/server/weapons/weaponstats.qc @@ -1,5 +1,7 @@ #include "weaponstats.qh" +#include +#include #include "../g_world.qh" #include diff --git a/qcsrc/server/weapons/weaponsystem.qh b/qcsrc/server/weapons/weaponsystem.qh index 2fb0f9956..4ddf5a515 100644 --- a/qcsrc/server/weapons/weaponsystem.qh +++ b/qcsrc/server/weapons/weaponsystem.qh @@ -1,5 +1,8 @@ #pragma once +#include +#include + float internalteam; float weaponswapping; entity weapon_dropevent_item;