aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Kurushin2005-06-02 16:18:44 +0000
committerAndrew Kurushin2005-06-02 16:18:44 +0000
commitae36a54c922aa6e953e0356720b9194901f88cbc (patch)
tree68ccfa65aeacbab63c281249658640b1ac1b4854
parent0e26360fe31dc467955292b097889cf7f1b7eb7a (diff)
downloadscummvm-rg350-ae36a54c922aa6e953e0356720b9194901f88cbc.tar.gz
scummvm-rg350-ae36a54c922aa6e953e0356720b9194901f88cbc.tar.bz2
scummvm-rg350-ae36a54c922aa6e953e0356720b9194901f88cbc.zip
fix - 'holes' in save slot filenames
svn-id: r18312
-rw-r--r--saga/saveload.cpp45
1 files changed, 26 insertions, 19 deletions
diff --git a/saga/saveload.cpp b/saga/saveload.cpp
index a4bea7b657..f87bcf74d0 100644
--- a/saga/saveload.cpp
+++ b/saga/saveload.cpp
@@ -88,19 +88,27 @@ bool SagaEngine::locateSaveFile(char *saveName, uint &titleNumber) {
}
uint SagaEngine::getNewSaveSlotNumber() {
- uint i;
- uint saveCount;
+ uint i, j;
+ bool found;
if (isSaveListFull()) {
error("getNewSaveSlotNumber save list is full");
}
- i = 0;
- saveCount = 0;
- while (saveCount < _saveFilesCount) {
- if (_saveMarks[i++]) {
- saveCount++;
+ for (i = 0; i < MAX_SAVES; i++) {
+ if (_saveMarks[i]) {
+ found = false;
+ for (j = 0; j < _saveFilesCount; j++) {
+ if (_saveFiles[j].slotNumber == i) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ return i;
+ }
}
}
- return i;
+
+ error("getNewSaveSlotNumber save list is full");
}
void SagaEngine::fillSaveList() {
@@ -128,18 +136,17 @@ void SagaEngine::fillSaveList() {
while (i < MAX_SAVES) {
if (_saveMarks[i]) {
name = calcSaveFileName(i);
- if (!(in = _saveFileMan->openForLoading(name))) {
- break;
- }
- in->read(&header, sizeof(header));
-
- if (header.type != MKID('SAGA')) {
- error("SagaEngine::load wrong format");
+ if (in = _saveFileMan->openForLoading(name)) {
+ in->read(&header, sizeof(header));
+
+ if (header.type != MKID('SAGA')) {
+ error("SagaEngine::load wrong format");
+ }
+ strcpy(_saveFiles[_saveFilesCount].name, header.name);
+ _saveFiles[_saveFilesCount].slotNumber = i;
+ delete in;
+ _saveFilesCount++;
}
- strcpy(_saveFiles[_saveFilesCount].name, header.name);
- _saveFiles[_saveFilesCount].slotNumber = i;
- delete in;
- _saveFilesCount++;
}
i++;
}