From: Mario Date: Mon, 21 Sep 2020 12:57:50 +0000 (+1000) Subject: Move some more functions out of miscfunctions, split eliminated players handling... X-Git-Tag: xonotic-v0.8.5~762 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2d1482e00c0f87227bb4b11e79d83c2c94f42ca9;p=xonotic%2Fxonotic-data.pk3dir.git Move some more functions out of miscfunctions, split eliminated players handling into its own file --- diff --git a/qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qh b/qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qh index f6420b852..78526bc26 100644 --- a/qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qh +++ b/qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qh @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include diff --git a/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc b/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc index 360dc7a4e..5378fb346 100644 --- a/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc +++ b/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc @@ -1,5 +1,6 @@ #include "sv_freezetag.qh" +#include #include float autocvar_g_freezetag_frozen_maxtime; diff --git a/qcsrc/common/mapobjects/triggers.qc b/qcsrc/common/mapobjects/triggers.qc index 29b00d5db..54550dcb2 100644 --- a/qcsrc/common/mapobjects/triggers.qc +++ b/qcsrc/common/mapobjects/triggers.qc @@ -1,5 +1,37 @@ #include "triggers.qh" +bool isPushable(entity e) +{ + if(e.pushable) + return true; +#ifdef SVQC + if(IS_VEHICLE(e)) + return false; + if(e.iscreature) + return true; + if (Item_IsLoot(e)) + { + return true; + } + switch(e.classname) + { + case "body": + return true; + case "bullet": // antilagged bullets can't hit this either + return false; + } + if (e.projectiledeathtype) + return true; +#endif +#ifdef CSQC + if(e.flags & FL_PROJECTILE) + return true; + if(e.isplayermodel) + return true; +#endif + return false; +} + void SUB_DontUseTargets(entity this, entity actor, entity trigger) { } void SUB_UseTargets(entity this, entity actor, entity trigger); diff --git a/qcsrc/common/physics/player.qh b/qcsrc/common/physics/player.qh index da45243b6..5d2fcf726 100644 --- a/qcsrc/common/physics/player.qh +++ b/qcsrc/common/physics/player.qh @@ -190,7 +190,6 @@ STATIC_INIT(PHYS_INPUT_BUTTON) #define IS_CLIENT(s) (((s).isplayermodel & ISPLAYER_CLIENT) || (s) == csqcplayer) #define IS_PLAYER(s) ((s).isplayermodel & ISPLAYER_PLAYER) #define IS_NOT_A_CLIENT(s) (!(s).isplayermodel && (s) != csqcplayer) - #define isPushable(s) ((s).isplayermodel || (s).pushable || ((s).flags & FL_PROJECTILE)) //float player_multijump; //float player_jumpheight; diff --git a/qcsrc/server/_mod.inc b/qcsrc/server/_mod.inc index fed18941b..b4c287a89 100644 --- a/qcsrc/server/_mod.inc +++ b/qcsrc/server/_mod.inc @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/qcsrc/server/_mod.qh b/qcsrc/server/_mod.qh index d8679eb8a..f9b39314a 100644 --- a/qcsrc/server/_mod.qh +++ b/qcsrc/server/_mod.qh @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/qcsrc/server/elimination.qc b/qcsrc/server/elimination.qc new file mode 100644 index 000000000..8024c9a5c --- /dev/null +++ b/qcsrc/server/elimination.qc @@ -0,0 +1,36 @@ +#include "elimination.qh" + +#include +#include + +.float(entity) isEliminated; +bool EliminatedPlayers_SendEntity(entity this, entity to, float sendflags) +{ + Stream out = MSG_ENTITY; + WriteHeader(out, ENT_CLIENT_ELIMINATEDPLAYERS); + serialize(byte, out, sendflags); + if (sendflags & 1) { + for (int i = 1; i <= maxclients; i += 8) { + int f = 0; + entity e = edict_num(i); + for (int b = 0; b < 8; ++b, e = nextent(e)) { + if (eliminatedPlayers.isEliminated(e)) { + f |= BIT(b); + } + } + serialize(byte, out, f); + } + } + return true; +} + +void EliminatedPlayers_Init(float(entity) isEliminated_func) +{ + if(eliminatedPlayers) + { + backtrace("Can't spawn eliminatedPlayers again!"); + return; + } + Net_LinkEntity(eliminatedPlayers = spawn(), false, 0, EliminatedPlayers_SendEntity); + eliminatedPlayers.isEliminated = isEliminated_func; +} diff --git a/qcsrc/server/elimination.qh b/qcsrc/server/elimination.qh new file mode 100644 index 000000000..5a50beb1b --- /dev/null +++ b/qcsrc/server/elimination.qh @@ -0,0 +1,4 @@ +#pragma once + +entity eliminatedPlayers; +void EliminatedPlayers_Init(float(entity) isEliminated_func); diff --git a/qcsrc/server/gamelog.qc b/qcsrc/server/gamelog.qc index 2c61419c5..a3e747cab 100644 --- a/qcsrc/server/gamelog.qc +++ b/qcsrc/server/gamelog.qc @@ -1,7 +1,7 @@ #include "gamelog.qh" #include -#include +#include string GameLog_ProcessIP(string s) { diff --git a/qcsrc/server/main.qc b/qcsrc/server/main.qc index bbafd022d..351cf738d 100644 --- a/qcsrc/server/main.qc +++ b/qcsrc/server/main.qc @@ -173,6 +173,11 @@ void SV_PausedTic(float elapsedtime) if (!server_is_dedicated) Pause_TryPause(false); } +void dedicated_print(string input) +{ + if (server_is_dedicated) print(input); +} + /* ============= StartFrame diff --git a/qcsrc/server/main.qh b/qcsrc/server/main.qh index dc3d80dbe..e89d68304 100644 --- a/qcsrc/server/main.qh +++ b/qcsrc/server/main.qh @@ -1,5 +1,8 @@ #pragma once +/** print(), but only print if the server is not local */ +void dedicated_print(string input); + bool expr_evaluate(string s); #ifdef PROFILING diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index e8b4ab681..cc5c2d139 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -87,11 +87,6 @@ void WarpZone_crosshair_trace(entity pl) WarpZone_traceline_antilag(pl, CS(pl).cursor_trace_start, CS(pl).cursor_trace_start + normalize(CS(pl).cursor_trace_endpos - CS(pl).cursor_trace_start) * max_shot_distance, MOVE_NORMAL, pl, ANTILAG_LATENCY(pl)); } -void dedicated_print(string input) -{ - if (server_is_dedicated) print(input); -} - entity findnearest(vector point, bool checkitems, vector axismod) { vector dist; @@ -966,41 +961,6 @@ void InitializeEntitiesRun() delete_fn = remove_unsafely; } -.float(entity) isEliminated; -bool EliminatedPlayers_SendEntity(entity this, entity to, float sendflags) -{ - Stream out = MSG_ENTITY; - WriteHeader(out, ENT_CLIENT_ELIMINATEDPLAYERS); - serialize(byte, out, sendflags); - if (sendflags & 1) { - for (int i = 1; i <= maxclients; i += 8) { - int f = 0; - entity e = edict_num(i); - for (int b = 0; b < 8; ++b, e = nextent(e)) { - if (eliminatedPlayers.isEliminated(e)) { - f |= BIT(b); - } - } - serialize(byte, out, f); - } - } - return true; -} - -void EliminatedPlayers_Init(float(entity) isEliminated_func) -{ - if(eliminatedPlayers) - { - backtrace("Can't spawn eliminatedPlayers again!"); - return; - } - Net_LinkEntity(eliminatedPlayers = spawn(), false, 0, EliminatedPlayers_SendEntity); - eliminatedPlayers.isEliminated = isEliminated_func; -} - - - - void adaptor_think2use_hittype_splash(entity this) // for timed projectile detonation { if(!(IS_ONGROUND(this))) // if onground, we ARE touching something, but HITTYPE_SPLASH is to be networked if the damage causing projectile is not touching ANYTHING @@ -1421,28 +1381,3 @@ float LostMovetypeFollow(entity ent) } return 0; } - -.bool pushable; -bool isPushable(entity e) -{ - if(e.pushable) - return true; - if(IS_VEHICLE(e)) - return false; - if(e.iscreature) - return true; - if (Item_IsLoot(e)) - { - return true; - } - switch(e.classname) - { - case "body": - return true; - case "bullet": // antilagged bullets can't hit this either - return false; - } - if (e.projectiledeathtype) - return true; - return false; -} diff --git a/qcsrc/server/miscfunctions.qh b/qcsrc/server/miscfunctions.qh index 8a2406316..f79c9e84a 100644 --- a/qcsrc/server/miscfunctions.qh +++ b/qcsrc/server/miscfunctions.qh @@ -15,9 +15,6 @@ .vector dropped_origin; -entity eliminatedPlayers; -void EliminatedPlayers_Init(float(entity) isEliminated_func); - void write_recordmarker(entity pl, float tstart, float dt); void play2all(string samp); @@ -61,15 +58,10 @@ void follow_sameorigin(entity e, entity to); string formatmessage(entity this, string msg); -/** print(), but only print if the server is not local */ -void dedicated_print(string input); - void GetCvars(entity this, entity store, int f); string GetMapname(); -float isPushable(entity e); - float LostMovetypeFollow(entity ent); string uid2name(string myuid);