diff --git a/GameSettings.h b/GameSettings.h index 496853e4..a358f4ce 100644 --- a/GameSettings.h +++ b/GameSettings.h @@ -93,7 +93,7 @@ typedef struct UINT8 ubSpeechVolume; // Volume Setting //The following are set from the status of the toggle boxes in the Options Screen - UINT8 fOptions[ NUM_ALL_GAME_OPTIONS ]; // Toggle Options (Speech, Subtitles, Show Tree Tops, etc.. ) + BOOLEAN fOptions[ NUM_ALL_GAME_OPTIONS + 1 ]; // Toggle Options (Speech, Subtitles, Show Tree Tops, etc.. ) UINT32 uiMeanwhileScenesSeenFlags; // Bit Vector describing seen 'mean whiles..' (not sure why this is in Game Settings ) diff --git a/Utils/INIReader.cpp b/Utils/INIReader.cpp index 640f7022..07f80887 100644 --- a/Utils/INIReader.cpp +++ b/Utils/INIReader.cpp @@ -27,7 +27,7 @@ CIniReader::CIniReader(const STR8 szFileName) } } -CIniReader::CIniReader(const STR8 szFileName, BOOL Force_Custom_Data_Path) +CIniReader::CIniReader(const STR8 szFileName, BOOLEAN Force_Custom_Data_Path) { // ary-05/05/2009 : force custom data path for potential non existing file -or- force default data path // : Also, flag file detection to allow functions to determine course of action for case of file [not found/is found]. @@ -161,7 +161,7 @@ FLOAT CIniReader::ReadFloat(const STR8 szSection, const STR8 szKey, FLOAT defaul return iniValueReadFromFile; } -BOOL CIniReader::ReadBoolean(const STR8 szSection, const STR8 szKey, BOOL defaultValue) +BOOLEAN CIniReader::ReadBoolean(const STR8 szSection, const STR8 szKey, BOOLEAN defaultValue) { char szResult[255]; char szDefault[255]; @@ -182,12 +182,14 @@ BOOL CIniReader::ReadBoolean(const STR8 szSection, const STR8 szKey, BOOL defaul } -STR8 CIniReader::ReadString(const STR8 szSection, const STR8 szKey, const STR8 szDefaultValue) +// ary-05/15/2009 : snippet on how to use CIniReader::ReadString +// const STR8 test_ini_string = new char[255]; +// memset(test_ini_string, 0x00, 255); +// iniReader.ReadString("JA2 Game Settings" , "TEST_STRING" , "default string" , test_ini_string , 255 ); + +void CIniReader::ReadString(const STR8 szSection, const STR8 szKey, const STR8 szDefaultValue, STR8 input_buffer, size_t buffer_size) { - STR8 szResult = new char[255]; - memset(szResult, 0x00, 255); - GetPrivateProfileString(szSection, szKey, szDefaultValue, szResult, 255, m_szFileName); - return szResult; + GetPrivateProfileString(szSection, szKey, szDefaultValue, input_buffer, buffer_size, m_szFileName); } @@ -237,7 +239,7 @@ UINT32 CIniReader::ReadUINT(const STR8 szSection, const STR8 szKey, UINT32 defau sprintf(szDefault, "%u", defaultValue); - sprintf_s( szResult , (size_t) 255 , "%s", this->ReadString (szSection , szKey , szDefault )); + this->ReadString (szSection , szKey , szDefault, szResult, (size_t) 255 ); iniValueReadFromFile = (UINT32) strtoul(szResult,NULL,0); //AssertGE(iniValueReadFromFile, minValue); diff --git a/Utils/INIReader.h b/Utils/INIReader.h index 34b51091..d2fb372d 100644 --- a/Utils/INIReader.h +++ b/Utils/INIReader.h @@ -21,17 +21,17 @@ class CIniReader { public: CIniReader(const STR8 szFileName); - CIniReader(const STR8 szFileName, BOOL Force_Custom_Data_Path); // force path for nonexisting INI files + CIniReader(const STR8 szFileName, BOOLEAN Force_Custom_Data_Path); // force path for nonexisting INI files // Warning: the following function will be removed int ReadInteger(const STR8 szSection, const STR8 szKey, int iDefaultValue); int ReadInteger(const STR8 szSection, const STR8 szKey, int defaultValue, int minValue, int maxValue); - //UINT32 CIniReader::testReadUINT32(void);//various limit tests of UINT and double/float handling + //void testReadUINT32(void);//various limit tests of UINT and double/float handling //front end functions that control type interpretation and range control, each calls internal ReadUINT - UINT32 CIniReader::ReadUINT32(const STR8 szSection, const STR8 szKey, UINT32 defaultValue, UINT32 minValue, UINT32 maxValue); - UINT16 CIniReader::ReadUINT16(const STR8 szSection, const STR8 szKey, UINT16 defaultValue, UINT16 minValue, UINT16 maxValue); - UINT8 CIniReader::ReadUINT8 (const STR8 szSection, const STR8 szKey, UINT8 defaultValue, UINT8 minValue, UINT8 maxValue); + UINT32 ReadUINT32(const STR8 szSection, const STR8 szKey, UINT32 defaultValue, UINT32 minValue, UINT32 maxValue); + UINT16 ReadUINT16(const STR8 szSection, const STR8 szKey, UINT16 defaultValue, UINT16 minValue, UINT16 maxValue); + UINT8 ReadUINT8 (const STR8 szSection, const STR8 szKey, UINT8 defaultValue, UINT8 minValue, UINT8 maxValue); // Warning: the following function will be removed //double ReadDouble(const STR8 szSection, const STR8 szKey, double fltDefaultValue); @@ -40,17 +40,17 @@ public: DOUBLE ReadDouble(const STR8 szSection, const STR8 szKey, DOUBLE defaultValue, DOUBLE minValue, DOUBLE maxValue); FLOAT ReadFloat (const STR8 szSection, const STR8 szKey, FLOAT defaultValue, FLOAT minValue, FLOAT maxValue); - BOOL ReadBoolean(const STR8 szSection, const STR8 szKey, BOOL bolDefaultValue); + BOOLEAN ReadBoolean(const STR8 szSection, const STR8 szKey, BOOLEAN bolDefaultValue); - STR8 ReadString(const STR8 szSection, const STR8 szKey, const STR8 szDefaultValue); - - BOOL Is_CIniReader_File_Found(void) {return (CIniReader_File_Found);} + void ReadString(const STR8 szSection, const STR8 szKey, const STR8 szDefaultValue, STR8 input_buffer, size_t buffer_size); + + BOOLEAN Is_CIniReader_File_Found(void) {return (CIniReader_File_Found);} private: char m_szFileName[MAX_PATH]; - BOOL CIniReader_File_Found; + BOOLEAN CIniReader_File_Found; - UINT32 CIniReader::ReadUINT(const STR8 szSection, const STR8 szKey, UINT32 defaultValue, UINT32 minValue, UINT32 maxValue); + UINT32 ReadUINT(const STR8 szSection, const STR8 szKey, UINT32 defaultValue, UINT32 minValue, UINT32 maxValue); };