]> git.localhorst.tv Git - blank.git/blobdiff - src/net/net.cpp
give unique IDs to entities
[blank.git] / src / net / net.cpp
index 852efd3a419f2075ebd4b2878ff17216ce61e36c..4d364124253d9e5d5e5668e77a6ec52ef29eb9b0 100644 (file)
@@ -282,8 +282,7 @@ void Packet::Login::ReadPlayerName(string &name) const noexcept {
 }
 
 void Packet::Join::WritePlayer(const Entity &player) noexcept {
-       // TODO: generate entity IDs
-       Write(uint32_t(1), 0);
+       Write(player.ID(), 0);
        Write(player.ChunkCoords(), 4);
        Write(player.Position(), 16);
        Write(player.Velocity(), 28);
@@ -291,15 +290,17 @@ void Packet::Join::WritePlayer(const Entity &player) noexcept {
        Write(player.AngularVelocity(), 56);
 }
 
+void Packet::Join::ReadPlayerID(uint32_t &id) const noexcept {
+       Read(id, 0);
+}
+
 void Packet::Join::ReadPlayer(Entity &player) const noexcept {
-       uint32_t id = 0;
        glm::ivec3 chunk_coords(0);
        glm::vec3 pos;
        glm::vec3 vel;
        glm::quat rot;
        glm::vec3 ang;
 
-       Read(id, 0);
        Read(chunk_coords, 4);
        Read(pos, 16);
        Read(vel, 28);