]> git.lizzy.rs Git - minetest.git/blobdiff - src/mg_schematic.h
Fix memory leaks due to messed up memory handling for particles as well as their...
[minetest.git] / src / mg_schematic.h
index 8a495fef2e1fec2b011219c86b5935ccae3fe96d..ad5afb15f5d3a864032fbc5351b53f5c5b51dfb5 100644 (file)
@@ -26,15 +26,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 class Map;
 class Mapgen;
-class ManualMapVoxelManipulator;
+class MMVManip;
 class PseudoRandom;
 class NodeResolver;
 
-/////////////////// Decoration flags
-#define DECO_PLACE_CENTER_X     1
-#define DECO_PLACE_CENTER_Y     2
-#define DECO_PLACE_CENTER_Z     4
-#define DECO_SCHEM_CIDS_UPDATED 8
+/////////////////// Schematic flags
+#define SCHEM_CIDS_UPDATED 0x08
 
 
 #define MTSCHEM_FILE_SIGNATURE 0x4d54534d // 'MTSM'
@@ -44,44 +41,54 @@ class NodeResolver;
 #define MTSCHEM_PROB_NEVER  0x00
 #define MTSCHEM_PROB_ALWAYS 0xFF
 
-extern FlagDesc flagdesc_deco_schematic[];
 
-class DecoSchematic : public Decoration {
+class Schematic : public GenElement, public NodeResolver {
 public:
-       std::string filename;
-
        std::vector<content_t> c_nodes;
 
        u32 flags;
-       Rotation rotation;
        v3s16 size;
-       MapNode *schematic;
+       MapNode *schemdata;
        u8 *slice_probs;
 
-       DecoSchematic();
-       ~DecoSchematic();
+       Schematic();
+       virtual ~Schematic();
+
+       virtual void resolveNodeNames(NodeResolveInfo *nri);
 
        void updateContentIds();
-       virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p);
-       virtual int getHeight();
-       virtual std::string getName();
 
-       void blitToVManip(v3s16 p, ManualMapVoxelManipulator *vm,
-                                       Rotation rot, bool force_placement);
+       void blitToVManip(v3s16 p, MMVManip *vm,
+               Rotation rot, bool force_placement, INodeDefManager *ndef);
 
-       bool loadSchematicFile(NodeResolver *resolver,
+       bool loadSchematicFromFile(const char *filename, INodeDefManager *ndef,
                std::map<std::string, std::string> &replace_names);
-       void saveSchematicFile(INodeDefManager *ndef);
-
+       void saveSchematicToFile(const char *filename, INodeDefManager *ndef);
        bool getSchematicFromMap(Map *map, v3s16 p1, v3s16 p2);
-       void placeStructure(Map *map, v3s16 p, bool force_placement);
+
+       void placeStructure(Map *map, v3s16 p, u32 flags,
+               Rotation rot, bool force_placement, INodeDefManager *nef);
        void applyProbabilities(v3s16 p0,
                std::vector<std::pair<v3s16, u8> > *plist,
                std::vector<std::pair<s16, u8> > *splist);
 };
 
+class SchematicManager : public GenElementManager {
+public:
+       static const char *ELEMENT_TITLE;
+       static const size_t ELEMENT_LIMIT = 0x10000;
+
+       SchematicManager(IGameDef *gamedef);
+       ~SchematicManager() {}
+
+       Schematic *create(int type)
+       {
+               return new Schematic;
+       }
+};
+
 void build_nnlist_and_update_ids(MapNode *nodes, u32 nodecount,
-                                       std::vector<content_t> *usednodes);
+       std::vector<content_t> *usednodes);
 
 
 #endif