Quote:
Originally Posted by MAGNAT2645
That's just a stock which returns true (only if string treated as true) or false (in any other case), you don't have to use it. It was just an example of simple/advanced conversion.
|
alright, put this code in your cfgmap.inc and test out how it goes:
Code:
public int GetBool(const char[] key_path, bool& b, bool simple=true) {
if( this==null ) {
return 0;
}
PackVal val;
bool result = this.GetVal(key_path, val);
if( result && val.tag==KeyValType_Value ) {
val.data.Reset();
char[] strval = new char[val.size];
val.data.ReadString(strval, val.size);
if( simple ) {
b = StringToInt(strval) != 0;
} else {
if( !strcmp(strval, "true", false) || !strcmp(strval, "1", false) ) {
b = true;
} else if( !strcmp(strval, "false", false) || !strcmp(strval, "0", false) ) {
b = false;
} else {
return 0;
}
}
return val.size - 1;
}
return 0;
}
__________________