[Scummvm-cvs-logs] scummvm master -> dfc87237264a76e820015bd9f7ebc8c1e5583d2c

clone2727 clone2727 at gmail.com
Sat Apr 2 07:02:18 CEST 2011


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

Summary:
dfc8723726 SCUMM: Add support for append mode to o72_openFile()


Commit: dfc87237264a76e820015bd9f7ebc8c1e5583d2c
    https://github.com/scummvm/scummvm/commit/dfc87237264a76e820015bd9f7ebc8c1e5583d2c
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-04-01T21:59:29-07:00

Commit Message:
SCUMM: Add support for append mode to o72_openFile()

The baseball2001 hall of fame data saves properly now

Changed paths:
    engines/scumm/he/script_v72he.cpp



diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp
index 25f5f3d..8aaf16e 100644
--- a/engines/scumm/he/script_v72he.cpp
+++ b/engines/scumm/he/script_v72he.cpp
@@ -1408,24 +1408,49 @@ void ScummEngine_v72he::o72_openFile() {
 
 	if (slot != -1) {
 		switch (mode) {
-		case 1:
+		case 1:   // Read mode
 			if (!_saveFileMan->listSavefiles(filename).empty()) {
 				_hInFileTable[slot] = _saveFileMan->openForLoading(filename);
 			} else {
 				_hInFileTable[slot] = SearchMan.createReadStreamForMember(filename);
 			}
 			break;
-		case 2:
+		case 2:   // Write mode
 			if (!strchr(filename, '/')) {
 				_hOutFileTable[slot] = _saveFileMan->openForSaving(filename);
 			}
 			break;
-		case 6:
-			// FIXME: Appending to saved game file is not supported right now
-			// This is used in several Backyard Sports games. The stub is required for
-			// baseball2001 to continue after trying to save Hall of Fame data.
-			slot = -1;
-			break;
+		case 6: { // Append mode
+			if (strchr(filename, '/'))
+				break;
+
+			// First check if the file already exists
+			Common::InSaveFile *initialState = 0;
+			if (!_saveFileMan->listSavefiles(filename).empty())
+				initialState = _saveFileMan->openForLoading(filename);
+			else
+				initialState = SearchMan.createReadStreamForMember(filename);
+
+			// Read in the data from the initial file
+			uint32 initialSize = 0;
+			byte *initialData = 0;
+			if (initialState) {
+				initialSize = initialState->size();
+				initialData = new byte[initialSize];
+				initialState->read(initialData, initialSize);
+				delete initialState;
+			}
+
+			// Attempt to open a save file
+			_hOutFileTable[slot] = _saveFileMan->openForSaving(filename);
+
+			// Begin us off with the data from the previous file
+			if (_hOutFileTable[slot] && initialData) {
+				_hOutFileTable[slot]->write(initialData, initialSize);
+				delete[] initialData;
+			}
+			
+			} break;
 		default:
 			error("o72_openFile(): wrong open file mode %d", mode);
 		}






More information about the Scummvm-git-logs mailing list