#include <mg_schematic.h>
Public Member Functions | |
Schematic ()=default | |
virtual | ~Schematic () |
ObjDef * | clone () const |
virtual void | resolveNodeNames () |
bool | loadSchematicFromFile (const std::string &filename, const NodeDefManager *ndef, StringMap *replace_names=NULL) |
bool | saveSchematicToFile (const std::string &filename, const NodeDefManager *ndef) |
bool | getSchematicFromMap (Map *map, v3s16 p1, v3s16 p2) |
bool | deserializeFromMts (std::istream *is) |
bool | serializeToMts (std::ostream *os) const |
bool | serializeToLua (std::ostream *os, bool use_comments, u32 indent_spaces) const |
void | blitToVManip (MMVManip *vm, v3s16 p, Rotation rot, bool force_place) |
bool | placeOnVManip (MMVManip *vm, v3s16 p, u32 flags, Rotation rot, bool force_place) |
void | placeOnMap (ServerMap *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) |
Public Member Functions inherited from ObjDef | |
virtual | ~ObjDef ()=default |
Public Member Functions inherited from NodeResolver | |
NodeResolver () | |
virtual | ~NodeResolver () |
void | cloneTo (NodeResolver *res) const |
bool | getIdFromNrBacklog (content_t *result_out, const std::string &node_alt, content_t c_fallback, bool error_on_fallback=true) |
bool | getIdsFromNrBacklog (std::vector< content_t > *result_out, bool all_required=false, content_t c_fallback=CONTENT_IGNORE) |
bool | isResolveDone () const |
void | reset (bool resolve_done=false) |
Public Attributes | |
std::vector< content_t > | c_nodes |
u32 | flags = 0 |
v3s16 | size |
MapNode * | schemdata = nullptr |
u8 * | slice_probs = nullptr |
Public Attributes inherited from ObjDef | |
u32 | index |
u32 | uid |
ObjDefHandle | handle |
std::string | name |
Public Attributes inherited from NodeResolver | |
std::vector< std::string > | m_nodenames |
std::vector< size_t > | m_nnlistsizes |
Private Member Functions | |
void | condenseContentIds () |
Additional Inherited Members | |
Protected Member Functions inherited from ObjDef | |
void | cloneTo (ObjDef *def) const |
Protected Attributes inherited from NodeResolver | |
const NodeDefManager * | m_ndef = nullptr |
u32 | m_nodenames_idx = 0 |
|
default |
|
virtual |
References schemdata, size, slice_probs, and porting::TrackFreedMemory().
void Schematic::applyProbabilities | ( | v3s16 | p0, |
std::vector< std::pair< v3s16, u8 > > * | plist, | ||
std::vector< std::pair< s16, u8 > > * | splist ) |
References CONTENT_AIR, ObjDef::index, MTSCHEM_PROB_NEVER, p(), MapNode::param1, schemdata, MapNode::setContent(), size, and slice_probs.
Referenced by ModApiMapgen::l_create_schematic().
References VoxelArea::contains(), CONTENT_AIR, CONTENT_IGNORE, MapNode::getContent(), VoxelArea::index(), VoxelManipulator::m_area, VoxelManipulator::m_data, NodeResolver::m_ndef, MTSCHEM_FORCE_PLACE, MTSCHEM_PROB_ALWAYS, MTSCHEM_PROB_MASK, MTSCHEM_PROB_NEVER, myrand_range(), p(), MapNode::param1, ROTATE_180, ROTATE_270, ROTATE_90, MapNode::rotateAlongYAxis(), sanity_check, schemdata, size, slice_probs, and SWAP.
Referenced by DecoSchematic::generate(), placeOnMap(), and placeOnVManip().
|
virtual |
Implements ObjDef.
References Schematic(), c_nodes, NodeResolver::cloneTo(), ObjDef::cloneTo(), FATAL_ERROR_IF, flags, schemdata, size, and slice_probs.
Referenced by DecoSchematic::clone(), and saveSchematicToFile().
|
private |
References NodeDefManager::get(), MapNode::getContent(), NodeResolver::m_ndef, NodeResolver::m_nodenames, ContentFeatures::name, NodeResolver::reset(), schemdata, MapNode::setContent(), and size.
Referenced by saveSchematicToFile().
bool Schematic::deserializeFromMts | ( | std::istream * | is | ) |
References CONTENT_IGNORE, decompress(), MapNode::deSerializeBulk(), deSerializeString16(), errorstream, NodeResolver::m_nnlistsizes, NodeResolver::m_nodenames, MTSCHEM_FILE_SIGNATURE, MTSCHEM_FILE_VER_HIGHEST_READ, MTSCHEM_MAPNODE_SER_FMT_VER, MTSCHEM_PROB_ALWAYS_OLD, MTSCHEM_PROB_NEVER, ObjDef::name, MapNode::param1, readU16(), readU32(), readU8(), readV3S16(), NodeResolver::reset(), schemdata, size, and slice_probs.
Referenced by loadSchematicFromFile(), and TestSchematic::testMtsSerializeDeserialize().
References getNodeBlockPos(), VoxelArea::index(), MMVManip::initialEmerge(), VoxelManipulator::m_area, VoxelManipulator::m_data, MTSCHEM_PROB_ALWAYS, MapNode::param1, NodeResolver::reset(), schemdata, size, and slice_probs.
Referenced by ModApiMapgen::l_create_schematic().
bool Schematic::loadSchematicFromFile | ( | const std::string & | filename, |
const NodeDefManager * | ndef, | ||
StringMap * | replace_names = NULL ) |
References deserializeFromMts(), NodeResolver::m_ndef, NodeResolver::m_nodenames, ObjDef::name, open_ifstream(), and NodeDefManager::pendNodeResolve().
Referenced by load_schematic(), and TestSchematic::testFileSerializeDeserialize().
References voxalgo::blit_back_with_light(), blitToVManip(), DECO_PLACE_CENTER_X, DECO_PLACE_CENTER_Y, DECO_PLACE_CENTER_Z, Map::dispatchEvent(), flags, getNodeBlockPos(), MMVManip::initialEmerge(), NodeResolver::m_ndef, MEET_OTHER, myrand_range(), p(), ROTATE_0, ROTATE_270, ROTATE_90, ROTATE_RAND, sanity_check, schemdata, size, and MapEditEvent::type.
Referenced by ModApiMapgen::l_place_schematic().
References blitToVManip(), VoxelArea::contains(), DECO_PLACE_CENTER_X, DECO_PLACE_CENTER_Y, DECO_PLACE_CENTER_Z, flags, VoxelManipulator::m_area, NodeResolver::m_ndef, myrand_range(), p(), ROTATE_0, ROTATE_270, ROTATE_90, ROTATE_RAND, sanity_check, schemdata, size, and slice_probs.
Referenced by ModApiMapgen::l_place_schematic_on_vmanip().
|
virtual |
Implements NodeResolver.
References c_nodes, CONTENT_AIR, errorstream, MapNode::getContent(), NodeResolver::getIdsFromNrBacklog(), ObjDef::name, schemdata, MapNode::setContent(), and size.
bool Schematic::saveSchematicToFile | ( | const std::string & | filename, |
const NodeDefManager * | ndef ) |
References clone(), condenseContentIds(), NodeResolver::isResolveDone(), NodeResolver::m_ndef, fs::safeWriteToFile(), and serializeToMts().
Referenced by ModApiMapgen::l_create_schematic(), and TestSchematic::testFileSerializeDeserialize().
bool Schematic::serializeToLua | ( | std::ostream * | os, |
bool | use_comments, | ||
u32 | indent_spaces ) const |
References FATAL_ERROR_IF, NodeDefManager::get(), MapNode::getContent(), NodeResolver::isResolveDone(), NodeResolver::m_ndef, NodeResolver::m_nodenames, MTSCHEM_FORCE_PLACE, MTSCHEM_PROB_MASK, ContentFeatures::name, MapNode::param1, MapNode::param2, schemdata, size, and slice_probs.
Referenced by ModApiMapgen::l_serialize_schematic(), and TestSchematic::testLuaTableSerialize().
bool Schematic::serializeToMts | ( | std::ostream * | os | ) | const |
References compress(), NodeResolver::m_nodenames, MTSCHEM_FILE_SIGNATURE, MTSCHEM_FILE_VER_HIGHEST_WRITE, MTSCHEM_MAPNODE_SER_FMT_VER, schemdata, MapNode::serializeBulk(), serializeString16(), size, slice_probs, writeU16(), writeU32(), writeU8(), and writeV3S16().
Referenced by ModApiMapgen::l_serialize_schematic(), saveSchematicToFile(), and TestSchematic::testMtsSerializeDeserialize().
std::vector<content_t> Schematic::c_nodes |
Referenced by clone(), and resolveNodeNames().
u32 Schematic::flags = 0 |
MapNode* Schematic::schemdata = nullptr |
Referenced by ~Schematic(), applyProbabilities(), blitToVManip(), clone(), condenseContentIds(), deserializeFromMts(), getSchematicFromMap(), ModApiMapgen::l_read_schematic(), placeOnMap(), placeOnVManip(), read_schematic_def(), resolveNodeNames(), serializeToLua(), serializeToMts(), TestSchematic::testFileSerializeDeserialize(), TestSchematic::testLuaTableSerialize(), and TestSchematic::testMtsSerializeDeserialize().
v3s16 Schematic::size |
Referenced by ~Schematic(), applyProbabilities(), blitToVManip(), clone(), condenseContentIds(), deserializeFromMts(), DecoSchematic::generate(), getSchematicFromMap(), ModApiMapgen::l_read_schematic(), placeOnMap(), placeOnVManip(), read_schematic_def(), resolveNodeNames(), serializeToLua(), serializeToMts(), TestSchematic::testFileSerializeDeserialize(), TestSchematic::testLuaTableSerialize(), and TestSchematic::testMtsSerializeDeserialize().
u8* Schematic::slice_probs = nullptr |
Referenced by ~Schematic(), applyProbabilities(), blitToVManip(), clone(), deserializeFromMts(), getSchematicFromMap(), ModApiMapgen::l_read_schematic(), placeOnVManip(), read_schematic_def(), serializeToLua(), serializeToMts(), TestSchematic::testFileSerializeDeserialize(), TestSchematic::testLuaTableSerialize(), and TestSchematic::testMtsSerializeDeserialize().