summaryrefslogtreecommitdiff
path: root/src/materials.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-11-15 19:58:36 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-11-29 19:13:44 +0200
commiteed727c61b51f46f6d172c56ecd26a3b1752d449 (patch)
tree0c6efe4379ace6c20f76267cc40ba01a69ef9ecc /src/materials.cpp
parent89e7bacd991060fe6cdada6bf8112f9f20c3e310 (diff)
downloadminetest-eed727c61b51f46f6d172c56ecd26a3b1752d449.tar.gz
minetest-eed727c61b51f46f6d172c56ecd26a3b1752d449.tar.bz2
minetest-eed727c61b51f46f6d172c56ecd26a3b1752d449.zip
Completely generalized mesh generation; ContentFeatures serialization
Diffstat (limited to 'src/materials.cpp')
-rw-r--r--src/materials.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/materials.cpp b/src/materials.cpp
index d89b1e079..72547face 100644
--- a/src/materials.cpp
+++ b/src/materials.cpp
@@ -1,7 +1,49 @@
+/*
+Minetest-c55
+Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
#include "materials.h"
#include "mapnode.h"
#include "nodedef.h"
#include "tooldef.h"
+#include "utility.h"
+
+void MaterialProperties::serialize(std::ostream &os)
+{
+ writeU8(os, 0); // version
+ writeU8(os, diggability);
+ writeF1000(os, weight);
+ writeF1000(os, crackiness);
+ writeF1000(os, crumbliness);
+ writeF1000(os, cuttability);
+}
+
+void MaterialProperties::deSerialize(std::istream &is)
+{
+ int version = readU8(is);
+ if(version != 0)
+ throw SerializationError("unsupported MaterialProperties version");
+ diggability = (enum Diggability)readU8(is);
+ weight = readF1000(is);
+ crackiness = readF1000(is);
+ crumbliness = readF1000(is);
+ cuttability = readF1000(is);
+}
DiggingProperties getDiggingProperties(u16 content, ToolDiggingProperties *tp,
INodeDefManager *nodemgr)