Skip to content

Commit ce26b33

Browse files
committed
Merge branch 'develop'
2 parents 62870da + 52f284d commit ce26b33

22 files changed

Lines changed: 158 additions & 126 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/msvc-gtasa/
88
/nbproject/
99
/release/
10-
10+
/premake5.exe
1111

1212

1313
#################

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ Still not sure? Check out [this](https://www.youtube.com/watch?v=TvRpQa8dJ7E) ni
1010

1111
Requirements:
1212

13-
+ [Premake 5](http://industriousone.com/premake/download) *(pre-built executable available in this repository root)*
14-
+ [Visual Studio](http://www.visualstudio.com/downloads) 2013 or greater.
13+
+ [Premake 5](https://premake.github.io/download/) *(install with `winget install -e --id Premake.Premake.5.Beta`, or download from the official website)*
14+
+ [Visual Studio](https://www.visualstudio.com/downloads) 2017 or greater.
15+
+ [Windows XP Platform Toolset](https://learn.microsoft.com/en-us/cpp/build/configuring-programs-for-windows-xp) is required; add it from Visual Studio’s Individual Components Installer if needed.
1516

1617
Run the following command in the root of this directory to generate the project files:
1718

18-
premake5 vs2013
19+
premake5 vs2022
1920

2021
You can install the generated binaries into your game directory by running:
2122

2223
premake5 install "C:/Program Files (x86)/Rockstar Games/GTA San Andreas"
2324

24-
Or, you might want the files to be automatically installed everytime you build the solution:
25+
Or, you might want the files to be automatically installed every time you build the solution:
2526

26-
premake5 vs2013 "--idir=C:/Program Files (x86)/Rockstar Games/GTA San Andreas"
27-
27+
premake5 vs2022 "--idir=C:/Program Files (x86)/Rockstar Games/GTA San Andreas"

doc/config/modloader.ini.0

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
;
44
[Folder.Config]
55
Profile = Default ; Profile to be used to configure mods
6+
PriorityLimit = 100 ; Max allowed value in Profiles.*.Priority (minimum is 1)
67

78
[Profiles.Default.Config]
89
IgnoreAllMods = false ; Ignores all mods. This essentially disables mods loading.
910
ExcludeAllMods = false ; Excludes all mods from being loaded except the ones at IncludeMods list
1011

1112
[Profiles.Default.Priority]
1213
; Defines mods priority (which mods should go into effect if both replaces the same file)
13-
; The priority should be between 1 and 100, where 100 overrides 1, additionally priority 0 makes be ignored (just like IgnoreMods)
14-
; The default priority is 50!
14+
; The priority should be between 1 and PriorityLimit, where higher values override lower ones.
15+
; Additionally priority 0 makes the mod be ignored (just like IgnoreMods).
16+
; The default priority is 50.
1517
;MyMod=50
1618

1719
[Profiles.Default.IgnoreFiles]

include/modloader/modloader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ extern "C" {
2929
/* Version */
3030
#define MODLOADER_VERSION_MAJOR 0
3131
#define MODLOADER_VERSION_MINOR 3
32-
#define MODLOADER_VERSION_REVISION 7
32+
#define MODLOADER_VERSION_REVISION 9
3333
#ifdef NDEBUG
34-
#define MODLOADER_VERSION_ISDEV 0
34+
#define MODLOADER_VERSION_ISDEV 1
3535
#else
3636
#define MODLOADER_VERSION_ISDEV 1
3737
#endif

premake5.exe

-928 KB
Binary file not shown.

premake5.lua

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ newaction {
5959
Install Functionality
6060
--]]
6161
install_files = {}
62-
cmd_copyfile = os.is("windows") and { "xcopy", "/f /y /i" } or { "cp", "-v" }
63-
cmd_copydir = os.is("windows") and { "xcopy", "/e /f /y /i" } or { "cp", "-vr" }
62+
cmd_copyfile = os.ishost("windows") and { "xcopy", "/f /y /i" } or { "cp", "-v" }
63+
cmd_copydir = os.ishost("windows") and { "xcopy", "/e /f /y /i" } or { "cp", "-vr" }
6464

6565
-- Gets the install command for the specified file
6666
function installcommand(file, destdir)
@@ -164,11 +164,11 @@ function dummyproject()
164164
flags { "NoPCH" }
165165

166166
-- Dummy cpp file for Premake's generated none project (bug workaround)
167-
configuration "gmake"
167+
filter "action:gmake*"
168168
kind "StaticLib"
169169
files { "src/shared/dummy.cpp" }
170170

171-
configuration {}
171+
filter {}
172172
end
173173

174174
--[[
@@ -184,10 +184,10 @@ solution "modloader"
184184
targetprefix "" -- no 'lib' prefix on gcc
185185
targetdir "bin"
186186
implibdir "bin"
187+
staticruntime "On"
188+
symbols "On" -- Produce symbols whenever possible for logging purposes
187189

188190
flags {
189-
"StaticRuntime",
190-
"Symbols", -- Produce symbols whenever possible for logging purposes
191191
"NoImportLib", -- Mod Loader itself and it's plugins are dlls which exports some funcs but a implib isn't required
192192
--"NoRTTI", (std.data uses it now on handling.cpp)
193193
"NoBufferSecurityCheck"
@@ -214,26 +214,23 @@ solution "modloader"
214214
"src/shared",
215215
}
216216

217-
configuration "Debug*"
218-
flags { "Symbols" }
217+
filter "configurations:Debug*"
218+
symbols "On"
219219

220-
configuration "Release*"
220+
filter "configurations:Release*"
221221
defines { "NDEBUG" }
222222
optimize "Speed"
223223

224-
configuration "gmake"
224+
filter "action:gmake*"
225225
buildoptions { "-std=gnu++14", "-Wno-deprecated" }
226-
configuration "vs*"
226+
227+
-- Visual Studio 2017+ (v141_xp)
228+
filter "action:vs*"
229+
toolset "v141_xp"
227230
buildoptions { "/arch:IA32" } -- disable the use of SSE/SSE2 instructions (old game, old computers)
228231
buildoptions { "/Zm250", "/bigobj" } -- gta3.std.data is a monster
229-
230-
configuration "vs2012"
231-
toolset "v110_xp"
232-
configuration "vs2013"
233-
toolset "v120_xp"
234-
configuration "vs2015"
235-
toolset "v140_xp"
236-
buildoptions { "/Zc:threadSafeInit-" }
232+
buildoptions { "/Zc:threadSafeInit-" } -- threadSafeInit not available in WinXP
233+
filter {}
237234

238235
project "docs"
239236
dummyproject()
@@ -272,8 +269,9 @@ solution "modloader"
272269
project "shared"
273270
dummyproject()
274271
setupfiles "src/shared"
275-
configuration { "gmake" }
272+
filter "action:gmake*"
276273
includedirs { "src/shared/stdinc" } -- gmake compatibility since it'll compile the dummyproject
274+
filter {}
277275

278276

279277
local gta3_plugins = { -- ordered by time taken to compile

src/core/config.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ void Loader::UpdateOldConfig_0115_021()
242242
for(auto& kv : newer["Priority"])
243243
{
244244
auto pr = std::stoi(kv.second);
245-
kv.second = std::to_string(pr > 0 && pr <= 100? 101 - pr : pr);
245+
auto limit = this->mods.GetPriorityLimit();
246+
kv.second = std::to_string(pr > 0 && pr <= limit? (limit + 1) - pr : pr);
246247
}
247248

248249
newer.write_file(gamePath + "modloader/" + folderConfigFilename);

src/core/extras/gta3/menu.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ void TheMenu::ModPageEvents()
610610
// Helper function to setup a integer priority entry in the menu
611611
auto SetupPriorityEntry = [this](const char* label, uint32_t& priority, std::function<void(MenuEntry&)> cb) -> std::function<bool(ActionInfo&)>
612612
{
613-
static const uint32_t min = 0, max = 100, step = 1;
613+
const uint32_t min = 0, max = loader.mods.GetPriorityLimit(), step = 1;
614614

615615
auto PriorityLabel = [](const uint32_t& priority)
616616
{
@@ -624,10 +624,14 @@ void TheMenu::ModPageEvents()
624624
entry->SetHelper(HelpLabel(label));
625625
entry->OnStateChange(cb);
626626

627-
auto fInitStates = entry->SetupStatefulEntry(std::ref(priority), std::ref(PriorityLabel), [](const uint32_t& value, ActionInfo& info)
628-
{
629-
return std::min(std::max((value + step * info.wheel), min), max);
630-
});
627+
auto fInitStates = entry->SetupStatefulEntry(
628+
std::ref(priority),
629+
std::ref(PriorityLabel),
630+
[min, max, step](const uint32_t& value, ActionInfo& info)
631+
{
632+
return std::min(std::max((value + step * info.wheel), min), max);
633+
}
634+
);
631635

632636
return fInitStates;
633637
}

src/core/folder.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ using namespace modloader;
1414
void Loader::FolderInformation::Clear()
1515
{
1616
mods.clear();
17-
profiles.clear();
18-
current_profile = nullptr;
17+
RemoveProfiles();
18+
priority_limit = default_priority_limit;
1919
}
2020

2121
/*
@@ -127,8 +127,9 @@ void Loader::FolderInformation::RemoveReferencesToProfile(Loader::Profile& rm)
127127
*/
128128
void Loader::FolderInformation::RemoveProfiles()
129129
{
130-
for(auto it = this->profiles.begin(); it != this->profiles.end(); )
131-
it = this->profiles.erase(it); // Profile destructor automatically cleans this->current_profile
130+
for(auto& prof : this->profiles)
131+
RemoveReferencesToProfile(prof);
132+
this->profiles.clear();
132133
}
133134

134135
/*
@@ -374,7 +375,13 @@ void Loader::FolderInformation::LoadConfigFromINI()
374375

375376
// First take the profiles from modloader.ini
376377
if(ini.load_file(loader.folderConfigFilename))
378+
{
379+
const auto default_limit = std::to_string(default_priority_limit);
380+
const auto priority_limit = std::strtol(ini.get("Folder.Config", "PriorityLimit", default_limit).c_str(), 0, 0);
381+
this->SetPriorityLimit(priority_limit);
382+
377383
ReadProfilesFromINI(ini, "");
384+
}
378385
else
379386
Log("Warning: Failed to load folder config file");
380387

@@ -411,6 +418,7 @@ void Loader::FolderInformation::SaveConfigForINI()
411418

412419
// Save current profile
413420
ini.set("Folder.Config", "Profile", this->Profile().GetName());
421+
ini.set("Folder.Config", "PriorityLimit", std::to_string(this->GetPriorityLimit()));
414422

415423
// Save all the profiles
416424
for(auto& profile : this->profiles)

src/core/loader.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ static const char* downurl = "https://github.com/thelink2012/modloader/releases"
3434
//
3535
static const char* default_profile_name = "Default";
3636

37+
static const int default_priority_limit = 100;
38+
3739
// Functor for sorting based on priority
3840
template<class T>
3941
struct SimplePriorityPred
@@ -272,7 +274,6 @@ class Loader : public modloader_t
272274
{}
273275

274276
Profile(const Profile&) = default;
275-
~Profile();
276277

277278
//
278279
FolderInformation& Parent() const { return this->parent; }
@@ -413,6 +414,9 @@ class Loader : public modloader_t
413414

414415
// Gets the path to this modfolder (relative to gamedir, normalized)
415416
const std::string& GetPath() { return path; }
417+
418+
int GetPriorityLimit() const { return this->priority_limit; }
419+
void SetPriorityLimit(int value) { this->priority_limit = std::max(value, 1); }
416420

417421
// Clears all buffers from this structure
418422
void Clear();
@@ -454,6 +458,7 @@ class Loader : public modloader_t
454458
Loader::Profile* current_profile;// Curretly selected profile from the 'profiles' list
455459
std::unique_ptr<Loader::Profile> anon_profile;// Forced temporary profile (made by command line, conditionals, etc)
456460
// The .first boolean specifies whether we have a temporary profile
461+
int priority_limit = default_priority_limit; // Max allowed priority for mods in this folder config
457462

458463
protected:
459464
void SetUnchanged() { if(status != Status::Removed) status = Status::Unchanged; }

0 commit comments

Comments
 (0)