[Scummvm-git-logs] scummvm master -> 3afaca351a798f81133be363c8d8dadd4a7a796c

athrxx noreply at scummvm.org
Tue May 7 17:26:27 UTC 2024


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

Summary:
b53dbf18c2 SCUMM: (FM-Towns) - improve dirty rect handling
158614fce6 SCUMM: some Coverity fixes
3afaca351a SCUMM: (DIG) - fix regression


Commit: b53dbf18c2b913323796a863de7bff70732ac938
    https://github.com/scummvm/scummvm/commit/b53dbf18c2b913323796a863de7bff70732ac938
Author: athrxx (athrxx at scummvm.org)
Date: 2024-05-07T19:26:06+02:00

Commit Message:
SCUMM: (FM-Towns) - improve dirty rect handling

Changed paths:
    engines/scumm/gfx_towns.cpp


diff --git a/engines/scumm/gfx_towns.cpp b/engines/scumm/gfx_towns.cpp
index 699f6830cfa..678b8796ebe 100644
--- a/engines/scumm/gfx_towns.cpp
+++ b/engines/scumm/gfx_towns.cpp
@@ -515,29 +515,47 @@ void TownsScreen::addDirtyRect(int x, int y, int w, int h) {
 
 	assert(x >= 0 && y >= 0 && x2 < _width && y2 < _height);
 
-	bool skip = false;
+	bool merge = false;
+	Common::List<Common::Rect>::iterator r2 = _dirtyRects.end();
+
 	for (Common::List<Common::Rect>::iterator r = _dirtyRects.begin(); r != _dirtyRects.end(); ++r) {
-		// Try to merge new rect with an existing rect (only once, since trying to merge
-		// more than one overlapping rect would be causing more overhead than doing any good).
+		// Try to merge new rect with existing rects.
+		if (merge) {
+			r = _dirtyRects.begin();
+			merge = false;
+		}
+		if (r == r2)
+			continue;
 		if (y == r->top && y2 == r->bottom) {
 			if ((x >= r->left && x <= r->right) || (x2 >= r->left - 1 && x2 <= r->right)) {
-				r->left = MIN<int>(x, r->left);
-				r->right = MAX<int>(x2, r->right);
-				skip = true;
+				x = MIN<int>(x, r->left);
+				x2 = MAX<int>(x2, r->right);
+				merge = true;
 			}
 		}
 		if (x == r->left && x2 == r->right) {
 			if ((y >= r->top && y <= r->bottom) || (y2 >= r->top - 1 && y2 <= r->bottom)) {
-				r->top = MIN<int>(y, r->top);
-				r->bottom = MAX<int>(y2, r->bottom);
-				skip = true;
+				y = MIN<int>(y, r->top);
+				y2 = MAX<int>(y2, r->bottom);
+				merge = true;
 			}
 		}
+		if (merge) {
+			if (r2 == _dirtyRects.end())
+				r2 = r;
+			else
+				_dirtyRects.erase(r);
+		}
 	}
 
-	if (!skip) {
+	if (r2 == _dirtyRects.end()) {
 		_dirtyRects.push_back(Common::Rect(x, y, x2, y2));
 		_numDirtyRects++;
+	} else {
+		r2->left = x;
+		r2->top = y;
+		r2->right = x2;
+		r2->bottom = y2;
 	}
 }
 


Commit: 158614fce6ba9ffd064d0fd3bf0a0bc3e20d2164
    https://github.com/scummvm/scummvm/commit/158614fce6ba9ffd064d0fd3bf0a0bc3e20d2164
Author: athrxx (athrxx at scummvm.org)
Date: 2024-05-07T19:26:06+02:00

Commit Message:
SCUMM: some Coverity fixes

Changed paths:
    engines/scumm/he/intern_he.h
    engines/scumm/he/wizwarp_he.cpp
    engines/scumm/imuse/imuse.cpp
    engines/scumm/saveload.cpp
    engines/scumm/script.cpp
    engines/scumm/script_v5.cpp
    engines/scumm/script_v6.cpp
    engines/scumm/scumm.cpp


diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index 91e31e8b7e5..9a14cf7b548 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -644,12 +644,13 @@ protected:
 
 	VideoParameters _videoParams;
 
-	int32 _heObject, _heObjectNum;
-	int32 _hePaletteNum;
+	int32 _heObject = 0;
+	int32 _heObjectNum = 0;
+	int32 _hePaletteNum = 0;
 
 	int32 _maxSpriteNum = 0;
 	int32 _minSpriteNum = 0;
-	int32 _curSpriteGroupId;
+	int32 _curSpriteGroupId = 0;
 
 	LogicHE *_logicHE = nullptr;
 	MoviePlayer *_moviePlay;
@@ -783,9 +784,9 @@ protected:
 	byte VAR_U32_ARRAY_UNK;
 
 #ifdef USE_ENET
-	byte VAR_REMOTE_START_SCRIPT;
-	byte VAR_NETWORK_AVAILABLE;
-	byte VAR_NETWORK_RECEIVE_ARRAY_SCRIPT;
+	byte VAR_REMOTE_START_SCRIPT = 98;
+	byte VAR_NETWORK_AVAILABLE = 109;
+	byte VAR_NETWORK_RECEIVE_ARRAY_SCRIPT = 101;
 
 public:
 	int networkSessionDialog();
diff --git a/engines/scumm/he/wizwarp_he.cpp b/engines/scumm/he/wizwarp_he.cpp
index 6cff1045d71..9efd7ffdcfd 100644
--- a/engines/scumm/he/wizwarp_he.cpp
+++ b/engines/scumm/he/wizwarp_he.cpp
@@ -219,6 +219,7 @@ WarpWizOneSpanTable *Wiz::warpCreateSpanTable(int spanCount) {
 	if (!spanTable) {
 		return nullptr;
 	}
+	memset(spanTable, 0, sizeof(WarpWizOneSpanTable));
 
 	spanTable->spanCount = spanCount;
 	spanTable->spans = (WarpWizOneSpan *)malloc(spanCount * sizeof(WarpWizOneSpan));
@@ -226,6 +227,7 @@ WarpWizOneSpanTable *Wiz::warpCreateSpanTable(int spanCount) {
 		warpDestroySpanTable(spanTable);
 		return nullptr;
 	}
+	memset(spanTable->spans, 0, spanCount * sizeof(WarpWizOneSpan));
 
 	spanPtr = spanTable->spans;
 	for (counter = 0; counter < spanCount; counter++) {
@@ -239,6 +241,7 @@ WarpWizOneSpanTable *Wiz::warpCreateSpanTable(int spanCount) {
 		warpDestroySpanTable(spanTable);
 		return nullptr;
 	}
+	memset(spanTable->drawSpans, 0, spanCount * sizeof(WarpWizOneDrawSpan));
 
 	return spanTable;
 }
diff --git a/engines/scumm/imuse/imuse.cpp b/engines/scumm/imuse/imuse.cpp
index e6b20234106..a5a043626f6 100644
--- a/engines/scumm/imuse/imuse.cpp
+++ b/engines/scumm/imuse/imuse.cpp
@@ -45,8 +45,8 @@ namespace Scumm {
 
 IMuseInternal::IMuseInternal(ScummEngine *vm, MidiDriverFlags sndType, bool nativeMT32) :
 	_native_mt32(nativeMT32),
-	_newSystem(vm->_game.id == GID_SAMNMAX),
-	_dynamicChanAllocation(vm->_game.id != GID_MONKEY2 && vm->_game.id != GID_INDY4), // For the non-iMuse games that (unfortunately) run on this player we need to pretend we're on the more modern version
+	_newSystem(vm && vm->_game.id == GID_SAMNMAX),
+	_dynamicChanAllocation(vm && (vm->_game.id != GID_MONKEY2 && vm->_game.id != GID_INDY4)), // For the non-iMuse games that (unfortunately) run on this player we need to pretend we're on the more modern version
 	_midi_adlib(nullptr),
 	_midi_native(nullptr),
 	_sysex(nullptr),
diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index 2c0c2cd0693..36c314c68ac 100644
--- a/engines/scumm/saveload.cpp
+++ b/engines/scumm/saveload.cpp
@@ -210,7 +210,7 @@ bool ScummEngine::canSaveGameStateCurrently(Common::U32String *msg) {
 		}
 
 		// Also deny persistence operations while the script opening the save menu is running...
-		isOriginalMenuActive = _currentRoom == saveRoom || vm.slot[_currentScript].number == saveMenuScript;
+		isOriginalMenuActive = _currentRoom == saveRoom || (_currentScript != 0xFF && vm.slot[_currentScript].number == saveMenuScript);
 	}
 
 	// SCUMM v4+ doesn't allow saving in room 0 or if
diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp
index 29e58a0061b..68eca38862a 100644
--- a/engines/scumm/script.cpp
+++ b/engines/scumm/script.cpp
@@ -813,6 +813,7 @@ int ScummEngine::pop() {
 void ScummEngine::stopObjectCode() {
 	ScriptSlot *ss;
 
+	assert(_currentScript != 0xFF);
 	ss = &vm.slot[_currentScript];
 	if (_game.version <= 2) {
 		if (ss->where == WIO_GLOBAL || ss->where == WIO_LOCAL) {
diff --git a/engines/scumm/script_v5.cpp b/engines/scumm/script_v5.cpp
index 54183aecfed..dc59ef8c840 100644
--- a/engines/scumm/script_v5.cpp
+++ b/engines/scumm/script_v5.cpp
@@ -3321,20 +3321,20 @@ void ScummEngine_v5::decodeParseStringTextString(int textSlot) {
 	const int len = resStrLen(_scriptPointer);
 
 	if (_game.id == GID_LOOM && _game.version == 4 && _language == Common::EN_ANY &&
-		vm.slot[_currentScript].number == 95 && enhancementEnabled(kEnhTextLocFixes) &&
+		_currentScript != 0xFF && vm.slot[_currentScript].number == 95 && enhancementEnabled(kEnhTextLocFixes) &&
 			strcmp((const char *)_scriptPointer, "I am Choas.") == 0) {
 		// WORKAROUND: This happens when Chaos introduces
 		// herself to bishop Mandible. Of all the places to put
 		// a typo...
 		printString(textSlot, (const byte *)"I am Chaos.");
 	} else if (_game.id == GID_LOOM && _game.version == 4 && _roomResource == 90 &&
-			   vm.slot[_currentScript].number == 203 && _string[textSlot].color == 0x0F && enhancementEnabled(kEnhSubFmtCntChanges)) {
+		_currentScript != 0xFF && vm.slot[_currentScript].number == 203 && _string[textSlot].color == 0x0F && enhancementEnabled(kEnhSubFmtCntChanges)) {
 		// WORKAROUND: When Mandible speaks with Goodmold, his second
 		// speech line is missing its color parameter.
 		_string[textSlot].color = 0x0A;
 		printString(textSlot, _scriptPointer);
 	} else if (_game.id == GID_INDY3 && _game.platform == Common::kPlatformFMTowns && _roomResource == 80 &&
-			   vm.slot[_currentScript].number == 201 && enhancementEnabled(kEnhSubFmtCntChanges)) {
+		_currentScript != 0xFF && vm.slot[_currentScript].number == 201 && enhancementEnabled(kEnhSubFmtCntChanges)) {
 		// WORKAROUND: When Indy and his father escape the zeppelin
 		// with the biplane in the FM-TOWNS version, they share the
 		// same text color. Indeed, they're not given any explicit
@@ -3347,8 +3347,8 @@ void ScummEngine_v5::decodeParseStringTextString(int textSlot) {
 		else
 			_string[textSlot].color = 0x0E;
 		printString(textSlot, _scriptPointer);
-	} else if (_game.id == GID_INDY4 && _roomResource == 23 && vm.slot[_currentScript].number == 167 &&
-			len == 24 && enhancementEnabled(kEnhTextLocFixes) && memcmp(_scriptPointer+16, "pregod", 6) == 0) {
+	} else if (_game.id == GID_INDY4 && _roomResource == 23 && _currentScript != 0xFF && vm.slot[_currentScript].number == 167 &&
+		len == 24 && enhancementEnabled(kEnhTextLocFixes) && memcmp(_scriptPointer+16, "pregod", 6) == 0) {
 		// WORKAROUND for bug #2961: At the end of Indy4, if Ubermann is told
 		// to use 20 orichalcum beads, he'll count "pregod8" and "pregod9"
 		// instead of "18" and "19", in some releases.
@@ -3364,7 +3364,7 @@ void ScummEngine_v5::decodeParseStringTextString(int textSlot) {
 			Common::strlcpy((char *)tmpBuf+16, "^19^", sizeof(tmpBuf) - 16);
 		printString(textSlot, tmpBuf);
 	} else if (_game.id == GID_INDY4 && _language == Common::EN_ANY && _roomResource == 10 &&
-			vm.slot[_currentScript].number == 209 && _actorToPrintStrFor == 4 && len == 81 &&
+		_currentScript != 0xFF && vm.slot[_currentScript].number == 209 && _actorToPrintStrFor == 4 && len == 81 &&
 			strcmp(_game.variant, "Floppy") != 0 && enhancementEnabled(kEnhSubFmtCntChanges)) {
 		// WORKAROUND: The English Talkie version of Indy4 changed Kerner's
 		// lines when he uses the phone booth in New York, but the text doesn't
@@ -3381,8 +3381,8 @@ void ScummEngine_v5::decodeParseStringTextString(int textSlot) {
 		} else {
 			printString(textSlot, _scriptPointer);
 		}
-	} else if (_game.id == GID_INDY4 && vm.slot[_currentScript].number == 161 && _actorToPrintStrFor == 2 &&
-			_game.platform != Common::kPlatformAmiga && strcmp(_game.variant, "Floppy") != 0 &&
+	} else if (_game.id == GID_INDY4 && _currentScript != 0xFF && vm.slot[_currentScript].number == 161 && _actorToPrintStrFor == 2 &&
+		_game.platform != Common::kPlatformAmiga && strcmp(_game.variant, "Floppy") != 0 &&
 			enhancementEnabled(kEnhAudioChanges)) {
 		// WORKAROUND: In Indy 4, if one plays as Sophia and looks at Indy, then
 		// her "There's nothing to look at." reaction line will be said with
@@ -3390,7 +3390,7 @@ void ScummEngine_v5::decodeParseStringTextString(int textSlot) {
 		// case. Script 68-4 has a "There's nothing to look at." line for Sophia,
 		// though, so we reuse this if the current line contains the expected
 		// audio offset.
-		if (memcmp(_scriptPointer, "\xFF\x0A\x5D\x8E\xFF\x0A\x63\x08\xFF\x0A\x0E\x00\xFF\x0A\x00\x00", 16) == 0) {
+		if (memcmp(_scriptPointer, "\xFF\x0A\x5D\x8E\xFF\x0A\x63\x08\xFF\x0A\x0E\x00\xFF\x0A\x00\x00", 16) == 0 && len >= 16) {
 			byte *tmpBuf = new byte[len];
 			memcpy(tmpBuf, "\xFF\x0A\xCE\x3B\xFF\x0A\x01\x05\xFF\x0A\x0E\x00\xFF\x0A\x00\x00", 16);
 			memcpy(tmpBuf + 16, _scriptPointer + 16, len - 16);
@@ -3399,8 +3399,8 @@ void ScummEngine_v5::decodeParseStringTextString(int textSlot) {
 		} else {
 			printString(textSlot, _scriptPointer);
 		}
-	} else if (_game.id == GID_MONKEY_EGA && _roomResource == 30 && vm.slot[_currentScript].number == 411 &&
-				strstr((const char *)_scriptPointer, "NCREDIT-NOTE-AMOUNT")) {
+	} else if (_game.id == GID_MONKEY_EGA && _roomResource == 30 && _currentScript != 0xFF && vm.slot[_currentScript].number == 411 &&
+		strstr((const char *)_scriptPointer, "NCREDIT-NOTE-AMOUNT")) {
 		// WORKAROUND for bug #4886 (MI1EGA German: Credit text incorrect)
 		// The script contains buggy text.
 		const char *tmp = strstr((const char *)_scriptPointer, "NCREDIT-NOTE-AMOUNT");
@@ -3411,8 +3411,8 @@ void ScummEngine_v5::decodeParseStringTextString(int textSlot) {
 		Common::strlcpy(tmpBuf + diff + 4, tmp + sizeof("NCREDIT-NOTE-AMOUNT") - 1, sizeof(tmpBuf) - diff - 4);
 		printString(textSlot, (byte *)tmpBuf);
 	} else if (_game.id == GID_MONKEY && !(_game.features & GF_ULTIMATE_TALKIE) &&
-			_game.platform != Common::kPlatformSegaCD &&
-			((_roomResource == 78 && vm.slot[_currentScript].number == 201) ||
+		_game.platform != Common::kPlatformSegaCD &&
+			_currentScript != 0xFF && ((_roomResource == 78 && vm.slot[_currentScript].number == 201) ||
 			(_roomResource == 45 && vm.slot[_currentScript].number == 200 &&
 			isValidActor(10) && _actors[10]->isInCurrentRoom())) &&
 			_actorToPrintStrFor == 255 && _string[textSlot].color != 0x0F &&
@@ -3425,7 +3425,7 @@ void ScummEngine_v5::decodeParseStringTextString(int textSlot) {
 		_string[textSlot].color = (_game.platform == Common::kPlatformFMTowns) ? 0x0A : 0xF9;
 		printString(textSlot, _scriptPointer);
 	} else if (_game.id == GID_MONKEY && !(_game.features & GF_ULTIMATE_TALKIE) &&
-			_game.platform != Common::kPlatformSegaCD &&
+			_game.platform != Common::kPlatformSegaCD && _currentScript != 0xFF && 
 			(vm.slot[_currentScript].number == 140 || vm.slot[_currentScript].number == 294) &&
 			_actorToPrintStrFor == 255 && _string[textSlot].color == 0x06 &&
 			enhancementEnabled(kEnhSubFmtCntChanges)) {
@@ -3438,7 +3438,7 @@ void ScummEngine_v5::decodeParseStringTextString(int textSlot) {
 		// different releases and scenes, so we don't know the original intent.
 		_string[textSlot].color = (_game.platform == Common::kPlatformFMTowns) ? 0x0C : 0xEA;
 		printString(textSlot, _scriptPointer);
-	} else if (_game.id == GID_MONKEY && _roomResource == 25 && vm.slot[_currentScript].number == 205) {
+	} else if (_game.id == GID_MONKEY && _roomResource == 25 && _currentScript != 0xFF && vm.slot[_currentScript].number == 205) {
 		printPatchedMI1CannibalString(textSlot, _scriptPointer);
 	} else {
 		printString(textSlot, _scriptPointer);
diff --git a/engines/scumm/script_v6.cpp b/engines/scumm/script_v6.cpp
index 4229dd37e5c..83b083797e0 100644
--- a/engines/scumm/script_v6.cpp
+++ b/engines/scumm/script_v6.cpp
@@ -2001,7 +2001,7 @@ void ScummEngine_v6::o6_roomOps() {
 		// this way, we avoid some graphics glitches that the original
 		// interpreter had.
 
-		if (_game.id == GID_SAMNMAX && vm.slot[_currentScript].number == 64)
+		if (_game.id == GID_SAMNMAX && _currentScript != 0xFF && vm.slot[_currentScript].number == 64)
 			setDirtyColors(0, 255);
 		else
 			setCurrentPalette(a);
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index f37a7142e23..44f73feca4b 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -3188,6 +3188,7 @@ void ScummEngine_v3::terminateSaveMenuScript() {
 		int cur = _currentScript;
 		int scriptToChain = _game.platform == Common::kPlatformFMTowns ? 6 : 5;
 
+		assert(cur != 0xFF);
 		chainedArgs[0] = 0;
 		vm.slot[cur].number = 0;
 		vm.slot[cur].status = ssDead;


Commit: 3afaca351a798f81133be363c8d8dadd4a7a796c
    https://github.com/scummvm/scummvm/commit/3afaca351a798f81133be363c8d8dadd4a7a796c
Author: athrxx (athrxx at scummvm.org)
Date: 2024-05-07T19:26:06+02:00

Commit Message:
SCUMM: (DIG) - fix regression

Changed paths:
    engines/scumm/string.cpp


diff --git a/engines/scumm/string.cpp b/engines/scumm/string.cpp
index 3643d7e756a..4d65ddb922b 100644
--- a/engines/scumm/string.cpp
+++ b/engines/scumm/string.cpp
@@ -2019,35 +2019,35 @@ void ScummEngine_v7::translateText(const byte *text, byte *trans_buff, int trans
 	if (_game.id == GID_DIG) {
 		// Based on the second release of The Dig
 		// Only applies to the subtitles and not speech
-		if (!strncmp((const char *)text, "faint light", 11))
+		if (!strncmp((const char *)text, "faint light", 12))
 			text = (const byte *)"/NEW.007/faint light";
-		else if (!strncmp((const char *)text, "glowing crystal", 15))
+		else if (!strncmp((const char *)text, "glowing crystal", 16))
 			text = (const byte *)"/NEW.008/glowing crystal";
-		else if (!strncmp((const char *)text, "glowing crystals", 16))
+		else if (!strncmp((const char *)text, "glowing crystals", 17))
 			text = (const byte *)"/NEW.009/glowing crystals";
-		else if (!strncmp((const char *)text, "pit", 3))
+		else if (!strncmp((const char *)text, "pit", 4))
 			text = (const byte *)"/NEW.010/pit";
-		else if (!strncmp((const char *)text, "You wish.", 9))
+		else if (!strncmp((const char *)text, "You wish.", 10))
 			text = (const byte *)"/NEW.011/You wish.";
-		else if (!strncmp((const char *)text, "In your dreams.", 15))
+		else if (!strncmp((const char *)text, "In your dreams.", 16))
 			text = (const byte *)"/NEW.012/In your dreams";
-		else if (!strncmp((const char *)text, "left", 4))
+		else if (!strncmp((const char *)text, "left", 5))
 			text = (const byte *)"/CATHPLAT.068/left";
-		else if (!strncmp((const char *)text, "right", 5))
+		else if (!strncmp((const char *)text, "right", 6))
 			text = (const byte *)"/CATHPLAT.070/right";
-		else if (!strncmp((const char *)text, "top", 3))
+		else if (!strncmp((const char *)text, "top", 4))
 			text = (const byte *)"/CATHPLAT.067/top";
-		else if (!strncmp((const char *)text, "exit", 4))
+		else if (!strncmp((const char *)text, "exit", 5))
 			text = (const byte *)"/SKY.008/exit";
-		else if (!strncmp((const char *)text, "unattached lens", 15))
+		else if (!strncmp((const char *)text, "unattached lens", 16))
 			text = (const byte *)"/NEW.013/unattached lens";
-		else if (!strncmp((const char *)text, "lens slot", 9))
+		else if (!strncmp((const char *)text, "lens slot", 10))
 			text = (const byte *)"/NEW.014/lens slot";
-		else if (!strncmp((const char *)text, "Jonathon Jackson", 16))
+		else if (!strncmp((const char *)text, "Jonathon Jackson", 17))
 			text = (const byte *)"Aram Gutowski";
-		else if (!strncmp((const char *)text, "Brink", 5))
+		else if (!strncmp((const char *)text, "Brink", 6))
 			text = (const byte *)"/CREVICE.049/Brink";
-		else if (!strncmp((const char *)text, "Robbins", 7))
+		else if (!strncmp((const char *)text, "Robbins", 8))
 			text = (const byte *)"/NEST.061/Robbins";
 	}
 




More information about the Scummvm-git-logs mailing list