From 8d2d28f1dc575a6ed5e3aeb63a6c1b917813aeb4 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Mon, 14 Nov 2011 23:39:32 +0200 Subject: [PATCH] ToolDefinition serialization --- src/tooldef.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++++++++- src/tooldef.h | 21 +++++++---------- 2 files changed, 67 insertions(+), 14 deletions(-) diff --git a/src/tooldef.cpp b/src/tooldef.cpp index f35cf2b8..93bedf92 100644 --- a/src/tooldef.cpp +++ b/src/tooldef.cpp @@ -20,7 +20,65 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "tooldef.h" #include "irrlichttypes.h" #include "log.h" -#include +#include +#include "utility.h" + +ToolDiggingProperties::ToolDiggingProperties( + float a, float b, float c, float d, float e, + float f, float g, float h, float i, float j): + 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) +{} + +std::string ToolDefinition::dump() +{ + std::ostringstream os(std::ios::binary); + os<<"[ToolDefinition::dump() not implemented due to lazyness]" + < +#include /* TODO: Rename to tooldef.h @@ -40,19 +41,9 @@ struct ToolDiggingProperties float dd_crumbliness; float dd_cuttability; - ToolDiggingProperties(float a=0.75, float b=0, float c=0, float d=0, float e=0, - float f=50, float g=0, float h=0, float i=0, float j=0): - 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) - {} + ToolDiggingProperties( + float a=0.75, float b=0, float c=0, float d=0, float e=0, + float f=50, float g=0, float h=0, float i=0, float j=0); }; struct ToolDefinition @@ -66,6 +57,10 @@ struct ToolDefinition imagename(imagename_), properties(properties_) {} + + std::string dump(); + void serialize(std::ostream &os); + void deSerialize(std::istream &is); }; class IToolDefManager -- 2.30.2