Skip to content

Commit 337e79c

Browse files
committedApr 1, 2015
ObjDefManager, Mapgen SAPI: Huge refactoring
- General code cleanup - Unified object creation and loading - Specifying objects in APIs is now orthogonal (i.e. anything can take an ID, name string, or the raw table definition (and automatically registers if present
1 parent d1d5618 commit 337e79c

File tree

8 files changed

+313
-165
lines changed

8 files changed

+313
-165
lines changed
 

Diff for: ‎doc/lua_api.txt

+2
Original file line numberDiff line numberDiff line change
@@ -3195,6 +3195,7 @@ Definition tables
31953195
biomes = {"Oceanside", "Hills", "Plains"},
31963196
-- ^ List of biomes in which this decoration occurs. Occurs in all biomes if this is omitted,
31973197
-- ^ and ignored if the Mapgen being used does not support biomes.
3198+
-- ^ Can be a list of (or a single) biome names, IDs, or definitions.
31983199
y_min = -31000
31993200
y_max = 31000
32003201
-- ^ Minimum and maximum `y` positions these decorations can be generated at.
@@ -3221,6 +3222,7 @@ Definition tables
32213222
schematic = "foobar.mts",
32223223
-- ^ If schematic is a string, it is the filepath relative to the current working directory of the
32233224
-- ^ specified Minetest schematic file.
3225+
-- ^ - OR -, could be the ID of a previously registered schematic
32243226
-- ^ - OR -, could instead be a table containing two mandatory fields, size and data,
32253227
-- ^ and an optional table yslice_prob:
32263228
schematic = {

Diff for: ‎src/mapgen.h

-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ class ObjDefManager {
213213

214214
virtual const char *getObjectTitle() const = 0;
215215

216-
virtual ObjDef *create(int type) = 0;
217216
virtual void clear();
218217
virtual ObjDef *getByName(const std::string &name) const;
219218

Diff for: ‎src/mg_biome.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ struct NoiseParams;
2626

2727
enum BiomeType
2828
{
29-
BIOME_TYPE_NORMAL,
30-
BIOME_TYPE_LIQUID,
31-
BIOME_TYPE_NETHER,
32-
BIOME_TYPE_AETHER,
33-
BIOME_TYPE_FLAT
29+
BIOME_NORMAL,
30+
BIOME_LIQUID,
31+
BIOME_NETHER,
32+
BIOME_AETHER,
33+
BIOME_FLAT
3434
};
3535

3636
class Biome : public ObjDef, public NodeResolver {
@@ -68,7 +68,7 @@ class BiomeManager : public ObjDefManager {
6868
return "biome";
6969
}
7070

71-
Biome *create(int btt)
71+
static Biome *create(BiomeType type)
7272
{
7373
return new Biome;
7474
}

Diff for: ‎src/mg_decoration.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class DecorationManager : public ObjDefManager {
131131
return "decoration";
132132
}
133133

134-
Decoration *create(int type)
134+
static Decoration *create(DecorationType type)
135135
{
136136
switch (type) {
137137
case DECO_SIMPLE:

Diff for: ‎src/mg_ore.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ class MMVManip;
3939

4040

4141
enum OreType {
42-
ORE_TYPE_SCATTER,
43-
ORE_TYPE_SHEET,
44-
ORE_TYPE_BLOB,
45-
ORE_TYPE_VEIN,
42+
ORE_SCATTER,
43+
ORE_SHEET,
44+
ORE_BLOB,
45+
ORE_VEIN,
4646
};
4747

4848
extern FlagDesc flagdesc_ore[];
@@ -122,16 +122,16 @@ class OreManager : public ObjDefManager {
122122
return "ore";
123123
}
124124

125-
Ore *create(int type)
125+
static Ore *create(OreType type)
126126
{
127127
switch (type) {
128-
case ORE_TYPE_SCATTER:
128+
case ORE_SCATTER:
129129
return new OreScatter;
130-
case ORE_TYPE_SHEET:
130+
case ORE_SHEET:
131131
return new OreSheet;
132-
case ORE_TYPE_BLOB:
132+
case ORE_BLOB:
133133
return new OreBlob;
134-
case ORE_TYPE_VEIN:
134+
case ORE_VEIN:
135135
return new OreVein;
136136
default:
137137
return NULL;

Diff for: ‎src/mg_schematic.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ class NodeResolver;
4141
#define MTSCHEM_PROB_NEVER 0x00
4242
#define MTSCHEM_PROB_ALWAYS 0xFF
4343

44+
enum SchematicType
45+
{
46+
SCHEMATIC_NORMAL,
47+
};
48+
4449

4550
class Schematic : public ObjDef, public NodeResolver {
4651
public:
@@ -83,7 +88,7 @@ class SchematicManager : public ObjDefManager {
8388
return "schematic";
8489
}
8590

86-
Schematic *create(int type)
91+
static Schematic *create(SchematicType type)
8792
{
8893
return new Schematic;
8994
}

0 commit comments

Comments
 (0)
Please sign in to comment.