Skip to content

Commit dbbf178

Browse files
committed
Fix branch not compiling
1 parent 32bd7e6 commit dbbf178

4 files changed

Lines changed: 32 additions & 36 deletions

File tree

extension/src/openvic-extension/singletons/MenuSingleton.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ String MenuSingleton::_make_modifier_effect_value_coloured(
8585
}
8686

8787
String MenuSingleton::_make_modifier_effect_tooltip(ModifierEffect const& effect, const fixed_point_t value) const {
88-
return tr(Utilities::std_to_godot_string(effect.get_localisation_key())) + ": " +
88+
return tr(effect.get_localisation_key().data()) + ": " +
8989
_make_modifier_effect_value_coloured(effect, value, true);
9090
}
9191

extension/src/openvic-extension/singletons/MenuSingleton.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <openvic-simulation/types/IndexedFlatMap.hpp>
1212
#include <openvic-simulation/types/OrderedContainers.hpp>
1313
#include <openvic-simulation/modifier/ModifierEffect.hpp>
14-
#include <openvic-simulation/pop/Pop.hpp>
14+
#include <openvic-simulation/population/Pop.hpp>
1515
#include <openvic-simulation/types/UnitBranchType.hpp>
1616
#include "openvic-extension/classes/GFXPieChartTexture.hpp"
1717
#include "openvic-extension/components/budget/BudgetMenu.hpp"
@@ -247,7 +247,7 @@ namespace OpenVic {
247247
/* TECHNOLOGY MENU */
248248
godot::Dictionary get_technology_menu_defines() const;
249249
godot::Dictionary get_technology_menu_info() const;
250-
godot::Dictionary get_specific_technology_info(godot::String technology_identifier) const;
250+
godot::Dictionary get_specific_technology_info(const godot::String& technology_identifier) const;
251251

252252
/* TRADE MENU */
253253
godot::Dictionary get_trade_menu_good_categories_info() const;

extension/src/openvic-extension/singletons/PlayerSingleton.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,16 +261,16 @@ void PlayerSingleton::start_research(String const& technology_identifier) const
261261

262262
Technology const* technology =
263263
game_singleton.get_definition_manager().get_research_manager().get_technology_manager().get_technology_by_identifier(
264-
Utilities::godot_to_std_string(technology_identifier)
264+
technology_identifier.utf8().get_data()
265265
);
266266
ERR_FAIL_NULL(technology);
267267

268268
InstanceManager* instance_manager = game_singleton.get_instance_manager();
269269
ERR_FAIL_NULL(instance_manager);
270270

271-
instance_manager->queue_game_action(
272-
game_action_type_t::GAME_ACTION_START_RESEARCH,
273-
std::pair<uint64_t, uint64_t> { player_country->get_index(), technology->get_index() }
271+
instance_manager->queue_game_action<start_research_argument_t>(
272+
player_country->index,
273+
technology->index
274274
);
275275
}
276276

extension/src/openvic-extension/singletons/TechnologyMenu.cpp

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@ Dictionary MenuSingleton::get_technology_menu_defines() const {
2424

2525
Dictionary ret;
2626

27-
std::vector<OpenVic::TechnologyFolder> const& tech_folders = GameSingleton::get_singleton()->get_definition_manager()
27+
memory::vector<TechnologyFolder> const& tech_folders = GameSingleton::get_singleton()->get_definition_manager()
2828
.get_research_manager().get_technology_manager().get_technology_folders();
2929

3030
PackedStringArray tech_folder_identifiers {};
3131
TypedArray<PackedStringArray> tech_area_identifiers {};
3232
Array tech_identifiers {};
3333
PackedInt32Array folder_tech_count {};
3434
for (TechnologyFolder const& folder : tech_folders) {
35-
tech_folder_identifiers.push_back(Utilities::std_to_godot_string(folder.get_identifier()));
35+
tech_folder_identifiers.push_back(folder.get_identifier().data());
3636
int32_t num_in_folder = 0;
3737

3838
PackedStringArray folder_areas {};
3939
TypedArray<PackedStringArray> tech_folder_nested_array {}; // tech_identifiers has three levels of nested arrays :P
4040
for (TechnologyArea const* area : folder.get_technology_areas()) {
41-
folder_areas.push_back(Utilities::std_to_godot_string(area->get_identifier()));
41+
folder_areas.push_back(area->get_identifier().data());
4242

4343
PackedStringArray area_technologies {};
4444
for (Technology const* tech : area->get_technologies()) {
45-
area_technologies.push_back(Utilities::std_to_godot_string(tech->get_identifier()));
45+
area_technologies.push_back(tech->get_identifier().data());
4646
num_in_folder++;
4747
}
4848
tech_folder_nested_array.push_back(std::move(area_technologies));
@@ -85,17 +85,17 @@ Dictionary MenuSingleton::get_technology_menu_info() const {
8585

8686
Dictionary ret;
8787

88-
CountryInstance const* country = PlayerSingleton::get_singleton()->get_player_country();
88+
CountryInstance* country = PlayerSingleton::get_singleton()->get_player_country();
8989
if (country == nullptr) {
9090
return ret;
9191
}
9292

93-
TechnologySchool const* tech_school = country->get_tech_school();
93+
TechnologySchool const* tech_school = country->get_tech_school().get_untracked();
9494
if (tech_school == nullptr) {
9595
tech_school = tech_manager.get_technology_school_by_index(0);
9696
}
9797
if (tech_school != nullptr) {
98-
ret[tech_school_key] = Utilities::std_to_godot_string(tech_school->get_identifier());
98+
ret[tech_school_key] =tech_school->get_identifier().data();
9999
PackedFloat32Array school_modifier_values;
100100
PackedInt32Array school_modifier_icons;
101101
PackedStringArray school_modifier_tt;
@@ -104,9 +104,9 @@ Dictionary MenuSingleton::get_technology_menu_info() const {
104104
definition_manager.get_modifier_manager().get_modifier_effect_cache().get_research_bonus_effects()
105105
) {
106106
const fixed_point_t research_bonus_value = tech_school->get_effect(*research_bonus_effect);
107-
if (research_bonus_value != fixed_point_t::_0()) {
108-
school_modifier_values.push_back(research_bonus_value.to_float());
109-
school_modifier_icons.push_back(1 + tech_folder.get_index());
107+
if (research_bonus_value != fixed_point_t::_0) {
108+
school_modifier_values.push_back(static_cast<float>(research_bonus_value));
109+
school_modifier_icons.push_back(1 + tech_folder.index.value_);
110110
school_modifier_tt.push_back(_make_modifier_effect_tooltip(*research_bonus_effect, research_bonus_value));
111111
}
112112
}
@@ -119,32 +119,32 @@ Dictionary MenuSingleton::get_technology_menu_info() const {
119119
PackedStringArray researchable_technologies {};
120120
for (Technology const& tech : tech_manager.get_technologies()) {
121121
if (country->is_technology_unlocked(tech)) {
122-
researched_technologies.push_back(Utilities::std_to_godot_string(tech.get_identifier()));
122+
researched_technologies.push_back(tech.get_identifier().data());
123123
}
124124
if (country->can_research_tech(tech, instance_manager->get_today())) {
125-
researchable_technologies.push_back(Utilities::std_to_godot_string(tech.get_identifier()));
125+
researchable_technologies.push_back(tech.get_identifier().data());
126126
}
127127
}
128128
ret[researched_technologies_key] = std::move(researched_technologies);
129129
ret[researchable_technologies_key] = std::move(researchable_technologies);
130130

131-
Technology const* current_research = country->get_current_research();
131+
Technology const* current_research = country->get_current_research().get_untracked();
132132
if (current_research != nullptr) {
133-
ret[current_research_tech_key] = Utilities::std_to_godot_string(current_research->get_identifier());
133+
ret[current_research_tech_key] = current_research->get_identifier().data();
134134
ret[current_research_cat_key] =
135-
tr(Utilities::std_to_godot_string(current_research->get_area().get_folder().get_identifier())) + ", " +
136-
tr(Utilities::std_to_godot_string(current_research->get_area().get_identifier()));
137-
ret[current_research_finish_date_key] = Utilities::date_to_string(country->get_expected_research_completion_date());
138-
ret[current_research_invested_key] = country->get_invested_research_points().to_int32_t();
139-
ret[current_research_cost_key] = country->get_current_research_cost().to_int32_t();
135+
tr(current_research->area.folder.get_identifier().data()) + ", " +
136+
tr(current_research->area.get_identifier().data());
137+
ret[current_research_finish_date_key] = Utilities::date_to_string(country->get_expected_research_completion_date().get_untracked());
138+
ret[current_research_invested_key] = static_cast<int32_t>(country->get_invested_research_points().get_untracked());
139+
ret[current_research_cost_key] = static_cast<int32_t>(country->get_current_research_cost().get_untracked());
140140
ret[current_research_effect_tt_key] = _make_modifier_effects_tooltip(*current_research).trim_prefix("\n");
141-
ret[current_research_progress_key] = country->get_research_progress().to_float();
141+
ret[current_research_progress_key] = static_cast<float>(country->research_progress.get_untracked());
142142
}
143143

144144
return ret;
145145
}
146146

147-
Dictionary MenuSingleton::get_specific_technology_info(String technology_identifier) const {
147+
Dictionary MenuSingleton::get_specific_technology_info(const String& technology_identifier) const {
148148
DefinitionManager const& definition_manager = GameSingleton::get_singleton()->get_definition_manager();
149149

150150
static const StringName effect_tooltip_key = "effects_tooltip";
@@ -156,22 +156,18 @@ Dictionary MenuSingleton::get_specific_technology_info(String technology_identif
156156

157157
Technology const* technology =
158158
definition_manager.get_research_manager().get_technology_manager().get_technology_by_identifier(
159-
Utilities::godot_to_std_string(technology_identifier)
159+
technology_identifier.utf8().get_data()
160160
);
161161
CountryInstance const* player_country = PlayerSingleton::get_singleton()->get_player_country();
162162
if (technology == nullptr || player_country == nullptr) {
163163
return ret;
164164
}
165165

166166
ret[effect_tooltip_key] = _make_modifier_effects_tooltip(*technology).trim_prefix("\n");
167-
ret[research_points_key] = player_country->calculate_research_cost(
168-
*technology, definition_manager.get_modifier_manager().get_modifier_effect_cache()
169-
).to_int32_t();
167+
ret[research_points_key] = static_cast<int32_t>(player_country->calculate_research_cost(*technology));
170168
ret[start_year_key] = technology->get_year();
171-
if (technology->get_index_in_area() > 0) {
172-
ret[prerequisite_key] = Utilities::std_to_godot_string(
173-
technology->get_area().get_technologies()[technology->get_index_in_area() - 1]->get_identifier()
174-
);
169+
if (technology->index_in_area > 0) {
170+
ret[prerequisite_key] = technology->area.get_technologies()[technology->index_in_area - 1]->get_identifier().data();
175171
}
176172

177173
return ret;

0 commit comments

Comments
 (0)