3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "main.h" // For g_settings
29 #include "nameidmapping.h"
30 #include "util/serialize.h"
38 type = NODEBOX_REGULAR;
41 // default is sign/ladder-like
42 wall_top = aabb3f(-BS/2, BS/2-BS/16., -BS/2, BS/2, BS/2, BS/2);
43 wall_bottom = aabb3f(-BS/2, -BS/2, -BS/2, BS/2, -BS/2+BS/16., BS/2);
44 wall_side = aabb3f(-BS/2, -BS/2, -BS/2, -BS/2+BS/16., BS/2, BS/2);
47 void NodeBox::serialize(std::ostream &os) const
49 writeU8(os, 1); // version
52 if(type == NODEBOX_FIXED)
54 writeU16(os, fixed.size());
55 for(std::vector<aabb3f>::const_iterator
57 i != fixed.end(); i++)
59 writeV3F1000(os, i->MinEdge);
60 writeV3F1000(os, i->MaxEdge);
63 else if(type == NODEBOX_WALLMOUNTED)
65 writeV3F1000(os, wall_top.MinEdge);
66 writeV3F1000(os, wall_top.MaxEdge);
67 writeV3F1000(os, wall_bottom.MinEdge);
68 writeV3F1000(os, wall_bottom.MaxEdge);
69 writeV3F1000(os, wall_side.MinEdge);
70 writeV3F1000(os, wall_side.MaxEdge);
74 void NodeBox::deSerialize(std::istream &is)
76 int version = readU8(is);
78 throw SerializationError("unsupported NodeBox version");
82 type = (enum NodeBoxType)readU8(is);
84 if(type == NODEBOX_FIXED)
86 u16 fixed_count = readU16(is);
90 box.MinEdge = readV3F1000(is);
91 box.MaxEdge = readV3F1000(is);
95 else if(type == NODEBOX_WALLMOUNTED)
97 wall_top.MinEdge = readV3F1000(is);
98 wall_top.MaxEdge = readV3F1000(is);
99 wall_bottom.MinEdge = readV3F1000(is);
100 wall_bottom.MaxEdge = readV3F1000(is);
101 wall_side.MinEdge = readV3F1000(is);
102 wall_side.MaxEdge = readV3F1000(is);
110 void TileDef::serialize(std::ostream &os, u16 protocol_version) const
112 if(protocol_version >= 17)
116 os<<serializeString(name);
117 writeU8(os, animation.type);
118 writeU16(os, animation.aspect_w);
119 writeU16(os, animation.aspect_h);
120 writeF1000(os, animation.length);
121 if(protocol_version >= 17)
122 writeU8(os, backface_culling);
125 void TileDef::deSerialize(std::istream &is)
127 int version = readU8(is);
128 name = deSerializeString(is);
129 animation.type = (TileAnimationType)readU8(is);
130 animation.aspect_w = readU16(is);
131 animation.aspect_h = readU16(is);
132 animation.length = readF1000(is);
134 backface_culling = readU8(is);
138 SimpleSoundSpec serialization
141 static void serializeSimpleSoundSpec(const SimpleSoundSpec &ss,
144 os<<serializeString(ss.name);
145 writeF1000(os, ss.gain);
147 static void deSerializeSimpleSoundSpec(SimpleSoundSpec &ss, std::istream &is)
149 ss.name = deSerializeString(is);
150 ss.gain = readF1000(is);
157 ContentFeatures::ContentFeatures()
162 ContentFeatures::~ContentFeatures()
166 void ContentFeatures::reset()
173 visual_solidness = 0;
174 backface_culling = true;
176 has_on_construct = false;
177 has_on_destruct = false;
178 has_after_destruct = false;
182 NOTE: Most of this is always overridden by the default values given
187 // Unknown nodes can be dug
188 groups["dig_immediate"] = 2;
189 drawtype = NDT_NORMAL;
191 for(u32 i=0; i<6; i++)
192 tiledef[i] = TileDef();
193 for(u16 j=0; j<CF_SPECIAL_COUNT; j++)
194 tiledef_special[j] = TileDef();
196 post_effect_color = video::SColor(0, 0, 0, 0);
197 param_type = CPT_NONE;
198 param_type_2 = CPT2_NONE;
199 is_ground_content = false;
200 light_propagates = false;
201 sunlight_propagates = false;
206 buildable_to = false;
207 rightclickable = true;
208 liquid_type = LIQUID_NONE;
209 liquid_alternative_flowing = "";
210 liquid_alternative_source = "";
211 liquid_viscosity = 0;
212 liquid_renewable = true;
214 damage_per_second = 0;
215 node_box = NodeBox();
216 selection_box = NodeBox();
217 legacy_facedir_simple = false;
218 legacy_wallmounted = false;
219 sound_footstep = SimpleSoundSpec();
220 sound_dig = SimpleSoundSpec("__group");
221 sound_dug = SimpleSoundSpec();
224 void ContentFeatures::serialize(std::ostream &os, u16 protocol_version)
226 if(protocol_version < 14){
227 serializeOld(os, protocol_version);
231 writeU8(os, 6); // version
232 os<<serializeString(name);
233 writeU16(os, groups.size());
234 for(ItemGroupList::const_iterator
235 i = groups.begin(); i != groups.end(); i++){
236 os<<serializeString(i->first);
237 writeS16(os, i->second);
239 writeU8(os, drawtype);
240 writeF1000(os, visual_scale);
242 for(u32 i=0; i<6; i++)
243 tiledef[i].serialize(os, protocol_version);
244 writeU8(os, CF_SPECIAL_COUNT);
245 for(u32 i=0; i<CF_SPECIAL_COUNT; i++){
246 tiledef_special[i].serialize(os, protocol_version);
249 writeU8(os, post_effect_color.getAlpha());
250 writeU8(os, post_effect_color.getRed());
251 writeU8(os, post_effect_color.getGreen());
252 writeU8(os, post_effect_color.getBlue());
253 writeU8(os, param_type);
254 writeU8(os, param_type_2);
255 writeU8(os, is_ground_content);
256 writeU8(os, light_propagates);
257 writeU8(os, sunlight_propagates);
258 writeU8(os, walkable);
259 writeU8(os, pointable);
260 writeU8(os, diggable);
261 writeU8(os, climbable);
262 writeU8(os, buildable_to);
263 os<<serializeString(""); // legacy: used to be metadata_name
264 writeU8(os, liquid_type);
265 os<<serializeString(liquid_alternative_flowing);
266 os<<serializeString(liquid_alternative_source);
267 writeU8(os, liquid_viscosity);
268 writeU8(os, liquid_renewable);
269 writeU8(os, light_source);
270 writeU32(os, damage_per_second);
271 node_box.serialize(os);
272 selection_box.serialize(os);
273 writeU8(os, legacy_facedir_simple);
274 writeU8(os, legacy_wallmounted);
275 serializeSimpleSoundSpec(sound_footstep, os);
276 serializeSimpleSoundSpec(sound_dig, os);
277 serializeSimpleSoundSpec(sound_dug, os);
278 writeU8(os, rightclickable);
279 // Stuff below should be moved to correct place in a version that otherwise changes
280 // the protocol version
283 void ContentFeatures::deSerialize(std::istream &is)
285 int version = readU8(is);
287 deSerializeOld(is, version);
291 name = deSerializeString(is);
293 u32 groups_size = readU16(is);
294 for(u32 i=0; i<groups_size; i++){
295 std::string name = deSerializeString(is);
296 int value = readS16(is);
297 groups[name] = value;
299 drawtype = (enum NodeDrawType)readU8(is);
300 visual_scale = readF1000(is);
302 throw SerializationError("unsupported tile count");
303 for(u32 i=0; i<6; i++)
304 tiledef[i].deSerialize(is);
305 if(readU8(is) != CF_SPECIAL_COUNT)
306 throw SerializationError("unsupported CF_SPECIAL_COUNT");
307 for(u32 i=0; i<CF_SPECIAL_COUNT; i++)
308 tiledef_special[i].deSerialize(is);
310 post_effect_color.setAlpha(readU8(is));
311 post_effect_color.setRed(readU8(is));
312 post_effect_color.setGreen(readU8(is));
313 post_effect_color.setBlue(readU8(is));
314 param_type = (enum ContentParamType)readU8(is);
315 param_type_2 = (enum ContentParamType2)readU8(is);
316 is_ground_content = readU8(is);
317 light_propagates = readU8(is);
318 sunlight_propagates = readU8(is);
319 walkable = readU8(is);
320 pointable = readU8(is);
321 diggable = readU8(is);
322 climbable = readU8(is);
323 buildable_to = readU8(is);
324 deSerializeString(is); // legacy: used to be metadata_name
325 liquid_type = (enum LiquidType)readU8(is);
326 liquid_alternative_flowing = deSerializeString(is);
327 liquid_alternative_source = deSerializeString(is);
328 liquid_viscosity = readU8(is);
329 liquid_renewable = readU8(is);
330 light_source = readU8(is);
331 damage_per_second = readU32(is);
332 node_box.deSerialize(is);
333 selection_box.deSerialize(is);
334 legacy_facedir_simple = readU8(is);
335 legacy_wallmounted = readU8(is);
336 deSerializeSimpleSoundSpec(sound_footstep, is);
337 deSerializeSimpleSoundSpec(sound_dig, is);
338 deSerializeSimpleSoundSpec(sound_dug, is);
339 rightclickable = readU8(is);
340 // If you add anything here, insert it primarily inside the try-catch
341 // block to not need to increase the version.
343 // Stuff below should be moved to correct place in a version that
344 // otherwise changes the protocol version
345 }catch(SerializationError &e) {};
352 class CNodeDefManager: public IWritableNodeDefManager
357 m_name_id_mapping.clear();
358 m_name_id_mapping_with_aliases.clear();
360 for(u16 i=0; i<=MAX_CONTENT; i++)
362 ContentFeatures &f = m_content_features[i];
363 f.reset(); // Reset to defaults
370 f.drawtype = NDT_AIRLIKE;
371 f.param_type = CPT_LIGHT;
372 f.light_propagates = true;
373 f.sunlight_propagates = true;
377 f.buildable_to = true;
378 // Insert directly into containers
379 content_t c = CONTENT_AIR;
380 m_content_features[c] = f;
381 addNameIdMapping(c, f.name);
383 // Set CONTENT_IGNORE
387 f.drawtype = NDT_AIRLIKE;
388 f.param_type = CPT_NONE;
389 f.light_propagates = false;
390 f.sunlight_propagates = false;
394 // A way to remove accidental CONTENT_IGNOREs
395 f.buildable_to = true;
396 // Insert directly into containers
397 content_t c = CONTENT_IGNORE;
398 m_content_features[c] = f;
399 addNameIdMapping(c, f.name);
402 // CONTENT_IGNORE = not found
403 content_t getFreeId()
405 for(u32 i=0; i<=0xffff; i++){
406 const ContentFeatures &f = m_content_features[i];
410 return CONTENT_IGNORE;
416 virtual ~CNodeDefManager()
419 virtual IWritableNodeDefManager* clone()
421 CNodeDefManager *mgr = new CNodeDefManager();
422 for(u16 i=0; i<=MAX_CONTENT; i++)
428 virtual const ContentFeatures& get(content_t c) const
430 assert(c <= MAX_CONTENT);
431 return m_content_features[c];
433 virtual const ContentFeatures& get(const MapNode &n) const
435 return get(n.getContent());
437 virtual bool getId(const std::string &name, content_t &result) const
439 std::map<std::string, content_t>::const_iterator
440 i = m_name_id_mapping_with_aliases.find(name);
441 if(i == m_name_id_mapping_with_aliases.end())
446 virtual content_t getId(const std::string &name) const
448 content_t id = CONTENT_IGNORE;
452 virtual void getIds(const std::string &name, std::set<content_t> &result)
455 if(name.substr(0,6) != "group:"){
456 content_t id = CONTENT_IGNORE;
461 std::string group = name.substr(6);
462 for(u16 id=0; id<=MAX_CONTENT; id++)
464 const ContentFeatures &f = m_content_features[id];
465 if(f.name == "") // Quickly discard undefined nodes
467 if(itemgroup_get(f.groups, group) != 0)
471 virtual const ContentFeatures& get(const std::string &name) const
473 content_t id = CONTENT_IGNORE;
477 // IWritableNodeDefManager
478 virtual void set(content_t c, const ContentFeatures &def)
480 verbosestream<<"registerNode: registering content id \""<<c
481 <<"\": name=\""<<def.name<<"\""<<std::endl;
482 assert(c <= MAX_CONTENT);
483 // Don't allow redefining CONTENT_IGNORE (but allow air)
484 if(def.name == "ignore" || c == CONTENT_IGNORE){
485 infostream<<"registerNode: WARNING: Ignoring "
486 <<"CONTENT_IGNORE redefinition"<<std::endl;
489 // Check that the special contents are not redefined as different id
490 // because it would mess up everything
491 if((def.name == "ignore" && c != CONTENT_IGNORE) ||
492 (def.name == "air" && c != CONTENT_AIR)){
493 errorstream<<"registerNode: IGNORING ERROR: "
494 <<"trying to register built-in type \""
495 <<def.name<<"\" as different id"<<std::endl;
498 m_content_features[c] = def;
500 addNameIdMapping(c, def.name);
502 virtual content_t set(const std::string &name,
503 const ContentFeatures &def)
505 assert(name == def.name);
506 u16 id = CONTENT_IGNORE;
507 bool found = m_name_id_mapping.getId(name, id); // ignore aliases
511 if(id == CONTENT_IGNORE)
512 return CONTENT_IGNORE;
514 addNameIdMapping(id, name);
519 virtual content_t allocateDummy(const std::string &name)
526 virtual void updateAliases(IItemDefManager *idef)
528 std::set<std::string> all = idef->getAll();
529 m_name_id_mapping_with_aliases.clear();
530 for(std::set<std::string>::iterator
531 i = all.begin(); i != all.end(); i++)
533 std::string name = *i;
534 std::string convert_to = idef->getAlias(name);
536 if(m_name_id_mapping.getId(convert_to, id))
538 m_name_id_mapping_with_aliases.insert(
539 std::make_pair(name, id));
543 virtual void updateTextures(ITextureSource *tsrc)
546 infostream<<"CNodeDefManager::updateTextures(): Updating "
547 <<"textures in node definitions"<<std::endl;
549 bool new_style_water = g_settings->getBool("new_style_water");
550 bool new_style_leaves = g_settings->getBool("new_style_leaves");
551 bool opaque_water = g_settings->getBool("opaque_water");
553 for(u16 i=0; i<=MAX_CONTENT; i++)
555 ContentFeatures *f = &m_content_features[i];
557 // Figure out the actual tiles to use
559 for(u32 j=0; j<6; j++)
561 tiledef[j] = f->tiledef[j];
562 if(tiledef[j].name == "")
563 tiledef[j].name = "unknown_block.png";
566 bool is_liquid = false;
576 assert(f->liquid_type == LIQUID_SOURCE);
583 f->backface_culling = false;
587 case NDT_FLOWINGLIQUID:
588 assert(f->liquid_type == LIQUID_FLOWING);
596 f->visual_solidness = 1;
600 f->visual_solidness = 1;
602 case NDT_ALLFACES_OPTIONAL:
603 if(new_style_leaves){
604 f->drawtype = NDT_ALLFACES;
606 f->visual_solidness = 1;
608 f->drawtype = NDT_NORMAL;
610 for(u32 i=0; i<6; i++){
611 tiledef[i].name += std::string("^[noalpha");
617 f->backface_culling = false;
628 u8 material_type = 0;
631 material_type = TILE_MATERIAL_LIQUID_OPAQUE;
633 material_type = TILE_MATERIAL_LIQUID_TRANSPARENT;
635 material_type = TILE_MATERIAL_BASIC;
638 // Tiles (fill in f->tiles[])
639 for(u16 j=0; j<6; j++){
641 f->tiles[j].texture = tsrc->getTexture(tiledef[j].name);
643 f->tiles[j].alpha = f->alpha;
645 f->tiles[j].material_type = material_type;
647 f->tiles[j].material_flags = 0;
648 if(f->backface_culling)
649 f->tiles[j].material_flags |= MATERIAL_FLAG_BACKFACE_CULLING;
650 if(tiledef[j].animation.type == TAT_VERTICAL_FRAMES)
651 f->tiles[j].material_flags |= MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES;
652 // Animation parameters
653 if(f->tiles[j].material_flags &
654 MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES)
656 // Get raw texture size to determine frame count by
658 video::ITexture *t = tsrc->getTextureRaw(tiledef[j].name);
659 v2u32 size = t->getOriginalSize();
660 int frame_height = (float)size.X /
661 (float)tiledef[j].animation.aspect_w *
662 (float)tiledef[j].animation.aspect_h;
663 int frame_count = size.Y / frame_height;
664 int frame_length_ms = 1000.0 *
665 tiledef[j].animation.length / frame_count;
666 f->tiles[j].animation_frame_count = frame_count;
667 f->tiles[j].animation_frame_length_ms = frame_length_ms;
669 // If there are no frames for an animation, switch
670 // animation off (so that having specified an animation
671 // for something but not using it in the texture pack
672 // gives no overhead)
673 if(frame_count == 1){
674 f->tiles[j].material_flags &=
675 ~MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES;
679 // Special tiles (fill in f->special_tiles[])
680 for(u16 j=0; j<CF_SPECIAL_COUNT; j++){
682 f->special_tiles[j].texture =
683 tsrc->getTexture(f->tiledef_special[j].name);
685 f->special_tiles[j].alpha = f->alpha;
687 f->special_tiles[j].material_type = material_type;
689 f->special_tiles[j].material_flags = 0;
690 if(f->tiledef_special[j].backface_culling)
691 f->special_tiles[j].material_flags |= MATERIAL_FLAG_BACKFACE_CULLING;
692 if(f->tiledef_special[j].animation.type == TAT_VERTICAL_FRAMES)
693 f->special_tiles[j].material_flags |= MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES;
694 // Animation parameters
695 if(f->special_tiles[j].material_flags &
696 MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES)
698 // Get raw texture size to determine frame count by
700 video::ITexture *t = tsrc->getTextureRaw(f->tiledef_special[j].name);
701 v2u32 size = t->getOriginalSize();
702 int frame_height = (float)size.X /
703 (float)f->tiledef_special[j].animation.aspect_w *
704 (float)f->tiledef_special[j].animation.aspect_h;
705 int frame_count = size.Y / frame_height;
706 int frame_length_ms = 1000.0 *
707 f->tiledef_special[j].animation.length / frame_count;
708 f->special_tiles[j].animation_frame_count = frame_count;
709 f->special_tiles[j].animation_frame_length_ms = frame_length_ms;
711 // If there are no frames for an animation, switch
712 // animation off (so that having specified an animation
713 // for something but not using it in the texture pack
714 // gives no overhead)
715 if(frame_count == 1){
716 f->special_tiles[j].material_flags &=
717 ~MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES;
724 void serialize(std::ostream &os, u16 protocol_version)
726 writeU8(os, 1); // version
728 std::ostringstream os2(std::ios::binary);
729 for(u16 i=0; i<=MAX_CONTENT; i++)
731 if(i == CONTENT_IGNORE || i == CONTENT_AIR)
733 ContentFeatures *f = &m_content_features[i];
737 // Wrap it in a string to allow different lengths without
738 // strict version incompatibilities
739 std::ostringstream wrapper_os(std::ios::binary);
740 f->serialize(wrapper_os, protocol_version);
741 os2<<serializeString(wrapper_os.str());
745 os<<serializeLongString(os2.str());
747 void deSerialize(std::istream &is)
750 int version = readU8(is);
752 throw SerializationError("unsupported NodeDefinitionManager version");
753 u16 count = readU16(is);
754 std::istringstream is2(deSerializeLongString(is), std::ios::binary);
755 for(u16 n=0; n<count; n++){
756 u16 i = readU16(is2);
758 errorstream<<"ContentFeatures::deSerialize(): "
759 <<"Too large content id: "<<i<<std::endl;
762 /*// Do not deserialize special types
763 if(i == CONTENT_IGNORE || i == CONTENT_AIR)
765 ContentFeatures *f = &m_content_features[i];
766 // Read it from the string wrapper
767 std::string wrapper = deSerializeString(is2);
768 std::istringstream wrapper_is(wrapper, std::ios::binary);
769 f->deSerialize(wrapper_is);
770 verbosestream<<"deserialized "<<f->name<<std::endl;
772 addNameIdMapping(i, f->name);
776 void addNameIdMapping(content_t i, std::string name)
778 m_name_id_mapping.set(i, name);
779 m_name_id_mapping_with_aliases.insert(std::make_pair(name, i));
782 // Features indexed by id
783 ContentFeatures m_content_features[MAX_CONTENT+1];
784 // A mapping for fast converting back and forth between names and ids
785 NameIdMapping m_name_id_mapping;
786 // Like m_name_id_mapping, but only from names to ids, and includes
787 // item aliases too. Updated by updateAliases()
788 // Note: Not serialized.
789 std::map<std::string, content_t> m_name_id_mapping_with_aliases;
792 IWritableNodeDefManager* createNodeDefManager()
794 return new CNodeDefManager();
798 Serialization of old ContentFeatures formats
801 void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version)
803 if(protocol_version == 13)
805 writeU8(os, 5); // version
806 os<<serializeString(name);
807 writeU16(os, groups.size());
808 for(ItemGroupList::const_iterator
809 i = groups.begin(); i != groups.end(); i++){
810 os<<serializeString(i->first);
811 writeS16(os, i->second);
813 writeU8(os, drawtype);
814 writeF1000(os, visual_scale);
816 for(u32 i=0; i<6; i++)
817 tiledef[i].serialize(os, protocol_version);
818 writeU8(os, CF_SPECIAL_COUNT);
819 for(u32 i=0; i<CF_SPECIAL_COUNT; i++){
820 tiledef_special[i].serialize(os, protocol_version);
823 writeU8(os, post_effect_color.getAlpha());
824 writeU8(os, post_effect_color.getRed());
825 writeU8(os, post_effect_color.getGreen());
826 writeU8(os, post_effect_color.getBlue());
827 writeU8(os, param_type);
828 writeU8(os, param_type_2);
829 writeU8(os, is_ground_content);
830 writeU8(os, light_propagates);
831 writeU8(os, sunlight_propagates);
832 writeU8(os, walkable);
833 writeU8(os, pointable);
834 writeU8(os, diggable);
835 writeU8(os, climbable);
836 writeU8(os, buildable_to);
837 os<<serializeString(""); // legacy: used to be metadata_name
838 writeU8(os, liquid_type);
839 os<<serializeString(liquid_alternative_flowing);
840 os<<serializeString(liquid_alternative_source);
841 writeU8(os, liquid_viscosity);
842 writeU8(os, light_source);
843 writeU32(os, damage_per_second);
844 node_box.serialize(os);
845 selection_box.serialize(os);
846 writeU8(os, legacy_facedir_simple);
847 writeU8(os, legacy_wallmounted);
848 serializeSimpleSoundSpec(sound_footstep, os);
849 serializeSimpleSoundSpec(sound_dig, os);
850 serializeSimpleSoundSpec(sound_dug, os);
854 throw SerializationError("ContentFeatures::serialize(): Unsupported version requested");
858 void ContentFeatures::deSerializeOld(std::istream &is, int version)
860 if(version == 5) // In PROTOCOL_VERSION 13
862 name = deSerializeString(is);
864 u32 groups_size = readU16(is);
865 for(u32 i=0; i<groups_size; i++){
866 std::string name = deSerializeString(is);
867 int value = readS16(is);
868 groups[name] = value;
870 drawtype = (enum NodeDrawType)readU8(is);
871 visual_scale = readF1000(is);
873 throw SerializationError("unsupported tile count");
874 for(u32 i=0; i<6; i++)
875 tiledef[i].deSerialize(is);
876 if(readU8(is) != CF_SPECIAL_COUNT)
877 throw SerializationError("unsupported CF_SPECIAL_COUNT");
878 for(u32 i=0; i<CF_SPECIAL_COUNT; i++)
879 tiledef_special[i].deSerialize(is);
881 post_effect_color.setAlpha(readU8(is));
882 post_effect_color.setRed(readU8(is));
883 post_effect_color.setGreen(readU8(is));
884 post_effect_color.setBlue(readU8(is));
885 param_type = (enum ContentParamType)readU8(is);
886 param_type_2 = (enum ContentParamType2)readU8(is);
887 is_ground_content = readU8(is);
888 light_propagates = readU8(is);
889 sunlight_propagates = readU8(is);
890 walkable = readU8(is);
891 pointable = readU8(is);
892 diggable = readU8(is);
893 climbable = readU8(is);
894 buildable_to = readU8(is);
895 deSerializeString(is); // legacy: used to be metadata_name
896 liquid_type = (enum LiquidType)readU8(is);
897 liquid_alternative_flowing = deSerializeString(is);
898 liquid_alternative_source = deSerializeString(is);
899 liquid_viscosity = readU8(is);
900 light_source = readU8(is);
901 damage_per_second = readU32(is);
902 node_box.deSerialize(is);
903 selection_box.deSerialize(is);
904 legacy_facedir_simple = readU8(is);
905 legacy_wallmounted = readU8(is);
906 deSerializeSimpleSoundSpec(sound_footstep, is);
907 deSerializeSimpleSoundSpec(sound_dig, is);
908 deSerializeSimpleSoundSpec(sound_dug, is);
912 throw SerializationError("unsupported ContentFeatures version");