Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduced amount of log entries from FXT files parsing. #102

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/CPluginSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace CLEO
{
if (loaded.find(name) != loaded.end())
{
LOG_WARNING(0, "Plugin `%s` already loaded. Skipping '%s'", fullPath, name);
LOG_WARNING(0, "Plugin `%s` already loaded. Skipping '%s'", name, fullPath);
return;
}

Expand Down
20 changes: 13 additions & 7 deletions source/CTextManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,12 @@ namespace CLEO
std::string str = key;
std::transform(str.begin(), str.end(), str.begin(), ::toupper);
fxts[str.c_str()] = new FxtEntry(value, !dynamic);

TRACE("Added FXT[%s]", str.c_str());
}
return true;
}

bool CTextManager::RemoveFxt(const char *key)
{
TRACE("Deleting FXT[%s]", key);
return fxts.erase(key) != 0;
}

Expand Down Expand Up @@ -174,7 +171,7 @@ namespace CLEO

CTextManager::~CTextManager()
{
TRACE("Deleting fxts...");
TRACE("Deleting FXTs...");
size_t count = 0;
for (auto it = fxts.begin(); it != fxts.end();)
{
Expand All @@ -195,7 +192,8 @@ namespace CLEO
try
{
std::ifstream stream(fullPath);
ParseFxtFile(stream);
auto result = ParseFxtFile(stream);
TRACE("Added %d new FXT entries from file %s", result, fullPath);
}
catch (std::exception& ex)
{
Expand Down Expand Up @@ -229,12 +227,13 @@ namespace CLEO
{
}

void CTextManager::ParseFxtFile(std::istream& stream)
size_t CTextManager::ParseFxtFile(std::istream& stream)
{
static char buf[0x100];
char *key_iterator, *value_iterator, *value_start, *key_start;
stream.exceptions(std::ios::badbit);

size_t addedCount = 0;
while (true)
{
if (stream.eof()) break;
Expand Down Expand Up @@ -264,12 +263,19 @@ namespace CLEO
break;
value_iterator++;
}

// register found fxt entry
AddFxt(key_start, value_start, false);
if (AddFxt(key_start, value_start, false))
{
addedCount++;
}

break;
}
key_iterator++;
}
}

return addedCount;
}
}
2 changes: 1 addition & 1 deletion source/CTextManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace CLEO
const char *LocateFxt(const char *key);
// erase all fxts, added by scripts
void ClearDynamicFxts();
void ParseFxtFile(std::istream& stream);
size_t ParseFxtFile(std::istream& stream);
virtual void Inject(CCodeInjector& inj);
};

Expand Down