Skip to content

Commit

Permalink
ObjDefManager, Mapgen SAPI: Huge refactoring
Browse files Browse the repository at this point in the history
 - 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
  • Loading branch information
kwolekr committed Apr 1, 2015
1 parent d1d5618 commit 337e79c
Show file tree
Hide file tree
Showing 8 changed files with 313 additions and 165 deletions.
2 changes: 2 additions & 0 deletions doc/lua_api.txt
Expand Up @@ -3195,6 +3195,7 @@ Definition tables
biomes = {"Oceanside", "Hills", "Plains"},
-- ^ List of biomes in which this decoration occurs. Occurs in all biomes if this is omitted,
-- ^ and ignored if the Mapgen being used does not support biomes.
-- ^ Can be a list of (or a single) biome names, IDs, or definitions.
y_min = -31000
y_max = 31000
-- ^ Minimum and maximum `y` positions these decorations can be generated at.
Expand All @@ -3221,6 +3222,7 @@ Definition tables
schematic = "foobar.mts",
-- ^ If schematic is a string, it is the filepath relative to the current working directory of the
-- ^ specified Minetest schematic file.
-- ^ - OR -, could be the ID of a previously registered schematic
-- ^ - OR -, could instead be a table containing two mandatory fields, size and data,
-- ^ and an optional table yslice_prob:
schematic = {
Expand Down
1 change: 0 additions & 1 deletion src/mapgen.h
Expand Up @@ -213,7 +213,6 @@ class ObjDefManager {

virtual const char *getObjectTitle() const = 0;

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

Expand Down
12 changes: 6 additions & 6 deletions src/mg_biome.h
Expand Up @@ -26,11 +26,11 @@ struct NoiseParams;

enum BiomeType
{
BIOME_TYPE_NORMAL,
BIOME_TYPE_LIQUID,
BIOME_TYPE_NETHER,
BIOME_TYPE_AETHER,
BIOME_TYPE_FLAT
BIOME_NORMAL,
BIOME_LIQUID,
BIOME_NETHER,
BIOME_AETHER,
BIOME_FLAT
};

class Biome : public ObjDef, public NodeResolver {
Expand Down Expand Up @@ -68,7 +68,7 @@ class BiomeManager : public ObjDefManager {
return "biome";
}

Biome *create(int btt)
static Biome *create(BiomeType type)
{
return new Biome;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mg_decoration.h
Expand Up @@ -131,7 +131,7 @@ class DecorationManager : public ObjDefManager {
return "decoration";
}

Decoration *create(int type)
static Decoration *create(DecorationType type)
{
switch (type) {
case DECO_SIMPLE:
Expand Down
18 changes: 9 additions & 9 deletions src/mg_ore.h
Expand Up @@ -39,10 +39,10 @@ class MMVManip;


enum OreType {
ORE_TYPE_SCATTER,
ORE_TYPE_SHEET,
ORE_TYPE_BLOB,
ORE_TYPE_VEIN,
ORE_SCATTER,
ORE_SHEET,
ORE_BLOB,
ORE_VEIN,
};

extern FlagDesc flagdesc_ore[];
Expand Down Expand Up @@ -122,16 +122,16 @@ class OreManager : public ObjDefManager {
return "ore";
}

Ore *create(int type)
static Ore *create(OreType type)
{
switch (type) {
case ORE_TYPE_SCATTER:
case ORE_SCATTER:
return new OreScatter;
case ORE_TYPE_SHEET:
case ORE_SHEET:
return new OreSheet;
case ORE_TYPE_BLOB:
case ORE_BLOB:
return new OreBlob;
case ORE_TYPE_VEIN:
case ORE_VEIN:
return new OreVein;
default:
return NULL;
Expand Down
7 changes: 6 additions & 1 deletion src/mg_schematic.h
Expand Up @@ -41,6 +41,11 @@ class NodeResolver;
#define MTSCHEM_PROB_NEVER 0x00
#define MTSCHEM_PROB_ALWAYS 0xFF

enum SchematicType
{
SCHEMATIC_NORMAL,
};


class Schematic : public ObjDef, public NodeResolver {
public:
Expand Down Expand Up @@ -83,7 +88,7 @@ class SchematicManager : public ObjDefManager {
return "schematic";
}

Schematic *create(int type)
static Schematic *create(SchematicType type)
{
return new Schematic;
}
Expand Down

0 comments on commit 337e79c

Please sign in to comment.