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
[email protected]
     1
/**
[email protected]
     2
 * vim: set ts=4 :
[email protected]
     3
 * ===============================================================
[email protected]
     4
 * CS:S DM, Copyright (C) 2004-2007 AlliedModders LLC. 
[email protected]
     5
 * By David "BAILOPAN" Anderson
[email protected]
     6
 * All rights reserved.
[email protected]
     7
 * ===============================================================
[email protected]
     8
 *
[email protected]
     9
 * This program is free software; you can redistribute it and/or modify
[email protected]
    10
 * it under the terms of the GNU General Public License as published by
[email protected]
    11
 * the Free Software Foundation; either version 2 of the License, or (at
[email protected]
    12
 * your option) any later version.
[email protected]
    13
 * 
[email protected]
    14
 * This program is distributed in the hope that it will be useful, but
[email protected]
    15
 * WITHOUT ANY WARRANTY; without even the implied warranty of
[email protected]
    16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
[email protected]
    17
 * General Public License for more details.
[email protected]
    18
 * 
[email protected]
    19
 * You should have received a copy of the GNU General Public License
[email protected]
    20
 * along with this program; see the file COPYING; if not, write to the
[email protected]
    21
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
[email protected]
    22
 * MA 02110-1301 USA
[email protected]
    23
 * 
[email protected]
    24
 * Version: $Id$
[email protected]
    25
 */
[email protected]
    26
[email protected]
    27
#include "smsdk_ext.h"
[email protected]
    28
#include "cssdm_config.h"
[email protected]
    29
#include "cssdm_ctrl.h"
[email protected]
    30
#include "cssdm_ffa.h"
[email protected]
    31
#include "cssdm_callbacks.h"
[email protected]
    32
#include "cssdm_headers.h"
[email protected]
    33
#include "cssdm_version.h"
[email protected]
    34
[email protected]
    35
static void ChangeStatus(IConVar *cvar, const char *value, float flOldValue);
[email protected]
    36
static void ChangeFFAStatus(IConVar *cvar, const char *value, float flOldValue);
[email protected]
    37
static void ChangeSpawnStatus(IConVar *cvar, const char *value, float flOldValue);
[email protected]
    38
[email protected]
    39
ConVar cssdm_ragdoll_time("cssdm_ragdoll_time", "2", 0, "Sets ragdoll stay time", true, 0.0, true, 20.0);
[email protected]
    40
ConVar cssdm_respawn_wait("cssdm_respawn_wait", "0.75", 0, "Sets respawn wait time");
[email protected]
    41
ConVar cssdm_allow_c4("cssdm_allow_c4", "0", 0, "Sets whether C4 is allowed");
[email protected]
    42
ConVar cssdm_version("cssdm_version", CSSDM_FULL_VERSION, FCVAR_REPLICATED|FCVAR_NOTIFY, "CS:S DM Version");
[email protected]
    43
ConVar cssdm_enabled("cssdm_enabled", 
[email protected]
    44
					 "1", 
[email protected]
    45
					 FCVAR_REPLICATED|FCVAR_NOTIFY, 
[email protected]
    46
					 "Sets whether CS:S DM is enabled",
[email protected]
    47
					 false, 0.0f, false, 0.0f,
[email protected]
    48
					 ChangeStatus);
[email protected]
    49
ConVar cssdm_ffa_enabled("cssdm_ffa_enabled", 
[email protected]
    50
						 "0", 
[email protected]
    51
						 FCVAR_REPLICATED|FCVAR_NOTIFY, 
[email protected]
    52
						 "Sets whether Free-For-All mode is enabled",
[email protected]
    53
						 false, 0.0f, false, 0.0f,
[email protected]
    54
						 ChangeFFAStatus);
[email protected]
    55
ConVar cssdm_spawn_method("cssdm_spawn_method",
[email protected]
    56
						  "preset",
[email protected]
    57
						  0,
[email protected]
    58
						  "Sets how and where players are spawned",
[email protected]
    59
						  false, 0.0f, false, 0.0f,
[email protected]
    60
						  ChangeSpawnStatus);
