Add serialization for node aliases to let client show inventory images correctly
[oweals/minetest.git] / src / nodedef.cpp
1 /*
2 Minetest-c55
3 Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
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 General Public License for more details.
14
15 You should have received a copy of the GNU 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.
18 */
19
20 #include "nodedef.h"
21
22 #include "main.h" // For g_settings
23 #include "nodemetadata.h"
24 #ifndef SERVER
25 #include "tile.h"
26 #endif
27 #include "log.h"
28 #include "settings.h"
29 #include "nameidmapping.h"
30
31 /*
32         NodeBox
33 */
34
35 void NodeBox::serialize(std::ostream &os) const
36 {
37         writeU8(os, 0); // version
38         writeU8(os, type);
39         writeV3F1000(os, fixed.MinEdge);
40         writeV3F1000(os, fixed.MaxEdge);
41         writeV3F1000(os, wall_top.MinEdge);
42         writeV3F1000(os, wall_top.MaxEdge);
43         writeV3F1000(os, wall_bottom.MinEdge);
44         writeV3F1000(os, wall_bottom.MaxEdge);
45         writeV3F1000(os, wall_side.MinEdge);
46         writeV3F1000(os, wall_side.MaxEdge);
47 }
48
49 void NodeBox::deSerialize(std::istream &is)
50 {
51         int version = readU8(is);
52         if(version != 0)
53                 throw SerializationError("unsupported NodeBox version");
54         type = (enum NodeBoxType)readU8(is);
55         fixed.MinEdge = readV3F1000(is);
56         fixed.MaxEdge = readV3F1000(is);
57         wall_top.MinEdge = readV3F1000(is);
58         wall_top.MaxEdge = readV3F1000(is);
59         wall_bottom.MinEdge = readV3F1000(is);
60         wall_bottom.MaxEdge = readV3F1000(is);
61         wall_side.MinEdge = readV3F1000(is);
62         wall_side.MaxEdge = readV3F1000(is);
63 }
64
65 /*
66         MaterialSpec
67 */
68
69 void MaterialSpec::serialize(std::ostream &os) const
70 {
71         os<<serializeString(tname);
72         writeU8(os, backface_culling);
73 }
74
75 void MaterialSpec::deSerialize(std::istream &is)
76 {
77         tname = deSerializeString(is);
78         backface_culling = readU8(is);
79 }
80
81 /*
82         ContentFeatures
83 */
84
85 ContentFeatures::ContentFeatures()
86 {
87         reset();
88 }
89
90 ContentFeatures::~ContentFeatures()
91 {
92 #ifndef SERVER
93         for(u16 j=0; j<CF_SPECIAL_COUNT; j++){
94                 delete special_materials[j];
95                 delete special_aps[j];
96         }
97 #endif
98 }
99
100 void ContentFeatures::reset()
101 {
102         /*
103                 Cached stuff
104         */
105 #ifndef SERVER
106         inventory_texture = NULL;
107         
108         for(u16 j=0; j<CF_SPECIAL_COUNT; j++){
109                 special_materials[j] = NULL;
110                 special_aps[j] = NULL;
111         }
112         solidness = 2;
113         visual_solidness = 0;
114         backface_culling = true;
115 #endif
116         used_texturenames.clear();
117         /*
118                 Actual data
119                 
120                 NOTE: Most of this is always overridden by the default values given
121                       in builtin.lua
122         */
123         name = "";
124         drawtype = NDT_NORMAL;
125         visual_scale = 1.0;
126         for(u32 i=0; i<6; i++)
127                 tname_tiles[i] = "";
128         for(u16 j=0; j<CF_SPECIAL_COUNT; j++)
129                 mspec_special[j] = MaterialSpec();
130         tname_inventory = "";
131         alpha = 255;
132         post_effect_color = video::SColor(0, 0, 0, 0);
133         param_type = CPT_NONE;
134         is_ground_content = false;
135         light_propagates = false;
136         sunlight_propagates = false;
137         walkable = true;
138         pointable = true;
139         diggable = true;
140         climbable = false;
141         buildable_to = false;
142         wall_mounted = false;
143         often_contains_mineral = false;
144         dug_item = "";
145         extra_dug_item = "";
146         extra_dug_item_rarity = 2;
147         metadata_name = "";
148         liquid_type = LIQUID_NONE;
149         liquid_alternative_flowing = "";
150         liquid_alternative_source = "";
151         liquid_viscosity = 0;
152         light_source = 0;
153         damage_per_second = 0;
154         selection_box = NodeBox();
155         material = MaterialProperties();
156         cookresult_item = ""; // Cannot be cooked
157         furnace_cooktime = 3.0;
158         furnace_burntime = -1.0; // Cannot be burned
159 }
160
161 void ContentFeatures::serialize(std::ostream &os)
162 {
163         writeU8(os, 0); // version
164         os<<serializeString(name);
165         writeU8(os, drawtype);
166         writeF1000(os, visual_scale);
167         writeU8(os, 6);
168         for(u32 i=0; i<6; i++)
169                 os<<serializeString(tname_tiles[i]);
170         os<<serializeString(tname_inventory);
171         writeU8(os, CF_SPECIAL_COUNT);
172         for(u32 i=0; i<CF_SPECIAL_COUNT; i++){
173                 mspec_special[i].serialize(os);
174         }
175         writeU8(os, alpha);
176         writeU8(os, post_effect_color.getAlpha());
177         writeU8(os, post_effect_color.getRed());
178         writeU8(os, post_effect_color.getGreen());
179         writeU8(os, post_effect_color.getBlue());
180         writeU8(os, param_type);
181         writeU8(os, is_ground_content);
182         writeU8(os, light_propagates);
183         writeU8(os, sunlight_propagates);
184         writeU8(os, walkable);
185         writeU8(os, pointable);
186         writeU8(os, diggable);
187         writeU8(os, climbable);
188         writeU8(os, buildable_to);
189         writeU8(os, wall_mounted);
190         writeU8(os, often_contains_mineral);
191         os<<serializeString(dug_item);
192         os<<serializeString(extra_dug_item);
193         writeS32(os, extra_dug_item_rarity);
194         os<<serializeString(metadata_name);
195         writeU8(os, liquid_type);
196         os<<serializeString(liquid_alternative_flowing);
197         os<<serializeString(liquid_alternative_source);
198         writeU8(os, liquid_viscosity);
199         writeU8(os, light_source);
200         writeU32(os, damage_per_second);
201         selection_box.serialize(os);
202         material.serialize(os);
203         os<<serializeString(cookresult_item);
204         writeF1000(os, furnace_cooktime);
205         writeF1000(os, furnace_burntime);
206 }
207
208 void ContentFeatures::deSerialize(std::istream &is, IGameDef *gamedef)
209 {
210         int version = readU8(is);
211         if(version != 0)
212                 throw SerializationError("unsupported ContentFeatures version");
213         name = deSerializeString(is);
214         drawtype = (enum NodeDrawType)readU8(is);
215         visual_scale = readF1000(is);
216         if(readU8(is) != 6)
217                 throw SerializationError("unsupported tile count");
218         for(u32 i=0; i<6; i++)
219                 setTexture(i, deSerializeString(is));
220                 //tname_tiles[i] = deSerializeString(is);
221         tname_inventory = deSerializeString(is);
222         if(readU8(is) != CF_SPECIAL_COUNT)
223                 throw SerializationError("unsupported CF_SPECIAL_COUNT");
224         for(u32 i=0; i<CF_SPECIAL_COUNT; i++){
225                 mspec_special[i].deSerialize(is);
226         }
227         alpha = readU8(is);
228         post_effect_color.setAlpha(readU8(is));
229         post_effect_color.setRed(readU8(is));
230         post_effect_color.setGreen(readU8(is));
231         post_effect_color.setBlue(readU8(is));
232         param_type = (enum ContentParamType)readU8(is);
233         is_ground_content = readU8(is);
234         light_propagates = readU8(is);
235         sunlight_propagates = readU8(is);
236         walkable = readU8(is);
237         pointable = readU8(is);
238         diggable = readU8(is);
239         climbable = readU8(is);
240         buildable_to = readU8(is);
241         wall_mounted = readU8(is);
242         often_contains_mineral = readU8(is);
243         dug_item = deSerializeString(is);
244         extra_dug_item = deSerializeString(is);
245         extra_dug_item_rarity = readS32(is);
246         metadata_name = deSerializeString(is);
247         liquid_type = (enum LiquidType)readU8(is);
248         liquid_alternative_flowing = deSerializeString(is);
249         liquid_alternative_source = deSerializeString(is);
250         liquid_viscosity = readU8(is);
251         light_source = readU8(is);
252         damage_per_second = readU32(is);
253         selection_box.deSerialize(is);
254         material.deSerialize(is);
255         cookresult_item = deSerializeString(is);
256         furnace_cooktime = readF1000(is);
257         furnace_burntime = readF1000(is);
258 }
259
260 void ContentFeatures::setTexture(u16 i, std::string name)
261 {
262         used_texturenames.insert(name);
263         tname_tiles[i] = name;
264         if(tname_inventory == "")
265                 tname_inventory = name;
266 }
267
268 void ContentFeatures::setAllTextures(std::string name)
269 {
270         for(u16 i=0; i<6; i++)
271                 setTexture(i, name);
272         // Force inventory texture too
273         setInventoryTexture(name);
274 }
275
276 void ContentFeatures::setSpecialMaterial(u16 i, const MaterialSpec &mspec)
277 {
278         assert(i < CF_SPECIAL_COUNT);
279         mspec_special[i] = mspec;
280 }
281
282 void ContentFeatures::setInventoryTexture(std::string imgname)
283 {
284         tname_inventory = imgname;
285 }
286
287 void ContentFeatures::setInventoryTextureCube(std::string top,
288                 std::string left, std::string right)
289 {
290         str_replace_char(top, '^', '&');
291         str_replace_char(left, '^', '&');
292         str_replace_char(right, '^', '&');
293
294         std::string imgname_full;
295         imgname_full += "[inventorycube{";
296         imgname_full += top;
297         imgname_full += "{";
298         imgname_full += left;
299         imgname_full += "{";
300         imgname_full += right;
301         tname_inventory = imgname_full;
302 }
303
304 /*
305         CNodeDefManager
306 */
307
308 class CNodeDefManager: public IWritableNodeDefManager
309 {
310 public:
311         void clear()
312         {
313                 m_name_id_mapping.clear();
314
315                 m_aliases.clear();
316                 
317                 for(u16 i=0; i<=MAX_CONTENT; i++)
318                 {
319                         ContentFeatures &f = m_content_features[i];
320                         f.reset(); // Reset to defaults
321                         f.setAllTextures("unknown_block.png");
322                 }
323                 
324                 // Set CONTENT_AIR
325                 {
326                         ContentFeatures f;
327                         f.name = "air";
328                         f.drawtype = NDT_AIRLIKE;
329                         f.param_type = CPT_LIGHT;
330                         f.light_propagates = true;
331                         f.sunlight_propagates = true;
332                         f.walkable = false;
333                         f.pointable = false;
334                         f.diggable = false;
335                         f.buildable_to = true;
336                         // Insert directly into containers
337                         content_t c = CONTENT_AIR;
338                         m_content_features[c] = f;
339                         m_name_id_mapping.set(c, f.name);
340                 }
341                 // Set CONTENT_IGNORE
342                 {
343                         ContentFeatures f;
344                         f.name = "ignore";
345                         f.drawtype = NDT_AIRLIKE;
346                         f.param_type = CPT_NONE;
347                         f.light_propagates = false;
348                         f.sunlight_propagates = false;
349                         f.walkable = false;
350                         f.pointable = false;
351                         f.diggable = false;
352                         // A way to remove accidental CONTENT_IGNOREs
353                         f.buildable_to = true;
354                         // Insert directly into containers
355                         content_t c = CONTENT_IGNORE;
356                         m_content_features[c] = f;
357                         m_name_id_mapping.set(c, f.name);
358                 }
359         }
360         // CONTENT_IGNORE = not found
361         content_t getFreeId(bool require_full_param2)
362         {
363                 // If allowed, first search in the large 4-byte-param2 pool
364                 if(!require_full_param2){
365                         for(u16 i=0x800; i<=0xfff; i++){
366                                 const ContentFeatures &f = m_content_features[i];
367                                 if(f.name == "")
368                                         return i;
369                         }
370                 }
371                 // Then search from the small 8-byte-param2 pool
372                 for(u16 i=0; i<=125; i++){
373                         const ContentFeatures &f = m_content_features[i];
374                         if(f.name == "")
375                                 return i;
376                 }
377                 return CONTENT_IGNORE;
378         }
379         CNodeDefManager()
380         {
381                 clear();
382         }
383         virtual ~CNodeDefManager()
384         {
385         }
386         virtual IWritableNodeDefManager* clone()
387         {
388                 CNodeDefManager *mgr = new CNodeDefManager();
389                 for(u16 i=0; i<=MAX_CONTENT; i++)
390                 {
391                         mgr->set(i, get(i));
392                 }
393                 return mgr;
394         }
395         virtual const ContentFeatures& get(content_t c) const
396         {
397                 assert(c <= MAX_CONTENT);
398                 return m_content_features[c];
399         }
400         virtual const ContentFeatures& get(const MapNode &n) const
401         {
402                 return get(n.getContent());
403         }
404         virtual bool getId(const std::string &name_, content_t &result) const
405         {
406                 std::string name = name_;
407                 // Convert name according to possible alias
408                 std::map<std::string, std::string>::const_iterator i;
409                 i = m_aliases.find(name);
410                 if(i != m_aliases.end()){
411                         /*infostream<<"ndef: alias active: "<<name<<" -> "<<i->second
412                                         <<std::endl;*/
413                         name = i->second;
414                 }
415                 // Get id
416                 return m_name_id_mapping.getId(name, result);
417         }
418         virtual content_t getId(const std::string &name) const
419         {
420                 content_t id = CONTENT_IGNORE;
421                 getId(name, id);
422                 return id;
423         }
424         virtual const ContentFeatures& get(const std::string &name) const
425         {
426                 content_t id = CONTENT_IGNORE;
427                 getId(name, id);
428                 return get(id);
429         }
430         // IWritableNodeDefManager
431         virtual void set(content_t c, const ContentFeatures &def)
432         {
433                 infostream<<"registerNode: registering content id \""<<c
434                                 <<"\": name=\""<<def.name<<"\""<<std::endl;
435                 assert(c <= MAX_CONTENT);
436                 // Don't allow redefining CONTENT_IGNORE (but allow air)
437                 if(def.name == "ignore" || c == CONTENT_IGNORE){
438                         infostream<<"registerNode: WARNING: Ignoring "
439                                         <<"CONTENT_IGNORE redefinition"<<std::endl;
440                         return;
441                 }
442                 // Check that the special contents are not redefined as different id
443                 // because it would mess up everything
444                 if((def.name == "ignore" && c != CONTENT_IGNORE) ||
445                         (def.name == "air" && c != CONTENT_AIR)){
446                         errorstream<<"registerNode: IGNORING ERROR: "
447                                         <<"trying to register built-in type \""
448                                         <<def.name<<"\" as different id"<<std::endl;
449                         return;
450                 }
451                 m_content_features[c] = def;
452                 if(def.name != "")
453                         m_name_id_mapping.set(c, def.name);
454
455                 // Remove conflicting alias if it exists
456                 bool alias_removed = (m_aliases.erase(def.name) != 0);
457                 if(alias_removed)
458                         infostream<<"ndef: erased alias "<<def.name
459                                         <<" because node was defined"<<std::endl;
460         }
461         virtual content_t set(const std::string &name,
462                         const ContentFeatures &def)
463         {
464                 assert(name == def.name);
465                 u16 id = CONTENT_IGNORE;
466                 bool found = m_name_id_mapping.getId(name, id);
467                 if(!found){
468                         // Determine if full param2 is required
469                         bool require_full_param2 = (
470                                 def.liquid_type == LIQUID_FLOWING
471                                 ||
472                                 def.drawtype == NDT_FLOWINGLIQUID
473                                 ||
474                                 def.drawtype == NDT_TORCHLIKE
475                                 ||
476                                 def.drawtype == NDT_SIGNLIKE
477                         );
478                         // Get some id
479                         id = getFreeId(require_full_param2);
480                         if(id == CONTENT_IGNORE)
481                                 return CONTENT_IGNORE;
482                         if(name != "")
483                                 m_name_id_mapping.set(id, name);
484                 }
485                 set(id, def);
486                 return id;
487         }
488         virtual content_t allocateDummy(const std::string &name)
489         {
490                 assert(name != "");
491                 ContentFeatures f;
492                 f.name = name;
493                 f.setAllTextures("unknown_block.png");
494                 // Make unknown blocks diggable
495                 f.material.diggability = DIGGABLE_NORMAL;
496                 return set(name, f);
497         }
498         virtual void setAlias(const std::string &name,
499                         const std::string &convert_to)
500         {
501                 content_t id;
502                 if(getId(name, id)){
503                         infostream<<"ndef: not setting alias "<<name<<" -> "<<convert_to
504                                         <<": "<<name<<" is already defined"<<std::endl;
505                         return;
506                 }
507                 infostream<<"ndef: setting alias "<<name<<" -> "<<convert_to
508                                 <<std::endl;
509                 m_aliases[name] = convert_to;
510         }
511         virtual void updateTextures(ITextureSource *tsrc)
512         {
513 #ifndef SERVER
514                 infostream<<"CNodeDefManager::updateTextures(): Updating "
515                                 <<"textures in node definitions"<<std::endl;
516
517                 bool new_style_water = g_settings->getBool("new_style_water");
518                 bool new_style_leaves = g_settings->getBool("new_style_leaves");
519                 bool opaque_water = g_settings->getBool("opaque_water");
520                 
521                 for(u16 i=0; i<=MAX_CONTENT; i++)
522                 {
523                         ContentFeatures *f = &m_content_features[i];
524
525                         switch(f->drawtype){
526                         default:
527                         case NDT_NORMAL:
528                                 f->solidness = 2;
529                                 break;
530                         case NDT_AIRLIKE:
531                                 f->solidness = 0;
532                                 break;
533                         case NDT_LIQUID:
534                                 assert(f->liquid_type == LIQUID_SOURCE);
535                                 if(opaque_water)
536                                         f->alpha = 255;
537                                 if(new_style_water){
538                                         f->solidness = 0;
539                                 } else {
540                                         f->solidness = 1;
541                                         if(f->alpha == 255)
542                                                 f->solidness = 2;
543                                         f->backface_culling = false;
544                                 }
545                                 break;
546                         case NDT_FLOWINGLIQUID:
547                                 assert(f->liquid_type == LIQUID_FLOWING);
548                                 f->solidness = 0;
549                                 if(opaque_water)
550                                         f->alpha = 255;
551                                 break;
552                         case NDT_GLASSLIKE:
553                                 f->solidness = 0;
554                                 f->visual_solidness = 1;
555                                 break;
556                         case NDT_ALLFACES:
557                                 f->solidness = 0;
558                                 f->visual_solidness = 1;
559                                 break;
560                         case NDT_ALLFACES_OPTIONAL:
561                                 if(new_style_leaves){
562                                         f->drawtype = NDT_ALLFACES;
563                                         f->solidness = 0;
564                                         f->visual_solidness = 1;
565                                 } else {
566                                         f->drawtype = NDT_NORMAL;
567                                         f->solidness = 2;
568                                         for(u32 i=0; i<6; i++){
569                                                 f->setTexture(i, f->tname_tiles[i]
570                                                                 + std::string("^[noalpha"));
571                                         }
572                                 }
573                                 break;
574                         case NDT_TORCHLIKE:
575                         case NDT_SIGNLIKE:
576                         case NDT_PLANTLIKE:
577                         case NDT_FENCELIKE:
578                         case NDT_RAILLIKE:
579                                 f->solidness = 0;
580                                 break;
581                         }
582
583                         // Inventory texture
584                         if(f->tname_inventory != "")
585                                 f->inventory_texture = tsrc->getTextureRaw(f->tname_inventory);
586                         else
587                                 f->inventory_texture = NULL;
588                         // Tile textures
589                         for(u16 j=0; j<6; j++){
590                                 if(f->tname_tiles[j] == "")
591                                         continue;
592                                 f->tiles[j].texture = tsrc->getTexture(f->tname_tiles[j]);
593                                 f->tiles[j].alpha = f->alpha;
594                                 if(f->alpha == 255)
595                                         f->tiles[j].material_type = MATERIAL_ALPHA_SIMPLE;
596                                 else
597                                         f->tiles[j].material_type = MATERIAL_ALPHA_VERTEX;
598                                 if(f->backface_culling)
599                                         f->tiles[j].material_flags |= MATERIAL_FLAG_BACKFACE_CULLING;
600                                 else
601                                         f->tiles[j].material_flags &= ~MATERIAL_FLAG_BACKFACE_CULLING;
602                         }
603                         // Special textures
604                         for(u16 j=0; j<CF_SPECIAL_COUNT; j++){
605                                 // Remove all stuff
606                                 if(f->special_aps[j]){
607                                         delete f->special_aps[j];
608                                         f->special_aps[j] = NULL;
609                                 }
610                                 if(f->special_materials[j]){
611                                         delete f->special_materials[j];
612                                         f->special_materials[j] = NULL;
613                                 }
614                                 // Skip if should not exist
615                                 if(f->mspec_special[j].tname == "")
616                                         continue;
617                                 // Create all stuff
618                                 f->special_aps[j] = new AtlasPointer(
619                                                 tsrc->getTexture(f->mspec_special[j].tname));
620                                 f->special_materials[j] = new video::SMaterial;
621                                 f->special_materials[j]->setFlag(video::EMF_LIGHTING, false);
622                                 f->special_materials[j]->setFlag(video::EMF_BACK_FACE_CULLING,
623                                                 f->mspec_special[j].backface_culling);
624                                 f->special_materials[j]->setFlag(video::EMF_BILINEAR_FILTER, false);
625                                 f->special_materials[j]->setFlag(video::EMF_FOG_ENABLE, true);
626                                 f->special_materials[j]->setTexture(0, f->special_aps[j]->atlas);
627                                 if(f->alpha != 255)
628                                         f->special_materials[j]->MaterialType =
629                                                         video::EMT_TRANSPARENT_VERTEX_ALPHA;
630                         }
631                 }
632 #endif
633         }
634         void serialize(std::ostream &os)
635         {
636                 u16 count = 0;
637                 std::ostringstream tmp_os(std::ios::binary);
638                 for(u16 i=0; i<=MAX_CONTENT; i++)
639                 {
640                         if(i == CONTENT_IGNORE || i == CONTENT_AIR)
641                                 continue;
642                         ContentFeatures *f = &m_content_features[i];
643                         if(f->name == "")
644                                 continue;
645                         writeU16(tmp_os, i);
646                         f->serialize(tmp_os);
647                         count++;
648                 }
649                 writeU16(os, count);
650                 os<<serializeLongString(tmp_os.str());
651
652                 writeU16(os, m_aliases.size());
653                 for(std::map<std::string, std::string>::const_iterator
654                                 i = m_aliases.begin(); i != m_aliases.end(); i++)
655                 {
656                         os<<serializeString(i->first);
657                         os<<serializeString(i->second);
658                 }
659         }
660         void deSerialize(std::istream &is, IGameDef *gamedef)
661         {
662                 clear();
663                 u16 count = readU16(is);
664                 std::istringstream tmp_is(deSerializeLongString(is), std::ios::binary);
665                 for(u16 n=0; n<count; n++){
666                         u16 i = readU16(tmp_is);
667                         if(i > MAX_CONTENT){
668                                 errorstream<<"ContentFeatures::deSerialize(): "
669                                                 <<"Too large content id: "<<i<<std::endl;
670                                 continue;
671                         }
672                         /*// Do not deserialize special types
673                         if(i == CONTENT_IGNORE || i == CONTENT_AIR)
674                                 continue;*/
675                         ContentFeatures *f = &m_content_features[i];
676                         f->deSerialize(tmp_is, gamedef);
677                         if(f->name != "")
678                                 m_name_id_mapping.set(i, f->name);
679                 }
680
681                 u16 num_aliases = readU16(is);
682                 if(!is.eof()){
683                         for(u16 i=0; i<num_aliases; i++){
684                                 std::string name = deSerializeString(is);
685                                 std::string convert_to = deSerializeString(is);
686                                 m_aliases[name] = convert_to;
687                         }
688                 }
689         }
690 private:
691         // Features indexed by id
692         ContentFeatures m_content_features[MAX_CONTENT+1];
693         // A mapping for fast converting back and forth between names and ids
694         NameIdMapping m_name_id_mapping;
695         // Aliases for loading legacy crap
696         std::map<std::string, std::string> m_aliases;
697 };
698
699 IWritableNodeDefManager* createNodeDefManager()
700 {
701         return new CNodeDefManager();
702 }
703