-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcvar.cpp
62 lines (51 loc) · 1.14 KB
/
cvar.cpp
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
#include "shared.h"
Cvar_Get_t Cvar_Get = (Cvar_Get_t)0x439350;
Cvar_Set_t Cvar_Set = (Cvar_Set_t)0x439650;
Cvar_FindVar_t Cvar_FindVar = (Cvar_FindVar_t)0x439280;
float Cvar_VariableValue(const char *var_name) {
cvar_t *var;
var = Cvar_FindVar(var_name);
if (!var) {
return 0;
}
return var->value;
}
int Cvar_VariableIntegerValue(const char *var_name) {
cvar_t *var;
var = Cvar_FindVar(var_name);
if (!var) {
return 0;
}
return var->integer;
}
char *Cvar_VariableString(const char *var_name) {
cvar_t *var;
var = Cvar_FindVar(var_name);
if (!var) {
return "";
}
return var->string;
}
char* Cvar_VariableStringBuffer(const char *var_name, char *buffer, int bufsize) {
cvar_t *var;
var = Cvar_FindVar(var_name);
if (!var) {
*buffer = 0;
} else {
Q_strncpyz(buffer, var->string, bufsize);
}
return buffer;
}
void Cvar_LatchedVariableStringBuffer(const char *var_name, char *buffer, int bufsize) {
cvar_t *var;
var = Cvar_FindVar(var_name);
if (!var) {
*buffer = 0;
} else {
if (var->latchedString) {
Q_strncpyz(buffer, var->latchedString, bufsize);
} else {
Q_strncpyz(buffer, var->string, bufsize);
}
}
}