cssdm_config.cpp
author Ruben Gonzalez <drifter01620@gmail.com>
Wed Oct 01 11:50:24 2014 -0400 (2014-10-01)
changeset 193 277c856152b0
parent 53 3c0401873aa6
permissions -rw-r--r--
Update linix CS:GO gamedata
     1 /**
     2  * vim: set ts=4 :
     3  * ===============================================================
     4  * CS:S DM, Copyright (C) 2004-2007 AlliedModders LLC. 
     5  * By David "BAILOPAN" Anderson
     6  * All rights reserved.
     7  * ===============================================================
     8  *
     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.
    13  * 
    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.
    18  * 
    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,
    22  * MA 02110-1301 USA
    23  * 
    24  * Version: $Id$
    25  */
    26 
    27 #include "smsdk_ext.h"
    28 #include "cssdm_config.h"
    29 #include "cssdm_ctrl.h"
    30 #include "cssdm_ffa.h"
    31 #include "cssdm_callbacks.h"
    32 #include "cssdm_headers.h"
    33 #include "cssdm_version.h"
    34 
    35 static void ChangeStatus(IConVar *cvar, const char *value, float flOldValue);
    36 static void ChangeFFAStatus(IConVar *cvar, const char *value, float flOldValue);
    37 static void ChangeSpawnStatus(IConVar *cvar, const char *value, float flOldValue);
    38 
    39 ConVar cssdm_ragdoll_time("cssdm_ragdoll_time", "2", 0, "Sets ragdoll stay time", true, 0.0, true, 20.0);
    40 ConVar cssdm_respawn_wait("cssdm_respawn_wait", "0.75", 0, "Sets respawn wait time");
    41 ConVar cssdm_allow_c4("cssdm_allow_c4", "0", 0, "Sets whether C4 is allowed");
    42 ConVar cssdm_version("cssdm_version", CSSDM_FULL_VERSION, FCVAR_REPLICATED|FCVAR_NOTIFY, "CS:S DM Version");
    43 ConVar cssdm_enabled("cssdm_enabled", 
    44 					 "1", 
    45 					 FCVAR_REPLICATED|FCVAR_NOTIFY, 
    46 					 "Sets whether CS:S DM is enabled",
    47 					 false, 0.0f, false, 0.0f,
    48 					 ChangeStatus);
    49 ConVar cssdm_ffa_enabled("cssdm_ffa_enabled", 
    50 						 "0", 
    51 						 FCVAR_REPLICATED|FCVAR_NOTIFY, 
    52 						 "Sets whether Free-For-All mode is enabled",
    53 						 false, 0.0f, false, 0.0f,
    54 						 ChangeFFAStatus);
    55 ConVar cssdm_spawn_method("cssdm_spawn_method",
    56 						  "preset",
    57 						  0,
    58 						  "Sets how and where players are spawned",
    59 						  false, 0.0f, false, 0.0f,
    60 						  ChangeSpawnStatus);
    61 ConVar cssdm_remove_drops("cssdm_remove_drops", "1", 0, "Sets whether dropped items are removed");
    62 
    63 class LinkConVars : public IConCommandBaseAccessor
    64 {
    65 public:
    66 	bool RegisterConCommandBase(ConCommandBase *pBase)
    67 	{
    68 		return META_REGCVAR(pBase);
    69 	}
    70 } s_LinkConVars;
    71 
    72 void SM_InitConCommandBase()
    73 {
    74 	g_pCVar = icvar;
    75 	ConVar_Register(0, &s_LinkConVars);
    76 }
    77 
    78 static void ChangeStatus(IConVar *cvar, const char *value, float flOldValue)
    79 {
    80 	if (cssdm_enabled.GetInt())
    81 	{
    82 		DM_Enable();
    83 	} else {
    84 		DM_Disable();
    85 	}
    86 }
    87 
    88 static void ChangeFFAStatus(IConVar *cvar, const char *value, float flOldValue)
    89 {
    90 	if (cssdm_ffa_enabled.GetInt() && !DM_FFA_IsPatched() && DM_FFA_IsPrepared())
    91 	{
    92 		DM_Patch_FFA();
    93 	} else if (!cssdm_ffa_enabled.GetInt() && DM_FFA_IsPatched()) {
    94 		DM_Unpatch_FFA();
    95 	}
    96 }
    97 
    98 static void ChangeSpawnStatus(IConVar *cvar, const char *value, float flOldValue)
    99 {
   100 	if (strcmp(value, cssdm_spawn_method.GetString()) == 0)
   101 	{
   102 		return;
   103 	}
   104 
   105 	DM_OnSetSpawnMethod(cssdm_spawn_method.GetString());
   106 }
   107 
   108 const char *DM_GetSpawnMethod()
   109 {
   110 	return cssdm_spawn_method.GetString();
   111 }
   112 
   113 unsigned int DM_GetBodyStayTime()
   114 {
   115 	return cssdm_ragdoll_time.GetInt();
   116 }
   117 
   118 float DM_GetRespawnWait()
   119 {
   120 	return cssdm_respawn_wait.GetFloat();
   121 }
   122 
   123 bool DM_AllowC4()
   124 {
   125 	return (cssdm_allow_c4.GetInt() != 0);
   126 }
   127 
   128 bool DM_IsEnabled()
   129 {
   130 	return (cssdm_enabled.GetInt() != 0);
   131 }
   132 
   133 bool DM_IsFFAEnabled()
   134 {
   135 	return (cssdm_ffa_enabled.GetInt() != 0);
   136 }
   137 
   138 bool DM_ShouldRemoveDrops()
   139 {
   140 	return (cssdm_remove_drops.GetInt() != 0);
   141 }