New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow game to specify first and last mod in mod loading order. #14177
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Unofficial review, not a core dev.)
Allowing games to do something here makes sense.
I'm not a fan of the repeated
if minetest.global_exists("first_mod") then
table.insert(first_mod.mods,minetest.get_current_modname())
else
error("ERROR: Mod "..minetest.get_current_modname().." loaded before first_mod.")
end
boilerplate in every devtest mod. Could you perhaps test this differently, for example by means of C++ unit tests?
Alternatively we can add some hooks |
It will be complicated I think. Because every mod will have to be loaded twice time. At first time check if there are some hooks registration and the second time register nodes etc. So it will result in breaking backward compatibility, I am afraid. But it will be a more flexible solution to do something like it. |
The problem with this is that it doesn't make much sense: There can't be multiple mods that load first or last. And this has practical implications: Mods that want to load first usually want to do so to, say, override some function. If you have two mods attempting to do this, you can easily get a conflict. |
Thanks for the feedback. Should be testable in C++ unittests. Lua solutions take less effort to create. |
just some a thought, not 100% relating to the keys in game.conf, would it make sense to have them be something like |
Not a problem to change key names. |
Fair enough. I thoughts since games control their mods, they can control the sets of mods that do that. |
I think, that |
Each world has a list of enabled mods. Why not set the order with that list with enabled mods at the top of the list with the user able to change that order to needs? Slightly off-topic: It would be nice to have mod settings in that list as well instead of a just a boolean it could be something like: just use the mod's default or game.conf settings: this world uses this mod in a particular way: |
I am afraid, it will be extremely complicated for the user to determine the correct loading order to satisfy all dependencies in a manually configured loading order list. In addition, this feature works with an enabled mods list. It changes only the logic of ordering that list by dependencies. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should update src/unittest/test_servermodmanager.cpp
to add a test that first_mod and last_mod are in the correct places. If you do this, you could maybe remove all the checks from mods inside devtest
Adding to 5.9.0 as it reduces the impact of #14486 |
b304f62
to
83959b2
Compare
I have compiled Minetest on my MacBook M2 and run Will be nice if somebody checks it also on a MacBook with an Intel CPU. |
@fluxionary why 👎?
I pressed the "run again" button, who knows. But if that doesn't work, you'll have to fix CI either way. |
…ast mod in loading order, defined by the game.
6d7feb1
to
7002f21
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your patience.
*/ | ||
void checkConflictsAndDeps(); | ||
|
||
private: | ||
std::optional<std::string> m_first_mod; | ||
std::optional<std::string> m_last_mod; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw I think it's okay to use an empty string as an implicit null, avoid possible confusion between ""
(often not valid) and std::nullopt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like @appgurueu should answer this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could have left this as it was tbh, both are fine. Though since I already converted some to optionals, it improves consistency to also use optionals here. Strings are just used as mod "IDs" / "names" here. When I see a std::string
in the context of a name / ID, I don't know if an empty string is allowed (a comment could help communicate this, but only by convention), and I can easily forget to handle the empty string properly.
std::optional<std::string>
makes this pretty clear IMO if you know that the std::string
is conceptually a name (and hence not supposed to be empty), though something like std::optional<NonEmptyString>
would be better.
If we were to make this even cleaner, we could do std::optional<ModName>
and using ModName = std::string;
, and if we were to make this completely idiot-proof we could even have ModName
be a type that enforces a valid, non-empty mod name (this would be overkill, though).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::optional<std::string>
makes this pretty clear IMO if you know that thestd::string
is conceptually a name (and hence not supposed to be empty),
I would have interpreted that exactly opposite: someone went to the effort of adding std:optional<>
, so there must be something special about ""
that makes it different from a null value. maybe it's valid too?
8cc3b40
to
3280fba
Compare
Allow games to do something at the beginning and end of the mod loading process.
first_mod
andlast_mod
ingame.conf
to determine which mod has to be loaded first and which has to be loaded last.To do
This PR is Ready for Review.
How to test
Switch to this branch and load the devtest game.
In devtest
game.conf
linesfirst_mod
andlast_mod
are added. There are added checks in every devtest mod and inlast_mod
mod to verify if the loading order is right.