X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fio%2FWorldSave.cpp;h=ce7c71d35ea55c19d85b85b56b0a3f7d8e83db01;hb=e3e598182da7d1639de83f473a55bf6a585b3c61;hp=f45410b8d75b2eb0a2cbb145958584b2402d845c;hpb=a50aa0f2a2fea14f5f8c56209e2ecde3088ef913;p=blank.git diff --git a/src/io/WorldSave.cpp b/src/io/WorldSave.cpp index f45410b..ce7c71d 100644 --- a/src/io/WorldSave.cpp +++ b/src/io/WorldSave.cpp @@ -125,11 +125,15 @@ void WorldSave::Read(Player &player) const { in.ReadIdentifier(name); in.Skip(Token::EQUALS); if (name == "chunk") { - in.ReadVec(state.chunk_pos); + in.ReadVec(state.pos.chunk); } else if (name == "position") { - in.ReadVec(state.block_pos); + in.ReadVec(state.pos.block); } else if (name == "orientation") { in.ReadQuat(state.orient); + } else if (name == "pitch") { + state.pitch = in.GetFloat(); + } else if (name == "yaw") { + state.yaw = in.GetFloat(); } else if (name == "slot") { int slot; in.ReadNumber(slot); @@ -140,6 +144,7 @@ void WorldSave::Read(Player &player) const { } } player.GetEntity().SetState(state); + player.Update(0); } void WorldSave::Write(const Player &player) const { @@ -148,9 +153,11 @@ void WorldSave::Write(const Player &player) const { } const EntityState &state = player.GetEntity().GetState(); ofstream out(PlayerPath(player)); - out << "chunk = " << state.chunk_pos << ';' << endl; - out << "position = " << state.block_pos << ';' << endl; + out << "chunk = " << state.pos.chunk << ';' << endl; + out << "position = " << state.pos.block << ';' << endl; out << "orientation = " << state.orient << ';' << endl; + out << "pitch = " << state.pitch << ';' << endl; + out << "yaw = " << state.yaw << ';' << endl; out << "slot = " << player.GetInventorySlot() << ';' << endl; } @@ -161,7 +168,7 @@ string WorldSave::PlayerPath(const Player &player) const { } -bool WorldSave::Exists(const Chunk::Pos &pos) const noexcept { +bool WorldSave::Exists(const ExactLocation::Coarse &pos) const noexcept { return is_file(ChunkPath(pos)); } @@ -177,7 +184,8 @@ void WorldSave::Read(Chunk &chunk) const { if (gzclose(file) != Z_OK) { throw runtime_error("failed to read chunk file"); } - chunk.InvalidateModel(); + chunk.ScanActive(); + chunk.InvalidateMesh(); chunk.ClearSave(); } @@ -211,7 +219,7 @@ void WorldSave::Write(Chunk &chunk) const { } -const char *WorldSave::ChunkPath(const Chunk::Pos &pos) const { +const char *WorldSave::ChunkPath(const ExactLocation::Coarse &pos) const { snprintf(chunk_buf.get(), chunk_bufsiz, chunk_path.c_str(), pos.x, pos.y, pos.z); return chunk_buf.get(); }