[email protected]
    61
ConVar cssdm_remove_drops("cssdm_remove_drops", "1", 0, "Sets whether dropped items are removed");
[email protected]
    62
[email protected]
    63
class LinkConVars : public IConCommandBaseAccessor
[email protected]
    64
{
[email protected]
    65
public:
[email protected]
    66
	bool RegisterConCommandBase(ConCommandBase *pBase)
[email protected]
    67
	{
[email protected]
    68
		return META_REGCVAR(pBase);
[email protected]
    69
	}
[email protected]
    70
} s_LinkConVars;
[email protected]
    71
[email protected]
    72
void SM_InitConCommandBase()
[email protected]
    73
{
[email protected]
    74
	g_pCVar = icvar;
[email protected]
    75
	ConVar_Register(0, &s_LinkConVars);
[email protected]
    76
}
[email protected]
    77
[email protected]
    78
static void ChangeStatus(IConVar *cvar, const char *value, float flOldValue)
[email protected]
    79
{
[email protected]
    80
	if (cssdm_enabled.GetInt())
[email protected]
    81
	{
[email protected]
    82
		DM_Enable();
[email protected]
    83
	} else {
[email protected]
    84
		DM_Disable();
[email protected]
    85
	}
[email protected]
    86
}
[email protected]
    87
[email protected]
    88
static void ChangeFFAStatus(IConVar *cvar, const char *value, float flOldValue)
[email protected]
    89
{
[email protected]
    90
	if (cssdm_ffa_enabled.GetInt() && !DM_FFA_IsPatched() && DM_FFA_IsPrepared())
[email protected]
    91
	{
[email protected]
    92
		DM_Patch_FFA();
[email protected]
    93
	} else if (!cssdm_ffa_enabled.GetInt() && DM_FFA_IsPatched()) {
[email protected]
    94
		DM_Unpatch_FFA();
[email protected]
    95
	}
[email protected]
    96
}
[email protected]
    97
[email protected]
    98
static void ChangeSpawnStatus(IConVar *cvar, const char *value, float flOldValue)
[email protected]
    99
{
[email protected]
   100
	if (strcmp(value, cssdm_spawn_method.GetString()) == 0)
[email protected]
   101
	{
[email protected]
   102
		return;
[email protected]
   103
	}
[email protected]
   104
[email protected]
   105
	DM_OnSetSpawnMethod(cssdm_spawn_method.GetString());
[email protected]
   106
}
[email protected]
   107
[email protected]
   108
const char *DM_GetSpawnMethod()
[email protected]
   109
{
[email protected]
   110
	return cssdm_spawn_method.GetString();
[email protected]
   111
}
[email protected]
   112
[email protected]
   113
unsigned int DM_GetBodyStayTime()
[email protected]
   114
{
[email protected]
   115
	return cssdm_ragdoll_time.GetInt();
[email protected]
   116
}
[email protected]
   117
[email protected]
   118
float DM_GetRespawnWait()
[email protected]
   119
{
[email protected]
   120
	return cssdm_respawn_wait.GetFloat();
[email protected]
   121
}
[email protected]
   122
[email protected]
   123
bool DM_AllowC4()
[email protected]
   124
{
[email protected]
   125
	return (cssdm_allow_c4.GetInt() != 0);
[email protected]
   126
}
[email protected]
   127
[email protected]
   128
bool DM_IsEnabled()
[email protected]
   129
{
[email protected]
   130
	return (cssdm_enabled.GetInt() != 0);
[email protected]
   131
}
[email protected]
   132
[email protected]
   133
bool DM_IsFFAEnabled()
[email protected]
   134
{
[email protected]
   135
	return (cssdm_ffa_enabled.GetInt() != 0);
[email protected]
   136
}
[email protected]
   137
[email protected]
   138
bool DM_ShouldRemoveDrops()
[email protected]
   139
{
[email protected]
   140
	return (cssdm_remove_drops.GetInt() != 0);
[email protected]
   141
}