From 8447beb4c8f4fb29442ce74f376567a22b5d4cc0 Mon Sep 17 00:00:00 2001 From: MiranDMC Date: Tue, 12 Mar 2024 03:46:45 +0100 Subject: [PATCH] Reduced amount of log entries from FXT files parsing. (#102) --- source/CPluginSystem.h | 2 +- source/CTextManager.cpp | 20 +++++++++++++------- source/CTextManager.h | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/source/CPluginSystem.h b/source/CPluginSystem.h index 58341806..e9fe7fa8 100644 --- a/source/CPluginSystem.h +++ b/source/CPluginSystem.h @@ -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; } diff --git a/source/CTextManager.cpp b/source/CTextManager.cpp index e14cdc02..c43904d4 100644 --- a/source/CTextManager.cpp +++ b/source/CTextManager.cpp @@ -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; } @@ -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();) { @@ -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) { @@ -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; @@ -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; } } diff --git a/source/CTextManager.h b/source/CTextManager.h index bd86cd90..1ec67c1a 100644 --- a/source/CTextManager.h +++ b/source/CTextManager.h @@ -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); };