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

csnover csnover at users.noreply.github.com
Mon Sep 4 03:59:08 CEST 2017


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

Summary:
d2b4e16ab2 SDL: Fix unsafe sprintf usage
43a07abb46 SCI32: Implement kCelLink
7545bb7133 SCI32: Clip videos to the screen
ebd5139653 SCI32: Fix crash after credits in Lighthouse
768d698434 SCI32: Add standard SRDialog patches to Lighthouse
08a717530d SCI32: Correct LSL7 demo GUIOs
439a026844 SCI32: Fix Lighthouse GUIOs
cc3088c529 SCI32: Make audio resource size mismatch non-fatal
be64c6ba8b SCI32: Fix closing a Robot when its Plane has been destroyed already
6e35676a9e SCI32: Fix load from launcher for Lighthouse
aa20284027 SCI32: Ignore bad audio map entries on GK2 DE CD 6
d6139890fe SCI32: Exit early from screen shake if engine is quitting


Commit: d2b4e16ab2bd28ce8b39a6330683228bd48950c2
    https://github.com/scummvm/scummvm/commit/d2b4e16ab2bd28ce8b39a6330683228bd48950c2
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-03T20:00:23-05:00

Commit Message:
SDL: Fix unsafe sprintf usage

Translation strings come from external data sources and can cause
a stack buffer overflow here just by accidentally (or maliciously)
being too long.

Changed paths:
    backends/graphics/surfacesdl/surfacesdl-graphics.cpp


diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index 180ab42..f84c09f 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -2446,20 +2446,20 @@ bool SurfaceSdlGraphicsManager::handleScalerHotkeys(Common::KeyCode key) {
 			setFeatureState(OSystem::kFeatureAspectRatioCorrection, !_videoMode.aspectRatioCorrection);
 		endGFXTransaction();
 #ifdef USE_OSD
-		char buffer[128];
+		Common::String message;
 		if (_videoMode.aspectRatioCorrection)
-			sprintf(buffer, "%s\n%d x %d -> %d x %d",
+			message = Common::String::format("%s\n%d x %d -> %d x %d",
 				_("Enabled aspect ratio correction"),
 				_videoMode.screenWidth, _videoMode.screenHeight,
 				_hwscreen->w, _hwscreen->h
 				);
 		else
-			sprintf(buffer, "%s\n%d x %d -> %d x %d",
+			message = Common::String::format("%s\n%d x %d -> %d x %d",
 				_("Disabled aspect ratio correction"),
 				_videoMode.screenWidth, _videoMode.screenHeight,
 				_hwscreen->w, _hwscreen->h
 				);
-		displayMessageOnOSD(buffer);
+		displayMessageOnOSD(message.c_str());
 #endif
 		internUpdateScreen();
 		return true;
@@ -2526,14 +2526,13 @@ bool SurfaceSdlGraphicsManager::handleScalerHotkeys(Common::KeyCode key) {
 			g++;
 		}
 		if (newScalerName) {
-			char buffer[128];
-			sprintf(buffer, "%s %s\n%d x %d -> %d x %d",
+			const Common::String message = Common::String::format(
+				"%s %s\n%d x %d -> %d x %d",
 				_("Active graphics filter:"),
 				newScalerName,
 				_videoMode.screenWidth, _videoMode.screenHeight,
-				_hwscreen->w, _hwscreen->h
-				);
-			displayMessageOnOSD(buffer);
+				_hwscreen->w, _hwscreen->h);
+			displayMessageOnOSD(message.c_str());
 		}
 #endif
 		internUpdateScreen();


Commit: 43a07abb46cc55d09f7415090f9f53c068c856aa
    https://github.com/scummvm/scummvm/commit/43a07abb46cc55d09f7415090f9f53c068c856aa
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-03T20:58:07-05:00

Commit Message:
SCI32: Implement kCelLink

kCelLink exists in SSCI since 2.1mid, but it is only known to be
used in Lighthouse, during the weapon creation puzzle near the end
of the game.

Changed paths:
    engines/sci/engine/kernel.h
    engines/sci/engine/kernel_tables.h
    engines/sci/engine/kgraphics32.cpp
    engines/sci/graphics/celobj32.cpp
    engines/sci/graphics/celobj32.h


diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index d1dce37..baa8916 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -636,6 +636,9 @@ reg_t kCelInfo(EngineState *s, int argc, reg_t *argv);
 reg_t kCelInfoGetOriginX(EngineState *s, int argc, reg_t *argv);
 reg_t kCelInfoGetOriginY(EngineState *s, int argc, reg_t *argv);
 reg_t kCelInfoGetPixel(EngineState *s, int argc, reg_t *argv);
+reg_t kCelLink(EngineState *s, int argc, reg_t *argv);
+reg_t kCelLinkGetX(EngineState *s, int argc, reg_t *argv);
+reg_t kCelLinkGetY(EngineState *s, int argc, reg_t *argv);
 
 reg_t kSetLanguage(EngineState *s, int argc, reg_t *argv);
 reg_t kScrollWindow(EngineState *s, int argc, reg_t *argv);
diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index c653564..ac93219 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -575,6 +575,16 @@ static const SciKernelMapSubEntry kCelInfo_subops[] = {
 };
 
 //    version,         subId, function-mapping,                    signature,              workarounds
+static const SciKernelMapSubEntry kCelLink_subops[] = {
+	{ SIG_SINCE_SCI21MID,  0, MAP_DUMMY(CelLink0),                 "",                     NULL },
+	{ SIG_SINCE_SCI21MID,  1, MAP_DUMMY(CelLink1),                 "",                     NULL },
+	{ SIG_SINCE_SCI21MID,  2, MAP_CALL(CelLinkGetX),               "iiii",                 NULL },
+	{ SIG_SINCE_SCI21MID,  3, MAP_CALL(CelLinkGetY),               "iiii",                 NULL },
+	{ SIG_SINCE_SCI21MID,  4, MAP_DUMMY(CelLink4),                 "",                     NULL },
+	SCI_SUBOPENTRY_TERMINATOR
+};
+
+//    version,         subId, function-mapping,                    signature,              workarounds
 static const SciKernelMapSubEntry kScrollWindow_subops[] = {
 	{ SIG_SCI32,           0, MAP_CALL(ScrollWindowCreate),        "oi",                   NULL },
 	{ SIG_SCI32,           1, MAP_CALL(ScrollWindowAdd),           "iriii(i)",             kScrollWindowAdd_workarounds },
@@ -988,7 +998,7 @@ static SciKernelMapEntry s_kernelMap[] = {
 	{ MAP_DUMMY(FindClass),         SIG_EVERYWHERE,           "(.*)",                 NULL,            NULL },
 	{ MAP_DUMMY(CelRect),           SIG_EVERYWHERE,           "(.*)",                 NULL,            NULL },
 	{ MAP_DUMMY(BaseLineSpan),      SIG_EVERYWHERE,           "(.*)",                 NULL,            NULL },
-	{ MAP_DUMMY(CelLink),           SIG_EVERYWHERE,           "(.*)",                 NULL,            NULL },
+	{ MAP_CALL(CelLink),            SIG_SINCE_SCI21MID, SIGFOR_ALL, "(.*)",           kCelLink_subops, NULL },
 	{ MAP_DUMMY(AddPolygon),        SIG_EVERYWHERE,           "(.*)",                 NULL,            NULL },
 	{ MAP_DUMMY(DeletePolygon),     SIG_EVERYWHERE,           "(.*)",                 NULL,            NULL },
 	{ MAP_DUMMY(UpdatePolygon),     SIG_EVERYWHERE,           "(.*)",                 NULL,            NULL },
diff --git a/engines/sci/engine/kgraphics32.cpp b/engines/sci/engine/kgraphics32.cpp
index 44a3517..c07282f 100644
--- a/engines/sci/engine/kgraphics32.cpp
+++ b/engines/sci/engine/kgraphics32.cpp
@@ -449,6 +449,23 @@ reg_t kCelInfoGetPixel(EngineState *s, int argc, reg_t *argv) {
 	return make_reg(0, view.readPixel(argv[3].toSint16(), argv[4].toSint16(), view._mirrorX));
 }
 
+// Used by Lighthouse, room 800, script 16, when in the weapon-building puzzle
+reg_t kCelLink(EngineState *s, int argc, reg_t *argv) {
+	if (!s)
+		return make_reg(0, getSciVersion());
+	error("not supposed to call this");
+}
+
+reg_t kCelLinkGetX(EngineState *s, int argc, reg_t *argv) {
+	CelObjView view(argv[0].toUint16(), argv[1].toSint16(), argv[2].toSint16());
+	return make_reg(0, view.getLinkPosition(argv[3].toSint16()).x);
+}
+
+reg_t kCelLinkGetY(EngineState *s, int argc, reg_t *argv) {
+	CelObjView view(argv[0].toUint16(), argv[1].toSint16(), argv[2].toSint16());
+	return make_reg(0, view.getLinkPosition(argv[3].toSint16()).y);
+}
+
 reg_t kScrollWindow(EngineState *s, int argc, reg_t *argv) {
 	if (!s)
 		return make_reg(0, getSciVersion());
diff --git a/engines/sci/graphics/celobj32.cpp b/engines/sci/graphics/celobj32.cpp
index 49b3b00..687ecd6 100644
--- a/engines/sci/graphics/celobj32.cpp
+++ b/engines/sci/graphics/celobj32.cpp
@@ -1081,6 +1081,38 @@ const SciSpan<const byte> CelObjView::getResPointer() const {
 	return *resource;
 }
 
+Common::Point CelObjView::getLinkPosition(const int16 linkId) const {
+	const SciSpan<const byte> resource = getResPointer();
+
+	if (resource[18] < 0x84) {
+		error("%s unsupported version %u for Links", _info.toString().c_str(), resource[18]);
+	}
+
+	const SciSpan<const byte> celHeader = resource.subspan(_celHeaderOffset);
+	const int16 numLinks = celHeader.getInt16SEAt(40);
+
+	if (numLinks) {
+		const int recordSize = 6;
+		SciSpan<const byte> linkTable = resource.subspan(celHeader.getInt32SEAt(36), recordSize * numLinks);
+		for (int16 i = 0; i < numLinks; ++i) {
+			if (linkTable[4] == linkId) {
+				Common::Point point;
+				point.x = linkTable.getInt16SEAt(0);
+				if (_mirrorX) {
+					// NOTE: SSCI had an off-by-one error here (missing -1)
+					point.x = _width - point.x - 1;
+				}
+				point.y = linkTable.getInt16SEAt(2);
+				return point;
+			}
+
+			linkTable += recordSize;
+		}
+	}
+
+	return Common::Point(-1, -1);
+}
+
 #pragma mark -
 #pragma mark CelObjPic
 
diff --git a/engines/sci/graphics/celobj32.h b/engines/sci/graphics/celobj32.h
index d519134..6e50f72 100644
--- a/engines/sci/graphics/celobj32.h
+++ b/engines/sci/graphics/celobj32.h
@@ -540,6 +540,8 @@ public:
 
 	virtual CelObjView *duplicate() const override;
 	virtual const SciSpan<const byte> getResPointer() const override;
+
+	Common::Point getLinkPosition(const int16 linkId) const;
 };
 
 #pragma mark -


Commit: 7545bb7133099400245ef5db5cecc015e57acd56
    https://github.com/scummvm/scummvm/commit/7545bb7133099400245ef5db5cecc015e57acd56
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-03T20:58:07-05:00

Commit Message:
SCI32: Clip videos to the screen

This is needed for 8.VMD in Lighthouse (room 380, the credits
room), which is rendered partially off the bottom of the screen.
OSystem does not accept rects that are offscreen.

Technically this video probably should not have been doubled
vertically by game scripts, but there is not enough space to fix
the rendering with a regular script patch, and it is a very
unimportant video.

Changed paths:
    engines/sci/graphics/video32.cpp
    engines/sci/graphics/video32.h


diff --git a/engines/sci/graphics/video32.cpp b/engines/sci/graphics/video32.cpp
index 2b1f721..c9c48eb 100644
--- a/engines/sci/graphics/video32.cpp
+++ b/engines/sci/graphics/video32.cpp
@@ -252,7 +252,7 @@ void VideoPlayer::renderFrame(const Graphics::Surface &nextFrame) const {
 		freeConvertedFrame = true;
 	}
 
-	g_system->copyRectToScreen(convertedFrame->getPixels(), convertedFrame->pitch, _drawRect.left, _drawRect.top, convertedFrame->w, convertedFrame->h);
+	g_system->copyRectToScreen(convertedFrame->getPixels(), convertedFrame->pitch, _drawRect.left, _drawRect.top, _drawRect.width(), _drawRect.height());
 	g_sci->_gfxFrameout->updateScreen();
 
 	if (freeConvertedFrame) {
@@ -285,6 +285,14 @@ void VideoPlayer::renderLQToSurface(Graphics::Surface &out, const Graphics::Surf
 	}
 }
 
+void VideoPlayer::setDrawRect(const int16 x, const int16 y, const int16 width, const int16 height) {
+	_drawRect = Common::Rect(x, y, x + width, y + height);
+	if (_drawRect.right > g_system->getWidth() || _drawRect.bottom > g_system->getHeight()) {
+		warning("Draw rect (%d, %d, %d, %d) is out of bounds of the screen; clipping it", PRINT_RECT(_drawRect));
+		_drawRect.clip(g_system->getWidth(), g_system->getHeight());
+	}
+}
+
 #pragma mark SEQPlayer
 
 SEQPlayer::SEQPlayer(EventManager *eventMan) :
@@ -566,10 +574,9 @@ void VMDPlayer::init(int16 x, const int16 y, const PlayFlags flags, const int16
 #endif
 	_stretchVertical = flags & kPlayFlagStretchVertical;
 
-	_drawRect = Common::Rect(x,
-							 y,
-							 x + (_decoder->getWidth() << _doublePixels),
-							 y + (_decoder->getHeight() << (_doublePixels || _stretchVertical)));
+	setDrawRect(x, y,
+				(_decoder->getWidth() << _doublePixels),
+				(_decoder->getHeight() << (_doublePixels || _stretchVertical)));
 }
 
 VMDPlayer::IOStatus VMDPlayer::close() {
@@ -1010,9 +1017,9 @@ void DuckPlayer::open(const GuiResourceId resourceId, const int displayMode, con
 
 	// SSCI seems to incorrectly calculate the draw rect by scaling the origin
 	// in addition to the width/height for the BR point
-	_drawRect = Common::Rect(x, y,
-							 x + (_decoder->getWidth() << _doublePixels),
-							 y + (_decoder->getHeight() << _doublePixels));
+	setDrawRect(x, y,
+				(_decoder->getWidth() << _doublePixels),
+				(_decoder->getHeight() << _doublePixels));
 
 	g_sci->_gfxCursor32->hide();
 
diff --git a/engines/sci/graphics/video32.h b/engines/sci/graphics/video32.h
index 5c21348..cd4436f 100644
--- a/engines/sci/graphics/video32.h
+++ b/engines/sci/graphics/video32.h
@@ -162,6 +162,11 @@ protected:
 	void renderLQToSurface(Graphics::Surface &out, const Graphics::Surface &nextFrame, const bool doublePixels, const bool blackLines) const;
 
 	/**
+	 * Sets the draw rect, clipping it to the screen's dimensions if necessary.
+	 */
+	void setDrawRect(const int16 x, const int16 y, const int16 width, const int16 height);
+
+	/**
 	 * The rectangle where the video will be drawn, in screen coordinates.
 	 */
 	Common::Rect _drawRect;


Commit: ebd5139653961a1c69f0b84644352839c10b4ed2
    https://github.com/scummvm/scummvm/commit/ebd5139653961a1c69f0b84644352839c10b4ed2
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-03T20:58:07-05:00

Commit Message:
SCI32: Fix crash after credits in Lighthouse

Changed paths:
    engines/sci/engine/script_patches.cpp


diff --git a/engines/sci/engine/script_patches.cpp b/engines/sci/engine/script_patches.cpp
index 0415099..3d59adb 100644
--- a/engines/sci/engine/script_patches.cpp
+++ b/engines/sci/engine/script_patches.cpp
@@ -2286,6 +2286,33 @@ static const SciScriptPatcherEntry kq7Signatures[] = {
 	SCI_SIGNATUREENTRY_TERMINATOR
 };
 
+#pragma mark -
+#pragma mark Lighthouse
+
+// When going to room 5 (the sierra logo & menu room) from room 380 (the credits
+// room), the game tries to clear flags from 0 (global 116 bit 0) to 1423
+// (global 204 bit 15), but global 201 is not a flag global (it holds a
+// reference to theInvisCursor). This patch stops clearing after 1359 (global
+// 200 bit 15). Hopefully that is good enough to not break the game.
+// Applies to at least: English 1.0 & 2.0
+static const uint16 lighthouseFlagResetSignature[] = {
+	SIG_MAGICDWORD,
+	0x34, SIG_UINT16(0x58f), // ldi 1423
+	0x24,                    // le?
+	SIG_END
+};
+
+static const uint16 lighthouseFlagResetPatch[] = {
+	0x34, PATCH_UINT16(0x54f), // ldi 1359
+	PATCH_END
+};
+
+//          script, description,                                      signature                         patch
+static const SciScriptPatcherEntry lighthouseSignatures[] = {
+	{  true,     5, "fix bad globals clear after credits",         1, lighthouseFlagResetSignature,     lighthouseFlagResetPatch },
+	SCI_SIGNATUREENTRY_TERMINATOR
+};
+
 #endif
 
 // ===========================================================================
@@ -6741,6 +6768,11 @@ void ScriptPatcher::processScript(uint16 scriptNr, SciSpan<byte> scriptData) {
 	case GID_LAURABOW2:
 		signatureTable = laurabow2Signatures;
 		break;
+#ifdef ENABLE_SCI32
+	case GID_LIGHTHOUSE:
+		signatureTable = lighthouseSignatures;
+		break;
+#endif
 	case GID_LONGBOW:
 		signatureTable = longbowSignatures;
 		break;


Commit: 768d698434d38809932432ca37607c01370e9363
    https://github.com/scummvm/scummvm/commit/768d698434d38809932432ca37607c01370e9363
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-03T20:58:08-05:00

Commit Message:
SCI32: Add standard SRDialog patches to Lighthouse

Changed paths:
    engines/sci/engine/script_patches.cpp


diff --git a/engines/sci/engine/script_patches.cpp b/engines/sci/engine/script_patches.cpp
index 3d59adb..338c57f 100644
--- a/engines/sci/engine/script_patches.cpp
+++ b/engines/sci/engine/script_patches.cpp
@@ -2310,6 +2310,9 @@ static const uint16 lighthouseFlagResetPatch[] = {
 //          script, description,                                      signature                         patch
 static const SciScriptPatcherEntry lighthouseSignatures[] = {
 	{  true,     5, "fix bad globals clear after credits",         1, lighthouseFlagResetSignature,     lighthouseFlagResetPatch },
+	{  true, 64990, "increase number of save games",               1, sci2NumSavesSignature1,           sci2NumSavesPatch1 },
+	{  true, 64990, "increase number of save games",               1, sci2NumSavesSignature2,           sci2NumSavesPatch2 },
+	{  true, 64990, "disable change directory button",             1, sci2ChangeDirSignature,           sci2ChangeDirPatch },
 	SCI_SIGNATUREENTRY_TERMINATOR
 };
 


Commit: 08a717530d9f28dc39c6e98f2ed3229fc57dd11e
    https://github.com/scummvm/scummvm/commit/08a717530d9f28dc39c6e98f2ed3229fc57dd11e
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-03T20:58:08-05:00

Commit Message:
SCI32: Correct LSL7 demo GUIOs

Changed paths:
    engines/sci/detection_tables.h


diff --git a/engines/sci/detection_tables.h b/engines/sci/detection_tables.h
index d4e4a4f..c44d5f4 100644
--- a/engines/sci/detection_tables.h
+++ b/engines/sci/detection_tables.h
@@ -2687,14 +2687,12 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 
 #undef GUIO_LSL6HIRES
 
-// TODO: Correct GUIOs
-#define GUIO_LSL7_DEMO GUIO4(GUIO_NOASPECT, \
+#define GUIO_LSL7_DEMO GUIO3(GUIO_NOASPECT, \
                              GUIO_NOMIDI, \
-                             GUIO_NOLAUNCHLOAD, \
-                             GAMEOPTION_ORIGINAL_SAVELOAD)
-#define GUIO_LSL7      GUIO5(GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \
-                             GUIO_NOASPECT, \
+                             GUIO_NOLAUNCHLOAD)
+#define GUIO_LSL7      GUIO5(GUIO_NOASPECT, \
                              GUIO_NOMIDI, \
+                             GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \
                              GAMEOPTION_ORIGINAL_SAVELOAD, \
                              GAMEOPTION_HQ_VIDEO)
 


Commit: 439a026844d826761338aee31a2d0db177890e54
    https://github.com/scummvm/scummvm/commit/439a026844d826761338aee31a2d0db177890e54
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-03T20:58:08-05:00

Commit Message:
SCI32: Fix Lighthouse GUIOs

Changed paths:
    engines/sci/detection_tables.h


diff --git a/engines/sci/detection_tables.h b/engines/sci/detection_tables.h
index c44d5f4..3ee4459 100644
--- a/engines/sci/detection_tables.h
+++ b/engines/sci/detection_tables.h
@@ -2747,12 +2747,18 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 #undef GUIO_LSL7_DEMO
 #undef GUIO_LSL7
 
-// TODO: Correct GUIOs
-#define GUIO_LIGHTHOUSE_DEMO GUIO3(GUIO_NOSPEECH, \
-                                   GUIO_NOASPECT, \
-                                   GAMEOPTION_ORIGINAL_SAVELOAD)
-#define GUIO_LIGHTHOUSE      GUIO4(GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \
+#define GUIO_LIGHTHOUSE_DEMO GUIO6(GUIO_NOSPEECH, \
+                                   GUIO_NOMUSIC, \
                                    GUIO_NOASPECT, \
+                                   GUIO_NOMIDI, \
+                                   GUIO_NOLAUNCHLOAD, \
+                                   GAMEOPTION_HQ_VIDEO)
+#define GUIO_LIGHTHOUSE      GUIO8(GUIO_NOASPECT, \
+                                   GUIO_NOMIDI, \
+                                   GUIO_NOSUBTITLES, \
+                                   GUIO_LINKMUSICTOSFX, \
+                                   GUIO_LINKSPEECHTOSFX, \
+                                   GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \
                                    GAMEOPTION_ORIGINAL_SAVELOAD, \
                                    GAMEOPTION_HQ_VIDEO)
 


Commit: cc3088c5294ae9cc2e3eff995baa0fc70a61c704
    https://github.com/scummvm/scummvm/commit/cc3088c5294ae9cc2e3eff995baa0fc70a61c704
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-03T20:58:08-05:00

Commit Message:
SCI32: Make audio resource size mismatch non-fatal

Lighthouse audio.225 in RESSCI.002 (US English 1.0C) triggers this
condition; the audio resource says its data is one byte larger
than the recorded size in the volume. In this case, just use the
smaller of the two values for the size, to avoid overreads.

Changed paths:
    engines/sci/resource.cpp


diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index 9cca933..ee0f389 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -2256,9 +2256,9 @@ int Resource::decompress(ResVersion volVersion, Common::SeekableReadStream *file
 			const uint32 audioSize = READ_LE_UINT32(ptr + 9);
 			const uint32 calculatedTotalSize = audioSize + headerSize + kResourceHeaderSize;
 			if (calculatedTotalSize != _size) {
-				error("Unexpected audio file size: the size of %s in %s is %d, but the volume says it should be %d", _id.toString().c_str(), _source->getLocationName().c_str(), calculatedTotalSize, _size);
+				warning("Unexpected audio file size: the size of %s in %s is %d, but the volume says it should be %d", _id.toString().c_str(), _source->getLocationName().c_str(), calculatedTotalSize, _size);
 			}
-			_size = headerSize + audioSize;
+			_size = MIN(_size - kResourceHeaderSize, headerSize + audioSize);
 		}
 	}
 


Commit: be64c6ba8b5f4a81e6703b5a6325b7a7112c14d4
    https://github.com/scummvm/scummvm/commit/be64c6ba8b5f4a81e6703b5a6325b7a7112c14d4
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-03T20:58:09-05:00

Commit Message:
SCI32: Fix closing a Robot when its Plane has been destroyed already

This can happen during game restores in at least Lighthouse, which
has a Robot on the menu screen whose plane is deleted prior to
a call to kRestoreGame32 (which closes the Robot).

Changed paths:
    engines/sci/video/robot_decoder.cpp


diff --git a/engines/sci/video/robot_decoder.cpp b/engines/sci/video/robot_decoder.cpp
index 948f437..c0b5ee5 100644
--- a/engines/sci/video/robot_decoder.cpp
+++ b/engines/sci/video/robot_decoder.cpp
@@ -579,16 +579,6 @@ void RobotDecoder::close() {
 
 	debugC(kDebugLevelVideo, "Closing robot");
 
-	_robotId = -1;
-	_planeId = NULL_REG;
-	_status = kRobotStatusUninitialized;
-	_videoSizes.clear();
-	_recordPositions.clear();
-	_celDecompressionBuffer.clear();
-	_doVersion5Scratch.clear();
-	delete _stream;
-	_stream = nullptr;
-
 	for (CelHandleList::size_type i = 0; i < _celHandles.size(); ++i) {
 		if (_celHandles[i].status == CelHandleInfo::kFrameLifetime) {
 			_segMan->freeBitmap(_celHandles[i].bitmapId);
@@ -601,7 +591,7 @@ void RobotDecoder::close() {
 	}
 	_fixedCels.clear();
 
-	if (g_sci->_gfxFrameout->getPlanes().findByObject(_plane->_object) != nullptr) {
+	if (g_sci->_gfxFrameout->getPlanes().findByObject(_planeId) != nullptr) {
 		for (RobotScreenItemList::size_type i = 0; i < _screenItemList.size(); ++i) {
 			if (_screenItemList[i] != nullptr) {
 				g_sci->_gfxFrameout->deleteScreenItem(*_screenItemList[i]);
@@ -613,6 +603,17 @@ void RobotDecoder::close() {
 	if (_hasAudio) {
 		_audioList.reset();
 	}
+
+	_robotId = -1;
+	_planeId = NULL_REG;
+	_plane = nullptr;
+	_status = kRobotStatusUninitialized;
+	_videoSizes.clear();
+	_recordPositions.clear();
+	_celDecompressionBuffer.clear();
+	_doVersion5Scratch.clear();
+	delete _stream;
+	_stream = nullptr;
 }
 
 void RobotDecoder::pause() {
@@ -717,7 +718,7 @@ void RobotDecoder::showFrame(const uint16 frameNo, const uint16 newX, const uint
 				CelInfo32 celInfo;
 				celInfo.type = kCelTypeMem;
 				celInfo.bitmap = _celHandles[i].bitmapId;
-				ScreenItem *screenItem = new ScreenItem(_plane->_object, celInfo);
+				ScreenItem *screenItem = new ScreenItem(_planeId, celInfo);
 				_screenItemList[i] = screenItem;
 				screenItem->_position = Common::Point(_screenItemX[i], _screenItemY[i]);
 				if (_priority == -1) {
@@ -1167,6 +1168,7 @@ bool RobotDecoder::readPartialAudioRecordAndSubmit(const int startFrame, const i
 #pragma mark RobotDecoder - Rendering
 
 uint16 RobotDecoder::getFrameSize(Common::Rect &outRect) const {
+	assert(_plane != nullptr);
 	outRect.clip(0, 0);
 	for (RobotScreenItemList::size_type i = 0; i < _screenItemList.size(); ++i) {
 		ScreenItem &screenItem = *_screenItemList[i];
@@ -1396,7 +1398,7 @@ void RobotDecoder::doVersion5(const bool shouldSubmitAudio) {
 		if (_screenItemList[i] == nullptr) {
 			CelInfo32 celInfo;
 			celInfo.bitmap = _celHandles[i].bitmapId;
-			ScreenItem *screenItem = new ScreenItem(_plane->_object, celInfo, position, _scaleInfo);
+			ScreenItem *screenItem = new ScreenItem(_planeId, celInfo, position, _scaleInfo);
 			_screenItemList[i] = screenItem;
 			// TODO: Version 6 robot?
 			// screenItem->_field_30 = scaleXRemainder;


Commit: 6e35676a9efa9247edccd7acca069610f1a493ee
    https://github.com/scummvm/scummvm/commit/6e35676a9efa9247edccd7acca069610f1a493ee
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-03T20:58:09-05:00

Commit Message:
SCI32: Fix load from launcher for Lighthouse

Launcher loads of games without a saved Robot were fine, but games
that were saved with a Robot (e.g. room 480 when facing the water)
would crash.

Changed paths:
    engines/sci/engine/guest_additions.cpp
    engines/sci/engine/guest_additions.h
    engines/sci/engine/kvideo.cpp


diff --git a/engines/sci/engine/guest_additions.cpp b/engines/sci/engine/guest_additions.cpp
index 17ae74e..0e4e35f 100644
--- a/engines/sci/engine/guest_additions.cpp
+++ b/engines/sci/engine/guest_additions.cpp
@@ -254,28 +254,47 @@ void GuestAdditions::segManSaveLoadScriptHook(Script &script) const {
 #endif
 
 bool GuestAdditions::kGetEventHook() const {
-	if (_state->_delayedRestoreGameId != -1) {
-		return g_sci->_guestAdditions->restoreFromLauncher();
+	if (_state->_delayedRestoreGameId == -1) {
+		return false;
+	}
+
+	// Loading a save game while Lighthouse is still initializing itself will
+	// cause loading to fail if the save game contains a saved Robot state,
+	// because the Robot will try to restore itself into a game plane which does
+	// not exist yet
+	if (g_sci->getGameId() == GID_LIGHTHOUSE) {
+		Common::List<ExecStack>::const_iterator it;
+		for (it = _state->_executionStack.begin(); it != _state->_executionStack.end(); ++it) {
+			const ExecStack &call = *it;
+			const reg_t gameObject = g_sci->getGameObject();
+			if (call.sendp == gameObject && call.debugSelector == SELECTOR(init)) {
+				return false;
+			}
+		}
 	}
-	return false;
+
+	return g_sci->_guestAdditions->restoreFromLauncher();
 }
 
 bool GuestAdditions::kWaitHook() const {
-	if (_state->_delayedRestoreGameId != -1 &&
-		// kWait cannot be used in Phant2 for delayed restore because it is
-		// called during the fade-in of music in the intro room, before graphics
-		// are fully initialized, which causes "Click to continue" text to be
-		// brokenly drawn over the game and then crashes the engine on the next
-		// room transition
-		g_sci->getGameId() != GID_PHANTASMAGORIA2) {
+	if (_state->_delayedRestoreGameId == -1) {
+		return false;
+	}
 
-		return g_sci->_guestAdditions->restoreFromLauncher();
+	// kWait cannot be used in Phant2 for delayed restore because it is
+	// called during the fade-in of music in the intro room, before graphics
+	// are fully initialized, which causes "Click to continue" text to be
+	// brokenly drawn over the game and then crashes the engine on the next
+	// room transition
+	if (g_sci->getGameId() == GID_PHANTASMAGORIA2) {
+		return false;
 	}
-	return false;
+
+	return g_sci->_guestAdditions->restoreFromLauncher();
 }
 
 #ifdef ENABLE_SCI32
-bool GuestAdditions::kPlayDuckPlayHook() const {
+bool GuestAdditions::kPlayDuckPlayVMDHook() const {
 	return _state->_delayedRestoreGameId != -1;
 }
 #endif
diff --git a/engines/sci/engine/guest_additions.h b/engines/sci/engine/guest_additions.h
index cfa1139..36264b9 100644
--- a/engines/sci/engine/guest_additions.h
+++ b/engines/sci/engine/guest_additions.h
@@ -148,9 +148,9 @@ public:
 
 #ifdef ENABLE_SCI32
 	/**
-	 * Guest additions hook for kPlayDuck(Play).
+	 * Guest additions hook for kPlayDuck(Play) and kPlayVMD(PlayUntilEvent).
 	 */
-	bool kPlayDuckPlayHook() const;
+	bool kPlayDuckPlayVMDHook() const;
 #endif
 
 #pragma mark -
diff --git a/engines/sci/engine/kvideo.cpp b/engines/sci/engine/kvideo.cpp
index feb98f2..98b2ba2 100644
--- a/engines/sci/engine/kvideo.cpp
+++ b/engines/sci/engine/kvideo.cpp
@@ -444,6 +444,10 @@ reg_t kPlayVMDGetStatus(EngineState *s, int argc, reg_t *argv) {
 }
 
 reg_t kPlayVMDPlayUntilEvent(EngineState *s, int argc, reg_t *argv) {
+	if (g_sci->_guestAdditions->kPlayDuckPlayVMDHook()) {
+		return make_reg(0, VMDPlayer::kEventFlagEnd);
+	}
+
 	const VMDPlayer::EventFlags flags = (VMDPlayer::EventFlags)argv[0].toUint16();
 	const int16 lastFrameNo = argc > 1 ? argv[1].toSint16() : -1;
 	const int16 yieldInterval = argc > 2 ? argv[2].toSint16() : -1;
@@ -485,7 +489,7 @@ reg_t kPlayDuck(EngineState *s, int argc, reg_t *argv) {
 }
 
 reg_t kPlayDuckPlay(EngineState *s, int argc, reg_t *argv) {
-	if (g_sci->_guestAdditions->kPlayDuckPlayHook()) {
+	if (g_sci->_guestAdditions->kPlayDuckPlayVMDHook()) {
 		return NULL_REG;
 	}
 	kPlayDuckOpen(s, argc, argv);


Commit: aa2028402701d565e72165af7213451d6c049a76
    https://github.com/scummvm/scummvm/commit/aa2028402701d565e72165af7213451d6c049a76
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-03T20:58:09-05:00

Commit Message:
SCI32: Ignore bad audio map entries on GK2 DE CD 6

This patch also cleans up the GK2 audio map blacklisting code to
reduce the number of redundant checks being made during audio map
processing.

Fixes Trac#10172.

Changed paths:
    engines/sci/resource_audio.cpp


diff --git a/engines/sci/resource_audio.cpp b/engines/sci/resource_audio.cpp
index ddaec1e..39d742a 100644
--- a/engines/sci/resource_audio.cpp
+++ b/engines/sci/resource_audio.cpp
@@ -489,26 +489,38 @@ int ResourceManager::readAudioMapSCI11(IntMapResourceSource *map) {
 				continue;
 			}
 
-			// At least version 1.00 of the US release of GK2 has multiple
-			// invalid audio36 map entries on CD 6
-			if (g_sci->getGameId() == GID_GK2 &&
-				g_sci->getLanguage() == Common::EN_ANY &&
-				map->_volumeNumber == 6 &&
-				offset + syncSize >= srcSize) {
+			if (g_sci->getGameId() == GID_GK2) {
+				// At least version 1.00 of the US release, and the German
+				// release, of GK2 have multiple invalid audio36 map entries on
+				// CD 6
+				if (map->_volumeNumber == 6 && offset + syncSize >= srcSize) {
+					bool skip;
+					switch (g_sci->getLanguage()) {
+					case Common::EN_ANY:
+						skip = (map->_mapNumber == 22 || map->_mapNumber == 160);
+						break;
+					case Common::DE_DEU:
+						skip = (map->_mapNumber == 22);
+						break;
+					default:
+						skip = false;
+					}
 
-				debugC(kDebugLevelResMan, "Invalid offset %u for %s in map %d for disc %d", offset + syncSize, id.toPatchNameBase36().c_str(), map->_mapNumber, map->_volumeNumber);
-				continue;
-			}
+					if (skip) {
+						continue;
+					}
+				}
 
-			// Map 2020 on CD 1 of the German release of GK2 is invalid. This
-			// content does not appear to ever be used by the game (it does not
-			// even exist in the US release), and there is a correct copy of it
-			// on CD 6, so just ignore the bad copy on CD 1
-			if (g_sci->getGameId() == GID_GK2 &&
-				g_sci->getLanguage() == Common::DE_DEU &&
-				map->_volumeNumber == 1 &&
-				map->_mapNumber == 2020) {
-				continue;
+				// Map 2020 on CD 1 of the German release of GK2 is invalid.
+				// This content does not appear to ever be used by the game (it
+				// does not even exist in the US release), and there is a
+				// correct copy of it on CD 6, so just ignore the bad copy on
+				// CD 1
+				if (g_sci->getLanguage() == Common::DE_DEU &&
+					map->_volumeNumber == 1 &&
+					map->_mapNumber == 2020) {
+					continue;
+				}
 			}
 
 			// Map 800 and 4176 contain content that was cut from the game. The


Commit: d6139890fec62a4c8e5d050bc6d3d75423fb2b85
    https://github.com/scummvm/scummvm/commit/d6139890fec62a4c8e5d050bc6d3d75423fb2b85
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-03T20:58:10-05:00

Commit Message:
SCI32: Exit early from screen shake if engine is quitting

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


diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index 4e28f80..9a7bfc8 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -1164,6 +1164,10 @@ void GfxFrameout::shakeScreen(int16 numShakes, const ShakeDirection direction) {
 	}
 
 	while (numShakes--) {
+		if (g_engine->shouldQuit()) {
+			break;
+		}
+
 		if (direction & kShakeVertical) {
 			g_system->setShakePos(_isHiRes ? 8 : 4);
 		}





More information about the Scummvm-git-logs mailing list