Fix a plethora of bugs and crashes when loading new savegames; loading now works, though with a few glitches still

This commit is contained in:
2014-04-20 17:43:16 -04:00
parent 3a0f1ad7f5
commit 4cf1c5a8f6
16 changed files with 75 additions and 62 deletions

View File

@@ -368,6 +368,7 @@ void cParty::readFrom(std::istream& file){
bin.str(cur);
while(bin) { // continue as long as no error, such as eof, occurs
getline(bin, cur);
printf("Parsing line in party.txt: %s\n", cur.c_str());
std::istringstream sin(cur);
sin >> cur;
if(cur == "AGE")
@@ -468,7 +469,9 @@ void cParty::readFrom(std::istream& file){
sin >> i;
graphicUsed[i] = true;
}
sin.clear();
}
bin.clear();
while(file) {
getline(file, cur, '\f');
bin.str(cur);
@@ -483,7 +486,6 @@ void cParty::readFrom(std::istream& file){
bin >> i;
horses[i].exists = true;
horses[i].readFrom(bin);
} else if(cur == "MAGICSTORE") {
int i,j;
bin >> i >> j;
@@ -563,6 +565,7 @@ void cParty::readFrom(std::istream& file){
getline(bin, note.the_str1);
getline(bin, note.the_str2);
}
bin.clear();
}
}

View File

@@ -245,10 +245,10 @@ void operator -= (eMainStatus& stat, eMainStatus othr){
}
void cPlayer::writeTo(std::ostream& file){
file << "STATUS main " << main_status << '\n';
file << "STATUS -1 " << main_status << '\n';
file << "NAME " << name << '\n';
file << "SKILL hp " << max_health << '\n';
file << "SKILL sp " << max_sp << '\n';
file << "SKILL -2 " << max_health << '\n';
file << "SKILL -1 " << max_sp << '\n';
for(int i = 0; i < 30; i++)
if(skills[i] > 0)
file << "SKILL " << i << ' ' << skills[i] << '\n';
@@ -292,6 +292,7 @@ void cPlayer::readFrom(std::istream& file){
bin.str(cur);
while(bin) { // continue as long as no error, such as eof, occurs
getline(bin, cur);
printf("Parsing line in pcN.txt: %s\n", cur.c_str());
sin.str(cur);
sin >> cur;
if(cur == "STATUS"){
@@ -352,7 +353,9 @@ void cPlayer::readFrom(std::istream& file){
sin >> race;
else if(cur == "POISON")
sin >> weap_poisoned;
sin.clear();
}
bin.clear();
while(file) {
getline(file, cur, '\f');
bin.str(cur);
@@ -365,7 +368,9 @@ void cPlayer::readFrom(std::istream& file){
sin >> i >> cur;
items[i].readFrom(sin);
}
sin.clear();
}
bin.clear();
}
}

View File

@@ -774,7 +774,9 @@ void cCurTown::readFrom(std::istream& file){
sin >> in_boat;
else if(cur == "AT")
sin >> p_loc.x >> p_loc.y;
sin.clear();
}
bin.clear();
while(file) {
getline(file, cur, '\f');
bin.str(cur);
@@ -807,6 +809,7 @@ void cCurTown::readFrom(std::istream& file){
}
record->readTerrainFrom(bin);
}
bin.clear();
}
}