Update CS:GO TakeDmg gamedata.
3 * ===============================================================
4 * CS:S DM, Copyright (C) 2004-2007 AlliedModders LLC.
5 * By David "BAILOPAN" Anderson
7 * ===============================================================
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or (at
12 * your option) any later version.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; see the file COPYING; if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
27 #include "cssdm_headers.h"
28 #include "cssdm_config.h"
29 #include "cssdm_ctrl.h"
30 #include "cssdm_ffa.h"
31 #include "cssdm_callbacks.h"
32 #include "cssdm_events.h"
34 extern ConVar cssdm_enabled;
35 extern ConVar cssdm_ffa_enabled;
36 extern bool g_IsLoadedOkay;
38 bool g_IsRunning = false;
39 bool g_IsMapStarted = false;
40 bool g_HasConfigRan = false;
42 void DM_StartEverything()
44 if (!g_IsMapStarted || g_HasConfigRan)
49 g_HasConfigRan = true;
51 /* If we're not running but we should be, start up now.
52 * g_IsRunning should never be true here.
54 if (!g_IsRunning && cssdm_enabled.GetInt() == 1)
56 /* We should be enabled! */
61 void OnLevelInitialized()
68 g_IsMapStarted = true;
69 engine->ServerCommand("exec cssdm/cssdm.cfg\n");
72 snprintf(map_cmd, sizeof(map_cmd), "exec cssdm/maps/%s.cssdm.cfg\n", STRING(gpGlobals->mapname));
73 engine->ServerCommand(map_cmd);
75 engine->ServerCommand("cssdm internal 1\n");
80 /* We fully disable CS:S DM when the map ends.
81 * This is so our DM_Enable call is properly paired, but
82 * also so CGameRules hooks get flushed.
84 DM_ClearRagdollTimers();
90 g_IsMapStarted = false;
91 g_HasConfigRan = false;
96 if (!g_IsLoadedOkay || !g_IsRunning)
103 /* If FFA is enabled, we must unpatch it. */
104 if (DM_FFA_IsPatched())
116 if (!g_IsLoadedOkay || g_IsRunning || !g_IsMapStarted || !g_HasConfigRan)
125 /* If FFA should be enabled, patch it. */
126 if (cssdm_ffa_enabled.GetInt() != 0
127 && DM_FFA_IsPrepared()
128 && !DM_FFA_IsPatched())
136 CON_COMMAND(cssdm, "CS:S DM console menu")
138 int argc = args.ArgC();
141 /* :TODO: display menu */
145 const char *arg = args.Arg(1);
146 if (strcmp(arg, "internal") == 0)
152 int num = atoi(args.Arg(2));
155 DM_StartEverything();