Skip to content

Commit 608cbae

Browse files
committed
Add HasIndex to ideology
1 parent 3a61a0a commit 608cbae

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/openvic-simulation/politics/Ideology.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ IdeologyGroup::IdeologyGroup(std::string_view new_identifier) : HasIdentifier {
1010

1111
Ideology::Ideology(
1212
std::string_view new_identifier,
13+
index_t new_index,
1314
colour_t new_colour,
1415
IdeologyGroup const& new_group,
1516
bool new_uncivilised,
@@ -23,6 +24,7 @@ Ideology::Ideology(
2324
ConditionalWeightBase&& new_add_military_reform,
2425
ConditionalWeightBase&& new_add_economic_reform
2526
) : HasIdentifierAndColour { new_identifier, new_colour, false },
27+
HasIndex { new_index },
2628
group { new_group },
2729
uncivilised { new_uncivilised },
2830
can_reduce_consciousness { new_can_reduce_consciousness },
@@ -82,8 +84,10 @@ bool IdeologyManager::add_ideology(
8284
return false;
8385
}
8486

87+
const Ideology::index_t new_index = ideologies.size();
8588
return ideologies.add_item({
8689
identifier,
90+
new_index,
8791
colour,
8892
*group,
8993
uncivilised,

src/openvic-simulation/politics/Ideology.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace OpenVic {
1616
IdeologyGroup(IdeologyGroup&&) = default;
1717
};
1818

19-
struct Ideology : HasIdentifierAndColour {
19+
struct Ideology : HasIdentifierAndColour, HasIndex<Ideology> {
2020
friend struct IdeologyManager;
2121

2222
static constexpr colour_t NO_IDEOLOGY_COLOUR = colour_t::fill_as(colour_t::max_value);
@@ -38,6 +38,7 @@ namespace OpenVic {
3838

3939
Ideology(
4040
std::string_view new_identifier,
41+
index_t new_index,
4142
colour_t new_colour,
4243
IdeologyGroup const& new_group,
4344
bool new_uncivilised,

0 commit comments

Comments
 (0)