From 366f1b3941315641bdcb0ee98465b4d2134eee86 Mon Sep 17 00:00:00 2001 From: Hop311 Date: Fri, 25 Aug 2023 23:25:12 +0100 Subject: Followup big dataloader commit --- src/openvic/GameManager.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/openvic/GameManager.cpp') 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 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) -- cgit v1.2.3-56-ga3b1