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

@@ -281,6 +281,7 @@ void cPlayer::writeTo(std::ostream& file){
if(items[i].variety > ITEM_TYPE_NO_ITEM){
file << "ITEM " << i << '\n';
items[i].writeTo(file);
file << '\f';
}
}
@@ -327,10 +328,6 @@ void cPlayer::readFrom(std::istream& file){
int i;
sin >> i;
sin >> status[i];
}else if(cur == "ITEM"){
int i;
sin >> i >> cur;
items[i].readAttrFrom(cur, sin);
}else if(cur == "EQUIP"){
int i;
sin >> i;
@@ -356,6 +353,20 @@ void cPlayer::readFrom(std::istream& file){
else if(cur == "POISON")
sin >> weap_poisoned;
}
while(file) {
getline(file, cur, '\f');
bin.str(cur);
while(bin) {
getline(bin, cur);
sin.str(cur);
sin >> cur;
if(cur == "ITEM") {
int i;
sin >> i >> cur;
items[i].readFrom(sin);
}
}
}
}
std::ostream& operator << (std::ostream& out, eMainStatus& e){