From 8f3be051469bec81b4d83e91d4c53f577af4c88c Mon Sep 17 00:00:00 2001 From: Fabio Rossini Sluzala Date: Mon, 13 Apr 2026 13:22:40 -0300 Subject: [PATCH 1/5] feat(menu.cpp, loader.hpp, profiles.cpp): introduce priority_limit and use it to clamp priority values, allowing for more flexible configuration --- src/core/extras/gta3/menu.cpp | 2 +- src/core/loader.hpp | 2 ++ src/core/profiles.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/extras/gta3/menu.cpp b/src/core/extras/gta3/menu.cpp index 186ed6c8..7f42be49 100644 --- a/src/core/extras/gta3/menu.cpp +++ b/src/core/extras/gta3/menu.cpp @@ -610,7 +610,7 @@ void TheMenu::ModPageEvents() // Helper function to setup a integer priority entry in the menu auto SetupPriorityEntry = [this](const char* label, uint32_t& priority, std::function cb) -> std::function { - static const uint32_t min = 0, max = 100, step = 1; + static const uint32_t min = 0, max = priority_limit, step = 1; auto PriorityLabel = [](const uint32_t& priority) { diff --git a/src/core/loader.hpp b/src/core/loader.hpp index 2728ad39..8160dd62 100644 --- a/src/core/loader.hpp +++ b/src/core/loader.hpp @@ -34,6 +34,8 @@ static const char* downurl = "https://github.com/thelink2012/modloader/releases" // static const char* default_profile_name = "Default"; +static const int priority_limit = 9999; + // Functor for sorting based on priority template struct SimplePriorityPred diff --git a/src/core/profiles.cpp b/src/core/profiles.cpp index 94915281..dda4b729 100644 --- a/src/core/profiles.cpp +++ b/src/core/profiles.cpp @@ -256,7 +256,7 @@ void Loader::Profile::SetPriority(std::string name, int priority) if(priority == default_priority) mods_priority.erase(name); else - mods_priority[name] = std::max(std::min(priority, 100), 0); // clamp to 0-100 + mods_priority[name] = std::max(std::min(priority, priority_limit), 0); // clamp to 0-priority_limit } /* From 0bf80cff72e3a4e2176fa68af71ee869a1c4a623 Mon Sep 17 00:00:00 2001 From: Fabio Rossini Sluzala Date: Mon, 13 Apr 2026 13:25:03 -0300 Subject: [PATCH 2/5] fix(config.cpp): update priority calculation to use a variable limit instead of hardcoded 100 --- src/core/config.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/config.cpp b/src/core/config.cpp index dd953f38..37d4731b 100644 --- a/src/core/config.cpp +++ b/src/core/config.cpp @@ -242,7 +242,7 @@ void Loader::UpdateOldConfig_0115_021() for(auto& kv : newer["Priority"]) { auto pr = std::stoi(kv.second); - kv.second = std::to_string(pr > 0 && pr <= 100? 101 - pr : pr); + kv.second = std::to_string(pr > 0 && pr <= priority_limit? (priority_limit + 1) - pr : pr); } newer.write_file(gamePath + "modloader/" + folderConfigFilename); From 19c65160ccf11ca33ccaf7841bcbc068652da71b Mon Sep 17 00:00:00 2001 From: Fabio Rossini Sluzala Date: Mon, 13 Apr 2026 13:25:36 -0300 Subject: [PATCH 3/5] feat(translator_stdcall.hpp): include for intrinsic functions support --- src/plugins/gta3/std.asi/args_translator/translator_stdcall.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/gta3/std.asi/args_translator/translator_stdcall.hpp b/src/plugins/gta3/std.asi/args_translator/translator_stdcall.hpp index 5e897635..5a8c384c 100644 --- a/src/plugins/gta3/std.asi/args_translator/translator_stdcall.hpp +++ b/src/plugins/gta3/std.asi/args_translator/translator_stdcall.hpp @@ -9,6 +9,8 @@ #ifndef ARGS_TRANSLATOR_STDCALL_HPP #define ARGS_TRANSLATOR_STDCALL_HPP +#include + #include "translator_basic.hpp" From 888428c505e1667e827771db940b33e0454fefd0 Mon Sep 17 00:00:00 2001 From: Denilson Amorim Date: Sat, 25 Apr 2026 16:42:44 -0300 Subject: [PATCH 4/5] refactor: make priority limit folder-configurable and folder-scoped Keep mod priority bounds in Folder.Config with a default of 100, and store the effective limit in FolderInformation so clamping, menu editing, and config migration use the same folder-level policy. --- doc/config/modloader.ini.0 | 6 ++++-- src/core/config.cpp | 3 ++- src/core/extras/gta3/menu.cpp | 14 +++++++++----- src/core/folder.cpp | 8 ++++++++ src/core/loader.hpp | 6 +++++- src/core/profiles.cpp | 2 +- 6 files changed, 29 insertions(+), 10 deletions(-) diff --git a/doc/config/modloader.ini.0 b/doc/config/modloader.ini.0 index 11fa34f7..ffc06f3a 100644 --- a/doc/config/modloader.ini.0 +++ b/doc/config/modloader.ini.0 @@ -3,6 +3,7 @@ ; [Folder.Config] Profile = Default ; Profile to be used to configure mods +PriorityLimit = 100 ; Max allowed value in Profiles.*.Priority (minimum is 1) [Profiles.Default.Config] IgnoreAllMods = false ; Ignores all mods. This essentially disables mods loading. @@ -10,8 +11,9 @@ ExcludeAllMods = false ; Excludes all mods from being loaded except t [Profiles.Default.Priority] ; Defines mods priority (which mods should go into effect if both replaces the same file) -; The priority should be between 1 and 100, where 100 overrides 1, additionally priority 0 makes be ignored (just like IgnoreMods) -; The default priority is 50! +; The priority should be between 1 and PriorityLimit, where higher values override lower ones. +; Additionally priority 0 makes the mod be ignored (just like IgnoreMods). +; The default priority is 50. ;MyMod=50 [Profiles.Default.IgnoreFiles] diff --git a/src/core/config.cpp b/src/core/config.cpp index 37d4731b..623be4d9 100644 --- a/src/core/config.cpp +++ b/src/core/config.cpp @@ -242,7 +242,8 @@ void Loader::UpdateOldConfig_0115_021() for(auto& kv : newer["Priority"]) { auto pr = std::stoi(kv.second); - kv.second = std::to_string(pr > 0 && pr <= priority_limit? (priority_limit + 1) - pr : pr); + auto limit = this->mods.GetPriorityLimit(); + kv.second = std::to_string(pr > 0 && pr <= limit? (limit + 1) - pr : pr); } newer.write_file(gamePath + "modloader/" + folderConfigFilename); diff --git a/src/core/extras/gta3/menu.cpp b/src/core/extras/gta3/menu.cpp index 7f42be49..ffd07a1f 100644 --- a/src/core/extras/gta3/menu.cpp +++ b/src/core/extras/gta3/menu.cpp @@ -610,7 +610,7 @@ void TheMenu::ModPageEvents() // Helper function to setup a integer priority entry in the menu auto SetupPriorityEntry = [this](const char* label, uint32_t& priority, std::function cb) -> std::function { - static const uint32_t min = 0, max = priority_limit, step = 1; + const uint32_t min = 0, max = loader.mods.GetPriorityLimit(), step = 1; auto PriorityLabel = [](const uint32_t& priority) { @@ -624,10 +624,14 @@ void TheMenu::ModPageEvents() entry->SetHelper(HelpLabel(label)); entry->OnStateChange(cb); - auto fInitStates = entry->SetupStatefulEntry(std::ref(priority), std::ref(PriorityLabel), [](const uint32_t& value, ActionInfo& info) - { - return std::min(std::max((value + step * info.wheel), min), max); - }); + auto fInitStates = entry->SetupStatefulEntry( + std::ref(priority), + std::ref(PriorityLabel), + [min, max, step](const uint32_t& value, ActionInfo& info) + { + return std::min(std::max((value + step * info.wheel), min), max); + } + ); return fInitStates; } diff --git a/src/core/folder.cpp b/src/core/folder.cpp index 7ffe2865..aa194667 100644 --- a/src/core/folder.cpp +++ b/src/core/folder.cpp @@ -16,6 +16,7 @@ void Loader::FolderInformation::Clear() mods.clear(); profiles.clear(); current_profile = nullptr; + priority_limit = default_priority_limit; } /* @@ -374,7 +375,13 @@ void Loader::FolderInformation::LoadConfigFromINI() // First take the profiles from modloader.ini if(ini.load_file(loader.folderConfigFilename)) + { + const auto default_limit = std::to_string(default_priority_limit); + const auto priority_limit = std::strtol(ini.get("Folder.Config", "PriorityLimit", default_limit).c_str(), 0, 0); + this->SetPriorityLimit(priority_limit); + ReadProfilesFromINI(ini, ""); + } else Log("Warning: Failed to load folder config file"); @@ -411,6 +418,7 @@ void Loader::FolderInformation::SaveConfigForINI() // Save current profile ini.set("Folder.Config", "Profile", this->Profile().GetName()); + ini.set("Folder.Config", "PriorityLimit", std::to_string(this->GetPriorityLimit())); // Save all the profiles for(auto& profile : this->profiles) diff --git a/src/core/loader.hpp b/src/core/loader.hpp index 8160dd62..3b377853 100644 --- a/src/core/loader.hpp +++ b/src/core/loader.hpp @@ -34,7 +34,7 @@ static const char* downurl = "https://github.com/thelink2012/modloader/releases" // static const char* default_profile_name = "Default"; -static const int priority_limit = 9999; +static const int default_priority_limit = 100; // Functor for sorting based on priority template @@ -415,6 +415,9 @@ class Loader : public modloader_t // Gets the path to this modfolder (relative to gamedir, normalized) const std::string& GetPath() { return path; } + + int GetPriorityLimit() const { return this->priority_limit; } + void SetPriorityLimit(int value) { this->priority_limit = std::max(value, 1); } // Clears all buffers from this structure void Clear(); @@ -456,6 +459,7 @@ class Loader : public modloader_t Loader::Profile* current_profile;// Curretly selected profile from the 'profiles' list std::unique_ptr anon_profile;// Forced temporary profile (made by command line, conditionals, etc) // The .first boolean specifies whether we have a temporary profile + int priority_limit = default_priority_limit; // Max allowed priority for mods in this folder config protected: void SetUnchanged() { if(status != Status::Removed) status = Status::Unchanged; } diff --git a/src/core/profiles.cpp b/src/core/profiles.cpp index dda4b729..818665cf 100644 --- a/src/core/profiles.cpp +++ b/src/core/profiles.cpp @@ -256,7 +256,7 @@ void Loader::Profile::SetPriority(std::string name, int priority) if(priority == default_priority) mods_priority.erase(name); else - mods_priority[name] = std::max(std::min(priority, priority_limit), 0); // clamp to 0-priority_limit + mods_priority[name] = std::max(std::min(priority, this->parent.GetPriorityLimit()), 0); // clamp to 0-priorityLimit } /* From 23de4fba458dbfc78f64321b348508e4f2e5385a Mon Sep 17 00:00:00 2001 From: Denilson Amorim Date: Sat, 25 Apr 2026 16:48:07 -0300 Subject: [PATCH 5/5] remove intrin.h to rebase against develop branch --- src/plugins/gta3/std.asi/args_translator/translator_stdcall.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/plugins/gta3/std.asi/args_translator/translator_stdcall.hpp b/src/plugins/gta3/std.asi/args_translator/translator_stdcall.hpp index 5a8c384c..5e897635 100644 --- a/src/plugins/gta3/std.asi/args_translator/translator_stdcall.hpp +++ b/src/plugins/gta3/std.asi/args_translator/translator_stdcall.hpp @@ -9,8 +9,6 @@ #ifndef ARGS_TRANSLATOR_STDCALL_HPP #define ARGS_TRANSLATOR_STDCALL_HPP -#include - #include "translator_basic.hpp"