-
Notifications
You must be signed in to change notification settings - Fork 8
Mod Compatibility Fixes #291
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
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.
The changes in this PR do not reflect how Victoria 2 works.
Carefully research Victoria 2 instead of trusting in mods.
Mods often just use things without realising it doesn't work.
@@ -79,6 +79,7 @@ bool ConditionManager::setup_conditions(DefinitionManager const& definition_mana | |||
ret &= add_condition("any_greater_power", GROUP, COUNTRY, COUNTRY); | |||
ret &= add_condition("any_neighbor_country", GROUP, COUNTRY, COUNTRY); | |||
ret &= add_condition("any_owned_province", GROUP, COUNTRY, PROVINCE); | |||
ret &= add_condition("any_owned", GROUP, COUNTRY, PROVINCE); // alias? not in vanilla, but used by HPM poptypes, so used by a ton of derivative mods too |
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.
This is an effect scope. See https://vic2.paradoxwikis.com/List_of_scopes#any_owned
It is easily mistaken for a condition scope.
76f501e
to
e5a01cf
Compare
@@ -120,7 +121,10 @@ using namespace std::string_view_literals; | |||
constexpr bool key_value_success_callback(std::string_view, ast::NodeCPtr) { | |||
return true; | |||
} | |||
|
|||
inline bool key_value_warn_callback(std::string_view key, ast::NodeCPtr) { |
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.
map_key_value_ignore_invalid_callback
was added in a recent PR.
Please use that instead as it lists the valid keys.
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.
The issue with map_key_value_ignore_invalid_callback
for this usecase is it returns false, when the vic2 behaviour is to continue and ignore, hence a warning callback fits better here.
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.
map_key_value_ignore_invalid_callback
is only added in #363 see https://github.com/OpenVicProject/OpenVic-Simulation/pull/363/files#diff-863e89118363d8d3e04ddc1233a97cc3c3fef0851315e8d61847db35e681c07c
Once that is merged, you can use it here. If there is an obstacle to merging, I'll take the nodetools part out and make a separate PR for that.
"rotation", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(rotation)) | ||
"rotation", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(rotation)), | ||
|
||
"maxWidth", ZERO_OR_ONE, [](ast::NodeCPtr node) -> bool { Logger::warning("maxWidth has no effect, so this line will do nothing."); return true; }, /* some mods use these to no effect */ |
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.
Do we need a custom callback for this?
Wouldn't the default map_key_value_invalid_callback
suffice?
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.
Doesn't work in this scenario since we only have a NodeCPtr to pass. Changed to success_callback here to match the rest of GUI.cpp
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.
A success_callback
lies to modders by acting as if these values are parsed. Instead they are invalid and should result in a warning.
My clangd is broken so I can't untangle the nodetools overloads mess.
Still there is a method that uses map_key_value_invalid_callback
as default callback so invalid keys are reported as warnings and valid keys are listed. Use that instead of adding entries for made up keys.
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.
Approved with minor comments.
e5a01cf
to
5b7386e
Compare
5b7386e
to
558e096
Compare
558e096
to
73423c5
Compare
@@ -218,6 +234,7 @@ int main(int argc, char const* argv[]) { | |||
|
|||
char const* program_name = StringUtils::get_filename(argc > 0 ? argv[0] : nullptr, "<program>"); | |||
fs::path root; | |||
std::vector<std::string> mods; |
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::vector<std::string> mods; | |
std::vector<std::string> mods; | |
mods.reserve(argc); |
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.
Technically we could have std::vector<std::string_view>
here, but vector of string_views is not convertible to vector of strings so everything need to support vector of string_views instead.
@@ -159,7 +160,8 @@ bool ProvinceHistoryMap::_load_history_entry( | |||
} | |||
} | |||
return ret; | |||
} | |||
}, | |||
"revolt", ZERO_OR_ONE, [&entry](ast::NodeCPtr node) -> bool { Logger::warning("In province history for ", entry.get_province(), " key \"revolt\" has no effect!"); return true; } |
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.
No need for a custom message. Use either map_key_value_ignore_invalid_callback
or map_key_value_invalid_callback
to handle all such cases.
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.
Avoid custom callbacks for invalid keys. Use the default handling instead.
Either map_key_value_invalid_callback
or map_key_value_ignore_invalid_callback
replace_path
when searching for files