[Scummvm-git-logs] scummvm master -> debe25907419990337ae1f631fa04c8615fb68a4

sluicebox 22204938+sluicebox at users.noreply.github.com
Thu Sep 12 21:03:55 CEST 2019


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
698ca464d7 SCI32: Fix loading autosaves (slot 0)
debe259074 SCI32: Fix loading system font for Mac games


Commit: 698ca464d7d9c020374c1c80c98df70150083072
    https://github.com/scummvm/scummvm/commit/698ca464d7d9c020374c1c80c98df70150083072
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2019-09-12T11:58:20-07:00

Commit Message:
SCI32: Fix loading autosaves (slot 0)

Fixes bugs in trac #11029:

- Slot 1 loading when user selects slot 0 in ScummVM UI
- Slot 1 loading when slot 0 specified on command line
- QFG4 slot 0 not appearing in game's original Restore UI

Changed paths:
    engines/sci/engine/file.cpp
    engines/sci/engine/file.h
    engines/sci/engine/guest_additions.cpp
    engines/sci/engine/kfile.cpp


diff --git a/engines/sci/engine/file.cpp b/engines/sci/engine/file.cpp
index c311810..8d93269 100644
--- a/engines/sci/engine/file.cpp
+++ b/engines/sci/engine/file.cpp
@@ -349,9 +349,13 @@ void listSavegames(Common::Array<SavegameDesc> &saves) {
 		const Common::String &filename = *iter;
 
 #ifdef ENABLE_SCI32
-		const int id = strtol(filename.end() - 3, NULL, 10);
-		if (id == kNewGameId || id == kAutoSaveId) {
-			continue;
+		// exclude new game and autosave slots, except for QFG4,
+		//  whose autosave should appear as a normal saved game
+		if (g_sci->getGameId() != GID_QFG4) {
+			const int id = strtol(filename.end() - 3, NULL, 10);
+			if (id == kNewGameId || id == kAutoSaveId) {
+				continue;
+			}
 		}
 #endif
 
diff --git a/engines/sci/engine/file.h b/engines/sci/engine/file.h
index b94caa0..aafa881 100644
--- a/engines/sci/engine/file.h
+++ b/engines/sci/engine/file.h
@@ -47,8 +47,11 @@ enum {
 
 	// SCI engine expects game IDs to start at 0, but slot 0 in ScummVM is
 	// reserved for autosave, so non-autosave games get their IDs shifted up
-	// when saving or restoring, and shifted down when enumerating save games
-	kSaveIdShift = 1
+	// when saving or restoring, and shifted down when enumerating save games.
+	// ScummVM slot 0 can't be shifted down as -1 is an illegal SCI save ID
+	// so it is instead wrapped around to 99 and then back to 0 when shifting up.
+	kSaveIdShift = 1,
+	kMaxShiftedSaveId = 99
 };
 #endif
 
diff --git a/engines/sci/engine/guest_additions.cpp b/engines/sci/engine/guest_additions.cpp
index f07fb4c..7f5a11c 100644
--- a/engines/sci/engine/guest_additions.cpp
+++ b/engines/sci/engine/guest_additions.cpp
@@ -698,13 +698,15 @@ int GuestAdditions::runSaveRestore(const bool isSave, reg_t outDescription, cons
 		description.fromString(descriptionString);
 	}
 
+	// The autosave slot in ScummVM takes up slot 0, but in SCI the first
+	// non-autosave save game number needs to be 0, so reduce the save
+	// number here to match what would come from the normal SCI save/restore
+	// dialog. Wrap slot 0 around to kMaxShiftedSaveId so that it remains
+	// a legal SCI value.
 	if (saveNo > 0) {
-		// The autosave slot in ScummVM takes up slot 0, but in SCI the first
-		// non-autosave save game number needs to be 0, so reduce the save
-		// number here to match what would come from the normal SCI save/restore
-		// dialog. There is additional special code for handling the autosave
-		// game inside of kRestoreGame32.
 		saveNo -= kSaveIdShift;
+	} else if (saveNo == 0) {
+		saveNo = kMaxShiftedSaveId;
 	}
 
 	return saveNo;
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp
index 5edac18..e3d4fb2 100644
--- a/engines/sci/engine/kfile.cpp
+++ b/engines/sci/engine/kfile.cpp
@@ -1333,6 +1333,8 @@ reg_t kSaveGame32(EngineState *s, int argc, reg_t *argv) {
 			// Autosave slot 1 is a "new game" save
 			saveNo = kNewGameId;
 		}
+	} else if (saveNo == kMaxShiftedSaveId) {
+		saveNo = 0;
 	} else {
 		saveNo += kSaveIdShift;
 	}
@@ -1394,6 +1396,8 @@ reg_t kRestoreGame32(EngineState *s, int argc, reg_t *argv) {
 			// Autosave slot 1 is a "new game" save
 			saveNo = kNewGameId;
 		}
+	} else if (saveNo == kMaxShiftedSaveId) {
+		saveNo = 0;
 	} else {
 		saveNo += kSaveIdShift;
 	}
