-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcvar.cpp
More file actions
executable file
·61 lines (50 loc) · 1.1 KB
/
cvar.cpp
File metadata and controls
executable file
·61 lines (50 loc) · 1.1 KB
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
#include <string>
#include "cvar.hpp"
using namespace std;
VarPool *clientCvars = NULL,
*serverCvars = NULL;
bool loadingMap;
void VarPool::registerVar(BaseConsoleVar *var)
{
vars[var->getName()] = var;
}
BaseConsoleVar *VarPool::lookup(const char *name)
{
if(vars.find(std::string(name)) == vars.end())
return NULL;
return vars[ std::string(name) ];
}
VarPool::iterator VarPool::begin(void)
{ return vars.begin(); }
VarPool::iterator VarPool::end(void)
{ return vars.end(); }
void VarPool::restoreVars(void)
{
for(iterator ii=begin(); ii!=end(); ii++)
{
ii->second->restoreValue();
}
}
void ConsoleVar<bool>::valueFromString(const char *c_str)
{
if(!strcasecmp(c_str, "true"))
setValue(true);
else if(!strcasecmp(c_str, "false"))
setValue(false);
else if(atoi(c_str) != 0)
setValue(true);
else
setValue(false);
}
void ConsoleVar<int>::valueFromString(const char *c_str)
{
setValue(atoi(c_str));
}
void ConsoleVar<float>::valueFromString(const char *c_str)
{
setValue(atof(c_str));
}
void ConsoleVar<string>::valueFromString(const char *c_str)
{
setValue( string(c_str) );
}