From 6a76c226e10e92c3e3339096f07f8ab065e2098b Mon Sep 17 00:00:00 2001 From: Kahrl Date: Thu, 12 Jan 2012 06:10:39 +0100 Subject: The huge item definition and item namespace unification patch (itemdef), see http://c55.me/minetest/wiki/doku.php?id=changes:itemdef --- src/materials.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'src/materials.cpp') diff --git a/src/materials.cpp b/src/materials.cpp index d2d37ebf4..146209d58 100644 --- a/src/materials.cpp +++ b/src/materials.cpp @@ -20,7 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "materials.h" #include "mapnode.h" #include "nodedef.h" -#include "tooldef.h" #include "utility.h" void MaterialProperties::serialize(std::ostream &os) @@ -49,6 +48,56 @@ void MaterialProperties::deSerialize(std::istream &is) flammability = readF1000(is); } +ToolDiggingProperties::ToolDiggingProperties(float full_punch_interval_, + float a, float b, float c, float d, float e, + float f, float g, float h, float i, float j): + full_punch_interval(full_punch_interval_), + basetime(a), + dt_weight(b), + dt_crackiness(c), + dt_crumbliness(d), + dt_cuttability(e), + basedurability(f), + dd_weight(g), + dd_crackiness(h), + dd_crumbliness(i), + dd_cuttability(j) +{} + +void ToolDiggingProperties::serialize(std::ostream &os) +{ + writeU8(os, 0); // version + writeF1000(os, full_punch_interval); + writeF1000(os, basetime); + writeF1000(os, dt_weight); + writeF1000(os, dt_crackiness); + writeF1000(os, dt_crumbliness); + writeF1000(os, dt_cuttability); + writeF1000(os, basedurability); + writeF1000(os, dd_weight); + writeF1000(os, dd_crackiness); + writeF1000(os, dd_crumbliness); + writeF1000(os, dd_cuttability); +} + +void ToolDiggingProperties::deSerialize(std::istream &is) +{ + int version = readU8(is); + if(version != 0) throw SerializationError( + "unsupported ToolDiggingProperties version"); + full_punch_interval = readF1000(is); + basetime = readF1000(is); + dt_weight = readF1000(is); + dt_crackiness = readF1000(is); + dt_crumbliness = readF1000(is); + dt_cuttability = readF1000(is); + basedurability = readF1000(is); + dd_weight = readF1000(is); + dd_crackiness = readF1000(is); + dd_crumbliness = readF1000(is); + dd_cuttability = readF1000(is); +} + DiggingProperties getDiggingProperties(const MaterialProperties *mp, const ToolDiggingProperties *tp, float time_from_last_punch) { -- cgit v1.2.3