aboutsummaryrefslogtreecommitdiff
path: root/src/shared/net/proto.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/net/proto.cc')
-rw-r--r--src/shared/net/proto.cc64
1 files changed, 29 insertions, 35 deletions
diff --git a/src/shared/net/proto.cc b/src/shared/net/proto.cc
index 1c954b1..6d734a4 100644
--- a/src/shared/net/proto.cc
+++ b/src/shared/net/proto.cc
@@ -3,51 +3,45 @@
namespace shared {
namespace net {
-shared::player get_player(const proto::player& packet) noexcept {
- return shared::player{
- .index = packet.index(),
- .commands = packet.commands(),
- .chunk_pos = {packet.chunk_pos().x(), packet.chunk_pos().z()},
- .local_pos = {packet.local_pos().x(), packet.local_pos().y(),
- packet.local_pos().z()},
- .viewangles = {packet.viewangles().pitch(), packet.viewangles().yaw()},
- .velocity = {packet.velocity().x(), packet.velocity().y(),
- packet.velocity().z()},
- };
-}
-
-void set_angles(proto::angles& proto_angles,
+void set_angles(proto::angles* const proto_angles,
const shared::math::angles& angles) noexcept {
- proto_angles.set_pitch(angles.pitch);
- proto_angles.set_yaw(angles.yaw);
+ proto_angles->set_pitch(angles.pitch);
+ proto_angles->set_yaw(angles.yaw);
}
-void set_coords(proto::coords& proto_coords,
+void set_coords(proto::coords* const proto_coords,
const shared::math::coords& coords) noexcept {
- proto_coords.set_x(coords.x);
- proto_coords.set_z(coords.z);
+ proto_coords->set_x(coords.x);
+ proto_coords->set_z(coords.z);
}
-void set_vec3(proto::vec3& proto_vec3, const glm::vec3& vec3) noexcept {
- proto_vec3.set_x(vec3.x);
- proto_vec3.set_y(vec3.y);
- proto_vec3.set_z(vec3.z);
+void set_vec3(proto::vec3* const proto_vec3, const glm::vec3& vec3) noexcept {
+ proto_vec3->set_x(vec3.x);
+ proto_vec3->set_y(vec3.y);
+ proto_vec3->set_z(vec3.z);
}
-void set_ivec3(proto::ivec3& proto_ivec3, const glm::ivec3& ivec3) noexcept {
- proto_ivec3.set_x(ivec3.x);
- proto_ivec3.set_y(ivec3.y);
- proto_ivec3.set_z(ivec3.z);
+void set_ivec3(proto::ivec3* const proto_ivec3,
+ const glm::ivec3& ivec3) noexcept {
+ proto_ivec3->set_x(ivec3.x);
+ proto_ivec3->set_y(ivec3.y);
+ proto_ivec3->set_z(ivec3.z);
}
-void set_player(proto::player& proto_player,
- const shared::player& player) noexcept {
- proto_player.set_index(player.index);
- proto_player.set_commands(player.commands);
- set_coords(*proto_player.mutable_chunk_pos(), player.chunk_pos);
- set_vec3(*proto_player.mutable_local_pos(), player.local_pos);
- set_angles(*proto_player.mutable_viewangles(), player.viewangles);
- set_vec3(*proto_player.mutable_velocity(), player.velocity);
+shared::math::angles get_angles(const proto::angles& proto) noexcept {
+ return shared::math::angles{proto.pitch(), proto.yaw()};
+}
+
+shared::math::coords get_coords(const proto::coords& proto) noexcept {
+ return shared::math::coords{proto.x(), proto.z()};
+}
+
+glm::vec3 get_vec3(const proto::vec3& proto) noexcept {
+ return glm::vec3{proto.x(), proto.y(), proto.z()};
+}
+
+glm::ivec3 get_ivec3(const proto::ivec3& proto) noexcept {
+ return glm::ivec3{proto.x(), proto.y(), proto.z()};
}
} // namespace net