diff --git a/extension/deps/openvic-simulation b/extension/deps/openvic-simulation index c5afc7a5..0a08ff25 160000 --- a/extension/deps/openvic-simulation +++ b/extension/deps/openvic-simulation @@ -1 +1 @@ -Subproject commit c5afc7a5d88b4495463a3c2bf67b790c922aa994 +Subproject commit 0a08ff25f64a6d8d25a861d95f2de96398ded095 diff --git a/extension/src/openvic-extension/singletons/GameSingleton.cpp b/extension/src/openvic-extension/singletons/GameSingleton.cpp index b1b76e9a..73ec4069 100644 --- a/extension/src/openvic-extension/singletons/GameSingleton.cpp +++ b/extension/src/openvic-extension/singletons/GameSingleton.cpp @@ -479,7 +479,7 @@ Error GameSingleton::set_mapmode(int32_t index) { bool GameSingleton::is_parchment_mapmode_allowed() const { /* Disallows parchment mapmode, e.g. for the cosmetic terrain mapmode */ - return mapmode->is_parchment_mapmode_allowed(); + return mapmode->is_parchment_mapmode_allowed; } Error GameSingleton::update_clock() { diff --git a/extension/src/openvic-extension/singletons/MapItemSingleton.cpp b/extension/src/openvic-extension/singletons/MapItemSingleton.cpp index e1b6c781..e53b62d6 100644 --- a/extension/src/openvic-extension/singletons/MapItemSingleton.cpp +++ b/extension/src/openvic-extension/singletons/MapItemSingleton.cpp @@ -320,7 +320,7 @@ int32_t MapItemSingleton::get_clicked_port_province_number(Vector2 click_positio else if(province->is_water()){ // search the adjacent provinces for ones with ports for(ProvinceDefinition::adjacency_t const& adjacency : province->get_adjacencies()) { - ProvinceDefinition const* adjacent_province = adjacency.get_to(); + const type_safe::object_ref adjacent_province = adjacency.get_to(); if(!adjacent_province->has_port()) { continue; // skip provinces without ports (ie. other water provinces) } diff --git a/extension/src/openvic-extension/singletons/MenuSingleton.cpp b/extension/src/openvic-extension/singletons/MenuSingleton.cpp index 10a349da..341cf179 100644 --- a/extension/src/openvic-extension/singletons/MenuSingleton.cpp +++ b/extension/src/openvic-extension/singletons/MenuSingleton.cpp @@ -134,26 +134,19 @@ template String OpenVic::MenuSingleton::_make_modifier_effect_contributions_tool ) const; String MenuSingleton::_make_rules_tooltip(RuleSet const& rules) const { - if (rules.empty()) { - return {}; - } - static const StringName yes_key = "YES"; static const StringName no_key = "NO"; - - static const String start_text = ": " + GUILabel::get_colour_marker(); - static const String end_text = GUILabel::get_colour_marker() + String { "!" }; - - const String enabled_text = start_text + String { "G" } + tr(yes_key) + end_text; - const String disabled_text = start_text + String { "R" } + tr(no_key) + end_text; + static const String line_format = "\n%s: "+GUILabel::get_colour_marker()+"%s%s"+GUILabel::get_colour_marker()+"!"; String result; - - for (auto const& [rule_group, rule_map] : rules.get_rule_groups()) { - for (auto const& [rule, enabled] : rule_map) { - result += "\n" + tr(convert_to(rule->get_localisation_key())) - + (enabled ? enabled_text : disabled_text); - } + for (auto const& [rule_localisation_key, is_enabled] : rules.get_localisation_keys_and_values()) { + const bool is_bad_to_enable = rule_localisation_key == "RULE_SLAVERY_ALLOWED"; + result += Utilities::format( + line_format, + tr(convert_to(rule_localisation_key)), + is_bad_to_enable ? "R" : "G", + tr(is_enabled ? yes_key : no_key) + ); } return result; @@ -565,9 +558,9 @@ Dictionary MenuSingleton::get_province_info_from_number(int32_t province_number) using enum Job::effect_t; - std::optional const& owner_job = production_type.get_owner(); + std::optional const& owner_job = production_type.owner; if (owner_job.has_value()) { - PopType const& owner_pop_type = *owner_job->get_pop_type(); + PopType const& owner_pop_type = *owner_job->pop_type; State const* state = province->get_state(); if (unlikely(state == nullptr)) { @@ -578,14 +571,14 @@ Dictionary MenuSingleton::get_province_info_from_number(int32_t province_number) } else { const fixed_point_t effect_value = state->get_total_population() == 0 ? fixed_point_t::_0 - : owner_job->get_effect_multiplier().mul_div( + : owner_job->effect_multiplier.mul_div( state->get_population_by_type(owner_pop_type), state->get_total_population() ); static const StringName owners_localisation_key = "PRODUCTION_FACTOR_OWNER"; - switch (owner_job->get_effect_type()) { + switch (owner_job->effect_type) { case OUTPUT: output_multiplier += effect_value; output_string += Utilities::format( @@ -631,19 +624,19 @@ Dictionary MenuSingleton::get_province_info_from_number(int32_t province_number) ); for (Job const& job : production_type.get_jobs()) { - if (job.get_pop_type() != &pop_type) { + if (job.pop_type != nullptr && *job.pop_type != pop_type) { continue; } - const fixed_point_t effect_multiplier = job.get_effect_multiplier(); + const fixed_point_t effect_multiplier = job.effect_multiplier; fixed_point_t relative_to_workforce = fixed_point_t::from_fraction(employees_of_type, max_employee_count); const fixed_point_t effect_value = effect_multiplier == fixed_point_t::_1 ? relative_to_workforce - : effect_multiplier * std::min(relative_to_workforce, job.get_amount()); + : effect_multiplier * std::min(relative_to_workforce, job.amount); static const StringName workers_localisation_key = "PRODUCTION_FACTOR_WORKER"; - switch (job.get_effect_type()) { + switch (job.effect_type) { case OUTPUT: output_from_workers += effect_value; output_string += Utilities::format( diff --git a/extension/src/openvic-extension/singletons/ModelSingleton.cpp b/extension/src/openvic-extension/singletons/ModelSingleton.cpp index c0f01f7c..587db428 100644 --- a/extension/src/openvic-extension/singletons/ModelSingleton.cpp +++ b/extension/src/openvic-extension/singletons/ModelSingleton.cpp @@ -305,14 +305,14 @@ bool ModelSingleton::add_unit_dict( // TODO - government type based flag type dict[flag_index_key] = game_singleton->get_flag_sheet_index(country_definition.index, {}); - if (display_unit_type->has_floating_flag()) { + if (display_unit_type->has_floating_flag) { dict[flag_floating_key] = true; } dict[position_key] = game_singleton->normalise_map_position(unit.get_position()->province_definition.get_unit_position()); - if (display_unit_type->get_unit_category() != UnitType::unit_category_t::INFANTRY) { + if (display_unit_type->unit_category != UnitType::unit_category_t::INFANTRY) { dict[rotation_key] = -0.25f * std::numbers::pi_v; } diff --git a/extension/src/openvic-extension/singletons/PlayerSingleton.cpp b/extension/src/openvic-extension/singletons/PlayerSingleton.cpp index 355f6d25..0c39f614 100644 --- a/extension/src/openvic-extension/singletons/PlayerSingleton.cpp +++ b/extension/src/openvic-extension/singletons/PlayerSingleton.cpp @@ -208,14 +208,17 @@ void PlayerSingleton::decrease_speed() const { } // Production -void PlayerSingleton::expand_selected_province_building(int32_t building_index) const { +void PlayerSingleton::expand_selected_province_building(int32_t province_building_index) const { ERR_FAIL_NULL(selected_province); InstanceManager* instance_manager = GameSingleton::get_singleton()->get_instance_manager(); ERR_FAIL_NULL(instance_manager); + ERR_FAIL_NULL(player_country); instance_manager->queue_game_action( - selected_province->index, building_instance_index_t(building_index) + player_country->index, + selected_province->index, + province_building_index_t(province_building_index) ); }