aboutsummaryrefslogtreecommitdiff
path: root/src/openvic/GameManager.cpp
diff options
context:
space:
mode:
author Hop311 <hop3114@gmail.com>2023-08-26 00:25:12 +0200
committer Hop311 <hop3114@gmail.com>2023-09-03 12:53:52 +0200
commit366f1b3941315641bdcb0ee98465b4d2134eee86 (patch)
treeebb1e95b5e874c6eab09f19a323d721fd1fdac1b /src/openvic/GameManager.cpp
parentefa88c722fcb6c8fea7a86e1b3b8a83f1f59eb31 (diff)
Followup big dataloader commit
Diffstat (limited to 'src/openvic/GameManager.cpp')
-rw-r--r--src/openvic/GameManager.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/openvic/GameManager.cpp b/src/openvic/GameManager.cpp
index b4fa8b5..f9c9664 100644
--- a/src/openvic/GameManager.cpp
+++ b/src/openvic/GameManager.cpp
@@ -103,19 +103,14 @@ return_t GameManager::load_hardcoded_defines() {
return HIGH_ALPHA_VALUE | (fraction_to_colour_byte(province.get_total_population(), map.get_highest_province_population() + 1, 0.1f, 1.0f) << 8);
} },
{ "mapmode_culture",
- // TODO - use std::max_element and maybe change distribution_t to be an ordered std::map
[](Map const& map, Province const& province) -> colour_t {
- distribution_t const& cultures = province.get_culture_distribution();
- if (!cultures.empty()) {
- // This breaks if replaced with distribution_t::value_type, something
- // about operator=(volatile const&) being deleted.
- std::pair<HasIdentifierAndColour const*, float> culture = *cultures.begin();
- for (distribution_t::value_type const p : cultures) {
- if (p.second > culture.second) culture = p;
- }
- return HIGH_ALPHA_VALUE | culture.first->get_colour();
- }
- return NULL_COLOUR;
+ HasIdentifierAndColour const* largest = get_largest_item(province.get_culture_distribution()).first;
+ return largest != nullptr ? HIGH_ALPHA_VALUE | largest->get_colour() : NULL_COLOUR;
+ } },
+ { "mapmode_religion",
+ [](Map const& map, Province const& province) -> colour_t {
+ HasIdentifierAndColour const* largest = get_largest_item(province.get_religion_distribution()).first;
+ return largest != nullptr ? HIGH_ALPHA_VALUE | largest->get_colour() : NULL_COLOUR;
} }
};
for (mapmode_t const& mapmode : mapmodes)