aboutsummaryrefslogtreecommitdiff
path: root/src/nodedef.h
Commit message (Expand)AuthorAge
...
* Refactor decoration-related codekwolekr2014-10-29
* Add NodeResolver documentationkwolekr2014-10-28
* Add NodeResolver and clean up node name -> content ID resolution systemkwolekr2014-10-26
* Custom collision boxes node property.RealBadAngel2014-10-19
* Add meshnode drawtype.RealBadAngel2014-10-18
* Add optional framed glasslike drawtypeBlockMen2014-10-02
* Add firelike drawtypeTriBlade92014-09-21
* Allow use all 6 faces for special tiles.RealBadAngel2014-08-25
* Unite nodes shaders.RealBadAngel2014-06-15
* Shaders rework.RealBadAngel2013-12-03
* Add support for different drowning damage and allow drowning in other nodetypesBlockMen2013-08-06
* Leveled nodebox backward compatibilityproller2013-08-02
* Weather supportproller2013-07-27
* Add liquid_range to nodedefPilzAdam2013-07-20
* Change ContentFeatures array to a vectorKahrl2013-07-14
* Leveled nodeboxproller2013-07-13
* Remove texture atlas / AtlasPointer, rename getTextureRaw to getTextureKahrl2013-07-02
* Add drowningPilzAdam2013-06-19
* Fix compatibility of RBA's NDT_GLASSLIKE_FRAMEDPerttu Ahola2013-04-25
* Add new drawtype GLASSLIKE_FRAMEDRealBadAngel2013-04-24
* Optimize CNodeDefManager::getIdskwolekr2013-03-30
* Include backface_culling flag in serialization format for TileDefsJürgen Doser2013-03-23
* Update Copyright YearsSfan52013-02-24
* Change Minetest-c55 to MinetestPilzAdam2013-02-24
* Disable placement prediction for nodes that use on_rightclickJeija2013-02-19
* Support serialization of protocol 13 ContentFeaturesPerttu Ahola2012-11-29
* Add liquid_renewable property.Ilya Zhuravlev2012-09-07
* Custom boxy nodes (stairs, slabs) and collision changesKahrl2012-06-17
* Optimize headersPerttu Ahola2012-06-17
* Properly and efficiently use split utility headersPerttu Ahola2012-06-17
* Node texture animationPerttu Ahola2012-06-16
* Add after_destruct and cache the existence of on_construct, on_destruct and a...Perttu Ahola2012-06-05
* Switch the license to be LGPLv2/later, with small parts still remaining as GP...Perttu Ahola2012-06-05
* WIP node metadata, node timersKahrl2012-06-03
* Allow group:groupname in ABM definition and implement minetest.hash_node_posi...Perttu Ahola2012-03-31
* Add sound.digPerttu Ahola2012-03-24
* Add sounds, tune thingsPerttu Ahola2012-03-24
* Add event manager and use it to trigger soundsPerttu Ahola2012-03-24
* MapBlockMesh, mesh animation system, urgent mesh updates, athmospheric light,...Kahrl2012-03-15
* itemgroup.h and ItemGroupList typedefPerttu Ahola2012-03-10
* Digging time groups WIPPerttu Ahola2012-03-10
* Node placement / mineral / serialization / iron freq / node_dig callbackKahrl2012-01-22
* The huge item definition and item namespace unification patch (itemdef), see ...Kahrl2012-01-12
* Make ToolItem and MaterialItem to convert names by aliases at creation time t...Perttu Ahola2011-12-04
* Node definition aliasesPerttu Ahola2011-12-03
* Add node definitions in Lua and do not use content_mapnode_init anymore (exce...Kahrl2011-11-29
* Make liquid_alternative_* to be stringsPerttu Ahola2011-11-29
* Store metadata as metadata name in node definitionPerttu Ahola2011-11-29
* Optimize map generator for the dynamic content ids a bitPerttu Ahola2011-11-29
* Improved MaterialItem (stores nodename)Perttu Ahola2011-11-29
"><< serializeJsonString(n_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; }