]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/mg_schematic.h
src/client/tile.cpp: Fix reference counting
[dragonfireclient.git] / src / mg_schematic.h
index 5b546f879c539fa0e080d438bcd59b5f4609b9af..5c732648edaadd561bf3451af186e08c243ac21f 100644 (file)
@@ -36,7 +36,7 @@ class IGameDef;
 
        All values are stored in big-endian byte order.
        [u32] signature: 'MTSM'
-       [u16] version: 3
+       [u16] version: 4
        [u16] size X
        [u16] size Y
        [u16] size Z
@@ -51,7 +51,9 @@ class IGameDef;
        For each node in schematic:  (for z, y, x)
                [u16] content
        For each node in schematic:
-               [u8] probability of occurance (param1)
+               [u8] param1
+                 bit 0-6: probability
+                 bit 7:   specific node force placement
        For each node in schematic:
                [u8] param2
        }
@@ -60,17 +62,21 @@ class IGameDef;
        1 - Initial version
        2 - Fixed messy never/always place; 0 probability is now never, 0xFF is always
        3 - Added y-slice probabilities; this allows for variable height structures
+       4 - Compressed range of node occurence prob., added per-node force placement bit
 */
 
-/////////////////// Schematic flags
-#define SCHEM_CIDS_UPDATED 0x08
-
+//// Schematic constants
 #define MTSCHEM_FILE_SIGNATURE 0x4d54534d // 'MTSM'
-#define MTSCHEM_FILE_VER_HIGHEST_READ  3
-#define MTSCHEM_FILE_VER_HIGHEST_WRITE 3
+#define MTSCHEM_FILE_VER_HIGHEST_READ  4
+#define MTSCHEM_FILE_VER_HIGHEST_WRITE 4
+
+#define MTSCHEM_PROB_MASK       0x7F
+
+#define MTSCHEM_PROB_NEVER      0x00
+#define MTSCHEM_PROB_ALWAYS     0x7F
+#define MTSCHEM_PROB_ALWAYS_OLD 0xFF
 
-#define MTSCHEM_PROB_NEVER  0x00
-#define MTSCHEM_PROB_ALWAYS 0xFF
+#define MTSCHEM_FORCE_PLACE     0x80
 
 enum SchematicType
 {
@@ -85,26 +91,14 @@ enum SchematicFormatType {
 
 class Schematic : public ObjDef, public NodeResolver {
 public:
-       std::vector<content_t> c_nodes;
-
-       u32 flags;
-       v3s16 size;
-       MapNode *schemdata;
-       u8 *slice_probs;
-
        Schematic();
        virtual ~Schematic();
 
        virtual void resolveNodeNames();
 
-       void updateContentIds();
-
-       void blitToVManip(v3s16 p, MMVManip *vm,
-               Rotation rot, bool force_placement);
-
        bool loadSchematicFromFile(const std::string &filename, INodeDefManager *ndef,
-               StringMap *replace_names);
-       bool saveSchematicToFile(const std::string &filename);
+               StringMap *replace_names=NULL);
+       bool saveSchematicToFile(const std::string &filename, INodeDefManager *ndef);
        bool getSchematicFromMap(Map *map, v3s16 p1, v3s16 p2);
 
        bool deserializeFromMts(std::istream *is, std::vector<std::string> *names);
@@ -112,11 +106,18 @@ class Schematic : public ObjDef, public NodeResolver {
        bool serializeToLua(std::ostream *os, const std::vector<std::string> &names,
                bool use_comments, u32 indent_spaces);
 
-       void placeStructure(Map *map, v3s16 p, u32 flags,
-               Rotation rot, bool force_placement);
+       void blitToVManip(v3s16 p, MMVManip *vm, Rotation rot, bool force_place);
+       void placeStructure(Map *map, v3s16 p, u32 flags, Rotation rot, bool force_place);
+
        void applyProbabilities(v3s16 p0,
                std::vector<std::pair<v3s16, u8> > *plist,
                std::vector<std::pair<s16, u8> > *splist);
+
+       std::vector<content_t> c_nodes;
+       u32 flags;
+       v3s16 size;
+       MapNode *schemdata;
+       u8 *slice_probs;
 };
 
 class SchematicManager : public ObjDefManager {