Skip to content

Commit

Permalink
Fix a crash (assert) when client set serial version < 24 in INIT comm…
Browse files Browse the repository at this point in the history
…and SER_FMT_VER_LOWEST is set to zero, then the test is stupid in INIT because all client works. In mapblock we check if client's serialization version is < 24, but if client sent serialization version < 24 (15 for example) the server set it and tried to send nodes, then BOOM
  • Loading branch information
(@U-Exp) authored and Zeno- committed Jan 24, 2015
1 parent f8bd1f3 commit 800d192
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
6 changes: 0 additions & 6 deletions src/mapblock.cpp
Expand Up @@ -526,12 +526,6 @@ void MapBlock::serialize(std::ostream &os, u8 version, bool disk)
throw SerializationError("ERROR: Not writing dummy block.");
}

// Can't do this anymore; we have 16-bit dynamically allocated node IDs
// in memory; conversion just won't work in this direction.
if(version < 24)
throw SerializationError("MapBlock::serialize: serialization to "
"version < 24 not possible");

// First byte
u8 flags = 0;
if(is_underground)
Expand Down
6 changes: 3 additions & 3 deletions src/serialization.h
Expand Up @@ -30,11 +30,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
--------------------------------
For map data (blocks, nodes, sectors).
NOTE: The goal is to increment this so that saved maps will be
loadable by any version. Other compatibility is not
maintained.
0: original networked test with 1-byte nodes
1: update with 2-byte nodes
2: lighting is transmitted in param
Expand Down Expand Up @@ -70,7 +70,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
// Saved on disk version
#define SER_FMT_VER_HIGHEST_WRITE 25
// Lowest supported serialization version
#define SER_FMT_VER_LOWEST 0
#define SER_FMT_VER_LOWEST 24

inline bool ser_ver_supported(s32 v) {
return v >= SER_FMT_VER_LOWEST && v <= SER_FMT_VER_HIGHEST_READ;
Expand Down

2 comments on commit 800d192

@Jeija
Copy link
Contributor

@Jeija Jeija commented on 800d192 Jan 26, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit breaks old maps!
Mintest will crash with:

14:22:57: ERROR[main]: ServerError: World data version mismatch in MapBlock (-26,-3,-2)
14:22:57: ERROR[main]: ----
14:22:57: ERROR[main]: "ERROR: MapBlock format not supported"
14:22:57: ERROR[main]: See debug.txt.
14:22:57: ERROR[main]: World probably saved by a newer version of Minetest.

That is because in mapblock.cpp void MapBlock::deSerialize() makes this check:

if(!ser_ver_supported(version))
    throw VersionMismatchException("ERROR: MapBlock format not supported");

With this commit, the exception will be raised as

inline bool ser_ver_supported(s32 v) {
    return v >= SER_FMT_VER_LOWEST && v <= SER_FMT_VER_HIGHEST_READ;
}

clearly returns true with SER_FMT_VER_LOWEST=24 if the saved world data is older.

I'd say either fix this soon or revert this change, as people's maps won't open anymore and they won't know why.

@Zeno-
Copy link
Contributor

@Zeno- Zeno- commented on 800d192 Jan 26, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jeija commit ca217d0

Progress with commence after next release

Please sign in to comment.