From 54c32e29e8a4fc974919c00c352f639e06d0d7a0 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 13 Aug 2020 22:28:52 +1000 Subject: [PATCH] Remove dividing .cw spawn by 32 when spawn is outside map backwards compatibility patch This means if your position is outside the map and you save the map, when you load the map, you appear at this position again, instead of the position divided by 32. This was a workaround for ClassicalSharp maps saved before 0.98.6. Considering that was relased on Feb 2016, I think it's an acceptable loss that a few maps from waayyy back then have the wrong spawn when loaded. --- src/Formats.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/Formats.c b/src/Formats.c index bccaec105..19ccf3c9c 100644 --- a/src/Formats.c +++ b/src/Formats.c @@ -684,28 +684,17 @@ static void Cw_Callback(struct NbtTag* tag) { } cc_result Cw_Load(struct Stream* stream) { - cc_uint8 tag; struct Stream compStream; struct InflateState state; - Vec3* spawn; IVec3 pos; cc_result res; + cc_uint8 tag; Inflate_MakeStream2(&compStream, &state, stream); if ((res = Map_SkipGZipHeader(stream))) return res; if ((res = compStream.ReadU8(&compStream, &tag))) return res; if (tag != NBT_DICT) return CW_ERR_ROOT_TAG; - res = Nbt_ReadTag(NBT_DICT, true, &compStream, NULL, Cw_Callback); - if (res) return res; - - /* Older versions incorrectly multiplied spawn coords by * 32, so we check for that */ - spawn = &LocalPlayer_Instance.Spawn; - IVec3_Floor(&pos, spawn); - - if (!World_Contains(pos.X, pos.Y, pos.Z)) { - spawn->X /= 32.0f; spawn->Y /= 32.0f; spawn->Z /= 32.0f; - } - return 0; + return Nbt_ReadTag(NBT_DICT, true, &compStream, NULL, Cw_Callback); }