[Scummvm-cvs-logs] scummvm master -> 6b38731d393cdc85937c74b301df5f3b3de5af9e

bluegr md5 at scummvm.org
Mon May 14 10:07:11 CEST 2012


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:
6b38731d39 SCI: Implement savegame deletion functionality in SCI32


Commit: 6b38731d393cdc85937c74b301df5f3b3de5af9e
    https://github.com/scummvm/scummvm/commit/6b38731d393cdc85937c74b301df5f3b3de5af9e
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2012-05-14T01:04:58-07:00

Commit Message:
SCI: Implement savegame deletion functionality in SCI32

This is based on two kernel functions, kMakeSaveCatName and
kMakeSaveFileName

Changed paths:
    engines/sci/engine/kernel.h
    engines/sci/engine/kernel_tables.h
    engines/sci/engine/kfile.cpp
    engines/sci/graphics/text32.cpp



diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index e549c1f..42651ec 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -458,6 +458,8 @@ reg_t kListAllTrue(EngineState *s, int argc, reg_t *argv);
 reg_t kInPolygon(EngineState *s, int argc, reg_t *argv);
 reg_t kObjectIntersect(EngineState *s, int argc, reg_t *argv);
 reg_t kEditText(EngineState *s, int argc, reg_t *argv);
+reg_t kMakeSaveCatName(EngineState *s, int argc, reg_t *argv);
+reg_t kMakeSaveFileName(EngineState *s, int argc, reg_t *argv);
 
 // SCI2.1 Kernel Functions
 reg_t kText(EngineState *s, int argc, reg_t *argv);
diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index 622511c..ff06b79 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -500,6 +500,8 @@ static SciKernelMapEntry s_kernelMap[] = {
 	{ MAP_CALL(UpdateScreenItem),  SIG_EVERYWHERE,           "o",                     NULL,            NULL },
 	{ MAP_CALL(ObjectIntersect),   SIG_EVERYWHERE,           "oo",                    NULL,            NULL },
 	{ MAP_CALL(EditText),          SIG_EVERYWHERE,           "o",                     NULL,            NULL },
+	{ MAP_CALL(MakeSaveCatName),   SIG_EVERYWHERE,           "rr",                    NULL,            NULL },
+	{ MAP_CALL(MakeSaveFileName),  SIG_EVERYWHERE,           "rri",                   NULL,            NULL },
 
 	// SCI2 unmapped functions - TODO!
 
@@ -512,18 +514,6 @@ static SciKernelMapEntry s_kernelMap[] = {
 	// Debug function used to track resources
 	{ MAP_EMPTY(ResourceTrack),     SIG_EVERYWHERE,          "(.*)",                  NULL,            NULL },
 	
-	// SCI2 functions that are used in the original save/load menus. Marked as dummy, so
-	// that the engine errors out on purpose. TODO: Implement once the original save/load
-	// menus are implemented.
-
-	// Creates the name of the save catalogue/directory to save into.
-	// TODO: Implement once the original save/load menus are implemented.
-	{ MAP_DUMMY(MakeSaveCatName),     SIG_EVERYWHERE,          "(.*)",                  NULL,            NULL },
-	
-	// Creates the name of the save file to save into
-	// TODO: Implement once the original save/load menus are implemented.
-	{ MAP_DUMMY(MakeSaveFileName),    SIG_EVERYWHERE,          "(.*)",                  NULL,            NULL },
-
 	// Unused / debug SCI2 unused functions, always mapped to kDummy
 
 	// AddMagnify/DeleteMagnify are both called by script 64979 (the Magnifier
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp
index 3124977..24ef500 100644
--- a/engines/sci/engine/kfile.cpp
+++ b/engines/sci/engine/kfile.cpp
@@ -863,6 +863,10 @@ reg_t kFileIOUnlink(EngineState *s, int argc, reg_t *argv) {
 		int savedir_nr = saves[slotNum].id;
 		name = g_sci->getSavegameName(savedir_nr);
 		result = saveFileMan->removeSavefile(name);
+	} else if (getSciVersion() >= SCI_VERSION_2) {
+		// We don't need to wrap the filename in SCI32 games, as it's already
+		// constructed here
+		result = saveFileMan->removeSavefile(name);
 	} else {
 		const Common::String wrappedName = g_sci->wrapFilename(name);
 		result = saveFileMan->removeSavefile(wrappedName);
@@ -1168,6 +1172,35 @@ reg_t kCD(EngineState *s, int argc, reg_t *argv) {
 	return NULL_REG;
 }
 
+reg_t kMakeSaveCatName(EngineState *s, int argc, reg_t *argv) {
+	// Normally, this creates the name of the save catalogue/directory to save into.
+	// First parameter is the string to save the result into. Second is a string
+	// with game parameters. We don't have a use for this at all, as we have our own
+	// savegame directory management, thus we always return an empty string.
+	return argv[0];
+}
+
+reg_t kMakeSaveFileName(EngineState *s, int argc, reg_t *argv) {
+	// Creates a savegame name from a slot number. Used when deleting saved games.
+	// Param 0: the output buffer (same as in kMakeSaveCatName)
+	// Param 1: a string with game parameters, ignored
+	// Param 2: the selected slot
+
+	SciString *resultString = s->_segMan->lookupString(argv[0]);
+	uint16 saveSlot = argv[2].toUint16();
+	// For some reason, the save slot is incremented by 100... fix it here
+	if (saveSlot > 100)
+		saveSlot -= 100;
+	
+	Common::Array<SavegameDesc> saves;
+	listSavegames(saves);
+
+	Common::String filename = g_sci->getSavegameName(saveSlot);
+	resultString->fromString(filename);
+
+	return argv[0];
+}
+
 reg_t kSave(EngineState *s, int argc, reg_t *argv) {
 	switch (argv[0].toUint16()) {
 	case 0:
@@ -1181,12 +1214,9 @@ reg_t kSave(EngineState *s, int argc, reg_t *argv) {
 	case 5:
 		return kGetSaveFiles(s, argc - 1, argv + 1);
 	case 6:
-		// This is used in Shivers to delete saved games, however it
-		// always passes the same file name (SHIVER), so it doesn't
-		// actually delete anything...
-		// TODO: Check why this happens
-		// argv[1] is a string (most likely the save game directory)
-		return kFileIOUnlink(s, argc - 2, argv + 2);
+		return kMakeSaveCatName(s, argc - 1, argv + 1);
+	case 7:
+		return kMakeSaveFileName(s, argc - 1, argv + 1);
 	case 8:
 		// TODO
 		// This is a timer callback, with 1 parameter: the timer object
diff --git a/engines/sci/graphics/text32.cpp b/engines/sci/graphics/text32.cpp
index 7894c71..cd24ca5 100644
--- a/engines/sci/graphics/text32.cpp
+++ b/engines/sci/graphics/text32.cpp
@@ -187,8 +187,11 @@ void GfxText32::drawTextBitmap(int16 x, int16 y, Common::Rect planeRect, reg_t t
 
 	byte *memoryPtr = _segMan->getHunkPointer(hunkId);
 
-	if (!memoryPtr)
-		error("Attempt to draw an invalid text bitmap");
+	if (!memoryPtr) {
+		// Happens when restoring in some SCI32 games
+		warning("Attempt to draw an invalid text bitmap");
+		return;
+	}
 
 	byte *surface = memoryPtr + BITMAP_HEADER_SIZE;
 






More information about the Scummvm-git-logs mailing list