1
0

New IniFile functionality: read value and set default if it isn't present (GetValueSet() ); used by cWorld

git-svn-id: http://mc-server.googlecode.com/svn/trunk@586 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2012-06-09 15:12:52 +00:00
parent 8189487258
commit a9350c4361
5 changed files with 294 additions and 94 deletions

View File

@ -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;
}
return keys[keyID].values[valueID];
}
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;
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());
}

View File

@ -108,23 +108,21 @@ public:
// Gets value of [keyname] valuename =.
// Overloaded to return string, int, and double.
// Returns defValue if key/value not found.
std::string GetValue( const std::string & keyname, const std::string & valuename, const std::string & defValue = "") const; //tolua_export
std::string GetValue( const unsigned keyID, const unsigned valueID, const std::string & defValue = "") const; //tolua_export
int GetValueI( const std::string & keyname, const std::string & valuename, const int defValue = 0) const; //tolua_export
bool GetValueB( const std::string & keyname, const std::string & valuename, const bool defValue = false) const { //tolua_export
AString GetValue (const AString & keyname, const AString & valuename, const AString & defValue = "") const; // tolua_export
AString GetValue (const unsigned keyID, const unsigned valueID, const AString & defValue = "") const; // tolua_export
double GetValueF(const AString & keyname, const AString & valuename, const double defValue = 0) const; // tolua_export
int GetValueI(const AString & keyname, const AString & valuename, const int defValue = 0) const; // tolua_export
bool GetValueB(const AString & keyname, const AString & valuename, const bool defValue = false) const { // tolua_export
return ( GetValueI( keyname, valuename, int( defValue)) > 0);
} //tolua_export
double GetValueF( const std::string & keyname, const std::string & valuename, const double defValue = 0.0) const; //tolua_export
// This is a variable length formatted GetValue routine. All these voids
// are required because there is no vsscanf() like there is a vsprintf().
// Only a maximum of 8 variable can be read.
// NOTE: do not use this function, instead get the string value and parse it yourself
OBSOLETE unsigned GetValueV( const std::string & keyname, const std::string & valuename, char *format,
void *v1 = 0, void *v2 = 0, void *v3 = 0, void *v4 = 0,
void *v5 = 0, void *v6 = 0, void *v7 = 0, void *v8 = 0,
void *v9 = 0, void *v10 = 0, void *v11 = 0, void *v12 = 0,
void *v13 = 0, void *v14 = 0, void *v15 = 0, void *v16 = 0);
} // tolua_export
// Gets the value; if not found, write the default to the INI file
AString GetValueSet (const AString & keyname, const AString & valuename, const AString & defValue = ""); // tolua_export
double GetValueSetF(const AString & keyname, const AString & valuename, const double defValue = 0.0); // tolua_export
int GetValueSetI(const AString & keyname, const AString & valuename, const int defValue = 0); // tolua_export
bool GetValueSetB(const AString & keyname, const AString & valuename, const bool defValue = false) { // tolua_export
return (GetValueSetI(keyname, valuename, defValue ? 1 : 0) > 0);
} // tolua_export
// Sets value of [keyname] valuename =.
// Specify the optional paramter as false (0) if you do not want it to create

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 06/09/12 14:48:28.
** Generated automatically by tolua++-1.0.92 on 06/09/12 17:10:20.
*/
#ifndef __cplusplus
@ -1297,13 +1297,13 @@ static int tolua_AllToLua_cIniFile_GetValue00(lua_State* tolua_S)
#endif
{
const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
const std::string valuename = ((const std::string) tolua_tocppstring(tolua_S,3,0));
const AString keyname = ((const AString) tolua_tocppstring(tolua_S,2,0));
const AString valuename = ((const AString) tolua_tocppstring(tolua_S,3,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValue'", NULL);
#endif
{
std::string tolua_ret = (std::string) self->GetValue(keyname,valuename);
AString tolua_ret = (AString) self->GetValue(keyname,valuename);
tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
tolua_pushcppstring(tolua_S,(const char*)keyname);
tolua_pushcppstring(tolua_S,(const char*)valuename);
@ -1334,14 +1334,14 @@ static int tolua_AllToLua_cIniFile_GetValue01(lua_State* tolua_S)
else
{
const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
const std::string valuename = ((const std::string) tolua_tocppstring(tolua_S,3,0));
const std::string defValue = ((const std::string) tolua_tocppstring(tolua_S,4,0));
const AString keyname = ((const AString) tolua_tocppstring(tolua_S,2,0));
const AString valuename = ((const AString) tolua_tocppstring(tolua_S,3,0));
const AString defValue = ((const AString) tolua_tocppstring(tolua_S,4,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValue'", NULL);
#endif
{
std::string tolua_ret = (std::string) self->GetValue(keyname,valuename,defValue);
AString tolua_ret = (AString) self->GetValue(keyname,valuename,defValue);
tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
tolua_pushcppstring(tolua_S,(const char*)keyname);
tolua_pushcppstring(tolua_S,(const char*)valuename);
@ -1375,7 +1375,7 @@ static int tolua_AllToLua_cIniFile_GetValue02(lua_State* tolua_S)
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValue'", NULL);
#endif
{
std::string tolua_ret = (std::string) self->GetValue(keyID,valueID);
AString tolua_ret = (AString) self->GetValue(keyID,valueID);
tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
}
}
@ -1403,12 +1403,12 @@ static int tolua_AllToLua_cIniFile_GetValue03(lua_State* tolua_S)
const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
const unsigned keyID = ((const unsigned) tolua_tonumber(tolua_S,2,0));
const unsigned valueID = ((const unsigned) tolua_tonumber(tolua_S,3,0));
const std::string defValue = ((const std::string) tolua_tocppstring(tolua_S,4,0));
const AString defValue = ((const AString) tolua_tocppstring(tolua_S,4,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValue'", NULL);
#endif
{
std::string tolua_ret = (std::string) self->GetValue(keyID,valueID,defValue);
AString tolua_ret = (AString) self->GetValue(keyID,valueID,defValue);
tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
tolua_pushcppstring(tolua_S,(const char*)defValue);
}
@ -1419,6 +1419,46 @@ tolua_lerror:
}
#endif //#ifndef TOLUA_DISABLE
/* method: GetValueF of class cIniFile */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_GetValueF00
static int tolua_AllToLua_cIniFile_GetValueF00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
!tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
!tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
!tolua_isnumber(tolua_S,4,1,&tolua_err) ||
!tolua_isnoobj(tolua_S,5,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
const AString keyname = ((const AString) tolua_tocppstring(tolua_S,2,0));
const AString valuename = ((const AString) tolua_tocppstring(tolua_S,3,0));
const double defValue = ((const double) tolua_tonumber(tolua_S,4,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValueF'", NULL);
#endif
{
double tolua_ret = (double) self->GetValueF(keyname,valuename,defValue);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
tolua_pushcppstring(tolua_S,(const char*)keyname);
tolua_pushcppstring(tolua_S,(const char*)valuename);
}
}
return 3;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'GetValueF'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: GetValueI of class cIniFile */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_GetValueI00
static int tolua_AllToLua_cIniFile_GetValueI00(lua_State* tolua_S)
@ -1437,8 +1477,8 @@ static int tolua_AllToLua_cIniFile_GetValueI00(lua_State* tolua_S)
#endif
{
const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
const std::string valuename = ((const std::string) tolua_tocppstring(tolua_S,3,0));
const AString keyname = ((const AString) tolua_tocppstring(tolua_S,2,0));
const AString valuename = ((const AString) tolua_tocppstring(tolua_S,3,0));
const int defValue = ((const int) tolua_tonumber(tolua_S,4,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValueI'", NULL);
@ -1477,8 +1517,8 @@ static int tolua_AllToLua_cIniFile_GetValueB00(lua_State* tolua_S)
#endif
{
const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
const std::string valuename = ((const std::string) tolua_tocppstring(tolua_S,3,0));
const AString keyname = ((const AString) tolua_tocppstring(tolua_S,2,0));
const AString valuename = ((const AString) tolua_tocppstring(tolua_S,3,0));
const bool defValue = ((const bool) tolua_toboolean(tolua_S,4,false));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValueB'", NULL);
@ -1499,14 +1539,88 @@ static int tolua_AllToLua_cIniFile_GetValueB00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
/* method: GetValueF of class cIniFile */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_GetValueF00
static int tolua_AllToLua_cIniFile_GetValueF00(lua_State* tolua_S)
/* method: GetValueSet of class cIniFile */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_GetValueSet00
static int tolua_AllToLua_cIniFile_GetValueSet00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"const cIniFile",0,&tolua_err) ||
!tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
!tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
!tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,4,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
const AString keyname = ((const AString) tolua_tocppstring(tolua_S,2,0));
const AString valuename = ((const AString) tolua_tocppstring(tolua_S,3,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValueSet'", NULL);
#endif
{
AString tolua_ret = (AString) self->GetValueSet(keyname,valuename);
tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
tolua_pushcppstring(tolua_S,(const char*)keyname);
tolua_pushcppstring(tolua_S,(const char*)valuename);
}
}
return 3;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'GetValueSet'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: GetValueSet of class cIniFile */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_GetValueSet01
static int tolua_AllToLua_cIniFile_GetValueSet01(lua_State* tolua_S)
{
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
!tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
!tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
!tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,5,&tolua_err)
)
goto tolua_lerror;
else
{
cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
const AString keyname = ((const AString) tolua_tocppstring(tolua_S,2,0));
const AString valuename = ((const AString) tolua_tocppstring(tolua_S,3,0));
const AString defValue = ((const AString) tolua_tocppstring(tolua_S,4,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValueSet'", NULL);
#endif
{
AString tolua_ret = (AString) self->GetValueSet(keyname,valuename,defValue);
tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
tolua_pushcppstring(tolua_S,(const char*)keyname);
tolua_pushcppstring(tolua_S,(const char*)valuename);
tolua_pushcppstring(tolua_S,(const char*)defValue);
}
}
return 4;
tolua_lerror:
return tolua_AllToLua_cIniFile_GetValueSet00(tolua_S);
}
#endif //#ifndef TOLUA_DISABLE
/* method: GetValueSetF of class cIniFile */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_GetValueSetF00
static int tolua_AllToLua_cIniFile_GetValueSetF00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
!tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
!tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
!tolua_isnumber(tolua_S,4,1,&tolua_err) ||
@ -1516,15 +1630,15 @@ static int tolua_AllToLua_cIniFile_GetValueF00(lua_State* tolua_S)
else
#endif
{
const cIniFile* self = (const cIniFile*) tolua_tousertype(tolua_S,1,0);
const std::string keyname = ((const std::string) tolua_tocppstring(tolua_S,2,0));
const std::string valuename = ((const std::string) tolua_tocppstring(tolua_S,3,0));
cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
const AString keyname = ((const AString) tolua_tocppstring(tolua_S,2,0));
const AString valuename = ((const AString) tolua_tocppstring(tolua_S,3,0));
const double defValue = ((const double) tolua_tonumber(tolua_S,4,0.0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValueF'", NULL);
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValueSetF'", NULL);
#endif
{
double tolua_ret = (double) self->GetValueF(keyname,valuename,defValue);
double tolua_ret = (double) self->GetValueSetF(keyname,valuename,defValue);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
tolua_pushcppstring(tolua_S,(const char*)keyname);
tolua_pushcppstring(tolua_S,(const char*)valuename);
@ -1533,7 +1647,87 @@ static int tolua_AllToLua_cIniFile_GetValueF00(lua_State* tolua_S)
return 3;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'GetValueF'.",&tolua_err);
tolua_error(tolua_S,"#ferror in function 'GetValueSetF'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: GetValueSetI of class cIniFile */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_GetValueSetI00
static int tolua_AllToLua_cIniFile_GetValueSetI00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
!tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
!tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
!tolua_isnumber(tolua_S,4,1,&tolua_err) ||
!tolua_isnoobj(tolua_S,5,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
const AString keyname = ((const AString) tolua_tocppstring(tolua_S,2,0));
const AString valuename = ((const AString) tolua_tocppstring(tolua_S,3,0));
const int defValue = ((const int) tolua_tonumber(tolua_S,4,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValueSetI'", NULL);
#endif
{
int tolua_ret = (int) self->GetValueSetI(keyname,valuename,defValue);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
tolua_pushcppstring(tolua_S,(const char*)keyname);
tolua_pushcppstring(tolua_S,(const char*)valuename);
}
}
return 3;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'GetValueSetI'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: GetValueSetB of class cIniFile */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_GetValueSetB00
static int tolua_AllToLua_cIniFile_GetValueSetB00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
!tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
!tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
!tolua_isboolean(tolua_S,4,1,&tolua_err) ||
!tolua_isnoobj(tolua_S,5,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
const AString keyname = ((const AString) tolua_tocppstring(tolua_S,2,0));
const AString valuename = ((const AString) tolua_tocppstring(tolua_S,3,0));
const bool defValue = ((const bool) tolua_toboolean(tolua_S,4,false));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetValueSetB'", NULL);
#endif
{
bool tolua_ret = (bool) self->GetValueSetB(keyname,valuename,defValue);
tolua_pushboolean(tolua_S,(bool)tolua_ret);
tolua_pushcppstring(tolua_S,(const char*)keyname);
tolua_pushcppstring(tolua_S,(const char*)valuename);
}
}
return 3;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'GetValueSetB'.",&tolua_err);
return 0;
#endif
}
@ -17286,9 +17480,14 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"GetValue",tolua_AllToLua_cIniFile_GetValue01);
tolua_function(tolua_S,"GetValue",tolua_AllToLua_cIniFile_GetValue02);
tolua_function(tolua_S,"GetValue",tolua_AllToLua_cIniFile_GetValue03);
tolua_function(tolua_S,"GetValueF",tolua_AllToLua_cIniFile_GetValueF00);
tolua_function(tolua_S,"GetValueI",tolua_AllToLua_cIniFile_GetValueI00);
tolua_function(tolua_S,"GetValueB",tolua_AllToLua_cIniFile_GetValueB00);
tolua_function(tolua_S,"GetValueF",tolua_AllToLua_cIniFile_GetValueF00);
tolua_function(tolua_S,"GetValueSet",tolua_AllToLua_cIniFile_GetValueSet00);
tolua_function(tolua_S,"GetValueSet",tolua_AllToLua_cIniFile_GetValueSet01);
tolua_function(tolua_S,"GetValueSetF",tolua_AllToLua_cIniFile_GetValueSetF00);
tolua_function(tolua_S,"GetValueSetI",tolua_AllToLua_cIniFile_GetValueSetI00);
tolua_function(tolua_S,"GetValueSetB",tolua_AllToLua_cIniFile_GetValueSetB00);
tolua_function(tolua_S,"SetValue",tolua_AllToLua_cIniFile_SetValue00);
tolua_function(tolua_S,"SetValue",tolua_AllToLua_cIniFile_SetValue01);
tolua_function(tolua_S,"SetValueI",tolua_AllToLua_cIniFile_SetValueI00);

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 06/09/12 14:48:28.
** Generated automatically by tolua++-1.0.92 on 06/09/12 17:10:20.
*/
/* Exported function */

View File

@ -243,36 +243,27 @@ cWorld::cWorld( const AString & a_WorldName )
AString StorageSchema("Default");
cIniFile IniFile(m_IniFileName);
if (IniFile.ReadFile())
m_SpawnX = IniFile.GetValueF ("SpawnPosition", "X", m_SpawnX);
m_SpawnY = IniFile.GetValueF ("SpawnPosition", "Y", m_SpawnY);
m_SpawnZ = IniFile.GetValueF ("SpawnPosition", "Z", m_SpawnZ);
StorageSchema = IniFile.GetValue ("Storage", "Schema", StorageSchema);
m_MaxCactusHeight = IniFile.GetValueSetI("Plants", "MaxCactusHeight", 3);
m_MaxSugarcaneHeight = IniFile.GetValueSetI("Plants", "MaxSugarcaneHeight", 3);
m_IsCropsBonemealable = IniFile.GetValueSetB("Plants", "IsCropsBonemealable", true);
m_IsGrassBonemealable = IniFile.GetValueSetB("Plants", "IsGrassBonemealable", true);
m_IsSaplingBonemealable = IniFile.GetValueSetB("Plants", "IsSaplingBonemealable", true);
m_IsMelonStemBonemealable = IniFile.GetValueSetB("Plants", "IsMelonStemBonemealable", true);
m_IsMelonBonemealable = IniFile.GetValueSetB("Plants", "IsMelonBonemealable", false);
m_IsPumpkinStemBonemealable = IniFile.GetValueSetB("Plants", "IsPumpkinStemBonemealable", true);
m_IsPumpkinBonemealable = IniFile.GetValueSetB("Plants", "IsPumpkinBonemealable", false);
m_IsSugarcaneBonemealable = IniFile.GetValueSetB("Plants", "IsSugarcaneBonemealable", false);
m_IsCactusBonemealable = IniFile.GetValueSetB("Plants", "IsCactusBonemealable", false);
m_GameMode = (eGameMode)IniFile.GetValueI("GameMode", "GameMode", m_GameMode );
if (!IniFile.WriteFile())
{
m_SpawnX = IniFile.GetValueF("SpawnPosition", "X", m_SpawnX);
m_SpawnY = IniFile.GetValueF("SpawnPosition", "Y", m_SpawnY);
m_SpawnZ = IniFile.GetValueF("SpawnPosition", "Z", m_SpawnZ);
m_GameMode = (eGameMode)IniFile.GetValueI("GameMode", "GameMode", m_GameMode );
StorageSchema = IniFile.GetValue("Storage", "Schema", StorageSchema);
m_MaxCactusHeight = IniFile.GetValueI("Plants", "MaxCactusHeight", 3);
m_MaxSugarcaneHeight = IniFile.GetValueI("Plants", "MaxSugarcaneHeight", 3);
m_IsCropsBonemealable = IniFile.GetValueB("Plants", "IsCropsBonemealable", true);
m_IsGrassBonemealable = IniFile.GetValueB("Plants", "IsGrassBonemealable", true);
m_IsSaplingBonemealable = IniFile.GetValueB("Plants", "IsSaplingBonemealable", true);
m_IsMelonStemBonemealable = IniFile.GetValueB("Plants", "IsMelonStemBonemealable", true);
m_IsMelonBonemealable = IniFile.GetValueB("Plants", "IsMelonBonemealable", false);
m_IsPumpkinStemBonemealable = IniFile.GetValueB("Plants", "IsPumpkinStemBonemealable", true);
m_IsPumpkinBonemealable = IniFile.GetValueB("Plants", "IsPumpkinBonemealable", false);
m_IsSugarcaneBonemealable = IniFile.GetValueB("Plants", "IsSugarcaneBonemealable", false);
m_IsCactusBonemealable = IniFile.GetValueB("Plants", "IsCactusBonemealable", false);
}
else
{
IniFile.SetValueF("SpawnPosition", "X", m_SpawnX );
IniFile.SetValueF("SpawnPosition", "Y", m_SpawnY );
IniFile.SetValueF("SpawnPosition", "Z", m_SpawnZ );
IniFile.SetValueI("GameMode", "GameMode", m_GameMode );
IniFile.SetValue("Storage", "Schema", StorageSchema);
if( !IniFile.WriteFile() )
{
LOG("WARNING: Could not write to %s", m_IniFileName.c_str());
}
LOG("WARNING: Could not write to %s", m_IniFileName.c_str());
}
m_Lighting.Start(this);