Remove craftdef serialisation

It isn't needed anymore, sending ICraftDefManager over the network has been obsoleted
by protocol version 7.
master
est31 2015-04-21 22:24:45 +02:00
parent 4f851faa91
commit 27e3a353d8
2 changed files with 2 additions and 177 deletions

View File

@ -322,63 +322,6 @@ std::string CraftReplacements::dump() const
return os.str(); return os.str();
} }
void CraftReplacements::serialize(std::ostream &os) const
{
writeU16(os, pairs.size());
for (u32 i=0; i<pairs.size(); i++) {
os << serializeString(pairs[i].first);
os << serializeString(pairs[i].second);
}
}
void CraftReplacements::deSerialize(std::istream &is)
{
pairs.clear();
u32 count = readU16(is);
for (u32 i=0; i<count; i++) {
std::string first = deSerializeString(is);
std::string second = deSerializeString(is);
pairs.push_back(std::make_pair(first, second));
}
}
/*
CraftDefinition
*/
void CraftDefinition::serialize(std::ostream &os) const
{
writeU8(os, 1); // version
os << serializeString(getName());
serializeBody(os);
}
CraftDefinition* CraftDefinition::deSerialize(std::istream &is)
{
int version = readU8(is);
if (version != 1) throw SerializationError(
"unsupported CraftDefinition version");
std::string name = deSerializeString(is);
CraftDefinition *def = NULL;
if (name == "shaped") {
def = new CraftDefinitionShaped;
} else if (name == "shapeless") {
def = new CraftDefinitionShapeless;
} else if (name == "toolrepair") {
def = new CraftDefinitionToolRepair;
} else if (name == "cooking") {
def = new CraftDefinitionCooking;
} else if (name == "fuel") {
def = new CraftDefinitionFuel;
} else {
infostream << "Unknown CraftDefinition name=\""
<< name << '"' << std::endl;
throw SerializationError("Unknown CraftDefinition name");
}
def->deSerializeBody(is, version);
return def;
}
/* /*
CraftDefinitionShaped CraftDefinitionShaped
*/ */
@ -513,29 +456,6 @@ std::string CraftDefinitionShaped::dump() const
return os.str(); return os.str();
} }
void CraftDefinitionShaped::serializeBody(std::ostream &os) const
{
os << serializeString(output);
writeU16(os, width);
writeU16(os, recipe.size());
for (u32 i=0; i<recipe.size(); i++)
os << serializeString(recipe[i]);
replacements.serialize(os);
}
void CraftDefinitionShaped::deSerializeBody(std::istream &is, int version)
{
if (version != 1) throw SerializationError(
"unsupported CraftDefinitionShaped version");
output = deSerializeString(is);
width = readU16(is);
recipe.clear();
u32 count = readU16(is);
for (u32 i=0; i<count; i++)
recipe.push_back(deSerializeString(is));
replacements.deSerialize(is);
}
/* /*
CraftDefinitionShapeless CraftDefinitionShapeless
*/ */
@ -655,27 +575,6 @@ std::string CraftDefinitionShapeless::dump() const
return os.str(); return os.str();
} }
void CraftDefinitionShapeless::serializeBody(std::ostream &os) const
{
os << serializeString(output);
writeU16(os, recipe.size());
for (u32 i=0; i<recipe.size(); i++)
os << serializeString(recipe[i]);
replacements.serialize(os);
}
void CraftDefinitionShapeless::deSerializeBody(std::istream &is, int version)
{
if (version != 1) throw SerializationError(
"unsupported CraftDefinitionShapeless version");
output = deSerializeString(is);
recipe.clear();
u32 count = readU16(is);
for (u32 i=0; i<count; i++)
recipe.push_back(deSerializeString(is));
replacements.deSerialize(is);
}
/* /*
CraftDefinitionToolRepair CraftDefinitionToolRepair
*/ */
@ -773,18 +672,6 @@ std::string CraftDefinitionToolRepair::dump() const
return os.str(); return os.str();
} }
void CraftDefinitionToolRepair::serializeBody(std::ostream &os) const
{
writeF1000(os, additional_wear);
}
void CraftDefinitionToolRepair::deSerializeBody(std::istream &is, int version)
{
if (version != 1) throw SerializationError(
"unsupported CraftDefinitionToolRepair version");
additional_wear = readF1000(is);
}
/* /*
CraftDefinitionCooking CraftDefinitionCooking
*/ */
@ -876,24 +763,6 @@ std::string CraftDefinitionCooking::dump() const
return os.str(); return os.str();
} }
void CraftDefinitionCooking::serializeBody(std::ostream &os) const
{
os << serializeString(output);
os << serializeString(recipe);
writeF1000(os, cooktime);
replacements.serialize(os);
}
void CraftDefinitionCooking::deSerializeBody(std::istream &is, int version)
{
if (version != 1) throw SerializationError(
"unsupported CraftDefinitionCooking version");
output = deSerializeString(is);
recipe = deSerializeString(is);
cooktime = readF1000(is);
replacements.deSerialize(is);
}
/* /*
CraftDefinitionFuel CraftDefinitionFuel
*/ */
@ -983,22 +852,6 @@ std::string CraftDefinitionFuel::dump() const
return os.str(); return os.str();
} }
void CraftDefinitionFuel::serializeBody(std::ostream &os) const
{
os << serializeString(recipe);
writeF1000(os, burntime);
replacements.serialize(os);
}
void CraftDefinitionFuel::deSerializeBody(std::istream &is, int version)
{
if (version != 1) throw SerializationError(
"unsupported CraftDefinitionFuel version");
recipe = deSerializeString(is);
burntime = readF1000(is);
replacements.deSerialize(is);
}
/* /*
Craft definition manager Craft definition manager
*/ */

