[Scummvm-git-logs] scummvm master -> 84a0bff2813dbf1476276d8a45f2f845d424dcea

athrxx noreply at scummvm.org
Mon May 20 13:32:47 UTC 2024


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

Summary:
6b7f6869c2 KYRA: fix coverity warning
84a0bff281 SCUMM: fix Coverity warnings


Commit: 6b7f6869c276cdbfbad0af9c1f240c16ab0299c3
    https://github.com/scummvm/scummvm/commit/6b7f6869c276cdbfbad0af9c1f240c16ab0299c3
Author: athrxx (athrxx at scummvm.org)
Date: 2024-05-20T15:32:14+02:00

Commit Message:
KYRA: fix coverity warning

Changed paths:
    engines/kyra/engine/lol.cpp


diff --git a/engines/kyra/engine/lol.cpp b/engines/kyra/engine/lol.cpp
index dea6b326c9b..a645aa591ee 100644
--- a/engines/kyra/engine/lol.cpp
+++ b/engines/kyra/engine/lol.cpp
@@ -1049,7 +1049,7 @@ void LoLEngine::update() {
 			"Lora a quitte le groupe. Ses objets sont par terre.",
 			"Lora hat die Gruppe verlassen. Ihre Sachen sind auf dem Boden.",
 			"Lora has left the party. Her items are on the floor.", // TODO: Translate to Japanese
-			"Lora ha abandonado el grupo. Sus artículos estan en el suelo.",	
+			"Lora ha abandonado el grupo. Sus articulos estan en el suelo.",	
 			"Lora has left the party. Her items are on the floor."	// TODO: Translate to Traditional Chinese
 		};
 
@@ -1966,7 +1966,7 @@ int LoLEngine::playCharacterScriptChat(int charId, int mode, int restorePortrait
 		}
 	}
 
