2014-11-01 18:16:23 +01:00
|
|
|
/*
|
|
|
|
Minetest
|
|
|
|
Copyright (C) 2010-2013 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MG_SCHEMATIC_HEADER
|
|
|
|
#define MG_SCHEMATIC_HEADER
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include "mg_decoration.h"
|
|
|
|
#include "util/string.h"
|
|
|
|
|
|
|
|
class Map;
|
|
|
|
class Mapgen;
|
2015-01-05 08:42:27 +01:00
|
|
|
class MMVManip;
|
2014-11-01 18:16:23 +01:00
|
|
|
class PseudoRandom;
|
|
|
|
class NodeResolver;
|
|
|
|
|
2014-11-13 05:01:13 +01:00
|
|
|
/////////////////// Schematic flags
|
|
|
|
#define SCHEM_CIDS_UPDATED 0x08
|
2014-11-01 18:16:23 +01:00
|
|
|
|
|
|
|
|
|
|
|
#define MTSCHEM_FILE_SIGNATURE 0x4d54534d // 'MTSM'
|
|
|
|
#define MTSCHEM_FILE_VER_HIGHEST_READ 3
|
|
|
|
#define MTSCHEM_FILE_VER_HIGHEST_WRITE 3
|
|
|
|
|
|
|
|
#define MTSCHEM_PROB_NEVER 0x00
|
|
|
|
#define MTSCHEM_PROB_ALWAYS 0xFF
|
|
|
|
|
|
|
|
|
2015-03-31 05:40:35 +02:00
|
|
|
class Schematic : public ObjDef, public NodeResolver {
|
2014-11-01 18:16:23 +01:00
|
|
|
public:
|
|
|
|
std::vector<content_t> c_nodes;
|
|
|
|
|
|
|
|
u32 flags;
|
|
|
|
v3s16 size;
|
2014-11-13 05:01:13 +01:00
|
|
|
MapNode *schemdata;
|
2014-11-01 18:16:23 +01:00
|
|
|
u8 *slice_probs;
|
|
|
|
|
2014-11-13 05:01:13 +01:00
|
|
|
Schematic();
|
2014-12-17 09:20:17 +01:00
|
|
|
virtual ~Schematic();
|
|
|
|
|
|
|
|
virtual void resolveNodeNames(NodeResolveInfo *nri);
|
2014-11-01 18:16:23 +01:00
|
|
|
|
|
|
|
void updateContentIds();
|
|
|
|
|
2015-01-05 08:42:27 +01:00
|
|
|
void blitToVManip(v3s16 p, MMVManip *vm,
|
2014-11-13 05:01:13 +01:00
|
|
|
Rotation rot, bool force_placement, INodeDefManager *ndef);
|
2014-11-01 18:16:23 +01:00
|
|
|
|
2014-12-17 09:20:17 +01:00
|
|
|
bool loadSchematicFromFile(const char *filename, INodeDefManager *ndef,
|
2015-03-31 05:40:35 +02:00
|
|
|
StringMap *replace_names);
|
2014-11-13 05:01:13 +01:00
|
|
|
void saveSchematicToFile(const char *filename, INodeDefManager *ndef);
|
2014-11-01 18:16:23 +01:00
|
|
|
bool getSchematicFromMap(Map *map, v3s16 p1, v3s16 p2);
|
2014-11-13 05:01:13 +01:00
|
|
|
|
|
|
|
void placeStructure(Map *map, v3s16 p, u32 flags,
|
|
|
|
Rotation rot, bool force_placement, INodeDefManager *nef);
|
2014-11-01 18:16:23 +01:00
|
|
|
void applyProbabilities(v3s16 p0,
|
|
|
|
std::vector<std::pair<v3s16, u8> > *plist,
|
|
|
|
std::vector<std::pair<s16, u8> > *splist);
|
|
|
|
};
|
|
|
|
|
2015-03-31 05:40:35 +02:00
|
|
|
class SchematicManager : public ObjDefManager {
|
2014-11-13 05:01:13 +01:00
|
|
|
public:
|
2014-12-12 20:07:49 +01:00
|
|
|
SchematicManager(IGameDef *gamedef);
|
2014-11-13 05:01:13 +01:00
|
|
|
~SchematicManager() {}
|
|
|
|
|
2015-03-31 05:40:35 +02:00
|
|
|
const char *getObjectTitle() const
|
|
|
|
{
|
|
|
|
return "schematic";
|
|
|
|
}
|
|
|
|
|
2014-11-13 05:01:13 +01:00
|
|
|
Schematic *create(int type)
|
|
|
|
{
|
|
|
|
return new Schematic;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-11-01 18:16:23 +01:00
|
|
|
void build_nnlist_and_update_ids(MapNode *nodes, u32 nodecount,
|
2014-12-17 09:20:17 +01:00
|
|
|
std::vector<content_t> *usednodes);
|
2014-11-01 18:16:23 +01:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|