]> git.lizzy.rs Git - dragonfireclient.git/blob - src/mapnode.cpp
Decoration API: Allow force_placement of simple decorations
[dragonfireclient.git] / src / mapnode.cpp
1 /*
2 Minetest
3 Copyright (C) 2013 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 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.
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 Lesser General Public License for more details.
14
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.
18 */
19
20 #include "irrlichttypes_extrabloated.h"
21 #include "mapnode.h"
22 #include "porting.h"
23 #include "nodedef.h"
24 #include "content_mapnode.h" // For mapnode_translate_*_internal
25 #include "serialization.h" // For ser_ver_supported
26 #include "util/serialize.h"
27 #include "log.h"
28 #include "util/numeric.h"
29 #include <string>
30 #include <sstream>
31
32 static const Rotation wallmounted_to_rot[] = {
33         ROTATE_0, ROTATE_180, ROTATE_90, ROTATE_270
34 };
35
36 static const u8 rot_to_wallmounted[] = {
37         2, 4, 3, 5
38 };
39
40
41 /*
42         MapNode
43 */
44
45 // Create directly from a nodename
46 // If name is unknown, sets CONTENT_IGNORE
47 MapNode::MapNode(INodeDefManager *ndef, const std::string &name,
48                 u8 a_param1, u8 a_param2)
49 {
50         content_t id = CONTENT_IGNORE;
51         ndef->getId(name, id);
52         param0 = id;
53         param1 = a_param1;
54         param2 = a_param2;
55 }
56
57 void MapNode::setLight(enum LightBank bank, u8 a_light, INodeDefManager *nodemgr)
58 {
59         // If node doesn't contain light data, ignore this
60         if(nodemgr->get(*this).param_type != CPT_LIGHT)
61                 return;
62         if(bank == LIGHTBANK_DAY)
63         {
64                 param1 &= 0xf0;
65                 param1 |= a_light & 0x0f;
66         }
67         else if(bank == LIGHTBANK_NIGHT)
68         {
69                 param1 &= 0x0f;
70                 param1 |= (a_light & 0x0f)<<4;
71         }
72         else
73                 assert("Invalid light bank" == NULL);
74 }
75
76 bool MapNode::isLightDayNightEq(INodeDefManager *nodemgr) const
77 {
78         const ContentFeatures &f = nodemgr->get(*this);
79         bool isEqual;
80
81         if (f.param_type == CPT_LIGHT) {
82                 u8 day   = MYMAX(f.light_source, param1 & 0x0f);
83                 u8 night = MYMAX(f.light_source, (param1 >> 4) & 0x0f);
84                 isEqual = day == night;
85         } else {
86                 isEqual = true;
87         }
88
89         return isEqual;
90 }
91
92 u8 MapNode::getLight(enum LightBank bank, INodeDefManager *nodemgr) const
93 {
94         // Select the brightest of [light source, propagated light]
95         const ContentFeatures &f = nodemgr->get(*this);
96
97         u8 light;
98         if(f.param_type == CPT_LIGHT)
99                 light = bank == LIGHTBANK_DAY ? param1 & 0x0f : (param1 >> 4) & 0x0f;
100         else
101                 light = 0;
102
103         return MYMAX(f.light_source, light);
104 }
105
106 u8 MapNode::getLightNoChecks(enum LightBank bank, const ContentFeatures *f) const
107 {
108         return MYMAX(f->light_source,
109                      bank == LIGHTBANK_DAY ? param1 & 0x0f : (param1 >> 4) & 0x0f);
110 }
111
112 bool MapNode::getLightBanks(u8 &lightday, u8 &lightnight, INodeDefManager *nodemgr) const
113 {
114         // Select the brightest of [light source, propagated light]
115         const ContentFeatures &f = nodemgr->get(*this);
116         if(f.param_type == CPT_LIGHT)
117         {
118                 lightday = param1 & 0x0f;
119                 lightnight = (param1>>4)&0x0f;
120         }
121         else
122         {
123                 lightday = 0;
124                 lightnight = 0;
125         }
126         if(f.light_source > lightday)
127                 lightday = f.light_source;
128         if(f.light_source > lightnight)
129                 lightnight = f.light_source;
130         return f.param_type == CPT_LIGHT || f.light_source != 0;
131 }
132
133 u8 MapNode::getFaceDir(INodeDefManager *nodemgr) const
134 {
135         const ContentFeatures &f = nodemgr->get(*this);
136         if(f.param_type_2 == CPT2_FACEDIR)
137                 return (getParam2() & 0x1F) % 24;
138         return 0;
139 }
140
141 u8 MapNode::getWallMounted(INodeDefManager *nodemgr) const
142 {
143         const ContentFeatures &f = nodemgr->get(*this);
144         if(f.param_type_2 == CPT2_WALLMOUNTED)
145                 return getParam2() & 0x07;
146         return 0;
147 }
148
149 v3s16 MapNode::getWallMountedDir(INodeDefManager *nodemgr) const
150 {
151         switch(getWallMounted(nodemgr))
152         {
153         case 0: default: return v3s16(0,1,0);
154         case 1: return v3s16(0,-1,0);
155         case 2: return v3s16(1,0,0);
156         case 3: return v3s16(-1,0,0);
157         case 4: return v3s16(0,0,1);
158         case 5: return v3s16(0,0,-1);
159         }
160 }
161
162 void MapNode::rotateAlongYAxis(INodeDefManager *nodemgr, Rotation rot)
163 {
164         ContentParamType2 cpt2 = nodemgr->get(*this).param_type_2;
165
166         if (cpt2 == CPT2_FACEDIR) {
167                 static const u8 rotate_facedir[24 * 4] = {
168                         // Table value = rotated facedir
169                         // Columns: 0, 90, 180, 270 degrees rotation around vertical axis
170                         // Rotation is anticlockwise as seen from above (+Y)
171
172                         0, 1, 2, 3,  // Initial facedir 0 to 3
173                         1, 2, 3, 0,
174                         2, 3, 0, 1,
175                         3, 0, 1, 2,
176
177                         4, 13, 10, 19,  // 4 to 7
178                         5, 14, 11, 16,
179                         6, 15, 8, 17,
180                         7, 12, 9, 18,
181
182                         8, 17, 6, 15,  // 8 to 11
183                         9, 18, 7, 12,
184                         10, 19, 4, 13,
185                         11, 16, 5, 14,
186
187                         12, 9, 18, 7,  // 12 to 15
188                         13, 10, 19, 4,
189                         14, 11, 16, 5,
190                         15, 8, 17, 6,
191
192                         16, 5, 14, 11,  // 16 to 19
193                         17, 6, 15, 8,
194                         18, 7, 12, 9,
195                         19, 4, 13, 10,
196
197                         20, 23, 22, 21,  // 20 to 23
198                         21, 20, 23, 22,
199                         22, 21, 20, 23,
200                         23, 22, 21, 20
201                 };
202                 u8 facedir = (param2 & 31) % 24;
203                 u8 index = facedir * 4 + rot;
204                 param2 &= ~31;
205                 param2 |= rotate_facedir[index];
206         } else if (cpt2 == CPT2_WALLMOUNTED) {
207                 u8 wmountface = (param2 & 7);
208                 if (wmountface <= 1)
209                         return;
210
211                 Rotation oldrot = wallmounted_to_rot[wmountface - 2];
212                 param2 &= ~7;
213                 param2 |= rot_to_wallmounted[(oldrot - rot) & 3];
214         }
215 }
216
217 static std::vector<aabb3f> transformNodeBox(const MapNode &n,
218                 const NodeBox &nodebox, INodeDefManager *nodemgr)
219 {
220         std::vector<aabb3f> boxes;
221         if(nodebox.type == NODEBOX_FIXED || nodebox.type == NODEBOX_LEVELED)
222         {
223                 const std::vector<aabb3f> &fixed = nodebox.fixed;
224                 int facedir = n.getFaceDir(nodemgr);
225                 u8 axisdir = facedir>>2;
226                 facedir&=0x03;
227                 for(std::vector<aabb3f>::const_iterator
228                                 i = fixed.begin();
229                                 i != fixed.end(); ++i)
230                 {
231                         aabb3f box = *i;
232
233                         if (nodebox.type == NODEBOX_LEVELED) {
234                                 box.MaxEdge.Y = -BS/2 + BS*((float)1/LEVELED_MAX) * n.getLevel(nodemgr);
235                         }
236
237                         switch (axisdir)
238                         {
239                         case 0:
240                                 if(facedir == 1)
241                                 {
242                                         box.MinEdge.rotateXZBy(-90);
243                                         box.MaxEdge.rotateXZBy(-90);
244                                 }
245                                 else if(facedir == 2)
246                                 {
247                                         box.MinEdge.rotateXZBy(180);
248                                         box.MaxEdge.rotateXZBy(180);
249                                 }
250                                 else if(facedir == 3)
251                                 {
252                                         box.MinEdge.rotateXZBy(90);
253                                         box.MaxEdge.rotateXZBy(90);
254                                 }
255                                 break;
256                         case 1: // z+
257                                 box.MinEdge.rotateYZBy(90);
258                                 box.MaxEdge.rotateYZBy(90);
259                                 if(facedir == 1)
260                                 {
261                                         box.MinEdge.rotateXYBy(90);
262                                         box.MaxEdge.rotateXYBy(90);
263                                 }
264                                 else if(facedir == 2)
265                                 {
266                                         box.MinEdge.rotateXYBy(180);
267                                         box.MaxEdge.rotateXYBy(180);
268                                 }
269                                 else if(facedir == 3)
270                                 {
271                                         box.MinEdge.rotateXYBy(-90);
272                                         box.MaxEdge.rotateXYBy(-90);
273                                 }
274                                 break;
275                         case 2: //z-
276                                 box.MinEdge.rotateYZBy(-90);
277                                 box.MaxEdge.rotateYZBy(-90);
278                                 if(facedir == 1)
279                                 {
280                                         box.MinEdge.rotateXYBy(-90);
281                                         box.MaxEdge.rotateXYBy(-90);
282                                 }
283                                 else if(facedir == 2)
284                                 {
285                                         box.MinEdge.rotateXYBy(180);
286                                         box.MaxEdge.rotateXYBy(180);
287                                 }
288                                 else if(facedir == 3)
289                                 {
290                                         box.MinEdge.rotateXYBy(90);
291                                         box.MaxEdge.rotateXYBy(90);
292                                 }
293                                 break;
294                         case 3:  //x+
295                                 box.MinEdge.rotateXYBy(-90);
296                                 box.MaxEdge.rotateXYBy(-90);
297                                 if(facedir == 1)
298                                 {
299                                         box.MinEdge.rotateYZBy(90);
300                                         box.MaxEdge.rotateYZBy(90);
301                                 }
302                                 else if(facedir == 2)
303                                 {
304                                         box.MinEdge.rotateYZBy(180);
305                                         box.MaxEdge.rotateYZBy(180);
306                                 }
307                                 else if(facedir == 3)
308                                 {
309                                         box.MinEdge.rotateYZBy(-90);
310                                         box.MaxEdge.rotateYZBy(-90);
311                                 }
312                                 break;
313                         case 4:  //x-
314                                 box.MinEdge.rotateXYBy(90);
315                                 box.MaxEdge.rotateXYBy(90);
316                                 if(facedir == 1)
317                                 {
318                                         box.MinEdge.rotateYZBy(-90);
319                                         box.MaxEdge.rotateYZBy(-90);
320                                 }
321                                 else if(facedir == 2)
322                                 {
323                                         box.MinEdge.rotateYZBy(180);
324                                         box.MaxEdge.rotateYZBy(180);
325                                 }
326                                 else if(facedir == 3)
327                                 {
328                                         box.MinEdge.rotateYZBy(90);
329                                         box.MaxEdge.rotateYZBy(90);
330                                 }
331                                 break;
332                         case 5:
333                                 box.MinEdge.rotateXYBy(-180);
334                                 box.MaxEdge.rotateXYBy(-180);
335                                 if(facedir == 1)
336                                 {
337                                         box.MinEdge.rotateXZBy(90);
338                                         box.MaxEdge.rotateXZBy(90);
339                                 }
340                                 else if(facedir == 2)
341                                 {
342                                         box.MinEdge.rotateXZBy(180);
343                                         box.MaxEdge.rotateXZBy(180);
344                                 }
345                                 else if(facedir == 3)
346                                 {
347                                         box.MinEdge.rotateXZBy(-90);
348                                         box.MaxEdge.rotateXZBy(-90);
349                                 }
350                                 break;
351                         default:
352                                 break;
353                         }
354                         box.repair();
355                         boxes.push_back(box);
356                 }
357         }
358         else if(nodebox.type == NODEBOX_WALLMOUNTED)
359         {
360                 v3s16 dir = n.getWallMountedDir(nodemgr);
361
362                 // top
363                 if(dir == v3s16(0,1,0))
364                 {
365                         boxes.push_back(nodebox.wall_top);
366                 }
367                 // bottom
368                 else if(dir == v3s16(0,-1,0))
369                 {
370                         boxes.push_back(nodebox.wall_bottom);
371                 }
372                 // side
373                 else
374                 {
375                         v3f vertices[2] =
376                         {
377                                 nodebox.wall_side.MinEdge,
378                                 nodebox.wall_side.MaxEdge
379                         };
380
381                         for(s32 i=0; i<2; i++)
382                         {
383                                 if(dir == v3s16(-1,0,0))
384                                         vertices[i].rotateXZBy(0);
385                                 if(dir == v3s16(1,0,0))
386                                         vertices[i].rotateXZBy(180);
387                                 if(dir == v3s16(0,0,-1))
388                                         vertices[i].rotateXZBy(90);
389                                 if(dir == v3s16(0,0,1))
390                                         vertices[i].rotateXZBy(-90);
391                         }
392
393                         aabb3f box = aabb3f(vertices[0]);
394                         box.addInternalPoint(vertices[1]);
395                         boxes.push_back(box);
396                 }
397         }
398         else // NODEBOX_REGULAR
399         {
400                 boxes.push_back(aabb3f(-BS/2,-BS/2,-BS/2,BS/2,BS/2,BS/2));
401         }
402         return boxes;
403 }
404
405 std::vector<aabb3f> MapNode::getNodeBoxes(INodeDefManager *nodemgr) const
406 {
407         const ContentFeatures &f = nodemgr->get(*this);
408         return transformNodeBox(*this, f.node_box, nodemgr);
409 }
410
411 std::vector<aabb3f> MapNode::getCollisionBoxes(INodeDefManager *nodemgr) const
412 {
413         const ContentFeatures &f = nodemgr->get(*this);
414         if (f.collision_box.fixed.empty())
415                 return transformNodeBox(*this, f.node_box, nodemgr);
416         else
417                 return transformNodeBox(*this, f.collision_box, nodemgr);
418 }
419
420 std::vector<aabb3f> MapNode::getSelectionBoxes(INodeDefManager *nodemgr) const
421 {
422         const ContentFeatures &f = nodemgr->get(*this);
423         return transformNodeBox(*this, f.selection_box, nodemgr);
424 }
425
426 u8 MapNode::getMaxLevel(INodeDefManager *nodemgr) const
427 {
428         const ContentFeatures &f = nodemgr->get(*this);
429         // todo: after update in all games leave only if (f.param_type_2 ==
430         if( f.liquid_type == LIQUID_FLOWING || f.param_type_2 == CPT2_FLOWINGLIQUID)
431                 return LIQUID_LEVEL_MAX;
432         if(f.leveled || f.param_type_2 == CPT2_LEVELED)
433                 return LEVELED_MAX;
434         return 0;
435 }
436
437 u8 MapNode::getLevel(INodeDefManager *nodemgr) const
438 {
439         const ContentFeatures &f = nodemgr->get(*this);
440         // todo: after update in all games leave only if (f.param_type_2 ==
441         if(f.liquid_type == LIQUID_SOURCE)
442                 return LIQUID_LEVEL_SOURCE;
443         if (f.param_type_2 == CPT2_FLOWINGLIQUID)
444                 return getParam2() & LIQUID_LEVEL_MASK;
445         if(f.liquid_type == LIQUID_FLOWING) // can remove if all param_type_2 setted
446                 return getParam2() & LIQUID_LEVEL_MASK;
447         if(f.leveled || f.param_type_2 == CPT2_LEVELED) {
448                  u8 level = getParam2() & LEVELED_MASK;
449                  if(level)
450                         return level;
451                  if(f.leveled > LEVELED_MAX)
452                         return LEVELED_MAX;
453                  return f.leveled; //default
454         }
455         return 0;
456 }
457
458 u8 MapNode::setLevel(INodeDefManager *nodemgr, s8 level)
459 {
460         u8 rest = 0;
461         if (level < 1) {
462                 setContent(CONTENT_AIR);
463                 return 0;
464         }
465         const ContentFeatures &f = nodemgr->get(*this);
466         if (f.param_type_2 == CPT2_FLOWINGLIQUID
467                 || f.liquid_type == LIQUID_FLOWING
468                 || f.liquid_type == LIQUID_SOURCE) {
469                 if (level >= LIQUID_LEVEL_SOURCE) {
470                         rest = level - LIQUID_LEVEL_SOURCE;
471                         setContent(nodemgr->getId(f.liquid_alternative_source));
472                 } else {
473                         setContent(nodemgr->getId(f.liquid_alternative_flowing));
474                         setParam2(level & LIQUID_LEVEL_MASK);
475                 }
476         } else if (f.leveled || f.param_type_2 == CPT2_LEVELED) {
477                 if (level > LEVELED_MAX) {
478                         rest = level - LEVELED_MAX;
479                         level = LEVELED_MAX;
480                 }
481                 setParam2(level & LEVELED_MASK);
482         }
483         return rest;
484 }
485
486 u8 MapNode::addLevel(INodeDefManager *nodemgr, s8 add)
487 {
488         s8 level = getLevel(nodemgr);
489         if (add == 0) level = 1;
490         level += add;
491         return setLevel(nodemgr, level);
492 }
493
494 u32 MapNode::serializedLength(u8 version)
495 {
496         if(!ser_ver_supported(version))
497                 throw VersionMismatchException("ERROR: MapNode format not supported");
498
499         if(version == 0)
500                 return 1;
501         else if(version <= 9)
502                 return 2;
503         else if(version <= 23)
504                 return 3;
505         else
506                 return 4;
507 }
508 void MapNode::serialize(u8 *dest, u8 version)
509 {
510         if(!ser_ver_supported(version))
511                 throw VersionMismatchException("ERROR: MapNode format not supported");
512
513         // Can't do this anymore; we have 16-bit dynamically allocated node IDs
514         // in memory; conversion just won't work in this direction.
515         if(version < 24)
516                 throw SerializationError("MapNode::serialize: serialization to "
517                                 "version < 24 not possible");
518
519         writeU16(dest+0, param0);
520         writeU8(dest+2, param1);
521         writeU8(dest+3, param2);
522 }
523 void MapNode::deSerialize(u8 *source, u8 version)
524 {
525         if(!ser_ver_supported(version))
526                 throw VersionMismatchException("ERROR: MapNode format not supported");
527
528         if(version <= 21)
529         {
530                 deSerialize_pre22(source, version);
531                 return;
532         }
533
534         if(version >= 24){
535                 param0 = readU16(source+0);
536                 param1 = readU8(source+2);
537                 param2 = readU8(source+3);
538         }else{
539                 param0 = readU8(source+0);
540                 param1 = readU8(source+1);
541                 param2 = readU8(source+2);
542                 if(param0 > 0x7F){
543                         param0 |= ((param2&0xF0)<<4);
544                         param2 &= 0x0F;
545                 }
546         }
547 }
548 void MapNode::serializeBulk(std::ostream &os, int version,
549                 const MapNode *nodes, u32 nodecount,
550                 u8 content_width, u8 params_width, bool compressed)
551 {
552         if(!ser_ver_supported(version))
553                 throw VersionMismatchException("ERROR: MapNode format not supported");
554
555         sanity_check(content_width == 2);
556         sanity_check(params_width == 2);
557
558         // Can't do this anymore; we have 16-bit dynamically allocated node IDs
559         // in memory; conversion just won't work in this direction.
560         if(version < 24)
561                 throw SerializationError("MapNode::serializeBulk: serialization to "
562                                 "version < 24 not possible");
563
564         SharedBuffer<u8> databuf(nodecount * (content_width + params_width));
565
566         // Serialize content
567         for(u32 i=0; i<nodecount; i++)
568                 writeU16(&databuf[i*2], nodes[i].param0);
569
570         // Serialize param1
571         u32 start1 = content_width * nodecount;
572         for(u32 i=0; i<nodecount; i++)
573                 writeU8(&databuf[start1 + i], nodes[i].param1);
574
575         // Serialize param2
576         u32 start2 = (content_width + 1) * nodecount;
577         for(u32 i=0; i<nodecount; i++)
578                 writeU8(&databuf[start2 + i], nodes[i].param2);
579
580         /*
581                 Compress data to output stream
582         */
583
584         if(compressed)
585         {
586                 compressZlib(databuf, os);
587         }
588         else
589         {
590                 os.write((const char*) &databuf[0], databuf.getSize());
591         }
592 }
593
594 // Deserialize bulk node data
595 void MapNode::deSerializeBulk(std::istream &is, int version,
596                 MapNode *nodes, u32 nodecount,
597                 u8 content_width, u8 params_width, bool compressed)
598 {
599         if(!ser_ver_supported(version))
600                 throw VersionMismatchException("ERROR: MapNode format not supported");
601
602         if (version < 22
603                         || (content_width != 1 && content_width != 2)
604                         || params_width != 2)
605                 FATAL_ERROR("Deserialize bulk node data error");
606
607         // Uncompress or read data
608         u32 len = nodecount * (content_width + params_width);
609         SharedBuffer<u8> databuf(len);
610         if(compressed)
611         {
612                 std::ostringstream os(std::ios_base::binary);
613                 decompressZlib(is, os);
614                 std::string s = os.str();
615                 if(s.size() != len)
616                         throw SerializationError("deSerializeBulkNodes: "
617                                         "decompress resulted in invalid size");
618                 memcpy(&databuf[0], s.c_str(), len);
619         }
620         else
621         {
622                 is.read((char*) &databuf[0], len);
623                 if(is.eof() || is.fail())
624                         throw SerializationError("deSerializeBulkNodes: "
625                                         "failed to read bulk node data");
626         }
627
628         // Deserialize content
629         if(content_width == 1)
630         {
631                 for(u32 i=0; i<nodecount; i++)
632                         nodes[i].param0 = readU8(&databuf[i]);
633         }
634         else if(content_width == 2)
635         {
636                 for(u32 i=0; i<nodecount; i++)
637                         nodes[i].param0 = readU16(&databuf[i*2]);
638         }
639
640         // Deserialize param1
641         u32 start1 = content_width * nodecount;
642         for(u32 i=0; i<nodecount; i++)
643                 nodes[i].param1 = readU8(&databuf[start1 + i]);
644
645         // Deserialize param2
646         u32 start2 = (content_width + 1) * nodecount;
647         if(content_width == 1)
648         {
649                 for(u32 i=0; i<nodecount; i++) {
650                         nodes[i].param2 = readU8(&databuf[start2 + i]);
651                         if(nodes[i].param0 > 0x7F){
652                                 nodes[i].param0 <<= 4;
653                                 nodes[i].param0 |= (nodes[i].param2&0xF0)>>4;
654                                 nodes[i].param2 &= 0x0F;
655                         }
656                 }
657         }
658         else if(content_width == 2)
659         {
660                 for(u32 i=0; i<nodecount; i++)
661                         nodes[i].param2 = readU8(&databuf[start2 + i]);
662         }
663 }
664
665 /*
666         Legacy serialization
667 */
668 void MapNode::deSerialize_pre22(u8 *source, u8 version)
669 {
670         if(version <= 1)
671         {
672                 param0 = source[0];
673         }
674         else if(version <= 9)
675         {
676                 param0 = source[0];
677                 param1 = source[1];
678         }
679         else
680         {
681                 param0 = source[0];
682                 param1 = source[1];
683                 param2 = source[2];
684                 if(param0 > 0x7f){
685                         param0 <<= 4;
686                         param0 |= (param2&0xf0)>>4;
687                         param2 &= 0x0f;
688                 }
689         }
690
691         // Convert special values from old version to new
692         if(version <= 19)
693         {
694                 // In these versions, CONTENT_IGNORE and CONTENT_AIR
695                 // are 255 and 254
696                 // Version 19 is fucked up with sometimes the old values and sometimes not
697                 if(param0 == 255)
698                         param0 = CONTENT_IGNORE;
699                 else if(param0 == 254)
700                         param0 = CONTENT_AIR;
701         }
702
703         // Translate to our known version
704         *this = mapnode_translate_to_internal(*this, version);
705 }