cssdm_config.cpp
author David Anderson <dvander@alliedmods.net>
Wed Nov 14 07:38:20 2007 +0000 (2007-11-14)
changeset 38 0e19dc9365c7
parent 0 67dcd379a2d5
child 47 c53e1d3f3da0
permissions -rw-r--r--
added amb840 - cssdm_remove_drops cvar
     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 
    33 void ChangeStatus(ConVar *cvar, const char *value);
    34 void ChangeFFAStatus(ConVar *cvar, const char *value);
    35 void ChangeSpawnStatus(ConVar *cvar, const char *value);
    36 
    37 ConVar cssdm_ragdoll_time("cssdm_ragdoll_time", "2", 0, "Sets ragdoll stay time", true, 0.0, true, 20.0);
    38 ConVar cssdm_respawn_wait("cssdm_respawn_wait", "0.75", 0, "Sets respawn wait time");
    39 ConVar cssdm_allow_c4("cssdm_allow_c4", "0", 0, "Sets whether C4 is allowed");
    40 ConVar cssdm_version("cssdm_version", SMEXT_CONF_VERSION, FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY, "CS:S DM Version");
    41 ConVar cssdm_enabled("cssdm_enabled", 
    42 					 "1", 
    43 					 FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY, 
    44 					 "Sets whether CS:S DM is enabled",
    45 					 false, 0.0f, false, 0.0f,
    46 					 ChangeStatus);
    47 ConVar cssdm_ffa_enabled("cssdm_ffa_enabled", 
    48 						 "0", 
    49 						 FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY, 
    50 						 "Sets whether Free-For-All mode is enabled",
    51 						 false, 0.0f, false, 0.0f,
    52 						 ChangeFFAStatus);
    53 ConVar cssdm_spawn_method("cssdm_spawn_method",
    54 						  "preset",
    55 						  0,
    56 						  "Sets how and where players are spawned",
    57 						  false, 0.0f, false, 0.0f,
    58 						  ChangeSpawnStatus);
    59 ConVar cssdm_remove_drops("cssdm_remove_drops", "1", 0, "Sets whether dropped items are removed");
    60 
    61 class LinkConVars : public IConCommandBaseAccessor
    62 {
    63 public:
    64 	bool RegisterConCommandBase(ConCommandBase *pBase)
    65 	{
    66 		return META_REGCVAR(pBase);
    67 	}
    68 } s_LinkConVars;
    69 
    70 void SM_InitConCommandBase()
    71 {
    72 	ConCommandBaseMgr::OneTimeInit(&s_LinkConVars);
    73 }
    74 
    75 void ChangeStatus(ConVar *cvar, const char *value)
    76 {
    77 	if (cssdm_enabled.GetInt())
    78 	{
    79 		DM_Enable();
    80 	} else {
    81 		DM_Disable();
    82 	}
    83 }
    84 
    85 void ChangeFFAStatus(ConVar *cvar, const char *value)
    86 {
    87 	if (cssdm_ffa_enabled.GetInt() && !DM_FFA_IsPatched() && DM_FFA_IsPrepared())
    88 	{
    89 		DM_Patch_FFA();
    90 	} else if (!cssdm_ffa_enabled.GetInt() && DM_FFA_IsPatched()) {
    91 		DM_Unpatch_FFA();
    92 	}
    93 }
    94 
    95 void ChangeSpawnStatus(ConVar *cvar, const char *value)
    96 {
    97 	if (strcmp(value, cssdm_spawn_method.GetString()) == 0)
    98 	{
    99 		return;
   100 	}
   101 
   102 	DM_OnSetSpawnMethod(cssdm_spawn_method.GetString());
   103 }
   104 
   105 const char *DM_GetSpawnMethod()
   106 {
   107 	return cssdm_spawn_method.GetString();
   108 }
   109 
   110 unsigned int DM_GetBodyStayTime()
   111 {
   112 	return cssdm_ragdoll_time.GetInt();
   113 }
   114 
   115 float DM_GetRespawnWait()
   116 {
   117 	return cssdm_respawn_wait.GetFloat();
   118 }
   119 
   120 bool DM_AllowC4()
   121 {
   122 	return (cssdm_allow_c4.GetInt() != 0);
   123 }
   124 
   125 bool DM_IsEnabled()
   126 {
   127 	return (cssdm_enabled.GetInt() != 0);
   128 }
   129 
   130 bool DM_IsFFAEnabled()
   131 {
   132 	return (cssdm_ffa_enabled.GetInt() != 0);
   133 }
   134 
   135 bool DM_ShouldRemoveDrops()
   136 {
   137 	return (cssdm_remove_drops.GetInt() != 0);
   138 }