Finish up the bulk of the loading implementation, with some tweaks to saving to make sure it all matches

This commit is contained in:
2014-04-20 15:46:53 -04:00
parent 0c0450f4fe
commit 3a0f1ad7f5
19 changed files with 527 additions and 249 deletions

View File

@@ -60,3 +60,22 @@ void cVehicle::writeTo(std::ostream& file) {
file << "IN " << which_town << '\n';
if(property) file << "OWNED\n";
}
void cVehicle::readFrom(std::istream& file) {
while(file) {
std::string cur;
getline(file, cur);
std::istringstream lineIn(cur);
lineIn >> cur;
if(cur == "LOCATION")
lineIn >> loc.x >> loc.y;
else if(cur == "LOCINSECTOR")
lineIn >> loc_in_sec.x >> loc_in_sec.y;
else if(cur == "SECTOR")
lineIn >> sector.x >> sector.y;
else if(cur == "IN")
lineIn >> which_town;
else if(cur == "OWNED")
property = true;
}
}