3 Copyright (C) 2010-2013 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef MG_SCHEMATIC_HEADER
21 #define MG_SCHEMATIC_HEADER
24 #include "mg_decoration.h"
25 #include "util/string.h"
33 /////////////////// Schematic flags
34 #define SCHEM_CIDS_UPDATED 0x08
37 #define MTSCHEM_FILE_SIGNATURE 0x4d54534d // 'MTSM'
38 #define MTSCHEM_FILE_VER_HIGHEST_READ 3
39 #define MTSCHEM_FILE_VER_HIGHEST_WRITE 3
41 #define MTSCHEM_PROB_NEVER 0x00
42 #define MTSCHEM_PROB_ALWAYS 0xFF
45 class Schematic : public GenElement, public NodeResolver {
47 std::vector<content_t> c_nodes;
57 virtual void resolveNodeNames(NodeResolveInfo *nri);
59 void updateContentIds();
61 void blitToVManip(v3s16 p, MMVManip *vm,
62 Rotation rot, bool force_placement, INodeDefManager *ndef);
64 bool loadSchematicFromFile(const char *filename, INodeDefManager *ndef,
65 std::map<std::string, std::string> &replace_names);
66 void saveSchematicToFile(const char *filename, INodeDefManager *ndef);
67 bool getSchematicFromMap(Map *map, v3s16 p1, v3s16 p2);
69 void placeStructure(Map *map, v3s16 p, u32 flags,
70 Rotation rot, bool force_placement, INodeDefManager *nef);
71 void applyProbabilities(v3s16 p0,
72 std::vector<std::pair<v3s16, u8> > *plist,
73 std::vector<std::pair<s16, u8> > *splist);
76 class SchematicManager : public GenElementManager {
78 static const char *ELEMENT_TITLE;
79 static const size_t ELEMENT_LIMIT = 0x10000;
81 SchematicManager(IGameDef *gamedef);
82 ~SchematicManager() {}
84 Schematic *create(int type)
90 void build_nnlist_and_update_ids(MapNode *nodes, u32 nodecount,
91 std::vector<content_t> *usednodes);