Skip to content

Commit

Permalink
Fixed handling of INI files in game root directory. (#282)
Browse files Browse the repository at this point in the history
* Fixed handling of INI files in game root directory.

* fixup! Fixed handling of INI files in game root directory.
  • Loading branch information
MiranDMC authored Feb 5, 2025
1 parent bd49199 commit 1811b2d
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions cleo_plugins/IniFiles/IniFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@

using namespace CLEO;

// In case of naked file names without parent path INI file APIs searchs in Windows directory. Add leading ".\" to prevent that.
static void fixIniFilepath(char* buff)
{
if (!std::filesystem::path(buff).has_parent_path())
{
std::string filename = buff;
strcpy(buff, ".\\");
strcat(buff, filename.c_str());
}
}

#define OPCODE_READ_PARAM_FILEPATH_INI(_varName) OPCODE_READ_PARAM_FILEPATH(_varName); fixIniFilepath(_buff_##_varName)


class IniFiles
{
public:
Expand Down Expand Up @@ -35,7 +49,7 @@ class IniFiles
0AF0=4,%4d% = get_int_from_ini_file %1s% section %2s% key %3s%
****************************************************************/
{
OPCODE_READ_PARAM_FILEPATH(path);
OPCODE_READ_PARAM_FILEPATH_INI(path);
OPCODE_READ_PARAM_STRING(section);
OPCODE_READ_PARAM_STRING(key);

Expand Down Expand Up @@ -88,7 +102,7 @@ class IniFiles
****************************************************************/
{
auto value = OPCODE_READ_PARAM_INT();
OPCODE_READ_PARAM_FILEPATH(path);
OPCODE_READ_PARAM_FILEPATH_INI(path);
OPCODE_READ_PARAM_STRING(section);
OPCODE_READ_PARAM_STRING(key);

Expand All @@ -111,7 +125,7 @@ class IniFiles
0AF2=4,%4d% = get_float_from_ini_file %1s% section %2s% key %3s%
****************************************************************/
{
OPCODE_READ_PARAM_FILEPATH(path);
OPCODE_READ_PARAM_FILEPATH_INI(path);
OPCODE_READ_PARAM_STRING(section);
OPCODE_READ_PARAM_STRING(key);

Expand Down Expand Up @@ -153,7 +167,7 @@ class IniFiles
****************************************************************/
{
auto value = OPCODE_READ_PARAM_FLOAT();
OPCODE_READ_PARAM_FILEPATH(path);
OPCODE_READ_PARAM_FILEPATH_INI(path);
OPCODE_READ_PARAM_STRING(section);
OPCODE_READ_PARAM_STRING(key);

Expand All @@ -176,7 +190,7 @@ class IniFiles
0AF4=4,%4d% = read_string_from_ini_file %1s% section %2s% key %3s%
****************************************************************/
{
OPCODE_READ_PARAM_FILEPATH(path);
OPCODE_READ_PARAM_FILEPATH_INI(path);
OPCODE_READ_PARAM_STRING(section);
OPCODE_READ_PARAM_STRING(key);

Expand All @@ -201,7 +215,7 @@ class IniFiles
****************************************************************/
{
OPCODE_READ_PARAM_STRING(strValue);
OPCODE_READ_PARAM_FILEPATH(path);
OPCODE_READ_PARAM_FILEPATH_INI(path);
OPCODE_READ_PARAM_STRING(section);
OPCODE_READ_PARAM_STRING(key);

Expand Down

0 comments on commit 1811b2d

Please sign in to comment.