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

athrxx noreply at scummvm.org
Wed Dec 18 18:49:06 UTC 2024


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:
db2eceb4b9 SCI: fix bug caused by PR 6319


Commit: db2eceb4b9fb87c133c6b61846dc6bd4b44424e5
    https://github.com/scummvm/scummvm/commit/db2eceb4b9fb87c133c6b61846dc6bd4b44424e5
Author: athrxx (athrxx at scummvm.org)
Date: 2024-12-18T19:48:45+01:00

Commit Message:
SCI: fix bug caused by PR 6319

I made a mistake in that PR by assuming that the
handles for the hires graphics would be unique. So
when removing an object from the drawing chain
I really only removed the first object. But in reality
they often have the same handle and the original
interpreter continues to go over the loop until all
of the same handle have been removed.

Also, the original checks for already existent draw
objects with the same x/y-coordinates.

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


diff --git a/engines/sci/graphics/paint16.cpp b/engines/sci/graphics/paint16.cpp
index 6958250a680..df7062f37db 100644
--- a/engines/sci/graphics/paint16.cpp
+++ b/engines/sci/graphics/paint16.cpp
@@ -181,7 +181,7 @@ void GfxPaint16::drawHiresCelAndShow(GuiResourceId viewId, int16 loopNo, int16 c
 	// in the original. We do have that mode as a ScummVM feature, though. That's why we have that code, to be able to refresh the inventory.
 	// We also check if the portrait is drawn outside the viewport boundaries (happens in the unofficial mixed speech+text mode) and set
 	// a flag to trigger a workaround when restoring the background.
-	if (storeDrawingInfo)
+	if (storeDrawingInfo && !hasHiresDrawObjectAt(leftPos, topPos))
 		_hiresDrawObjs = new HiresDrawData(_hiresDrawObjs, hiresHandle, viewId, loopNo, celNo, leftPos, topPos, paletteNo, priority, picRect.top < _ports->_curPort->top);
 }
 
@@ -656,13 +656,17 @@ void GfxPaint16::kernelPortraitUnload(uint16 portraitId) {
 }
 
 void GfxPaint16::removeHiresDrawObject(reg_t handle) {
-	for (HiresDrawData *i = _hiresDrawObjs; i; i = i->next) {
-		if (i->handle != handle)
+	for (HiresDrawData *i = _hiresDrawObjs; i; ) {
+		HiresDrawData *next = i->next;
+		if (i->handle != handle) {
+			i = next;
 			continue;
+		}
 
 		// WORKAROUND for vertically misplaced hires portraits in mixed speech+text mode in KQ6CD. If we have
 		// an entry which is flagged as needing a workaround, we set the notification for bitsShow() here.
-		_hiresPortraitWorkaroundFlag = i->waFlag;
+		if (i->waFlag)
+			_hiresPortraitWorkaroundFlag = true;
 
 		// Unlink and delete entry
 		if (i->next)
@@ -673,8 +677,16 @@ void GfxPaint16::removeHiresDrawObject(reg_t handle) {
 			_hiresDrawObjs = i->next;
 		delete i;
 
-		return;
+		i = next;
+	}
+}
+
+bool GfxPaint16::hasHiresDrawObjectAt(uint16 x, uint16 y) const {
+	for (HiresDrawData *i = _hiresDrawObjs; i; i = i->next) {
+		if (i->leftPos == x && i->topPos == y)
+			return true;
 	}
+	return false;
 }
 
 Common::Rect GfxPaint16::makeHiresRect(Common::Rect &rect) const {
diff --git a/engines/sci/graphics/paint16.h b/engines/sci/graphics/paint16.h
index 115fb89809c..d2421f0be21 100644
--- a/engines/sci/graphics/paint16.h
+++ b/engines/sci/graphics/paint16.h
@@ -104,6 +104,7 @@ private:
 	// redrawing the inventory after displaying a text window over it. This only happens in mixed speech+text mode, which does not even exist
 	// in the original. We do have that mode as a ScummVM feature, though. That's why we have that code, to be able to refresh the inventory.
 	void removeHiresDrawObject(reg_t handle);
+	bool hasHiresDrawObjectAt(uint16 x, uint16 y) const;
 	Common::Rect makeHiresRect(Common::Rect &rect) const;
 
 	HiresDrawData *_hiresDrawObjs;




More information about the Scummvm-git-logs mailing list