View File

@ -128,8 +128,6 @@ struct CraftReplacements
pairs(pairs_) pairs(pairs_)
{} {}
std::string dump() const; std::string dump() const;
void serialize(std::ostream &os) const;
void deSerialize(std::istream &is);
}; };
/* /*
@ -141,9 +139,6 @@ public:
CraftDefinition(){} CraftDefinition(){}
virtual ~CraftDefinition(){} virtual ~CraftDefinition(){}
void serialize(std::ostream &os) const;
static CraftDefinition* deSerialize(std::istream &is);
// Returns type of crafting definition // Returns type of crafting definition
virtual std::string getName() const=0; virtual std::string getName() const=0;
@ -164,9 +159,6 @@ public:
virtual void initHash(IGameDef *gamedef) = 0; virtual void initHash(IGameDef *gamedef) = 0;
virtual std::string dump() const=0; virtual std::string dump() const=0;
protected:
virtual void serializeBody(std::ostream &os) const=0;
virtual void deSerializeBody(std::istream &is, int version)=0;
}; };
/* /*
@ -204,10 +196,6 @@ public:
virtual std::string dump() const; virtual std::string dump() const;
protected:
virtual void serializeBody(std::ostream &os) const;
virtual void deSerializeBody(std::istream &is, int version);
private: private:
// Output itemstring // Output itemstring
std::string output; std::string output;
@ -256,10 +244,6 @@ public:
virtual std::string dump() const; virtual std::string dump() const;
protected:
virtual void serializeBody(std::ostream &os) const;
virtual void deSerializeBody(std::istream &is, int version);
private: private:
// Output itemstring // Output itemstring
std::string output; std::string output;
@ -303,10 +287,6 @@ public:
virtual std::string dump() const; virtual std::string dump() const;
protected:
virtual void serializeBody(std::ostream &os) const;
virtual void deSerializeBody(std::istream &is, int version);
private: private:
// This is a constant that is added to the wear of the result. // This is a constant that is added to the wear of the result.
// May be positive or negative, allowed range [-1,1]. // May be positive or negative, allowed range [-1,1].
@ -349,10 +329,6 @@ public:
virtual std::string dump() const; virtual std::string dump() const;
protected:
virtual void serializeBody(std::ostream &os) const;
virtual void deSerializeBody(std::istream &is, int version);
private: private:
// Output itemstring // Output itemstring
std::string output; std::string output;
@ -398,10 +374,6 @@ public:
virtual std::string dump() const; virtual std::string dump() const;
protected:
virtual void serializeBody(std::ostream &os) const;
virtual void deSerializeBody(std::istream &is, int version);
private: private:
// Recipe itemstring // Recipe itemstring
std::string recipe; std::string recipe;