Cleande up the deserialization code

This commit is contained in:
Xawotihs
2011-10-02 14:11:30 +00:00
parent 7e1566fe77
commit 86131f7ea0
7 changed files with 22 additions and 220 deletions
-39
View File
@@ -342,42 +342,3 @@ bool Damageable::parseLine(const string& s)
return true;
}
istream& operator>>(istream& in, Damageable& p)
{
string s;
streampos pos = in.tellg();
while(std::getline(in, s))
{
size_t limiter = s.find("=");
if (limiter == string::npos) limiter = s.find(":");
string areaS;
if (limiter != string::npos)
{
areaS = s.substr(0, limiter);
if (areaS.compare("life") == 0)
{
p.life = atoi((s.substr(limiter + 1)).c_str());
}
else if (areaS.compare("poisoncount") == 0)
{
p.poisonCount = atoi((s.substr(limiter + 1)).c_str());
}
else if (areaS.compare("damagecount") == 0)
{
p.damageCount = atoi((s.substr(limiter + 1)).c_str());
}
else if (areaS.compare("preventable") == 0)
{
p.preventable = atoi((s.substr(limiter + 1)).c_str());
}
else
{
in.seekg(pos);
break;
}
}
pos = in.tellg();
}
return in;
}