diff options
author | kwolekr <kwolekr@minetest.net> | 2015-05-18 22:30:25 -0400 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2015-05-18 22:30:25 -0400 |
commit | 6c5a6967ecc162befc44f1adf15bcc9d11658ff7 (patch) | |
tree | d6a14c632b4f7be47b5d5359067510e129221a5a /src/mapgen.h | |
parent | 497299afd62e2f9b18dbf2a366bb22996e73102b (diff) | |
download | minetest-6c5a6967ecc162befc44f1adf15bcc9d11658ff7.tar.gz minetest-6c5a6967ecc162befc44f1adf15bcc9d11658ff7.tar.bz2 minetest-6c5a6967ecc162befc44f1adf15bcc9d11658ff7.zip |
Split ObjDef/ObjDefManager out to objdef.cpp
Diffstat (limited to 'src/mapgen.h')
-rw-r--r-- | src/mapgen.h | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/src/mapgen.h b/src/mapgen.h index b7fecb7a4..351a09bb2 100644 --- a/src/mapgen.h +++ b/src/mapgen.h @@ -186,72 +186,4 @@ struct MapgenFactory { virtual ~MapgenFactory() {} }; -typedef std::map<std::string, std::string> StringMap; -typedef u32 ObjDefHandle; - -#define OBJDEF_INVALID_INDEX ((u32)(-1)) -#define OBJDEF_INVALID_HANDLE 0 -#define OBJDEF_HANDLE_SALT 0x00585e6fu -#define OBJDEF_MAX_ITEMS (1 << 18) -#define OBJDEF_UID_MASK ((1 << 7) - 1) - -enum ObjDefType { - OBJDEF_GENERIC, - OBJDEF_BIOME, - OBJDEF_ORE, - OBJDEF_DECORATION, - OBJDEF_SCHEMATIC, -}; - -class ObjDef { -public: - virtual ~ObjDef() {} - - u32 index; - u32 uid; - ObjDefHandle handle; - std::string name; -}; - -// WARNING: Ownership of ObjDefs is transferred to the ObjDefManager it is -// added/set to. Note that ObjDefs managed by ObjDefManager are NOT refcounted, -// so the same ObjDef instance must not be referenced multiple -class ObjDefManager { -public: - ObjDefManager(IGameDef *gamedef, ObjDefType type); - virtual ~ObjDefManager(); - - virtual const char *getObjectTitle() const { return "ObjDef"; } - - virtual void clear(); - virtual ObjDef *getByName(const std::string &name) const; - - //// Add new/get/set object definitions by handle - virtual ObjDefHandle add(ObjDef *obj); - virtual ObjDef *get(ObjDefHandle handle) const; - virtual ObjDef *set(ObjDefHandle handle, ObjDef *obj); - - //// Raw variants that work on indexes - virtual u32 addRaw(ObjDef *obj); - - // It is generally assumed that getRaw() will always return a valid object - // This won't be true if people do odd things such as call setRaw() with NULL - virtual ObjDef *getRaw(u32 index) const; - virtual ObjDef *setRaw(u32 index, ObjDef *obj); - - size_t getNumObjects() const { return m_objects.size(); } - ObjDefType getType() const { return m_objtype; } - INodeDefManager *getNodeDef() const { return m_ndef; } - - u32 validateHandle(ObjDefHandle handle) const; - static ObjDefHandle createHandle(u32 index, ObjDefType type, u32 uid); - static bool decodeHandle(ObjDefHandle handle, u32 *index, - ObjDefType *type, u32 *uid); - -protected: - INodeDefManager *m_ndef; - std::vector<ObjDef *> m_objects; - ObjDefType m_objtype; -}; - #endif |