From 562ac3bce9fae076562bd2e92e7d330c296ac1b0 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 28 Feb 2012 19:45:23 +0200 Subject: Digging time groups WIP --- src/itemdef.cpp | 62 +++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 24 deletions(-) (limited to 'src/itemdef.cpp') diff --git a/src/itemdef.cpp b/src/itemdef.cpp index 22ca9f088..98232c6d5 100644 --- a/src/itemdef.cpp +++ b/src/itemdef.cpp @@ -22,7 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "gamedef.h" #include "nodedef.h" -#include "materials.h" +#include "tool.h" #include "inventory.h" #ifndef SERVER #include "mapblock_mesh.h" @@ -64,11 +64,12 @@ ItemDefinition& ItemDefinition::operator=(const ItemDefinition &def) stack_max = def.stack_max; usable = def.usable; liquids_pointable = def.liquids_pointable; - if(def.tool_digging_properties) + if(def.tool_capabilities) { - tool_digging_properties = new ToolDiggingProperties( - *def.tool_digging_properties); + tool_capabilities = new ToolCapabilities( + *def.tool_capabilities); } + groups = def.groups; #ifndef SERVER inventory_texture = def.inventory_texture; if(def.wield_mesh) @@ -88,7 +89,7 @@ ItemDefinition::~ItemDefinition() void ItemDefinition::resetInitial() { // Initialize pointers to NULL so reset() does not delete undefined pointers - tool_digging_properties = NULL; + tool_capabilities = NULL; #ifndef SERVER inventory_texture = NULL; wield_mesh = NULL; @@ -107,11 +108,12 @@ void ItemDefinition::reset() stack_max = 99; usable = false; liquids_pointable = false; - if(tool_digging_properties) + if(tool_capabilities) { - delete tool_digging_properties; - tool_digging_properties = NULL; + delete tool_capabilities; + tool_capabilities = NULL; } + groups.clear(); #ifndef SERVER inventory_texture = NULL; @@ -125,7 +127,7 @@ void ItemDefinition::reset() void ItemDefinition::serialize(std::ostream &os) const { - writeU8(os, 0); // version + writeU8(os, 1); // version writeU8(os, type); os<serialize(tmp_os); - tool_digging_properties_s = tmp_os.str(); + tool_capabilities->serialize(tmp_os); + tool_capabilities_s = tmp_os.str(); + } + os<::const_iterator + i = groups.begin(); i != groups.end(); i++){ + os<first); + writeS16(os, i->second); } - os<deSerialize(tmp_is); + std::istringstream tmp_is(tool_capabilities_s, std::ios::binary); + tool_capabilities = new ToolCapabilities; + tool_capabilities->deSerialize(tmp_is); + } + groups.clear(); + u32 groups_size = readU16(is); + for(u32 i=0; iname = ""; hand_def->wield_image = "wieldhand.png"; - hand_def->tool_digging_properties = new ToolDiggingProperties; + hand_def->tool_capabilities = new ToolCapabilities; m_item_definitions.insert(std::make_pair("", hand_def)); ItemDefinition* unknown_def = new ItemDefinition; @@ -273,9 +287,9 @@ public: virtual void registerItem(const ItemDefinition &def) { infostream<<"ItemDefManager: registering \""<