From 146c01a9c3bd0046b2d74f21cd5aa163d6cc0fc6 Mon Sep 17 00:00:00 2001 From: Detanup01 <91248446+Detanup01@users.noreply.github.com> Date: Tue, 9 Jan 2024 22:35:55 +0100 Subject: [PATCH] Update settings_parser.cpp adding code from recommended PR --- dll/settings_parser.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/dll/settings_parser.cpp b/dll/settings_parser.cpp index 1a908229..573c913c 100644 --- a/dll/settings_parser.cpp +++ b/dll/settings_parser.cpp @@ -805,7 +805,20 @@ static void parse_mods_folder(class Settings *settings_client, Settings *setting newMod.tagsTruncated = false; newMod.tags = mod.value().value("tags", std::string("")); newMod.primaryFileName = mod.value().value("primary_filename", std::string("")); - newMod.primaryFileSize = mod.value().value("primary_filesize", (int32)1000000); + if(newMod.primaryFileName!=""){ + long begin = 0, end = 0; + const char* name = primaryFileName; + std::fstream file(name); + begin = file.tellg(); + file.seekg(0, std::ios::end); + end = file.tellg(); + file.close(); + newMod.primaryFileSize = mod.value().value("primary_filesize", (end-begin)); + } + else + { + newMod.primaryFileSize = mod.value().value("primary_filesize", (int32)1000000); + } newMod.previewFileName = mod.value().value("preview_filename", std::string("")); newMod.previewFileSize = mod.value().value("preview_filesize", (int32)1000000); newMod.workshopItemURL = mod.value().value("workshop_item_url", std::string(""));