forked from Mirrorlandia_minetest/minetest
Add serialization for node aliases to let client show inventory images correctly
This commit is contained in:
parent
4b00d4d9d2
commit
658d1a7235
@ -311,6 +311,9 @@ public:
|
|||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
m_name_id_mapping.clear();
|
m_name_id_mapping.clear();
|
||||||
|
|
||||||
|
m_aliases.clear();
|
||||||
|
|
||||||
for(u16 i=0; i<=MAX_CONTENT; i++)
|
for(u16 i=0; i<=MAX_CONTENT; i++)
|
||||||
{
|
{
|
||||||
ContentFeatures &f = m_content_features[i];
|
ContentFeatures &f = m_content_features[i];
|
||||||
@ -645,6 +648,14 @@ public:
|
|||||||
}
|
}
|
||||||
writeU16(os, count);
|
writeU16(os, count);
|
||||||
os<<serializeLongString(tmp_os.str());
|
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)
|
void deSerialize(std::istream &is, IGameDef *gamedef)
|
||||||
{
|
{
|
||||||
@ -666,6 +677,15 @@ public:
|
|||||||
if(f->name != "")
|
if(f->name != "")
|
||||||
m_name_id_mapping.set(i, 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:
|
private:
|
||||||
// Features indexed by id
|
// Features indexed by id
|
||||||
|
Loading…
Reference in New Issue
Block a user