X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fmg_schematic.cpp;h=8874abd428ac1213b4c4460f7207eff73f45a7e5;hb=2efccb353625de9c25babd0387be23f9d4829871;hp=0b95fa267f7796e9f946d71b2022006be0e6885c;hpb=0aac1b74037ba0f6b0526e81ad0ea7367e31c224;p=dragonfireclient.git diff --git a/src/mg_schematic.cpp b/src/mg_schematic.cpp index 0b95fa267..8874abd42 100644 --- a/src/mg_schematic.cpp +++ b/src/mg_schematic.cpp @@ -1,6 +1,7 @@ /* Minetest -Copyright (C) 2010-2014 kwolekr, Ryan Kwolek +Copyright (C) 2014-2016 kwolekr, Ryan Kwolek +Copyright (C) 2015-2017 paramat 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 @@ -20,7 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include #include "mg_schematic.h" -#include "gamedef.h" +#include "server.h" #include "mapgen.h" #include "emerge.h" #include "map.h" @@ -30,20 +31,21 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "util/serialize.h" #include "serialization.h" #include "filesys.h" +#include "voxelalgorithms.h" /////////////////////////////////////////////////////////////////////////////// -SchematicManager::SchematicManager(IGameDef *gamedef) : - ObjDefManager(gamedef, OBJDEF_SCHEMATIC) +SchematicManager::SchematicManager(Server *server) : + ObjDefManager(server, OBJDEF_SCHEMATIC), + m_server(server) { - m_gamedef = gamedef; } void SchematicManager::clear() { - EmergeManager *emerge = m_gamedef->getEmergeManager(); + EmergeManager *emerge = m_server->getEmergeManager(); // Remove all dangling references in Decorations DecorationManager *decomgr = emerge->decomgr; @@ -54,7 +56,7 @@ void SchematicManager::clear() DecoSchematic *dschem = dynamic_cast(deco); if (dschem) dschem->schematic = NULL; - } catch (std::bad_cast) { + } catch (const std::bad_cast &) { } } @@ -66,12 +68,7 @@ void SchematicManager::clear() Schematic::Schematic() -{ - schemdata = NULL; - slice_probs = NULL; - flags = 0; - size = v3s16(0, 0, 0); -} += default; Schematic::~Schematic() @@ -202,7 +199,7 @@ bool Schematic::placeOnVManip(MMVManip *vm, v3s16 p, u32 flags, return vm->m_area.contains(VoxelArea(p, p + s - v3s16(1,1,1))); } -void Schematic::placeOnMap(Map *map, v3s16 p, u32 flags, +void Schematic::placeOnMap(ServerMap *map, v3s16 p, u32 flags, Rotation rot, bool force_place) { std::map lighting_modified_blocks; @@ -238,15 +235,10 @@ void Schematic::placeOnMap(Map *map, v3s16 p, u32 flags, blitToVManip(&vm, p, rot, force_place); - vm.blitBackAll(&modified_blocks); + voxalgo::blit_back_with_light(map, &vm, &modified_blocks); //// Carry out post-map-modification actions - //// Update lighting - // TODO: Optimize this by using Mapgen::calcLighting() instead - lighting_modified_blocks.insert(modified_blocks.begin(), modified_blocks.end()); - map->updateLighting(lighting_modified_blocks, modified_blocks); - //// Create & dispatch map modification events to observers MapEditEvent event; event.type = MEET_OTHER; @@ -564,14 +556,14 @@ void Schematic::applyProbabilities(v3s16 p0, void generate_nodelist_and_update_ids(MapNode *nodes, size_t nodecount, std::vector *usednodes, INodeDefManager *ndef) { - std::map nodeidmap; + std::unordered_map nodeidmap; content_t numids = 0; for (size_t i = 0; i != nodecount; i++) { content_t id; content_t c = nodes[i].getContent(); - std::map::const_iterator it = nodeidmap.find(c); + std::unordered_map::const_iterator it = nodeidmap.find(c); if (it == nodeidmap.end()) { id = numids; numids++;