From 440b545166918afb69eaa8b9359e251bf16900bc Mon Sep 17 00:00:00 2001 From: Lyberta Date: Thu, 31 Aug 2017 16:14:58 +0300 Subject: [PATCH] Survival: Moved from server to common. --- qcsrc/common/gamemodes/gamemode/_mod.inc | 1 + qcsrc/common/gamemodes/gamemode/_mod.qh | 1 + .../gamemodes/gamemode/survival/_mod.inc | 4 +++ .../gamemodes/gamemode/survival/_mod.qh | 4 +++ .../gamemode/survival/sv_survival.qc} | 33 ++++++++++++++++++- .../gamemode/survival/sv_survival.qh} | 2 -- qcsrc/server/mutators/mutator/_mod.inc | 1 - qcsrc/server/mutators/mutator/_mod.qh | 1 - 8 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 qcsrc/common/gamemodes/gamemode/survival/_mod.inc create mode 100644 qcsrc/common/gamemodes/gamemode/survival/_mod.qh rename qcsrc/{server/mutators/mutator/gamemode_survival.qc => common/gamemodes/gamemode/survival/sv_survival.qc} (98%) rename qcsrc/{server/mutators/mutator/gamemode_survival.qh => common/gamemodes/gamemode/survival/sv_survival.qh} (89%) diff --git a/qcsrc/common/gamemodes/gamemode/_mod.inc b/qcsrc/common/gamemodes/gamemode/_mod.inc index 2fc2c40467..6056ba7cc2 100644 --- a/qcsrc/common/gamemodes/gamemode/_mod.inc +++ b/qcsrc/common/gamemodes/gamemode/_mod.inc @@ -2,3 +2,4 @@ #include #include +#include diff --git a/qcsrc/common/gamemodes/gamemode/_mod.qh b/qcsrc/common/gamemodes/gamemode/_mod.qh index d799570126..333d341709 100644 --- a/qcsrc/common/gamemodes/gamemode/_mod.qh +++ b/qcsrc/common/gamemodes/gamemode/_mod.qh @@ -2,3 +2,4 @@ #include #include +#include diff --git a/qcsrc/common/gamemodes/gamemode/survival/_mod.inc b/qcsrc/common/gamemodes/gamemode/survival/_mod.inc new file mode 100644 index 0000000000..006e93fc75 --- /dev/null +++ b/qcsrc/common/gamemodes/gamemode/survival/_mod.inc @@ -0,0 +1,4 @@ +// generated file; do not modify +#ifdef SVQC + #include +#endif diff --git a/qcsrc/common/gamemodes/gamemode/survival/_mod.qh b/qcsrc/common/gamemodes/gamemode/survival/_mod.qh new file mode 100644 index 0000000000..5ace954770 --- /dev/null +++ b/qcsrc/common/gamemodes/gamemode/survival/_mod.qh @@ -0,0 +1,4 @@ +// generated file; do not modify +#ifdef SVQC + #include +#endif diff --git a/qcsrc/server/mutators/mutator/gamemode_survival.qc b/qcsrc/common/gamemodes/gamemode/survival/sv_survival.qc similarity index 98% rename from qcsrc/server/mutators/mutator/gamemode_survival.qc rename to qcsrc/common/gamemodes/gamemode/survival/sv_survival.qc index e7d810554d..4f917e8df2 100644 --- a/qcsrc/server/mutators/mutator/gamemode_survival.qc +++ b/qcsrc/common/gamemodes/gamemode/survival/sv_survival.qc @@ -1,4 +1,4 @@ -#include "gamemode_survival.qh" +#include "sv_survival.qh" #include #include @@ -1789,6 +1789,37 @@ MUTATOR_HOOKFUNCTION(surv, Player_ChangedTeam) } } +/// \brief Hook that is called when player is about to be killed when changing +/// teams. +MUTATOR_HOOKFUNCTION(surv, Player_ChangeTeamKill) +{ + entity player = M_ARGV(0, entity); + if (player.team != surv_defenderteam) + { + return false; + } + if (player.surv_savedplayerstate == NULL) + { + return false; + } + Surv_RestorePlayerState(player, player.surv_savedplayerstate); + delete(player.surv_savedplayerstate); + player.surv_savedplayerstate = NULL; + return true; +} + +/// \brief Hook that is called when player is about to be killed as a result of +/// the kill command or changing teams. +MUTATOR_HOOKFUNCTION(surv, ClientKill_Now) +{ + entity player = M_ARGV(0, entity); + if (player.team == surv_defenderteam) + { + // Deny suicide. + return true; + } +} + /// \brief Hook that is called when player connects to the server. MUTATOR_HOOKFUNCTION(surv, ClientConnect) { diff --git a/qcsrc/server/mutators/mutator/gamemode_survival.qh b/qcsrc/common/gamemodes/gamemode/survival/sv_survival.qh similarity index 89% rename from qcsrc/server/mutators/mutator/gamemode_survival.qh rename to qcsrc/common/gamemodes/gamemode/survival/sv_survival.qh index a4128c20ce..a381e07596 100644 --- a/qcsrc/server/mutators/mutator/gamemode_survival.qh +++ b/qcsrc/common/gamemodes/gamemode/survival/sv_survival.qh @@ -1,7 +1,5 @@ #pragma once -#include "../gamemode.qh" - /// \brief Initializes global data for the gametype. /// \return No return. void Surv_Initialize(); diff --git a/qcsrc/server/mutators/mutator/_mod.inc b/qcsrc/server/mutators/mutator/_mod.inc index a816108409..6835f5d560 100644 --- a/qcsrc/server/mutators/mutator/_mod.inc +++ b/qcsrc/server/mutators/mutator/_mod.inc @@ -11,5 +11,4 @@ #include #include #include -#include #include diff --git a/qcsrc/server/mutators/mutator/_mod.qh b/qcsrc/server/mutators/mutator/_mod.qh index 0b4a9bbcee..aef0b332ab 100644 --- a/qcsrc/server/mutators/mutator/_mod.qh +++ b/qcsrc/server/mutators/mutator/_mod.qh @@ -11,5 +11,4 @@ #include #include #include -#include #include -- 2.39.5