Project Alice
Loading...
Searching...
No Matches
recruitment.hpp
Go to the documentation of this file.
1#pragma once
2
3std::vector<uint32_t> recruitment_map_from(sys::state& state) {
4 uint32_t province_size = state.world.province_size();
5 uint32_t texture_size = province_size + 256 - province_size % 256;
6
7 std::vector<uint32_t> prov_color(texture_size * 2);
8
9 state.world.for_each_province([&](dcon::province_id prov_id) {
10 auto fat_id = dcon::fatten(state.world, prov_id);
11 auto nation = fat_id.get_nation_from_province_ownership();
12
13 if(nation == state.local_player_nation) {
14 auto max_regiments = military::regiments_max_possible_from_province(state, prov_id);
15 auto created_regiments = military::regiments_created_from_province(state, prov_id);
16
17 uint32_t color;
18 if(max_regiments == 0) {
19 // grey
20 color = sys::pack_color(155, 156, 149);
21 } else if(created_regiments >= max_regiments) {
22 // yellow
23 color = sys::pack_color(212, 214, 62);
24 } else {
25 // green
26 color = sys::pack_color(53, 196, 53);
27 }
28 auto i = province::to_map_id(prov_id);
29
30 prov_color[i] = color;
31 prov_color[i + texture_size] = color;
32 }
33 });
34
35 return prov_color;
36}
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
int32_t regiments_created_from_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:647
int32_t regiments_max_possible_from_province(sys::state &state, dcon::province_id p)
Definition: military.cpp:709
constexpr uint16_t to_map_id(dcon::province_id id)
Definition: province.hpp:10
uint32_t pack_color(float r, float g, float b)
uint uint32_t
std::vector< uint32_t > recruitment_map_from(sys::state &state)
Definition: recruitment.hpp:3