forked from haithun/CoD4X17a_testing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cvar.c
120 lines (99 loc) · 3.61 KB
/
cvar.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
===========================================================================
Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of CoD4X17a-Server source code.
CoD4X17a-Server source code is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
CoD4X17a-Server source code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
===========================================================================
*/
#include "cvar.h"
#include "cmd.h"
#include "cmd_completion.h"
// nothing outside the Cvar_*() functions should modify these fields!
#ifndef __CMD_COMPLETION_H__
void Cvar_CompleteCvarName(){}
#endif
void Cvar_VariableStringBuffer(const char* cvarname, char* buff, size_t size){
Q_strncpyz(buff, Cvar_GetVariantString(cvarname), size);
}
/*
============
Cvar_Init
Reads in all archived cvars
============
*/
void Cvar_Init (void)
{
Cmd_AddCommand ("toggle", Cvar_Toggle_f);
Cmd_SetCommandCompletionFunc( "toggle", Cvar_CompleteCvarName );
Cmd_AddCommand ("togglep", Cvar_TogglePrint_f);
Cmd_SetCommandCompletionFunc( "togglep", Cvar_CompleteCvarName );
Cmd_AddCommand ("set", Cvar_Set_f);
Cmd_SetCommandCompletionFunc( "set", Cvar_CompleteCvarName );
Cmd_AddCommand ("sets", Cvar_SetS_f);
Cmd_SetCommandCompletionFunc( "sets", Cvar_CompleteCvarName );
Cmd_AddCommand ("seta", Cvar_SetA_f);
Cmd_SetCommandCompletionFunc( "seta", Cvar_CompleteCvarName );
Cmd_AddCommand ("setfromdvar", Cvar_SetFromCvar_f);
Cmd_SetCommandCompletionFunc( "setfromdvar", Cvar_CompleteCvarName );
Cmd_AddCommand ("setfromlocString", Cvar_SetFromLocalizedStr_f);
Cmd_SetCommandCompletionFunc( "setfromlocString", Cvar_CompleteCvarName );
Cmd_AddCommand ("setdvartotime", Cvar_SetToTime_f);
Cmd_SetCommandCompletionFunc( "setdvartotime", Cvar_CompleteCvarName );
Cmd_AddCommand ("reset", Cvar_Reset_f);
Cmd_SetCommandCompletionFunc( "reset", Cvar_CompleteCvarName );
Cmd_AddCommand ("setu", Cvar_SetU_f);
Cmd_SetCommandCompletionFunc( "setu", Cvar_CompleteCvarName );
Cmd_AddCommand ("dvarlist", Cvar_List_f);
Cmd_AddCommand ("dvardump", Cvar_Dump_f);
Cmd_AddCommand ("dvar_bool", Cvar_RegisterBool_f);
Cmd_AddCommand ("dvar_int", Cvar_RegisterInt_f);
Cmd_AddCommand ("dvar_float", Cvar_RegisterFloat_f);
cvar_t **tmp = (cvar_t**)(0x14078480);
*tmp = Cvar_RegisterBool("sv_cheats", qfalse, CVAR_INIT, "Enable cheating on server");
}
/*
============
Cvar_VariableValue
============
*/
float Cvar_VariableValue( const char *var_name ) {
cvar_t *var;
var = Cvar_FindMalleableVar (var_name);
if (!var || var->type != CVAR_FLOAT)
return 0;
return var->value;
}
/*
============
Cvar_VariableIntegerValue
============
*/
int Cvar_VariableIntegerValue( const char *var_name ) {
cvar_t *var;
var = Cvar_FindMalleableVar (var_name);
if (!var || var->type != CVAR_INT)
return 0;
return var->integer;
}
/*
============
Cvar_VariableString
============
*/
const char* Cvar_VariableString( const char *var_name ) {
cvar_t *var;
var = Cvar_FindMalleableVar (var_name);
if (!var || var->type != CVAR_STRING)
return "";
return var->string;
}