summaryrefslogtreecommitdiff
path: root/bowshock/source/save/decode_save.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'bowshock/source/save/decode_save.cxx')
-rw-r--r--bowshock/source/save/decode_save.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/bowshock/source/save/decode_save.cxx b/bowshock/source/save/decode_save.cxx
new file mode 100644
index 0000000..1bfe8cd
--- /dev/null
+++ b/bowshock/source/save/decode_save.cxx
@@ -0,0 +1,35 @@
+// Copyright 2022-2023 Gabriel Bjørnager Jensen.
+
+#include <bow/save.hxx>
+
+#include <cstdint>
+#include <cstring>
+
+auto ::bow::decode_save(::bow::save_data& buffer, void const* data_pointer) noexcept -> void {
+ auto data = reinterpret_cast<::std::uint8_t const*>(data_pointer);
+
+ auto const decode_value = [&data]<typename T>(T& buffer) {
+ constexpr ::std::size_t size = sizeof (buffer);
+
+ ::std::memcpy(&buffer, data, size);
+ data += size;
+ };
+
+ decode_value(buffer.format_version);
+ decode_value(buffer.commander_name);
+ decode_value(buffer.time);
+ decode_value(buffer.system_identifier);
+ decode_value(buffer.ship_type);
+ decode_value(buffer.ship_position_x);
+ decode_value(buffer.ship_position_y);
+ decode_value(buffer.ship_position_z);
+ decode_value(buffer.ship_rotation_x);
+ decode_value(buffer.ship_rotation_y);
+ decode_value(buffer.ship_rotation_z);
+ decode_value(buffer.ship_positional_velocity_x);
+ decode_value(buffer.ship_positional_velocity_y);
+ decode_value(buffer.ship_positional_velocity_z);
+ decode_value(buffer.ship_rotational_velocity_x);
+ decode_value(buffer.ship_rotational_velocity_y);
+ decode_value(buffer.ship_rotational_velocity_z);
+}