From 32cd9e9d266e613666f68c6763484d568a759f9c Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 2 Aug 2020 09:57:47 +1000 Subject: [PATCH] Reorganise some more definitions out of defs.qh, show all racers on the radar in Race mode --- qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qh | 3 + .../gamemodes/gamemode/keyhunt/sv_keyhunt.qc | 1 + .../common/gamemodes/gamemode/race/sv_race.qc | 1 + qcsrc/common/turrets/sv_turrets.qc | 1 + qcsrc/common/vehicles/vehicle/racer.qc | 4 + qcsrc/common/vehicles/vehicle/raptor.qc | 4 + qcsrc/common/vehicles/vehicle/spiderbot.qc | 4 + qcsrc/server/bot/default/scripting.qc | 2 + qcsrc/server/client.qc | 85 ++++++++++++++++++ qcsrc/server/client.qh | 19 ++++ qcsrc/server/defs.qh | 25 +----- qcsrc/server/g_world.qc | 2 - qcsrc/server/player.qc | 88 +------------------ qcsrc/server/player.qh | 13 --- qcsrc/server/weapons/weaponsystem.qh | 11 +++ 15 files changed, 138 insertions(+), 125 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qh b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qh index 4cffb0c48..d0e13c132 100644 --- a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qh +++ b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qh @@ -75,6 +75,9 @@ const float VEHICLE_FLAG_SCALE = 1.0; .float score_return; .float score_team_capture; // shouldn't be too high +// property set on objects to point to the flag they're carrying (if any) +.entity flagcarried; + // effects .string toucheffect; .string passeffect; diff --git a/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc b/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc index 40870a790..d13ec1ac8 100644 --- a/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc +++ b/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc @@ -1,6 +1,7 @@ #include "sv_keyhunt.qh" #include +#include float autocvar_g_balance_keyhunt_damageforcescale; float autocvar_g_balance_keyhunt_delay_collect; diff --git a/qcsrc/common/gamemodes/gamemode/race/sv_race.qc b/qcsrc/common/gamemodes/gamemode/race/sv_race.qc index baf2131c8..29415649e 100644 --- a/qcsrc/common/gamemodes/gamemode/race/sv_race.qc +++ b/qcsrc/common/gamemodes/gamemode/race/sv_race.qc @@ -445,6 +445,7 @@ void race_Initialize() race_ScoreRules(); if(g_race_qualifying == 2) warmup_stage = 0; + radar_showennemies = true; } void rc_SetLimits() diff --git a/qcsrc/common/turrets/sv_turrets.qc b/qcsrc/common/turrets/sv_turrets.qc index c3f2af089..4b852d598 100644 --- a/qcsrc/common/turrets/sv_turrets.qc +++ b/qcsrc/common/turrets/sv_turrets.qc @@ -1,6 +1,7 @@ #include "sv_turrets.qh" #ifdef SVQC #include +#include #include // Generic aiming diff --git a/qcsrc/common/vehicles/vehicle/racer.qc b/qcsrc/common/vehicles/vehicle/racer.qc index a0e35e02e..784b3355e 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qc +++ b/qcsrc/common/vehicles/vehicle/racer.qc @@ -1,5 +1,9 @@ #include "racer.qh" +#if defined(SVQC) + #include +#endif + #ifdef GAMEQC #ifdef SVQC diff --git a/qcsrc/common/vehicles/vehicle/raptor.qc b/qcsrc/common/vehicles/vehicle/raptor.qc index a868eb4aa..b2ee42e1c 100644 --- a/qcsrc/common/vehicles/vehicle/raptor.qc +++ b/qcsrc/common/vehicles/vehicle/raptor.qc @@ -1,5 +1,9 @@ #include "raptor.qh" +#if defined(SVQC) + #include +#endif + #ifdef GAMEQC #ifdef SVQC diff --git a/qcsrc/common/vehicles/vehicle/spiderbot.qc b/qcsrc/common/vehicles/vehicle/spiderbot.qc index e03122271..069696639 100644 --- a/qcsrc/common/vehicles/vehicle/spiderbot.qc +++ b/qcsrc/common/vehicles/vehicle/spiderbot.qc @@ -1,5 +1,9 @@ #include "spiderbot.qh" +#if defined(SVQC) + #include +#endif + #ifdef GAMEQC const int SBRM_FIRST = 1; diff --git a/qcsrc/server/bot/default/scripting.qc b/qcsrc/server/bot/default/scripting.qc index 210e97104..65935cd68 100644 --- a/qcsrc/server/bot/default/scripting.qc +++ b/qcsrc/server/bot/default/scripting.qc @@ -3,9 +3,11 @@ #include #include #include +#include #include "cvars.qh" #include +#include #include #include diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 4990ed7ee..c0d389837 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -1309,6 +1309,91 @@ void UpdateChatBubble(entity this) } } +void calculate_player_respawn_time(entity this) +{ + if(MUTATOR_CALLHOOK(CalculateRespawnTime, this)) + return; + + float gametype_setting_tmp; + float sdelay_max = GAMETYPE_DEFAULTED_SETTING(respawn_delay_max); + float sdelay_small = GAMETYPE_DEFAULTED_SETTING(respawn_delay_small); + float sdelay_large = GAMETYPE_DEFAULTED_SETTING(respawn_delay_large); + float sdelay_small_count = GAMETYPE_DEFAULTED_SETTING(respawn_delay_small_count); + float sdelay_large_count = GAMETYPE_DEFAULTED_SETTING(respawn_delay_large_count); + float waves = GAMETYPE_DEFAULTED_SETTING(respawn_waves); + + float pcount = 1; // Include myself whether or not team is already set right and I'm a "player". + if (teamplay) + { + FOREACH_CLIENT(IS_PLAYER(it) && it != this, { + if(it.team == this.team) + ++pcount; + }); + if (sdelay_small_count == 0) + sdelay_small_count = 1; + if (sdelay_large_count == 0) + sdelay_large_count = 1; + } + else + { + FOREACH_CLIENT(IS_PLAYER(it) && it != this, { + ++pcount; + }); + if (sdelay_small_count == 0) + { + if (IS_INDEPENDENT_PLAYER(this)) + { + // Players play independently. No point in requiring enemies. + sdelay_small_count = 1; + } + else + { + // Players play AGAINST each other. Enemies required. + sdelay_small_count = 2; + } + } + if (sdelay_large_count == 0) + { + if (IS_INDEPENDENT_PLAYER(this)) + { + // Players play independently. No point in requiring enemies. + sdelay_large_count = 1; + } + else + { + // Players play AGAINST each other. Enemies required. + sdelay_large_count = 2; + } + } + } + + float sdelay; + + if (pcount <= sdelay_small_count) + sdelay = sdelay_small; + else if (pcount >= sdelay_large_count) + sdelay = sdelay_large; + else // NOTE: this case implies sdelay_large_count > sdelay_small_count. + sdelay = sdelay_small + (sdelay_large - sdelay_small) * (pcount - sdelay_small_count) / (sdelay_large_count - sdelay_small_count); + + if(waves) + this.respawn_time = ceil((time + sdelay) / waves) * waves; + else + this.respawn_time = time + sdelay; + + if(sdelay < sdelay_max) + this.respawn_time_max = time + sdelay_max; + else + this.respawn_time_max = this.respawn_time; + + if((sdelay + waves >= 5.0) && (this.respawn_time - time > 1.75)) + this.respawn_countdown = 10; // first number to count down from is 10 + else + this.respawn_countdown = -1; // do not count down + + if(autocvar_g_forced_respawn) + this.respawn_flags = this.respawn_flags | RESPAWN_FORCE; +} // LordHavoc: this hack will be removed when proper _pants/_shirt layers are // added to the model skins diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index 2f380ae2f..328726df9 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -231,8 +231,27 @@ METHOD(Client, m_unwind, bool(Client this)) return false; } +.int respawn_flags; +.float respawn_time; +.float respawn_time_max; + +// g__str: +// If 0, default is used. +// If <0, 0 is used. +// Otherwise, g_str (default value) is used. +// For consistency, negative values there are mapped to zero too. +#define GAMETYPE_DEFAULTED_SETTING(str) \ + ((gametype_setting_tmp = cvar(strcat("g_", GetGametype(), "_" #str))), \ + (gametype_setting_tmp < 0) ? 0 \ + : (gametype_setting_tmp == 0 || autocvar_g_respawn_delay_forced) ? max(0, autocvar_g_##str) \ + : gametype_setting_tmp) + +void calculate_player_respawn_time(entity this); + bool PlayerInList(entity player, string list); +void ClientData_Touch(entity e); + /// \brief Print the string to the client's chat. /// \param[in] client Client to print to. /// \param[in] text Text to print. diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index c36f033c9..9aebfebb5 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -3,8 +3,6 @@ #include #include -#define INDEPENDENT_ATTACK_FINISHED 1 - // Globals float g_footsteps, g_grappling_hook; @@ -24,8 +22,7 @@ float player_count; float currentbots; float bots_would_leave; -void UpdateFrags(entity player, int f); -.int totalfrags; +.int totalfrags; // NOTE: reused for multiple purposes // flag set on worldspawn so that the code knows if it is dedicated or not float server_is_dedicated; @@ -57,15 +54,10 @@ const .float air_finished = _STAT(AIR_FINISHED); .float count; //.float cnt2; -.int respawn_flags; -.float respawn_time; -.float respawn_time_max; .float death_time; .float fade_time; .float fade_rate; -void player_setupanimsformodel(entity this); - .string mdl; .string playermodel; @@ -139,8 +131,6 @@ int nJoinAllowed(entity this, entity ignore); .float spawnshieldtime; .float item_spawnshieldtime; -.entity flagcarried; - .int playerid; .float noalign; // if set to 1, the item or spawnpoint won't be dropped to the floor @@ -181,15 +171,6 @@ void FixClientCvars(entity e); float bot_waypoints_for_items; -.float attack_finished_for[REGISTRY_MAX(Weapons) * MAX_WEAPONSLOTS]; -.float attack_finished_single[MAX_WEAPONSLOTS]; -#if INDEPENDENT_ATTACK_FINISHED -#define ATTACK_FINISHED_FOR(ent, w, slot) ((ent).(attack_finished_for[((w) - WEP_FIRST) * MAX_WEAPONSLOTS + (slot)])) -#else -#define ATTACK_FINISHED_FOR(ent, w, slot) ((ent).attack_finished_single[slot]) -#endif -#define ATTACK_FINISHED(ent, w) ATTACK_FINISHED_FOR(ent, ent.(w).m_weapon.m_id, weaponslot(w)) - // speedrun: when 1, player auto teleports back when capture timeout happens .float speedrunning; @@ -217,8 +198,6 @@ bool sv_maxidle_slots_countbots; float tracebox_hits_trigger_hurt(vector start, vector mi, vector ma, vector end); -float next_pingtime; - // autotaunt system .float cvar_cl_autotaunt; .float cvar_cl_voice_directional; @@ -259,8 +238,6 @@ float g_nexball_meter_period; .void(entity this) reset; // if set, an entity is reset using this .void(entity this) reset2; // if set, an entity is reset using this (after calling ALL the reset functions for other entities) -void ClientData_Touch(entity e); - //vector debug_shotorg; // if non-zero, overrides the shot origin of all weapons .bool wasplayer; diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 88d531ae9..5dddc2fb3 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -935,8 +935,6 @@ spawnfunc(worldspawn) Nagger_Init(); - next_pingtime = time + 5; - // set up information replies for clients and server to use maplist_reply = strzone(getmaplist()); lsmaps_reply = strzone(getlsmaps()); diff --git a/qcsrc/server/player.qc b/qcsrc/server/player.qc index 1333b2386..8a626642e 100644 --- a/qcsrc/server/player.qc +++ b/qcsrc/server/player.qc @@ -3,6 +3,7 @@ #include #include "bot/api.qh" #include "cheats.qh" +#include "client.qh" #include "clientkill.qh" #include "g_damage.qh" #include "handicap.qh" @@ -32,6 +33,7 @@ #include "../common/wepent.qh" #include "weapons/weaponstats.qh" +#include #include "../common/animdecide.qh" @@ -222,92 +224,6 @@ void PlayerCorpseDamage(entity this, entity inflictor, entity attacker, float da } } -void calculate_player_respawn_time(entity this) -{ - if(MUTATOR_CALLHOOK(CalculateRespawnTime, this)) - return; - - float gametype_setting_tmp; - float sdelay_max = GAMETYPE_DEFAULTED_SETTING(respawn_delay_max); - float sdelay_small = GAMETYPE_DEFAULTED_SETTING(respawn_delay_small); - float sdelay_large = GAMETYPE_DEFAULTED_SETTING(respawn_delay_large); - float sdelay_small_count = GAMETYPE_DEFAULTED_SETTING(respawn_delay_small_count); - float sdelay_large_count = GAMETYPE_DEFAULTED_SETTING(respawn_delay_large_count); - float waves = GAMETYPE_DEFAULTED_SETTING(respawn_waves); - - float pcount = 1; // Include myself whether or not team is already set right and I'm a "player". - if (teamplay) - { - FOREACH_CLIENT(IS_PLAYER(it) && it != this, { - if(it.team == this.team) - ++pcount; - }); - if (sdelay_small_count == 0) - sdelay_small_count = 1; - if (sdelay_large_count == 0) - sdelay_large_count = 1; - } - else - { - FOREACH_CLIENT(IS_PLAYER(it) && it != this, { - ++pcount; - }); - if (sdelay_small_count == 0) - { - if (IS_INDEPENDENT_PLAYER(this)) - { - // Players play independently. No point in requiring enemies. - sdelay_small_count = 1; - } - else - { - // Players play AGAINST each other. Enemies required. - sdelay_small_count = 2; - } - } - if (sdelay_large_count == 0) - { - if (IS_INDEPENDENT_PLAYER(this)) - { - // Players play independently. No point in requiring enemies. - sdelay_large_count = 1; - } - else - { - // Players play AGAINST each other. Enemies required. - sdelay_large_count = 2; - } - } - } - - float sdelay; - - if (pcount <= sdelay_small_count) - sdelay = sdelay_small; - else if (pcount >= sdelay_large_count) - sdelay = sdelay_large; - else // NOTE: this case implies sdelay_large_count > sdelay_small_count. - sdelay = sdelay_small + (sdelay_large - sdelay_small) * (pcount - sdelay_small_count) / (sdelay_large_count - sdelay_small_count); - - if(waves) - this.respawn_time = ceil((time + sdelay) / waves) * waves; - else - this.respawn_time = time + sdelay; - - if(sdelay < sdelay_max) - this.respawn_time_max = time + sdelay_max; - else - this.respawn_time_max = this.respawn_time; - - if((sdelay + waves >= 5.0) && (this.respawn_time - time > 1.75)) - this.respawn_countdown = 10; // first number to count down from is 10 - else - this.respawn_countdown = -1; // do not count down - - if(autocvar_g_forced_respawn) - this.respawn_flags = this.respawn_flags | RESPAWN_FORCE; -} - void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force) { vector v; diff --git a/qcsrc/server/player.qh b/qcsrc/server/player.qh index 514b34726..0232c302e 100644 --- a/qcsrc/server/player.qh +++ b/qcsrc/server/player.qh @@ -15,19 +15,6 @@ void player_anim(entity this); void PlayerCorpseDamage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force); -// g__str: -// If 0, default is used. -// If <0, 0 is used. -// Otherwise, g_str (default value) is used. -// For consistency, negative values there are mapped to zero too. -#define GAMETYPE_DEFAULTED_SETTING(str) \ - ((gametype_setting_tmp = cvar(strcat("g_", GetGametype(), "_" #str))), \ - (gametype_setting_tmp < 0) ? 0 \ - : (gametype_setting_tmp == 0 || autocvar_g_respawn_delay_forced) ? max(0, autocvar_g_##str) \ - : gametype_setting_tmp) - -void calculate_player_respawn_time(entity this); - void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force); bool PlayerHeal(entity targ, entity inflictor, float amount, float limit); diff --git a/qcsrc/server/weapons/weaponsystem.qh b/qcsrc/server/weapons/weaponsystem.qh index dd9e42a24..23d1e5972 100644 --- a/qcsrc/server/weapons/weaponsystem.qh +++ b/qcsrc/server/weapons/weaponsystem.qh @@ -2,6 +2,8 @@ #include +#define INDEPENDENT_ATTACK_FINISHED 1 + // there is 2 weapon tics that can run in one server frame const int W_TICSPERFRAME = 2; @@ -20,6 +22,15 @@ entity weapon_dropevent_item; .int old_clip_load; .int clip_size; +.float attack_finished_for[REGISTRY_MAX(Weapons) * MAX_WEAPONSLOTS]; +.float attack_finished_single[MAX_WEAPONSLOTS]; +#if INDEPENDENT_ATTACK_FINISHED +#define ATTACK_FINISHED_FOR(ent, w, slot) ((ent).(attack_finished_for[((w) - WEP_FIRST) * MAX_WEAPONSLOTS + (slot)])) +#else +#define ATTACK_FINISHED_FOR(ent, w, slot) ((ent).attack_finished_single[slot]) +#endif +#define ATTACK_FINISHED(ent, w) ATTACK_FINISHED_FOR(ent, ent.(w).m_weapon.m_id, weaponslot(w)) + void CL_SpawnWeaponentity(entity e, .entity weaponentity); void w_clear(Weapon thiswep, entity actor, .entity weaponentity, int fire); -- 2.39.2