aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-12-04 00:07:02 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-12-04 00:07:02 +0200
commit658d1a72351e178282f2a09f30f05050ac89e862 (patch)
treee7d5b4cabc6d9607b5761b14563302d55537c456
parent4b00d4d9d2158fc65da39179448c03390f094987 (diff)
downloadminetest-658d1a72351e178282f2a09f30f05050ac89e862.tar.gz
minetest-658d1a72351e178282f2a09f30f05050ac89e862.tar.bz2
minetest-658d1a72351e178282f2a09f30f05050ac89e862.zip
Add serialization for node aliases to let client show inventory images correctly
-rw-r--r--src/nodedef.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/nodedef.cpp b/src/nodedef.cpp
index e2e5616f1..35ee291a0 100644
--- a/src/nodedef.cpp
+++ b/src/nodedef.cpp
@@ -311,6 +311,9 @@ public:
void clear()
{
m_name_id_mapping.clear();
+
+ m_aliases.clear();
+
for(u16 i=0; i<=MAX_CONTENT; i++)
{
ContentFeatures &f = m_content_features[i];
@@ -645,6 +648,14 @@ public:
}
writeU16(os, count);
os<<serializeLongString(tmp_os.str());
+
+ writeU16(os, m_aliases.size());
+ for(std::map<std::string, std::string>::const_iterator
+ i = m_aliases.begin(); i != m_aliases.end(); i++)
+ {
+ os<<serializeString(i->first);
+ os<<serializeString(i->second);
+ }
}
void deSerialize(std::istream &is, IGameDef *gamedef)
{
@@ -666,6 +677,15 @@ public:
if(f->name != "")
m_name_id_mapping.set(i, f->name);
}
+
+ u16 num_aliases = readU16(is);
+ if(!is.eof()){
+ for(u16 i=0; i<num_aliases; i++){
+ std::string name = deSerializeString(is);
+ std::string convert_to = deSerializeString(is);
+ m_aliases[name] = convert_to;
+ }
+ }
}
private:
// Features indexed by id