-	if (!skipAnim) {
+	if (!skipAnim && charId < 3) {
 		_updateCharNum = charId;
 		_portraitSpeechAnimMode = mode;
 		_updatePortraitSpeechAnimDuration = strlen(str) >> 1;
@@ -1997,7 +1997,7 @@ int LoLEngine::playCharacterScriptChat(int charId, int mode, int restorePortrait
 	}
 
 	_fadeText = false;
-	if (!skipAnim)
+	if (!skipAnim && charId < 3)
 		updatePortraitSpeechAnim();
 
 	return 1;


Commit: 84a0bff2813dbf1476276d8a45f2f845d424dcea
    https://github.com/scummvm/scummvm/commit/84a0bff2813dbf1476276d8a45f2f845d424dcea
Author: athrxx (athrxx at scummvm.org)
Date: 2024-05-20T15:32:19+02:00

Commit Message:
SCUMM: fix Coverity warnings

Changed paths:
    engines/scumm/script.cpp
    engines/scumm/script_v2.cpp
    engines/scumm/script_v5.cpp
    engines/scumm/scumm.cpp


diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp
index 0a84b1ff6da..45ed82e6b76 100644
--- a/engines/scumm/script.cpp
+++ b/engines/scumm/script.cpp
@@ -978,7 +978,7 @@ void ScummEngine::runExitScript() {
 	// The same sound effect is also used in the underwater cavern (room
 	// 33), so we do the same fade out as in that room's exit script.
 	if (_game.id == GID_DIG && _currentRoom == 44 && enhancementEnabled(kEnhAudioChanges)) {
-		int scriptCmds[] = { 14, 215, 0x600, 0, 30, 0, 0, 0 };
+		int scriptCmds[] = { 14, 215, 0x600, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 		_sound->soundKludge(scriptCmds, ARRAYSIZE(scriptCmds));
 	}
 }
diff --git a/engines/scumm/script_v2.cpp b/engines/scumm/script_v2.cpp
index 74d185359aa..c74f5dcc2cf 100644
--- a/engines/scumm/script_v2.cpp
+++ b/engines/scumm/script_v2.cpp
@@ -407,7 +407,7 @@ void ScummEngine_v2::decodeParseString() {
 	//
 	// (Not using `_enableEnhancements` because some users could be really confused
 	// by the game hanging and they may not know about the Esc key.)
-	if (_game.id == GID_MANIAC && _game.platform != Common::kPlatformNES && _language == Common::FR_FRA && vm.slot[_currentScript].number == 155 && _roomResource == 31 && _actorToPrintStrFor == 9) {
+	if (_game.id == GID_MANIAC && _game.platform != Common::kPlatformNES && _language == Common::FR_FRA && _currentScript != 0xFF && vm.slot [_currentScript].number == 155 && _roomResource == 31 && _actorToPrintStrFor == 9) {
 		while (ptr - buffer < 100) {
 			*ptr++ = ' ';
 		}
@@ -419,7 +419,7 @@ void ScummEngine_v2::decodeParseString() {
 	// as I know, this is the only version with the typo.
 	else if (_game.id == GID_MANIAC && _game.version == 1
 		&& _game.platform == Common::kPlatformDOS
-		&& !(_game.features & GF_DEMO) && _language == Common::EN_ANY
+		&& !(_game.features & GF_DEMO) && _language == Common::EN_ANY && _currentScript != 0xFF
 		&& vm.slot[_currentScript].number == 260 && enhancementEnabled(kEnhTextLocFixes)
 		&& strncmp((char *)buffer + 26, " tring ", 7) == 0) {
 		for (byte *p = ptr; p >= buffer + 29; p--)
@@ -812,7 +812,7 @@ void ScummEngine_v2::o2_resourceRoutines() {
 		return;
 
 	// HACK V2 Maniac Mansion tries to load an invalid sound resource in demo script.
-	if (_game.id == GID_MANIAC && _game.version == 2 && vm.slot[_currentScript].number == 9 && type == rtSound && resid == 1)
+	if (_game.id == GID_MANIAC && _game.version == 2 && _currentScript != 0xFF && vm.slot [_currentScript].number == 9 && type == rtSound && resid == 1)
 		return;
 
 	if ((opcode & 0x0f) == 1) {
@@ -1472,6 +1472,7 @@ void ScummEngine_v2::o2_delay() {
 	delay |= fetchScriptByte() << 16;
 	delay = 0xFFFFFF - delay;
 
+	assert(_currentScript != 0xFF);
 	vm.slot[_currentScript].delay = delay;
 	vm.slot[_currentScript].status = ssPaused;
 	o5_breakHere();
diff --git a/engines/scumm/script_v5.cpp b/engines/scumm/script_v5.cpp
index dc59ef8c840..4b79515ff1d 100644
--- a/engines/scumm/script_v5.cpp
+++ b/engines/scumm/script_v5.cpp
@@ -649,9 +649,9 @@ void ScummEngine_v5::o5_setClass() {
 		// are taken from the Ultimate Talkie Edition.
 		if (_game.id == GID_MONKEY && _game.platform != Common::kPlatformFMTowns &&
 		    _game.platform != Common::kPlatformSegaCD && _roomResource == 59 &&
-		    vm.slot[_currentScript].number == 10002 && obj == 915 && cls == 6 &&
-			_currentPalette[251 * 3] == 0 && enhancementEnabled(kEnhVisualChanges) &&
-		    !(_game.features & GF_ULTIMATE_TALKIE)) {
+			_currentScript != 0xFF && vm.slot [_currentScript].number == 10002 &&
+			obj == 915 && cls == 6 && _currentPalette[251 * 3] == 0 &&
+			enhancementEnabled(kEnhVisualChanges) && !(_game.features & GF_ULTIMATE_TALKIE)) {
 			// True as long as Guybrush isn't done with the voodoo recipe on the
 			// Sea Monkey. The Ultimate Talkie Edition probably does this as a way
 			// to limit this palette override to Part One; just copy this behavior.
@@ -798,7 +798,7 @@ void ScummEngine_v5::o5_breakHere() {
 	// least intrusive way of adding the delay. The script calls it a number
 	// of times, but only once from room 69.
 
-	if (_game.id == GID_LOOM && _game.platform == Common::kPlatformPCEngine && _language == Common::EN_ANY && vm.slot[_currentScript].number == 44 && _currentRoom == 69) {
+	if (_game.id == GID_LOOM && _game.platform == Common::kPlatformPCEngine && _language == Common::EN_ANY && _currentScript != 0xFF && vm.slot [_currentScript].number == 44 && _currentRoom == 69) {
 		vm.slot[_currentScript].delay = 120;
 		vm.slot[_currentScript].status = ssPaused;
 	}
@@ -835,6 +835,7 @@ void ScummEngine_v5::o5_chainScript() {
 		vars[5] = vm.localvar[cur][5];
 	}
 
+	assert(cur != 0xFF);
 	vm.slot[cur].number = 0;
 	vm.slot[cur].status = ssDead;
 	_currentScript = 0xFF;
@@ -935,7 +936,7 @@ void ScummEngine_v5::o5_cutscene() {
 	// from the zeppelin with the biplane is missing the `[1]` parameter
 	// which disables the verb interface. For some reason, this only causes
 	// a problem on the FM-TOWNS version, though... also happens under UNZ.
-	if (_game.id == GID_INDY3 && _game.platform == Common::kPlatformFMTowns && _currentRoom == 80 && vm.slot[_currentScript].number == 201 && args[0] == 0 && enhancementEnabled(kEnhVisualChanges)) {
+	if (_game.id == GID_INDY3 && _game.platform == Common::kPlatformFMTowns && _currentRoom == 80 && _currentScript != 0xFF && vm.slot[_currentScript].number == 201 && args[0] == 0 && enhancementEnabled(kEnhVisualChanges)) {
 		args[0] = 1;
 	}
 
@@ -960,12 +961,14 @@ void ScummEngine_v5::o5_delay() {
 	int delay = fetchScriptByte();
 	delay |= fetchScriptByte() << 8;
 	delay |= fetchScriptByte() << 16;
+	assert(_currentScript != 0xFF);
 	vm.slot[_currentScript].delay = delay;
 	vm.slot[_currentScript].status = ssPaused;
 	o5_breakHere();
 }
 
 void ScummEngine_v5::o5_delayVariable() {
+	assert(_currentScript != 0xFF);
 	vm.slot[_currentScript].delay = getVar();
 	vm.slot[_currentScript].status = ssPaused;
 	o5_breakHere();
@@ -1050,7 +1053,7 @@ void ScummEngine_v5::o5_drawObject() {
 	// face Guybrush even if he's already looking at him.  drawObject() should never
 	// be called if Bit[129] is set in that script, so if it does happen, it means
 	// the check was missing, and so we ignore the next 32 bytes of Dread's reaction.
-	if (_game.id == GID_MONKEY2 && !(_game.features & GF_ULTIMATE_TALKIE) && _currentRoom == 22 && vm.slot[_currentScript].number == 201 && obj == 237 &&
+	if (_game.id == GID_MONKEY2 && !(_game.features & GF_ULTIMATE_TALKIE) && _currentRoom == 22 && _currentScript != 0xFF && vm.slot [_currentScript].number == 201 && obj == 237 &&
 		state == 1 && readVar(0x8000 + 129) == 1 && enhancementEnabled(kEnhMinorBugFixes)) {
 		_scriptPointer += 32;
 		return;
@@ -1062,7 +1065,7 @@ void ScummEngine_v5::o5_drawObject() {
 	// picked up the real Grail. This was probably done as a way to unconditionally
 	// reset the animation if it's already been played, but we can just do an
 	// unconditional reset of all previous frames instead, restoring the first one.
-	if (_game.id == GID_INDY3 && _roomResource == 87 && vm.slot[_currentScript].number == 200 && obj == 899 && state == 1 && VAR(VAR_TIMER_NEXT) != 12 && enhancementEnabled(kEnhRestoredContent)) {
+	if (_game.id == GID_INDY3 && _roomResource == 87 && _currentScript != 0xFF && vm.slot [_currentScript].number == 200 && obj == 899 && state == 1 && VAR(VAR_TIMER_NEXT) != 12 && enhancementEnabled(kEnhRestoredContent)) {
 		i = _numLocalObjects - 1;
 		do {
 			if (_objs[i].obj_nr)
@@ -1440,7 +1443,7 @@ void ScummEngine_v5::o5_isScriptRunning() {
 	// cutscenes and are abrubtly stopped by the endcutscene in script 204 at 0x0060.
 	// This patch changes the result of isScriptRunning(164) to also wait for any
 	// inventory scripts that are in a cutscene state, preventing the crash.
-	if (_game.id == GID_MONKEY && vm.slot[_currentScript].number == 204 && _currentRoom == 25) {
+	if (_game.id == GID_MONKEY && _currentScript != 0xFF && vm.slot [_currentScript].number == 204 && _currentRoom == 25) {
 		ScriptSlot *ss = vm.slot;
 		for (int i = 0; i < NUM_SCRIPT_SLOT; i++, ss++) {
 			if (ss->status != ssDead && ss->where == WIO_INVENTORY && ss->cutsceneOverride) {
@@ -1524,7 +1527,7 @@ void ScummEngine_v5::o5_isEqual() {
 	//
 	// Not using `_enableEnhancements`, since this small oversight only
 	// exists in this fan-made edition which was made for enhancements.
-	if (_game.id == GID_MONKEY2 && (_game.features & GF_ULTIMATE_TALKIE) && _roomResource == 48 && vm.slot[_currentScript].number == 215 && a == vm.localvar[_currentScript][0]) {
+	if (_game.id == GID_MONKEY2 && (_game.features & GF_ULTIMATE_TALKIE) && _roomResource == 48 && _currentScript != 0xFF && vm.slot [_currentScript].number == 215 && a == vm.localvar[_currentScript][0]) {
 		if (a == 550 && b == 530)
 			b = 550;
 		else if (a == 549 && b == 529)
@@ -2139,11 +2142,11 @@ void ScummEngine_v5::o5_resourceRoutines() {
 	// TODO: For the following see also Hibernatus' information on bug #7315.
 	case 32:
 		// TODO (apparently never used in FM-TOWNS)
-		debug(0, "o5_resourceRoutines %d not yet handled (script %d)", op, vm.slot[_currentScript].number);
+		debug(0, "o5_resourceRoutines %d not yet handled (script %d)", op, _currentScript != 0xFF ? vm.slot [_currentScript].number : -1);
 		break;
 	case 33:
 		// TODO (apparently never used in FM-TOWNS)
-		debug(0, "o5_resourceRoutines %d not yet handled (script %d)", op, vm.slot[_currentScript].number);
+		debug(0, "o5_resourceRoutines %d not yet handled (script %d)", op, _currentScript != 0xFF ? vm.slot [_currentScript].number : -1);
 		break;
 	case 35:
 		if (_townsPlayer)
@@ -2738,7 +2741,7 @@ void ScummEngine_v5::o5_startScript() {
 	// book or KO the guy. The PC version correctly gives 10 points for puzzle
 	// 29 for KO and 15 for puzzle 30 when giving the book."
 	// This workaround is meant to address that.
-	if (_game.id == GID_INDY3 && vm.slot[_currentScript].number == 106 && script == 125 && VAR(115) != 2) {
+	if (_game.id == GID_INDY3 && _currentScript != 0xFF && vm.slot[_currentScript].number == 106 && script == 125 && VAR(115) != 2) {
 		// If Var[115] != 2, then:
 		// Correct: startScript(125,[29,10]);
 		// Wrong : startScript(125,[30,15]);
@@ -2750,7 +2753,7 @@ void ScummEngine_v5::o5_startScript() {
 	// shepherds, their first reaction line ("We are the masters of
 	// stealth") is missing a Local[0] value for the actor number. This
 	// causes the line to be silently skipped (as in the original).
-	if (_game.id == GID_LOOM && _game.version == 3 && _roomResource == 23 && script == 232 && data[0] == 0 &&
+	if (_game.id == GID_LOOM && _game.version == 3 && _roomResource == 23 && script == 232 && data[0] == 0 && _currentScript != 0xFF &&
 		vm.slot[_currentScript].number >= 422 && vm.slot[_currentScript].number <= 425 && enhancementEnabled(kEnhRestoredContent)) {
 		// Restore the missing line by attaching it to the shepherd on which the
 		// draft was used.
@@ -2802,7 +2805,7 @@ void ScummEngine_v5::o5_stopScript() {
 
 	script = getVarOrDirectByte(PARAM_1);
 
-	if (_game.id == GID_INDY4 && script == 164 && _roomResource == 50 &&
+	if (_game.id == GID_INDY4 && script == 164 && _roomResource == 50 && _currentScript != 0xFF &&
 		vm.slot[_currentScript].number == 213 && VAR(VAR_HAVE_MSG) &&
 		getOwner(933) == VAR(VAR_EGO) && getClass(933, 146) && enhancementEnabled(kEnhRestoredContent)) {
 		// WORKAROUND bug #2215: Due to a script bug, a line of text is skipped
@@ -3070,7 +3073,7 @@ void ScummEngine_v5::o5_walkActorTo() {
 	// the script which closes the door *before* he starts walking away from
 	// it, as in the other releases. Another v5 bug fixed on SegaCD, though!
 	if (_game.id == GID_MONKEY && !(_game.features & GF_ULTIMATE_TALKIE) && _game.platform != Common::kPlatformSegaCD &&
-		_currentRoom == 30 && vm.slot[_currentScript].number == 207 && a->_number == 11 &&
+		_currentRoom == 30 && _currentScript != 0xFF && vm.slot[_currentScript].number == 207 && a->_number == 11 &&
 		x == 232 && y == 141 && enhancementEnabled(kEnhVisualChanges)) {
 		if (whereIsObject(387) == WIO_ROOM && getState(387) == 1 && getState(437) == 1) {
 			int args[NUM_SCRIPT_LOCAL];
@@ -3089,7 +3092,7 @@ void ScummEngine_v5::o5_walkActorTo() {
 	//
 	// Intentionally not using `_enableEnhancements`, since you can get
 	// completely stuck.
-	if (_game.id == GID_INDY4 && vm.slot[_currentScript].number == 10002 &&
+	if (_game.id == GID_INDY4 && _currentScript != 0xFF && vm.slot[_currentScript].number == 10002 &&
 		_currentRoom == (_game.platform == Common::kPlatformAmiga ? 58 : 60) &&
 		VAR(224) == 140 && a->_number == VAR(VAR_EGO) && x == 45 && y == 137) {
 		// If the elevator isn't on the current floor yet...
@@ -3220,7 +3223,7 @@ void ScummEngine_v5::decodeParseString() {
 			// with a shadow, but in a Mac emulator the text is
 			// drawn in light gray with a shadow instead. Very
 			// strange.
-			if (_game.id == GID_INDY3 && _game.platform == Common::kPlatformMacintosh && vm.slot[_currentScript].number == 134 && color == 0x8F)
+			if (_game.id == GID_INDY3 && _game.platform == Common::kPlatformMacintosh && _currentScript != 0xFF && vm.slot [_currentScript].number == 134 && color == 0x8F)
 				color = 0x87;
 
 			// WORKAROUND: In the CD version of MI1, the text in
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index a0d379bbffe..1bb3e87bd54 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -3110,7 +3110,7 @@ void ScummEngine_v3::terminateSaveMenuScript() {
 
 		// If local variable 0 and the override flag are set, chain script 119
 		if (readVar(0x4000)) {
-			if (VAR(VAR_OVERRIDE)) {
+			if (VAR(VAR_OVERRIDE) && _currentScript != 0xFF) {
 				int cur = _currentScript;
 
 				vm.slot[cur].number = 0;




More information about the Scummvm-git-logs mailing list