summaryrefslogtreecommitdiffstats
path: root/iniFile/iniFile.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-09 17:12:52 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-09 17:12:52 +0200
commita9350c43614cdc399aea5f517405066e5e18ac2a (patch)
tree84d44f1f40b0b86768a74c6b33e3f92dda99b550 /iniFile/iniFile.cpp
parentSugarcane and cactus max height can be set in world.ini. (diff)
downloadcuberite-a9350c43614cdc399aea5f517405066e5e18ac2a.tar
cuberite-a9350c43614cdc399aea5f517405066e5e18ac2a.tar.gz
cuberite-a9350c43614cdc399aea5f517405066e5e18ac2a.tar.bz2
cuberite-a9350c43614cdc399aea5f517405066e5e18ac2a.tar.lz
cuberite-a9350c43614cdc399aea5f517405066e5e18ac2a.tar.xz
cuberite-a9350c43614cdc399aea5f517405066e5e18ac2a.tar.zst
cuberite-a9350c43614cdc399aea5f517405066e5e18ac2a.zip
Diffstat (limited to 'iniFile/iniFile.cpp')
-rw-r--r--iniFile/iniFile.cpp60
1 files changed, 36 insertions, 24 deletions
diff --git a/iniFile/iniFile.cpp b/iniFile/iniFile.cpp
index 23a1cfa92..adad8f515 100644
--- a/iniFile/iniFile.cpp
+++ b/iniFile/iniFile.cpp
@@ -388,33 +388,45 @@ double cIniFile::GetValueF(const string & keyname, const string & valuename, dou
-// 16 variables may be a bit of over kill, but hey, it's only code.
-unsigned cIniFile::GetValueV( const string & keyname, const string & valuename, char *format,
- void *v1, void *v2, void *v3, void *v4,
- void *v5, void *v6, void *v7, void *v8,
- void *v9, void *v10, void *v11, void *v12,
- void *v13, void *v14, void *v15, void *v16)
+AString cIniFile::GetValueSet(const AString & keyname, const AString & valuename, const AString & defValue)
{
- string value;
- // va_list args;
- unsigned nVals;
+ long keyID = FindKey( keyname);
+ if ( keyID == noID)
+ {
+ SetValue(keyname, valuename, defValue);
+ return defValue;
+ }
+ long valueID = FindValue( unsigned(keyID), valuename);
+ if ( valueID == noID)
+ {
+ SetValue(keyname, valuename, defValue);
+ return defValue;
+ }
- value = GetValue( keyname, valuename);
- if ( !value.length())
- return false;
- // Why is there not vsscanf() function. Linux man pages say that there is
- // but no compiler I've seen has it defined. Bummer!
- //
- // va_start( args, format);
- // nVals = vsscanf( value.c_str(), format, args);
- // va_end( args);
-
- nVals = sscanf_s( value.c_str(), format,
- v1, v2, v3, v4, v5, v6, v7, v8,
- v9, v10, v11, v12, v13, v14, v15, v16);
-
- return nVals;
+ return keys[keyID].values[valueID];
+}
+
+
+
+
+
+double cIniFile::GetValueSetF(const AString & keyname, const AString & valuename, const double defValue)
+{
+ AString Data;
+ Printf(Data, "%f", defValue);
+ return atof(GetValueSet(keyname, valuename, Data).c_str());
+}
+
+
+
+
+
+int cIniFile::GetValueSetI(const AString & keyname, const AString & valuename, const int defValue)
+{
+ AString Data;
+ Printf(Data, "%d", defValue);
+ return atoi(GetValueSet(keyname, valuename, Data).c_str());
}