1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Network: Fix serialization version checks (#15477)

This fixes some incorrect assumptions that the read and write version ranges are identical - whereas they're in fact not.
This commit is contained in:
SmallJoker 2024-11-27 18:39:57 +01:00 committed by GitHub
parent 6c324cb871
commit c175046d30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 46 additions and 49 deletions

View file

@ -307,11 +307,9 @@ static void correctBlockNodeIds(const NameIdMapping *nimap, MapNode *nodes,
void MapBlock::serialize(std::ostream &os_compressed, u8 version, bool disk, int compression_level)
{
if(!ser_ver_supported(version))
if (!ser_ver_supported_write(version))
throw VersionMismatchException("ERROR: MapBlock format not supported");
FATAL_ERROR_IF(version < SER_FMT_VER_LOWEST_WRITE, "Serialization version error");
std::ostringstream os_raw(std::ios_base::binary);
std::ostream &os = version >= 29 ? os_raw : os_compressed;
@ -423,7 +421,7 @@ void MapBlock::serializeNetworkSpecific(std::ostream &os)
void MapBlock::deSerialize(std::istream &in_compressed, u8 version, bool disk)
{
if(!ser_ver_supported(version))
if (!ser_ver_supported_read(version))
throw VersionMismatchException("ERROR: MapBlock format not supported");
TRACESTREAM(<<"MapBlock::deSerialize "<<getPos()<<std::endl);