aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-11-29 19:44:58 +0200
committerPerttu Ahola <celeron55@gmail.com>2012-11-29 22:08:25 +0200
commit69cdcea9fc30b9522da3f994e77ec54c5c7547af (patch)
tree80da671330c688303fbda6b8ea7c11530e48c356 /src
parent30ec69c7d393f09bc683ef9894da2ddbae15fc6f (diff)
downloadminetest-69cdcea9fc30b9522da3f994e77ec54c5c7547af.tar.gz
minetest-69cdcea9fc30b9522da3f994e77ec54c5c7547af.tar.bz2
minetest-69cdcea9fc30b9522da3f994e77ec54c5c7547af.zip
Modify new ObjectProperties format to such that 0.4.3 will eat it
Diffstat (limited to 'src')
-rw-r--r--src/object_properties.cpp87
1 files changed, 31 insertions, 56 deletions
diff --git a/src/object_properties.cpp b/src/object_properties.cpp
index 3368a5883..ec988a37d 100644
--- a/src/object_properties.cpp
+++ b/src/object_properties.cpp
@@ -74,86 +74,61 @@ std::string ObjectProperties::dump()
void ObjectProperties::serialize(std::ostream &os) const
{
- writeU8(os, 2); // version
+ writeU8(os, 1); // version
writeS16(os, hp_max);
writeU8(os, physical);
writeF1000(os, weight);
writeV3F1000(os, collisionbox.MinEdge);
writeV3F1000(os, collisionbox.MaxEdge);
os<<serializeString(visual);
- os<<serializeString(mesh);
writeV2F1000(os, visual_size);
writeU16(os, textures.size());
for(u32 i=0; i<textures.size(); i++){
os<<serializeString(textures[i]);
}
- writeU16(os, colors.size());
- for(u32 i=0; i<colors.size(); i++){
- writeARGB8(os, colors[i]);
- }
writeV2S16(os, spritediv);
writeV2S16(os, initial_sprite_basepos);
writeU8(os, is_visible);
writeU8(os, makes_footstep_sound);
writeF1000(os, automatic_rotate);
- // Stuff below should be moved to correct place in a version that otherwise changes
- // the protocol version
+ // Added in protocol version 14
+ os<<serializeString(mesh);
+ writeU16(os, colors.size());
+ for(u32 i=0; i<colors.size(); i++){
+ writeARGB8(os, colors[i]);
+ }
+ // Add stuff only at the bottom.
+ // Never remove anything, because we don't want new versions of this
}
void ObjectProperties::deSerialize(std::istream &is)
{
int version = readU8(is);
- if(version == 2) // In PROTOCOL_VERSION 14
- {
- hp_max = readS16(is);
- physical = readU8(is);
- weight = readF1000(is);
- collisionbox.MinEdge = readV3F1000(is);
- collisionbox.MaxEdge = readV3F1000(is);
- visual = deSerializeString(is);
- mesh = deSerializeString(is);
- visual_size = readV2F1000(is);
- textures.clear();
- u32 texture_count = readU16(is);
- for(u32 i=0; i<texture_count; i++){
- textures.push_back(deSerializeString(is));
- }
- u32 color_count = readU16(is);
- for(u32 i=0; i<color_count; i++){
- colors.push_back(readARGB8(is));
- }
- spritediv = readV2S16(is);
- initial_sprite_basepos = readV2S16(is);
- is_visible = readU8(is);
- makes_footstep_sound = readU8(is);
- automatic_rotate = readF1000(is);
- // If you add anything here, insert it primarily inside the try-catch
- // block to not need to increase the version.
- try{
- // Stuff below should be moved to correct place in a version that
- // otherwise changes the protocol version
- }catch(SerializationError &e){}
- }
- else if(version == 1) // In PROTOCOL_VERSION 13
+ if(version == 1)
{
- hp_max = readS16(is);
- physical = readU8(is);
- weight = readF1000(is);
- collisionbox.MinEdge = readV3F1000(is);
- collisionbox.MaxEdge = readV3F1000(is);
- visual = deSerializeString(is);
- visual_size = readV2F1000(is);
- textures.clear();
- u32 texture_count = readU16(is);
- for(u32 i=0; i<texture_count; i++){
- textures.push_back(deSerializeString(is));
- }
- spritediv = readV2S16(is);
- initial_sprite_basepos = readV2S16(is);
- is_visible = readU8(is);
- makes_footstep_sound = readU8(is);
try{
+ hp_max = readS16(is);
+ physical = readU8(is);
+ weight = readF1000(is);
+ collisionbox.MinEdge = readV3F1000(is);
+ collisionbox.MaxEdge = readV3F1000(is);
+ visual = deSerializeString(is);
+ visual_size = readV2F1000(is);
+ textures.clear();
+ u32 texture_count = readU16(is);
+ for(u32 i=0; i<texture_count; i++){
+ textures.push_back(deSerializeString(is));
+ }
+ spritediv = readV2S16(is);
+ initial_sprite_basepos = readV2S16(is);
+ is_visible = readU8(is);
+ makes_footstep_sound = readU8(is);
automatic_rotate = readF1000(is);
+ mesh = deSerializeString(is);
+ u32 color_count = readU16(is);
+ for(u32 i=0; i<color_count; i++){
+ colors.push_back(readARGB8(is));
+ }
}catch(SerializationError &e){}
}
else