aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/dataloader/NodeTools.cpp
diff options
context:
space:
mode:
author Joel Machens <ajmach6@gmail.com>2023-10-17 04:43:40 +0200
committer Joel Machens <ajmach6@gmail.com>2023-10-25 02:17:45 +0200
commitc9c198e3b47e84eaea998cd9d2f7a8aa2b50ce73 (patch)
treebd5fba638a55c683e587eb5e2bbde43ab5fb1a00 /src/openvic-simulation/dataloader/NodeTools.cpp
parent7bda541557722b2a244e80796c612b735d8b5cf7 (diff)
Country History & Order of Battle Loading
Diffstat (limited to 'src/openvic-simulation/dataloader/NodeTools.cpp')
-rw-r--r--src/openvic-simulation/dataloader/NodeTools.cpp36
1 files changed, 15 insertions, 21 deletions
diff --git a/src/openvic-simulation/dataloader/NodeTools.cpp b/src/openvic-simulation/dataloader/NodeTools.cpp
index c99a2f0..92080c4 100644
--- a/src/openvic-simulation/dataloader/NodeTools.cpp
+++ b/src/openvic-simulation/dataloader/NodeTools.cpp
@@ -123,22 +123,18 @@ node_callback_t NodeTools::expect_colour(callback_t<colour_t> callback) {
return [callback](ast::NodeCPtr node) -> bool {
colour_t col = NULL_COLOUR;
uint32_t components = 0;
- bool ret = expect_list_of_length(3,
- expect_fixed_point(
- [&col, &components](fixed_point_t val) -> bool {
- components++;
- col <<= 8;
- if (val < 0 || val > 255) {
- Logger::error("Invalid colour component: ", val);
- return false;
- } else {
- if (val <= 1) val *= 255;
- col |= val.to_int32_t();
- return true;
- }
- }
- )
- )(node);
+ bool ret = expect_list_of_length(3, expect_fixed_point([&col, &components](fixed_point_t val) -> bool {
+ components++;
+ col <<= 8;
+ if (val < 0 || val > 255) {
+ Logger::error("Invalid colour component: ", val);
+ return false;
+ } else {
+ if (val <= 1) val *= 255;
+ col |= val.to_int32_t();
+ return true;
+ }
+ }))(node);
ret &= callback(col << 8 * (3 - components));
return ret;
};
@@ -218,11 +214,9 @@ node_callback_t NodeTools::expect_list_and_length(length_callback_t length_callb
size = list.size();
ret = false;
}
- std::for_each(list.begin(), list.begin() + size,
- [callback, &ret](ast::NodeUPtr const& sub_node) -> void {
- ret &= callback(sub_node.get());
- }
- );
+ std::for_each(list.begin(), list.begin() + size, [callback, &ret](ast::NodeUPtr const& sub_node) -> void {
+ ret &= callback(sub_node.get());
+ });
return ret;
}
);