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"
29 class ManualMapVoxelManipulator;
33 /////////////////// Decoration flags
34 #define DECO_PLACE_CENTER_X 1
35 #define DECO_PLACE_CENTER_Y 2
36 #define DECO_PLACE_CENTER_Z 4
37 #define DECO_SCHEM_CIDS_UPDATED 8
40 #define MTSCHEM_FILE_SIGNATURE 0x4d54534d // 'MTSM'
41 #define MTSCHEM_FILE_VER_HIGHEST_READ 3
42 #define MTSCHEM_FILE_VER_HIGHEST_WRITE 3
44 #define MTSCHEM_PROB_NEVER 0x00
45 #define MTSCHEM_PROB_ALWAYS 0xFF
47 extern FlagDesc flagdesc_deco_schematic[];
49 class DecoSchematic : public Decoration {
53 std::vector<content_t> c_nodes;
64 void updateContentIds();
65 virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p);
66 virtual int getHeight();
67 virtual std::string getName();
69 void blitToVManip(v3s16 p, ManualMapVoxelManipulator *vm,
70 Rotation rot, bool force_placement);
72 bool loadSchematicFile(NodeResolver *resolver,
73 std::map<std::string, std::string> &replace_names);
74 void saveSchematicFile(INodeDefManager *ndef);
76 bool getSchematicFromMap(Map *map, v3s16 p1, v3s16 p2);
77 void placeStructure(Map *map, v3s16 p, bool force_placement);
78 void applyProbabilities(v3s16 p0,
79 std::vector<std::pair<v3s16, u8> > *plist,
80 std::vector<std::pair<s16, u8> > *splist);
83 void build_nnlist_and_update_ids(MapNode *nodes, u32 nodecount,
84 std::vector<content_t> *usednodes);