Cleande up the deserialization code
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user