Skip to content

Commit

Permalink
Merge pull request #122 from fallahn/golf-1.18
Browse files Browse the repository at this point in the history
Golf 1.18.2
  • Loading branch information
fallahn authored Oct 10, 2024
2 parents 52565af + 546e692 commit 0281562
Show file tree
Hide file tree
Showing 69 changed files with 4,640 additions and 519 deletions.
2 changes: 1 addition & 1 deletion crogine.sln
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,6 @@ Global
{64579103-DEC3-41E4-971F-9C0DF996BE8B}.Debug|ARM.ActiveCfg = Debug|Win32
{64579103-DEC3-41E4-971F-9C0DF996BE8B}.Debug|ARM64.ActiveCfg = Debug|Win32
{64579103-DEC3-41E4-971F-9C0DF996BE8B}.Debug|x64.ActiveCfg = Debug|x64
{64579103-DEC3-41E4-971F-9C0DF996BE8B}.Debug|x64.Build.0 = Debug|x64
{64579103-DEC3-41E4-971F-9C0DF996BE8B}.Debug|x86.ActiveCfg = Debug|Win32
{64579103-DEC3-41E4-971F-9C0DF996BE8B}.DebugASan|Any CPU.ActiveCfg = DebugASan|Win32
{64579103-DEC3-41E4-971F-9C0DF996BE8B}.DebugASan|ARM.ActiveCfg = DebugASan|Win32
Expand Down Expand Up @@ -671,6 +670,7 @@ Global
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Debug|ARM.ActiveCfg = Debug|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Debug|ARM64.ActiveCfg = Debug|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Debug|x64.ActiveCfg = Debug|x64
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Debug|x64.Build.0 = Debug|x64
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Debug|x86.ActiveCfg = Debug|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Debug|x86.Build.0 = Debug|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.DebugASan|Any CPU.ActiveCfg = DebugASan|Win32
Expand Down
60 changes: 51 additions & 9 deletions crogine/src/core/ConfigFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,24 @@ bool ConfigObject::loadFromFile(const std::string& filePath, bool relative)

//remove any opening comments
std::string data;
char* temp = nullptr;
std::int64_t readTotal = 0;
static const std::int32_t DEST_SIZE = 256;
static constexpr std::int32_t DEST_SIZE = 1024;// 256;
char dest[DEST_SIZE];
while (data.empty() && readTotal < fileSize)
{
data = std::string(Util::String::rwgets(dest, DEST_SIZE, rr.file, &readTotal));
removeComment(data);
temp = Util::String::rwgets(dest, DEST_SIZE, rr.file, &readTotal);

if (temp)
{
data = std::string(temp);
removeComment(data);
}
else
{
LogE << path << ": unexpected EOF" << std::endl;
return false;
}
}
//check config is not opened with a property
if (isProperty(data))
Expand All @@ -218,8 +229,18 @@ bool ConfigObject::loadFromFile(const std::string& filePath, bool relative)

//make sure next line is a brace to ensure we have an object
std::string lastLine = data;
data = std::string(Util::String::rwgets(dest, DEST_SIZE, rr.file, &readTotal));
removeComment(data);

temp = Util::String::rwgets(dest, DEST_SIZE, rr.file, &readTotal);
if (temp)
{
data = std::string(temp);
removeComment(data);
}
else
{
LogE << path << ": unexpected EOF" << std::endl;
return false;
}

//tracks brace balance
std::vector<ConfigObject*> objStack;
Expand All @@ -242,8 +263,18 @@ bool ConfigObject::loadFromFile(const std::string& filePath, bool relative)

while (readTotal < fileSize)
{
data = std::string(Util::String::rwgets(dest, DEST_SIZE, rr.file, &readTotal));
removeComment(data);
temp = Util::String::rwgets(dest, DEST_SIZE, rr.file, &readTotal);
if (temp)
{
data = std::string(temp);
removeComment(data);
}
else
{
LogE << path << ": unexpected EOF" << std::endl;
return false;
}

if (!data.empty())
{
if (data[0] == '}')
Expand Down Expand Up @@ -274,8 +305,19 @@ bool ConfigObject::loadFromFile(const std::string& filePath, bool relative)
{
//add a new object and make it current
std::string prevLine = data;
data = std::string(Util::String::rwgets(dest, DEST_SIZE, rr.file, &readTotal));
removeComment(data);

temp = Util::String::rwgets(dest, DEST_SIZE, rr.file, &readTotal);
if (temp)
{
data = std::string(temp);
removeComment(data);
}
else
{
LogE << path << ": unexpected EOF" << std::endl;
return false;
}

if (data[0] == '{')
{
//TODO we have to allow mutliple objects with the same name in this instance
Expand Down
Loading

0 comments on commit 0281562

Please sign in to comment.