From b1d01bcf26552f7bcd288da4524e689c82f863bd Mon Sep 17 00:00:00 2001 From: Ilia Solovianov Date: Mon, 4 Nov 2024 18:44:51 +0700 Subject: [PATCH 1/2] Fix for unintentional filename conflicts within raw_models in streaming --- src/plugins/gta3/std.stream/data.cpp | 7 ++++++- src/plugins/gta3/std.stream/streaming.cpp | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plugins/gta3/std.stream/data.cpp b/src/plugins/gta3/std.stream/data.cpp index 370dfac..7cfe5ec 100644 --- a/src/plugins/gta3/std.stream/data.cpp +++ b/src/plugins/gta3/std.stream/data.cpp @@ -82,7 +82,12 @@ std::string CAbstractStreaming::TryLoadNonStreamedResource(std::string filepath, if(!this->bHasInitializedStreaming) { - auto it = this->raw_models.find(filename); + auto it = std::find_if(this->raw_models.begin(), this->raw_models.end(), + [&filename](const std::pair& pair) { + auto model_filename = std::string(pair.second->filename()); + return model_filename == filename; + }); + if(it != this->raw_models.end()) { // Log about non streamed resource and make sure it's unique diff --git a/src/plugins/gta3/std.stream/streaming.cpp b/src/plugins/gta3/std.stream/streaming.cpp index eca6602..90ad4f5 100644 --- a/src/plugins/gta3/std.stream/streaming.cpp +++ b/src/plugins/gta3/std.stream/streaming.cpp @@ -202,7 +202,7 @@ bool CAbstractStreaming::InstallFile(const modloader::file& file) // Just push it to this list and it will get loaded when the streaming initializes // At this point we don't know if this is a clothing item or an model, for that reason "raw" // The initializer will take care of filtering clothes and models from the list - this->raw_models[file.filename()] = &file; + this->raw_models[file.filepath()] = &file; return true; } else @@ -242,7 +242,7 @@ bool CAbstractStreaming::UninstallFile(const modloader::file& file) return false; // Streaming hasn't initialized, just remove it from our raw list - raw_models.erase(file.filename()); + raw_models.erase(file.filepath()); return true; } else From 4b348e812b64f203e64de0a594943cd502b1ce53 Mon Sep 17 00:00:00 2001 From: Ilia Solovianov Date: Mon, 4 Nov 2024 19:48:55 +0700 Subject: [PATCH 2/2] Inline comparison in lambda --- src/plugins/gta3/std.stream/data.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plugins/gta3/std.stream/data.cpp b/src/plugins/gta3/std.stream/data.cpp index 7cfe5ec..296240b 100644 --- a/src/plugins/gta3/std.stream/data.cpp +++ b/src/plugins/gta3/std.stream/data.cpp @@ -84,8 +84,7 @@ std::string CAbstractStreaming::TryLoadNonStreamedResource(std::string filepath, { auto it = std::find_if(this->raw_models.begin(), this->raw_models.end(), [&filename](const std::pair& pair) { - auto model_filename = std::string(pair.second->filename()); - return model_filename == filename; + return std::string(pair.second->filename()) == filename; }); if(it != this->raw_models.end())