Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Mod Compatibility Fixes #291

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Mod Compatibility Fixes #291

wants to merge 2 commits into from

Conversation

BrickPi
Copy link
Contributor

@BrickPi BrickPi commented Feb 3, 2025

  • Implements a "ModManager" which loads .mod files
  • Implements replace_path when searching for files
  • Myriad changes to better reflect how V2 handles systems
  • HPM now successfully loads and runs under OpenVic

@BrickPi BrickPi added the enhancement New feature or request label Feb 3, 2025
Comment on lines +93 to +99
/// @brief Sets the directories the dataloader should pull content from.
///
/// @param new_roots Dataloader roots in reverse-load order, so base defines first and final loaded mod last
/// @param new_replace_paths All base define paths that should be ignored entirely in favour of mods.
/// @return True if successful, false if failed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doxygen style comments are a bit inconsistent with other forms of documentation, we probably should decide how we'll handle documentation consistently.

Copy link
Contributor

@wvpm wvpm left a 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
Copy link
Contributor

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.

@@ -230,6 +229,12 @@ bool ProductionTypeManager::load_production_types_file(
Logger::error("Failed get template identifier for ", key);
return false;
}
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example/proof?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with PDM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide a minimum working example?
Victoria 2 does nothing special with the name of a production type afaik.

Also, what is the point of having an unused template?
Is it not merely an unused production type?

@BrickPi BrickPi force-pushed the improve-mod-loading branch from 0f5ab25 to 4e23937 Compare March 2, 2025 16:05
@BrickPi BrickPi requested a review from wvpm March 2, 2025 16:11
@@ -263,7 +263,7 @@ bool ModifierManager::setup_modifier_effects() {
modifier_effect_cache.land_attack_modifier, "land_attack_modifier", true, PROPORTION_DECIMAL,
ModifierEffect::make_default_modifier_effect_localisation_key("land_attack")
);
ret &= register_technology_modifier_effect(
ret &= register_shared_tech_country_modifier_effect(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not valid as country modifier. It only works in tech.

@@ -114,7 +116,9 @@ bool Icon::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManag

"frame", ZERO_OR_ONE, expect_uint(assign_variable_callback(frame)),
"scale", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(scale)),
"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, success_callback, /* some mods use this, there's no effect afaik */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's not used, modders should receive a warning that their code does nothing.
Otherwise we pretend to understand it and then discard these values.

if (!entry.ruling_party.has_value()) {
std::string_view def {};
expect_identifier(assign_variable_callback(def))(value);
Logger::warning("In ", country.get_identifier(), " history: ruling_party ", def, " does NOT exist!");
Copy link
Contributor

@wvpm wvpm Mar 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This results in an invalid state that OpenVic can't handle yet.
It's not a minor warning we can just ignore.
We'll either have to add support for a noParty or treat this as a game breaking error.
As a quickfix, we could just pick the first active party, if there is none, we still have a game breaking error.

},
"revolt", ZERO_OR_ONE, expect_dictionary_keys(
"type", ONE_EXACTLY, definition_manager.get_politics_manager().get_rebel_manager().expect_rebel_type_identifier(assign_variable_callback_pointer_opt(entry.revolt)),
"controller", ONE_EXACTLY, success_callback
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything that is ignored should result in a warning.
We don't want to give modders the false impression that we do something with this.

@@ -159,7 +160,11 @@ bool ProvinceHistoryMap::_load_history_entry(
}
}
return ret;
}
},
"revolt", ZERO_OR_ONE, expect_dictionary_keys(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you provide a minimum working example?
I could not replicate it with

revolt = {
	type = liberal_rebels
}

@@ -546,6 +546,10 @@ bool PopManager::load_pop_bases_into_vector(
if (non_integer_size != nullptr && !size.is_integer()) {
*non_integer_size = true;
}
if (culture == nullptr || religion == nullptr) {
Logger::warning("No/invalid culture or relgion defined for pop of size ", size, ", ignored!");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning should contain more information.
At least provide the province containing the pop. Preferably also provide the culture and/or religion text values.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants