diff options
author | BrickPi <49528459+BrickPi@users.noreply.github.com> | 2023-10-25 12:16:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-25 12:16:05 +0200 |
commit | fd1b24dfc6988eaa301645f0f5f2fcd845eb0a29 (patch) | |
tree | bd5fba638a55c683e587eb5e2bbde43ab5fb1a00 /src/openvic-simulation/dataloader/NodeTools.cpp | |
parent | 7bda541557722b2a244e80796c612b735d8b5cf7 (diff) | |
parent | c9c198e3b47e84eaea998cd9d2f7a8aa2b50ce73 (diff) |
Merge pull request #60 from OpenVicProject/country-history-loading
Diffstat (limited to 'src/openvic-simulation/dataloader/NodeTools.cpp')
-rw-r--r-- | src/openvic-simulation/dataloader/NodeTools.cpp | 36 |
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; } ); |