4#include "dcon_generated.hpp"
10 return float(v & 0xFF) / 255.0f;
13 return float((v >> 8) & 0xFF) / 255.0f;
16 return float((v >> 16) & 0xFF) / 255.0f;
19 return ((
uint32_t(r * 255.0f) & 0xFF) << 0) | ((
uint32_t(g * 255.0f) & 0xFF) << 8) | ((
uint32_t(b * 255.0f) & 0xFF) << 16);
23 return int32_t(v & 0xFF);
26 return int32_t((v >> 8) & 0xFF);
29 return int32_t((v >> 16) & 0xFF);
46 auto cmin = std::min(r, std::min(g, b));
47 auto cmax = std::max(r, std::max(g, b));
48 auto delta = cmax - cmin;
53 }
else if(cmax == r) {
54 h = 60.0f * (fmod((g - b) / delta, 6.0f));
55 }
else if(cmax == g) {
56 h = 60.0f * ((b - r) / delta + 2.0f);
58 h = 60.0f * ((r - g) / delta + 4.0f);
63 cmax == 0.0f ? 0.0f : delta / cmax,
70 auto x = c * (1.0f - std::abs(fmod(v.
h / 60.0f, 2.0f) - 1.0f));
72 float r = 0.0f;
float g = 0.0f;
float b = 0.0f;
73 if(0.0f <= v.
h && v.
h < 60.0f) {
74 r = c; g = x; b = 0.0f;
75 }
else if(60.0f <= v.
h && v.
h < 120.0f) {
76 r = x; g = c; b = 0.0f;
77 }
else if(120.0f <= v.
h && v.
h < 180.0f) {
78 r = 0.0f; g = c; b = x;
79 }
else if(180.0f <= v.
h && v.
h < 240.0f) {
80 r = 0.0f; g = x; b = c;
81 }
else if(240.0f <= v.
h && v.
h < 300.0f) {
82 r = x; g = 0.0f; b = c;
84 r = c; g = 0.0f; b = x;
87 std::clamp(r + m, 0.0f, 255.0f),
88 std::clamp(g + m, 0.0f, 255.0f),
89 std::clamp(b + m, 0.0f, 255.0f)
131 int32_t index = m.index();
132 return ankerl::unordered_dense::hash<int32_t>()(index);
138template<
typename value_type,
typename tag_type,
typename allocator = std::allocator<value_type>>
141 std::vector<value_type, allocator> storage;
151 storage.resize(
size);
155 storage = other.storage;
159 storage = std::move(other.storage);
163 assert(
size_t(t.index()) < storage.size());
164 return *(storage.data() + t.index());
167 assert(
size_t(t.index()) < storage.size());
168 return *(storage.data() + t.index());
170 template<
typename... T>
172 storage.emplace_back(std::forward<T>(ts)...);
173 return tag_type(
typename tag_type::value_base_t(storage.size() - 1));
176 if(t.index() >= std::ssize(storage))
177 storage.resize(t.index() + 1);
178 return storage[t.index()];
181 return storage.data();
184 return storage.data();
187 return storage.data();
190 return storage.data();
193 return storage.begin();
196 return storage.end();
199 return storage.begin();
202 return storage.end();
205 return storage.size();
208 return std::ssize(storage);
211 storage.resize(
size);
214 storage.reserve(
size);
220 storage.push_back(v);
221 return tag_type(
typename tag_type::value_base_t(storage.size() - 1));
224 storage.push_back(std::move(v));
225 return tag_type(
typename tag_type::value_base_t(storage.size() - 1));
228 return storage.back();
230 value_type
const&
back()
const {
231 return storage.back();
243static_assert(
sizeof(commodity_set) ==
268 for(
size_t i = 0; i <
key_size; i++)
269 if(
key[i] != a.key[i])
275 return std::string_view{
reinterpret_cast<const char*
>(&
key[0]),
key_size };
281 return reinterpret_cast<const char*
>(&
key[0]);
286template<
size_t _Size>
288 std::array<uint8_t, _Size>
data = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
292 if(
data[i] ==
' ' ||
data[i] ==
'\0') {
293 return std::string_view{
reinterpret_cast<const char*
>(&
data[0]),
uint32_t(i) };
296 return std::string_view{
reinterpret_cast<const char*
>(&
data[0]),
sizeof(
data) };
300 size_t length_to_copy = std::min(sv.size(),
data.size());
301 sv.copy(
reinterpret_cast<char*
>(
data.data()), length_to_copy);
310 return data[0] ==
' ' ||
data[0] ==
'\0';
315 if(
data[i] ==
' ' ||
data[i] ==
'\0') {
324 if(
data[i] ==
' ' ||
data[i] ==
'\0') {
352 return std::memcmp(
this, &o,
sizeof(*
this));
356template<
typename IT,
typename PTR,
typename CMP>
358 auto rng_size = end - first;
361 }
else if(rng_size == 1) {
362 *first = *buffer_start;
364 }
else if(rng_size == 2) {
365 if(cmp(*buffer_start, *(buffer_start + 1))) {
366 *first = *buffer_start;
367 *(first + 1) = *(buffer_start + 1);
369 *first = *(buffer_start + 1);
370 *(first + 1) = *buffer_start;
375 auto half_way = first + rng_size / 2;
376 auto b_half_way = buffer_start + rng_size / 2;
381 auto temp_index = b_half_way;
382 while(temp_index != buffer_end && buffer_start != b_half_way) {
383 if(cmp(*temp_index, *buffer_start)) {
384 *first = *temp_index;
388 *first = *buffer_start;
393 if(temp_index == buffer_end) {
394 std::copy_n(buffer_start, (end - first), first);
395 }
else if(buffer_start == b_half_way) {
396 std::copy_n(temp_index, (end - first), first);
400template<
typename IT,
typename CMP>
402 auto rng_size = end - first;
403 if(rng_size == 0 || rng_size == 1) {
405 }
else if(rng_size == 2) {
406 if(!cmp(*first, *(first + 1))) {
412 using element_type = std::remove_cvref_t<
decltype(*first)>;
413 auto buffer =
new element_type[rng_size];
414 std::copy_n(first, rng_size, buffer);
value_type & operator[](tag_type t)
tagged_vector(tagged_vector< value_type, tag_type, allocator > &&other) noexcept
value_type const & operator[](tag_type t) const
tagged_vector & operator=(tagged_vector< value_type, tag_type, allocator > &&other) noexcept
tagged_vector(tagged_vector< value_type, tag_type, allocator > const &other) noexcept
tagged_vector(size_t size)
tag_type push_back(value_type &&v)
tag_type push_back(value_type const &v)
void reserve(size_t size)
value_type const & back() const
tag_type emplace_back(T &&... ts)
value_type public_value_type
value_type & safe_get(tag_type t)
tagged_vector & operator=(tagged_vector< value_type, tag_type, allocator > const &other) noexcept
#define assert(condition)
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression, cppcoreguidelines-noexcept-swap, performance-noexcept-swap) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
float blue_from_int(uint32_t v)
float green_from_int(uint32_t v)
uint32_t pack_color(float r, float g, float b)
player_value< 24 > player_password_raw
float red_from_int(uint32_t v)
uint32_t hsv_to_rgb(hsv v)
void merge_sort(IT first, IT end, CMP const &cmp) noexcept
int32_t int_red_from_int(uint32_t v)
player_value< 24 > player_password_salt
void merge_sort_interior(IT first, IT end, PTR buffer_start, PTR buffer_end, CMP const &cmp) noexcept
int32_t int_blue_from_int(uint32_t v)
player_value< 24 > player_name
hsv rgb_to_hsv(uint32_t v)
player_value< 64 > player_password_hash
int32_t int_green_from_int(uint32_t v)
float commodity_amounts[set_size]
dcon::commodity_id commodity_type[set_size]
static constexpr uint32_t set_size
float commodity_amounts[set_size]
static constexpr uint32_t set_size
dcon::commodity_id commodity_type[set_size]
std::string_view to_string_view() noexcept
static constexpr uint32_t key_size
bool is_equal(const checksum_key &a) noexcept
std::string to_string() noexcept
const char * to_char() noexcept
dcon::value_modifier_key ai_chance
dcon::nation_id target_nation
dcon::nation_id secondary_nation
dcon::national_identity_id wg_tag
dcon::state_definition_id state
bool operator!=(macro_builder_template &o)
sys::checksum_key scenario_checksum
uint8_t amounts[max_types]
static constexpr uint32_t max_types
auto operator()(dcon::modifier_id m) const noexcept -> uint64_t
player_value< _Size > from_string_view(std::string_view sv) noexcept
std::string to_string() noexcept
void append(char c) noexcept
std::string_view to_string_view() noexcept
std::array< uint8_t, _Size > data
uint16_t first_segment_offset
dcon::trigger_key condition