[Scummvm-cvs-logs] CVS: scummvm/saga saveload.cpp,1.12,1.13

Andrew Kurushin h00ligan at users.sourceforge.net
Thu Jun 2 09:20:00 CEST 2005


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26579

Modified Files:
	saveload.cpp 
Log Message:
fix - 'holes' in save slot filenames

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saveload.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- saveload.cpp	31 May 2005 20:08:46 -0000	1.12
+++ saveload.cpp	2 Jun 2005 16:18:44 -0000	1.13
@@ -88,19 +88,27 @@
 }
 
 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 @@
 	while (i < MAX_SAVES) {
 		if (_saveMarks[i]) {
 			name = calcSaveFileName(i);
-			if (!(in = _saveFileMan->openForLoading(name))) {
-				break;
-			}
-			in->read(&header, sizeof(header));
+			if (in = _saveFileMan->openForLoading(name)) {
+				in->read(&header, sizeof(header));
 
-			if (header.type != MKID('SAGA')) {
-				error("SagaEngine::load wrong format");
+				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++;
 	}





More information about the Scummvm-git-logs mailing list