aboutsummaryrefslogtreecommitdiff
path: root/src/mapgen_v6.cpp
Commit message (Expand)AuthorAge
* Add map limit config optionrubenwardy2015-08-02
* Remove profiler.h include where it's not needed. Remove some unreachable and ...Loic Blot2015-07-21
* Mgv6/treegen: (Re)Add fallback nodes for compatibility with subgamesparamat2015-07-13
* Mgv6: Don't create air gap in tundra at y = 48 in custom high terrainparamat2015-06-18
* Mgv6: Enable snowbiomes by default. Double biome noise spread. 3 octaves, 0.5...paramat2015-05-26
* Mapgen v5/6/7: Cleanup node resolver and aliasesparamat2015-05-12
* Mgv6: Fix taiga, allow pine tree spawning on snowblocksparamat2015-04-12
* Mgv6: Add optional snow biomesparamat2015-04-12
* Move globals from main.cpp to more sane locationsCraig Robbins2015-04-01
* Mgv6: Use heightmap in placeTreesAndJungleGrass()paramat2015-03-23
* Mgv6: Remove addDirtGravelBlobs, replaced by blob ore in Minetest Gameparamat2015-03-18
* Mgv6: Fix uninitialised heightmap used by cavegenparamat2015-03-11
* Ensure that heightmap is initialized before useCraig Robbins2015-03-10
* Heightmaps: Fix uninitialised values in mgv5/mgv6. findGroundLevel: Return -M...paramat2015-03-08
* Respect game mapgen flags and save world noise paramsngosang2015-03-07
* For usages of assert() that are meant to persist in Release builds (when NDEB...Craig Robbins2015-03-07
* Fix mapgen using unitialised height map valuesCraig Robbins2015-03-06
* Fix memory leak in MapgenV6Craig Robbins2015-03-05
* Mgv6: Add heightmap. Do not make large caves that are entirely above groundparamat2015-03-02
* Fix all warnings and remove -Wno-unused-but-set cflagkwolekr2015-01-18
* Mapgen V6: Re-enable liquid flowingkwolekr2015-01-07
* Lighting: Fix nearly all issueskwolekr2015-01-04
* MgV5/6/7: Generate dungeons above water levelparamat2015-01-01
* Fix some lingering code style issueskwolekr2014-12-29
* Mapgens: Rename m_emerge to prevent name collisionskwolekr2014-12-12
* Clean up Noise macroskwolekr2014-12-11
* Noise: Automatically transform noise maps if neededkwolekr2014-12-10
* Noise: Create a deep copy of NoiseParamskwolekr2014-12-10
* Add flags and lacunarity as new noise parameterskwolekr2014-12-07
* Rewrite generate notification mechanismkwolekr2014-12-06
* Fix warnings and other misc. minor changeskwolekr2014-11-14
* Add Generator Element Management frameworkkwolekr2014-11-12
* Split up mapgen.cppkwolekr2014-11-01
* mapgen: Resolve nodes in ctor rather than makeChunkkwolekr2014-10-30
* Make flag strings clear specified flag with 'no' prefixkwolekr2014-02-08
* Remove blank default values for emergequeue_limit_* settingskwolekr2014-02-05
* Revert "Fix settings to honor numeric conversion errors"kwolekr2014-02-05
* Fix settings to honor numeric conversion errorssapier2014-02-04
* Huge overhaul of the entire MapgenParams systemkwolekr2014-02-03
* Mapgen V6: Add flag to stop mud flowkwolekr2014-01-12
* Add map feature generation notify Lua APIkwolekr2013-12-14
* Dungeongen: Create dungeon gen tuneables; add desert temples for Mapgen V6kwolekr2013-12-07
* Mapgen V6: Respect water_level settingkwolekr2013-11-21
* Add Lua on_mapgen_init callback, and minetest.set_mapgen_params APIkwolekr2013-06-27
* Decoration: Place decorations in mgv6, check if air or cignore before placementkwolekr2013-06-17
* Add initial Decoration support, many misc. improvements & modificationskwolekr2013-06-17
* Fix nearly all warningskwolekr2013-05-19
* Remove no virtual dtor warnings, make MapgenParams contain actual NoiseParamskwolekr2013-05-19
* Enhance caves for mgv7, add ravineskwolekr2013-04-27
* Class-ify caves & move to cavegen.cpp, fix cave regression, add caves to Mapg...kwolekr2013-04-21
old.meta); os << ") -> (" << serializeJsonString(n_new.name); os << ", " << itos(n_new.param1); os << ", " << itos(n_new.param2); os << ", " << serializeJsonString(n_new.meta); os << ')'; case TYPE_MODIFY_INVENTORY_STACK: os << "modify_inventory_stack ("; os << serializeJsonString(inventory_location); os << ", " << serializeJsonString(inventory_list); os << ", " << inventory_index; os << ", " << (inventory_add ? "add" : "remove"); os << ", " << serializeJsonString(inventory_stack.getItemString()); os << ')'; default: return "<unknown action>"; } return os.str(); } bool RollbackAction::isImportant(IGameDef *gamedef) const { if (type != TYPE_SET_NODE) return true; // If names differ, action is always important if(n_old.name != n_new.name) return true; // If metadata differs, action is always important if(n_old.meta != n_new.meta) return true; const NodeDefManager *ndef = gamedef->ndef(); // Both are of the same name, so a single definition is needed const ContentFeatures &def = ndef->get(n_old.name); // If the type is flowing liquid, action is not important if (def.liquid_type == LIQUID_FLOWING) return false; // Otherwise action is important return true; } bool RollbackAction::getPosition(v3s16 *dst) const { switch (type) { case TYPE_SET_NODE: if (dst) *dst = p; return true; case TYPE_MODIFY_INVENTORY_STACK: { InventoryLocation loc; loc.deSerialize(inventory_location); if (loc.type != InventoryLocation::NODEMETA) { return false; } if (dst) *dst = loc.p; return true; } default: return false; } } bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gamedef) const { try { switch (type) { case TYPE_NOTHING: return true; case TYPE_SET_NODE: { const NodeDefManager *ndef = gamedef->ndef(); // Make sure position is loaded from disk map->emergeBlock(getContainerPos(p, MAP_BLOCKSIZE), false); // Check current node MapNode current_node = map->getNode(p); std::string current_name = ndef->get(current_node).name; // If current node not the new node, it's bad if (current_name != n_new.name) { return false; } // Create rollback node content_t id = CONTENT_IGNORE; if (!ndef->getId(n_old.name, id)) { // The old node is not registered return false; } MapNode n(id, n_old.param1, n_old.param2); // Set rollback node try { if (!map->addNodeWithEvent(p, n)) { infostream << "RollbackAction::applyRevert(): " << "AddNodeWithEvent failed at " << PP(p) << " for " << n_old.name << std::endl; return false; } if (n_old.meta.empty()) { map->removeNodeMetadata(p); } else { NodeMetadata *meta = map->getNodeMetadata(p); if (!meta) { meta = new NodeMetadata(gamedef->idef()); if (!map->setNodeMetadata(p, meta)) { delete meta; infostream << "RollbackAction::applyRevert(): " << "setNodeMetadata failed at " << PP(p) << " for " << n_old.name << std::endl; return false; } } std::istringstream is(n_old.meta, std::ios::binary); meta->deSerialize(is, 1); // FIXME: version bump?? } // Inform other things that the meta data has changed MapEditEvent event; event.type = MEET_BLOCK_NODE_METADATA_CHANGED; event.p = p; map->dispatchEvent(event); } catch (InvalidPositionException &e) { infostream << "RollbackAction::applyRevert(): " << "InvalidPositionException: " << e.what() << std::endl; return false; } // Success return true; } case TYPE_MODIFY_INVENTORY_STACK: { InventoryLocation loc; loc.deSerialize(inventory_location); Inventory *inv = imgr->getInventory(loc); if (!inv) { infostream << "RollbackAction::applyRevert(): Could not get " "inventory at " << inventory_location << std::endl; return false; } InventoryList *list = inv->getList(inventory_list); if (!list) { infostream << "RollbackAction::applyRevert(): Could not get " "inventory list \"" << inventory_list << "\" in " << inventory_location << std::endl; return false; } if (list->getSize() <= inventory_index) { infostream << "RollbackAction::applyRevert(): List index " << inventory_index << " too large in " << "inventory list \"" << inventory_list << "\" in " << inventory_location << std::endl; return false; } // If item was added, take away item, otherwise add removed item if (inventory_add) { // Silently ignore different current item if (list->getItem(inventory_index).name != gamedef->idef()->getAlias(inventory_stack.name)) return false; list->takeItem(inventory_index, inventory_stack.count); } else { list->addItem(inventory_index, inventory_stack); } // Inventory was modified; send to clients imgr->setInventoryModified(loc); return true; } default: errorstream << "RollbackAction::applyRevert(): type not handled" << std::endl; return false; } } catch(SerializationError &e) { errorstream << "RollbackAction::applyRevert(): n_old.name=" << n_old.name << ", SerializationError: " << e.what() << std::endl; } return false; }