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

mgerhardy martin.gerhardy at gmail.com
Wed Nov 4 21:46:29 UTC 2020


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:
3142218801 TWINE: fixed missing 0-byte at the end of the fla movie string
f388a14ad6 TWINE: fixed max value for getRandomNumber


Commit: 3142218801e13a4ee6f7fe4b727835d55b29aeae
    https://github.com/scummvm/scummvm/commit/3142218801e13a4ee6f7fe4b727835d55b29aeae
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-04T22:46:17+01:00

Commit Message:
TWINE: fixed missing 0-byte at the end of the fla movie string

Changed paths:
    engines/twine/script_life_v1.cpp


diff --git a/engines/twine/script_life_v1.cpp b/engines/twine/script_life_v1.cpp
index 5c8acd7538..4a4872dda1 100644
--- a/engines/twine/script_life_v1.cpp
+++ b/engines/twine/script_life_v1.cpp
@@ -1033,10 +1033,10 @@ static int32 lPLAY_FLA(TwinEEngine *engine, LifeScriptContext &ctx) {
 	char movie[64];
 	do {
 		const byte c = ctx.stream.readByte();
+		movie[strIdx++] = c;
 		if (c == '\0') {
 			break;
 		}
-		movie[strIdx++] = c;
 		if (strIdx >= ARRAYSIZE(movie)) {
 			error("Max string size exceeded for fla name");
 		}


Commit: f388a14ad67c67d91c1f4c101894b6eab5ccdade
    https://github.com/scummvm/scummvm/commit/f388a14ad67c67d91c1f4c101894b6eab5ccdade
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-04T22:46:17+01:00

Commit Message:
TWINE: fixed max value for getRandomNumber

the value was off-by-one causing all kind of weird errors in the game. E.g.
the first scene didn't drop a key each time.

Changed paths:
    engines/twine/actor.cpp
    engines/twine/twine.cpp
    engines/twine/twine.h


diff --git a/engines/twine/actor.cpp b/engines/twine/actor.cpp
index 742813a56d..461b9b9b82 100644
--- a/engines/twine/actor.cpp
+++ b/engines/twine/actor.cpp
@@ -507,7 +507,10 @@ void Actor::processActorExtraBonus(int32 actorIdx) { // GiveExtraBonus
 		return;
 	}
 
-	int8 currentBonus = bonusTable[_engine->getRandomNumber(numBonus)];
+	const int bonusIndex = _engine->getRandomNumber(numBonus);
+	assert(bonusIndex >= 0);
+	assert(bonusIndex < numBonus);
+	int8 currentBonus = bonusTable[bonusIndex];
 	// if bonus is magic an no magic level yet, then give life points
 	if (!_engine->_gameState->magicLevelIdx && currentBonus == 2) {
 		currentBonus = 1;
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 7aab9bf1fd..36103f1f1f 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -409,7 +409,10 @@ void TwinEEngine::initAll() {
 }
 
 int TwinEEngine::getRandomNumber(uint max) {
-	return _rnd.getRandomNumber(max);
+	if (max == 0) {
+		return 0;
+	}
+	return _rnd.getRandomNumber(max - 1);
 }
 
 void TwinEEngine::freezeTime() {
diff --git a/engines/twine/twine.h b/engines/twine/twine.h
index a445a93754..fc6cccc78f 100644
--- a/engines/twine/twine.h
+++ b/engines/twine/twine.h
@@ -243,6 +243,9 @@ public:
 	int32 runGameEngine();
 	/** Allocate video memory, both front and back buffers */
 	void allocVideoMemory();
+	/**
+	 * @return A random value between [0-max)
+	 */
 	int getRandomNumber(uint max = 0x7FFF);
 	int32 quitGame = 0;
 	int32 lbaTime = 0;




More information about the Scummvm-git-logs mailing list