forked from Mirrorlandia_minetest/minetest
Include backface_culling flag in serialization format for TileDefs
This way flowing liquids actually show the backface when specified to do so. Without this, TileDefs where by default initialized with backface_culling = true and never set otherwise. For backwards compatibility, an old client connected to a new server, or a new client connected to an old server will behave like before i.e., backface_culling is always true.
This commit is contained in:
parent
ca7043e52d
commit
dacc8cdb3a
@ -79,9 +79,11 @@ SharedBuffer<u8> makePacket_TOCLIENT_TIME_OF_DAY(u16 time, float time_speed);
|
|||||||
Serialization format changes
|
Serialization format changes
|
||||||
PROTOCOL_VERSION 16:
|
PROTOCOL_VERSION 16:
|
||||||
TOCLIENT_SHOW_FORMSPEC
|
TOCLIENT_SHOW_FORMSPEC
|
||||||
|
PROTOCOL_VERSION 17:
|
||||||
|
Serialization format change: include backface_culling flag in TileDef
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LATEST_PROTOCOL_VERSION 16
|
#define LATEST_PROTOCOL_VERSION 17
|
||||||
|
|
||||||
// Server's supported network protocol range
|
// Server's supported network protocol range
|
||||||
#define SERVER_PROTOCOL_VERSION_MIN 13
|
#define SERVER_PROTOCOL_VERSION_MIN 13
|
||||||
|
@ -107,26 +107,31 @@ void NodeBox::deSerialize(std::istream &is)
|
|||||||
TileDef
|
TileDef
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void TileDef::serialize(std::ostream &os) const
|
void TileDef::serialize(std::ostream &os, u16 protocol_version) const
|
||||||
{
|
{
|
||||||
writeU8(os, 0); // version
|
if(protocol_version >= 17)
|
||||||
|
writeU8(os, 1);
|
||||||
|
else
|
||||||
|
writeU8(os, 0);
|
||||||
os<<serializeString(name);
|
os<<serializeString(name);
|
||||||
writeU8(os, animation.type);
|
writeU8(os, animation.type);
|
||||||
writeU16(os, animation.aspect_w);
|
writeU16(os, animation.aspect_w);
|
||||||
writeU16(os, animation.aspect_h);
|
writeU16(os, animation.aspect_h);
|
||||||
writeF1000(os, animation.length);
|
writeF1000(os, animation.length);
|
||||||
|
if(protocol_version >= 17)
|
||||||
|
writeU8(os, backface_culling);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileDef::deSerialize(std::istream &is)
|
void TileDef::deSerialize(std::istream &is)
|
||||||
{
|
{
|
||||||
int version = readU8(is);
|
int version = readU8(is);
|
||||||
if(version != 0)
|
|
||||||
throw SerializationError("unsupported TileDef version");
|
|
||||||
name = deSerializeString(is);
|
name = deSerializeString(is);
|
||||||
animation.type = (TileAnimationType)readU8(is);
|
animation.type = (TileAnimationType)readU8(is);
|
||||||
animation.aspect_w = readU16(is);
|
animation.aspect_w = readU16(is);
|
||||||
animation.aspect_h = readU16(is);
|
animation.aspect_h = readU16(is);
|
||||||
animation.length = readF1000(is);
|
animation.length = readF1000(is);
|
||||||
|
if(version >= 1)
|
||||||
|
backface_culling = readU8(is);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -235,10 +240,10 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version)
|
|||||||
writeF1000(os, visual_scale);
|
writeF1000(os, visual_scale);
|
||||||
writeU8(os, 6);
|
writeU8(os, 6);
|
||||||
for(u32 i=0; i<6; i++)
|
for(u32 i=0; i<6; i++)
|
||||||
tiledef[i].serialize(os);
|
tiledef[i].serialize(os, protocol_version);
|
||||||
writeU8(os, CF_SPECIAL_COUNT);
|
writeU8(os, CF_SPECIAL_COUNT);
|
||||||
for(u32 i=0; i<CF_SPECIAL_COUNT; i++){
|
for(u32 i=0; i<CF_SPECIAL_COUNT; i++){
|
||||||
tiledef_special[i].serialize(os);
|
tiledef_special[i].serialize(os, protocol_version);
|
||||||
}
|
}
|
||||||
writeU8(os, alpha);
|
writeU8(os, alpha);
|
||||||
writeU8(os, post_effect_color.getAlpha());
|
writeU8(os, post_effect_color.getAlpha());
|
||||||
@ -809,10 +814,10 @@ void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version)
|
|||||||
writeF1000(os, visual_scale);
|
writeF1000(os, visual_scale);
|
||||||
writeU8(os, 6);
|
writeU8(os, 6);
|
||||||
for(u32 i=0; i<6; i++)
|
for(u32 i=0; i<6; i++)
|
||||||
tiledef[i].serialize(os);
|
tiledef[i].serialize(os, protocol_version);
|
||||||
writeU8(os, CF_SPECIAL_COUNT);
|
writeU8(os, CF_SPECIAL_COUNT);
|
||||||
for(u32 i=0; i<CF_SPECIAL_COUNT; i++){
|
for(u32 i=0; i<CF_SPECIAL_COUNT; i++){
|
||||||
tiledef_special[i].serialize(os);
|
tiledef_special[i].serialize(os, protocol_version);
|
||||||
}
|
}
|
||||||
writeU8(os, alpha);
|
writeU8(os, alpha);
|
||||||
writeU8(os, post_effect_color.getAlpha());
|
writeU8(os, post_effect_color.getAlpha());
|
||||||
|
@ -119,7 +119,7 @@ struct TileDef
|
|||||||
animation.length = 1.0;
|
animation.length = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void serialize(std::ostream &os) const;
|
void serialize(std::ostream &os, u16 protocol_version) const;
|
||||||
void deSerialize(std::istream &is);
|
void deSerialize(std::istream &is);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user