Skip to content

Commit 8bdde45

Browse files
committedJun 6, 2017
Revert "Remove deprecated code segments (#5891)"
This reverts commit 599e13e.
1 parent fee5171 commit 8bdde45

10 files changed

+418
-34
lines changed
 

‎build/android/jni/Android.mk

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ LOCAL_SRC_FILES := \
128128
jni/src/content_cao.cpp \
129129
jni/src/content_cso.cpp \
130130
jni/src/content_mapblock.cpp \
131+
jni/src/content_mapnode.cpp \
131132
jni/src/content_nodemeta.cpp \
132133
jni/src/content_sao.cpp \
133134
jni/src/convert_json.cpp \

‎src/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ set(common_SRCS
371371
clientiface.cpp
372372
collision.cpp
373373
content_abm.cpp
374+
content_mapnode.cpp
374375
content_nodemeta.cpp
375376
content_sao.cpp
376377
convert_json.cpp

‎src/content_mapnode.cpp

+169
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
/*
2+
Minetest
3+
Copyright (C) 2010-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 "content_mapnode.h"
21+
22+
#include "irrlichttypes_bloated.h"
23+
#include "mapnode.h"
24+
#include "nodedef.h"
25+
#include "nameidmapping.h"
26+
#include "util/string.h"
27+
28+
/*
29+
Legacy node content type IDs
30+
Ranges:
31+
0x000...0x07f (0...127): param2 is fully usable
32+
126 and 127 are reserved (CONTENT_AIR and CONTENT_IGNORE).
33+
0x800...0xfff (2048...4095): higher 4 bits of param2 are not usable
34+
*/
35+
#define CONTENT_STONE 0
36+
#define CONTENT_WATER 2
37+
#define CONTENT_TORCH 3
38+
#define CONTENT_WATERSOURCE 9
39+
#define CONTENT_SIGN_WALL 14
40+
#define CONTENT_CHEST 15
41+
#define CONTENT_FURNACE 16
42+
#define CONTENT_LOCKABLE_CHEST 17
43+
#define CONTENT_FENCE 21
44+
#define CONTENT_RAIL 30
45+
#define CONTENT_LADDER 31
46+
#define CONTENT_LAVA 32
47+
#define CONTENT_LAVASOURCE 33
48+
#define CONTENT_GRASS 0x800 //1
49+
#define CONTENT_TREE 0x801 //4
50+
#define CONTENT_LEAVES 0x802 //5
51+
#define CONTENT_GRASS_FOOTSTEPS 0x803 //6
52+
#define CONTENT_MESE 0x804 //7
53+
#define CONTENT_MUD 0x805 //8
54+
#define CONTENT_CLOUD 0x806 //10
55+
#define CONTENT_COALSTONE 0x807 //11
56+
#define CONTENT_WOOD 0x808 //12
57+
#define CONTENT_SAND 0x809 //13
58+
#define CONTENT_COBBLE 0x80a //18
59+
#define CONTENT_STEEL 0x80b //19
60+
#define CONTENT_GLASS 0x80c //20
61+
#define CONTENT_MOSSYCOBBLE 0x80d //22
62+
#define CONTENT_GRAVEL 0x80e //23
63+
#define CONTENT_SANDSTONE 0x80f //24
64+
#define CONTENT_CACTUS 0x810 //25
65+
#define CONTENT_BRICK 0x811 //26
66+
#define CONTENT_CLAY 0x812 //27
67+
#define CONTENT_PAPYRUS 0x813 //28
68+
#define CONTENT_BOOKSHELF 0x814 //29
69+
#define CONTENT_JUNGLETREE 0x815
70+
#define CONTENT_JUNGLEGRASS 0x816
71+
#define CONTENT_NC 0x817
72+
#define CONTENT_NC_RB 0x818
73+
#define CONTENT_APPLE 0x819
74+
#define CONTENT_SAPLING 0x820
75+
76+
/*
77+
A conversion table for backwards compatibility.
78+
Maps <=v19 content types to current ones.
79+
Should never be touched.
80+
*/
81+
content_t trans_table_19[21][2] = {
82+
{CONTENT_GRASS, 1},
83+
{CONTENT_TREE, 4},
84+
{CONTENT_LEAVES, 5},
85+
{CONTENT_GRASS_FOOTSTEPS, 6},
86+
{CONTENT_MESE, 7},
87+
{CONTENT_MUD, 8},
88+
{CONTENT_CLOUD, 10},
89+
{CONTENT_COALSTONE, 11},
90+
{CONTENT_WOOD, 12},
91+
{CONTENT_SAND, 13},
92+
{CONTENT_COBBLE, 18},
93+
{CONTENT_STEEL, 19},
94+
{CONTENT_GLASS, 20},
95+
{CONTENT_MOSSYCOBBLE, 22},
96+
{CONTENT_GRAVEL, 23},
97+
{CONTENT_SANDSTONE, 24},
98+
{CONTENT_CACTUS, 25},
99+
{CONTENT_BRICK, 26},
100+
{CONTENT_CLAY, 27},
101+
{CONTENT_PAPYRUS, 28},
102+
{CONTENT_BOOKSHELF, 29},
103+
};
104+
105+
MapNode mapnode_translate_to_internal(MapNode n_from, u8 version)
106+
{
107+
MapNode result = n_from;
108+
if(version <= 19)
109+
{
110+
content_t c_from = n_from.getContent();
111+
for(u32 i=0; i<sizeof(trans_table_19)/sizeof(trans_table_19[0]); i++)
112+
{
113+
if(trans_table_19[i][1] == c_from)
114+
{
115+
result.setContent(trans_table_19[i][0]);
116+
break;
117+
}
118+
}
119+
}
120+
return result;
121+
}
122+
123+
void content_mapnode_get_name_id_mapping(NameIdMapping *nimap)
124+
{
125+
nimap->set(0, "default:stone");
126+
nimap->set(2, "default:water_flowing");
127+
nimap->set(3, "default:torch");
128+
nimap->set(9, "default:water_source");
129+
nimap->set(14, "default:sign_wall");
130+
nimap->set(15, "default:chest");
131+
nimap->set(16, "default:furnace");
132+
nimap->set(17, "default:chest_locked");
133+
nimap->set(21, "default:fence_wood");
134+
nimap->set(30, "default:rail");
135+
nimap->set(31, "default:ladder");
136+
nimap->set(32, "default:lava_flowing");
137+
nimap->set(33, "default:lava_source");
138+
nimap->set(0x800, "default:dirt_with_grass");
139+
nimap->set(0x801, "default:tree");
140+
nimap->set(0x802, "default:leaves");
141+
nimap->set(0x803, "default:dirt_with_grass_footsteps");
142+
nimap->set(0x804, "default:mese");
143+
nimap->set(0x805, "default:dirt");
144+
nimap->set(0x806, "default:cloud");
145+
nimap->set(0x807, "default:coalstone");
146+
nimap->set(0x808, "default:wood");
147+
nimap->set(0x809, "default:sand");
148+
nimap->set(0x80a, "default:cobble");
149+
nimap->set(0x80b, "default:steelblock");
150+
nimap->set(0x80c, "default:glass");
151+
nimap->set(0x80d, "default:mossycobble");
152+
nimap->set(0x80e, "default:gravel");
153+
nimap->set(0x80f, "default:sandstone");
154+
nimap->set(0x810, "default:cactus");
155+
nimap->set(0x811, "default:brick");
156+
nimap->set(0x812, "default:clay");
157+
nimap->set(0x813, "default:papyrus");
158+
nimap->set(0x814, "default:bookshelf");
159+
nimap->set(0x815, "default:jungletree");
160+
nimap->set(0x816, "default:junglegrass");
161+
nimap->set(0x817, "default:nyancat");
162+
nimap->set(0x818, "default:nyancat_rainbow");
163+
nimap->set(0x819, "default:apple");
164+
nimap->set(0x820, "default:sapling");
165+
// Static types
166+
nimap->set(CONTENT_IGNORE, "ignore");
167+
nimap->set(CONTENT_AIR, "air");
168+
}
169+

‎src/content_mapnode.h

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Minetest
3+
Copyright (C) 2010-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+
#ifndef CONTENT_MAPNODE_HEADER
21+
#define CONTENT_MAPNODE_HEADER
22+
23+
#include "mapnode.h"
24+
25+
/*
26+
Legacy node definitions
27+
*/
28+
29+
// Backwards compatibility for non-extended content types in v19
30+
extern content_t trans_table_19[21][2];
31+
MapNode mapnode_translate_to_internal(MapNode n_from, u8 version);
32+
33+
// Get legacy node name mapping for loading old blocks
34+
class NameIdMapping;
35+
void content_mapnode_get_name_id_mapping(NameIdMapping *nimap);
36+
37+
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.