fix - 'holes' in save slot filenames

svn-id: r18312
This commit is contained in:
Andrew Kurushin 2005-06-02 16:18:44 +00:00
parent 0e26360fe3
commit ae36a54c92

View File

@ -88,19 +88,27 @@ bool SagaEngine::locateSaveFile(char *saveName, uint &titleNumber) {
} }
uint SagaEngine::getNewSaveSlotNumber() { uint SagaEngine::getNewSaveSlotNumber() {
uint i; uint i, j;
uint saveCount; bool found;
if (isSaveListFull()) { if (isSaveListFull()) {
error("getNewSaveSlotNumber save list is full"); error("getNewSaveSlotNumber save list is full");
} }
i = 0; for (i = 0; i < MAX_SAVES; i++) {
saveCount = 0; if (_saveMarks[i]) {
while (saveCount < _saveFilesCount) { found = false;
if (_saveMarks[i++]) { for (j = 0; j < _saveFilesCount; j++) {
saveCount++; if (_saveFiles[j].slotNumber == i) {
found = true;
break;
}
}
if (!found) {
return i;
}
} }
} }
return i;
error("getNewSaveSlotNumber save list is full");
} }
void SagaEngine::fillSaveList() { void SagaEngine::fillSaveList() {
@ -128,18 +136,17 @@ void SagaEngine::fillSaveList() {
while (i < MAX_SAVES) { while (i < MAX_SAVES) {
if (_saveMarks[i]) { if (_saveMarks[i]) {
name = calcSaveFileName(i); name = calcSaveFileName(i);
if (!(in = _saveFileMan->openForLoading(name))) { if (in = _saveFileMan->openForLoading(name)) {
break; in->read(&header, sizeof(header));
}
in->read(&header, sizeof(header));
if (header.type != MKID('SAGA')) { if (header.type != MKID('SAGA')) {
error("SagaEngine::load wrong format"); 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++; i++;
} }