@@ -1419,13 +1423,12 @@ reg_t kCheckSaveGame32(EngineState *s, int argc, reg_t *argv) {
 	int16 saveNo = argv[1].toSint16();
 	const Common::String gameVersion = argv[2].isNull() ? "" : s->_segMan->getString(argv[2]);
 
-	Common::Array<SavegameDesc> saves;
-	listSavegames(saves);
-
 	if (gameName == "Autosave" || gameName == "Autosv") {
 		if (saveNo == 1) {
 			saveNo = kNewGameId;
 		}
+	} else if (saveNo == kMaxShiftedSaveId) {
+		saveNo = 0;
 	} else {
 		saveNo += kSaveIdShift;
 	}
@@ -1488,7 +1491,8 @@ reg_t kGetSaveFiles32(EngineState *s, int argc, reg_t *argv) {
 		// At least Phant2 requires use of strncpy, since it creates save game
 		// names of exactly kMaxSaveNameLength
 		strncpy(target, save.name, kMaxSaveNameLength);
-		saveIds.setFromInt16(i, save.id - kSaveIdShift);
+		int16 sciSaveId = (save.id == 0) ? kMaxShiftedSaveId : (save.id - kSaveIdShift);
+		saveIds.setFromInt16(i, sciSaveId);
 	}
 
 	descriptions.charAt(kMaxSaveNameLength * saves.size()) = '\0';


Commit: debe25907419990337ae1f631fa04c8615fb68a4
    https://github.com/scummvm/scummvm/commit/debe25907419990337ae1f631fa04c8615fb68a4
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2019-09-12T12:02:56-07:00

Commit Message:
SCI32: Fix loading system font for Mac games

Fixes GK1 Mac crash on load due to reading hard-coded
little endian font data as big endian

Changed paths:
    engines/sci/graphics/font.cpp


diff --git a/engines/sci/graphics/font.cpp b/engines/sci/graphics/font.cpp
index 8dd6cbd..97627ec 100644
--- a/engines/sci/graphics/font.cpp
+++ b/engines/sci/graphics/font.cpp
@@ -185,7 +185,7 @@ static const byte sci32SystemFont[] = {
 };
 #endif
 
-	GfxFontFromResource::GfxFontFromResource(ResourceManager *resMan, GfxScreen *screen, GuiResourceId resourceId)
+GfxFontFromResource::GfxFontFromResource(ResourceManager *resMan, GfxScreen *screen, GuiResourceId resourceId)
 	: _resourceId(resourceId), _screen(screen), _resMan(resMan) {
 	if (getSciVersion() < SCI_VERSION_2) {
 		assert(resourceId != -1);
@@ -211,12 +211,22 @@ static const byte sci32SystemFont[] = {
 	}
 #endif
 
-	_numChars = _resourceData.getUint16SE32At(2);
-	_fontHeight = _resourceData.getUint16SE32At(4);
+	if (_resource) {
+		_numChars = _resourceData.getUint16SE32At(2);
+		_fontHeight = _resourceData.getUint16SE32At(4);
+	} else {
+		_numChars = _resourceData.getUint16LEAt(2);
+		_fontHeight = _resourceData.getUint16LEAt(4);
+	}
 	_chars = new Charinfo[_numChars];
 	// filling info for every char
 	for (int16 i = 0; i < _numChars; i++) {
-		_chars[i].offset = _resourceData.getUint16SE32At(6 + i * 2);
+		uint32 charOffsetIndex = 6 + i * 2;
+		if (_resource) {
+			_chars[i].offset = _resourceData.getUint16SE32At(charOffsetIndex);
+		} else {
+			_chars[i].offset = _resourceData.getUint16LEAt(charOffsetIndex);
+		}
 		_chars[i].width = _resourceData.getUint8At(_chars[i].offset);
 		_chars[i].height = _resourceData.getUint8At(_chars[i].offset + 1);
 	}





More information about the Scummvm-git-logs mailing list