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

antoniou79 a.antoniou79 at gmail.com
Wed Feb 5 16:32:19 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:
af84139d16 BLADERUNNER: A better approach for the DR01 flame glitch
d4c659610d BLADERUNNER: Fixes for McCoy's stamina system and drain


Commit: af84139d16100fc89e74fed97ea0656e321a72a6
    https://github.com/scummvm/scummvm/commit/af84139d16100fc89e74fed97ea0656e321a72a6
Author: Thanasis Antoniou (a.antoniou79 at gmail.com)
Date: 2020-02-05T18:28:46+02:00

Commit Message:
BLADERUNNER: A better approach for the DR01 flame glitch

This is the barrel flame effect glitch during the pans from DR04 to DR01

The advanceFrame() call in scene.cpp is restored in this new approach (the original code has it too), and InitializeScene is used to disable the effect when entering the scene coming from DR04.

Changed paths:
    engines/bladerunner/scene.cpp
    engines/bladerunner/script/scene/dr01.cpp


diff --git a/engines/bladerunner/scene.cpp b/engines/bladerunner/scene.cpp
index 7ee784f..ceef9ba 100644
--- a/engines/bladerunner/scene.cpp
+++ b/engines/bladerunner/scene.cpp
@@ -158,12 +158,14 @@ bool Scene::open(int setId, int sceneId, bool isLoadingGame) {
 		startDefaultLoop();
 	}
 
-#if BLADERUNNER_ORIGINAL_BUGS
-	// TODO Is this advanced frame (frame skip) required here?
-	// For a little testing without it, it seems to be redundant (or even unwanted)
-	// and it is contributing to the barrel flame glitch in pan from DR04 to DR01
+	// This frame advancement (frame skip) may be required here
+	// It is in the original code and possible initializes some variables
+	// (or perhaps z-buffering related stuff)
+	// It may cause issues when in a scene we need to trigger some action
+	// based on the first frame of the loop when entering the scene (using SceneFrameAdvanced())
+	// (eg. it is contributing to the barrel flame glitch in pan from DR04 to DR01)
+	// However, better to resolve those issues with a workaround (eg. using InitializeScene())
 	advanceFrame();
-#endif // BLADERUNNER_ORIGINAL_BUGS
 
 	_vm->_playerActor->setAtXYZ(_actorStartPosition, _actorStartFacing);
 	_vm->_playerActor->setSetId(setId);
diff --git a/engines/bladerunner/script/scene/dr01.cpp b/engines/bladerunner/script/scene/dr01.cpp
index 6a0ac2d..0469a8d 100644
--- a/engines/bladerunner/script/scene/dr01.cpp
+++ b/engines/bladerunner/script/scene/dr01.cpp
@@ -36,6 +36,12 @@ void SceneScriptDR01::InitializeScene() {
 	if (Game_Flag_Query(kFlagDR02toDR01)) {
 		Setup_Scene_Information(  -835.0f, -0.04f, -118.0f, 664);
 	} else if (Game_Flag_Query(kFlagDR04toDR01)) {
+#if BLADERUNNER_ORIGINAL_BUGS
+#else
+		// Part of the barrel flame glitch bug fix:
+		// Disable rogue barrel flame effect during the pan from DR04 to DR01
+		Screen_Effect_Skip(0, false);
+#endif // BLADERUNNER_ORIGINAL_BUGS
 		Setup_Scene_Information(  -711.0f, -0.04f,   70.0f, 307);
 	} else if (Game_Flag_Query(kFlagCT11toDR01)) {
 		Setup_Scene_Information(-1765.28f, -0.04f, -23.82f, 269);
@@ -286,10 +292,13 @@ void SceneScriptDR01::SceneFrameAdvanced(int frame) {
 	}
 #if BLADERUNNER_ORIGINAL_BUGS
 #else
+	// Part of the barrel flame glitch bug fix:
 	// Disable rogue barrel flame effect during the pan from DR04 to DR01
+	// loops: kDR01LoopPanFromDR04Pre, kDR01LoopPanFromDR04Post
 	if (frame == 89 || frame == 117 ){
 		Screen_Effect_Skip(0, false);
 	}
+	// And restore the flame effect at the end of the loops
 	if (frame == 116 || frame == 144) {
 		Screen_Effect_Restore_All(false);
 	}
@@ -349,6 +358,10 @@ void SceneScriptDR01::PlayerWalkedOut() {
 			// but don't play this extra outtake when going to Tyrell Building
 			Outtake_Play(kOuttakeAway1,   true, -1);
 		}
+
+		// Part of the barrel flame glitch bug fix:
+		// Add this effect restoration -- as a catch all case
+		Screen_Effect_Restore_All(false);
 #endif // BLADERUNNER_ORIGINAL_BUGS
 	}
 }


Commit: d4c659610daf371e5313a3094d6a109cf27c7c1b
    https://github.com/scummvm/scummvm/commit/d4c659610daf371e5313a3094d6a109cf27c7c1b
Author: Thanasis Antoniou (a.antoniou79 at gmail.com)
Date: 2020-02-05T18:28:46+02:00

Commit Message:
BLADERUNNER: Fixes for McCoy's stamina system and drain

The original game had broken stamina system we have it fixed.

This means that in vanilla mode, McCoy's stamina will drain fast if the player does not click the mouse, but he will increase speed up to a max, if the player keeps clicking the mouse.
In Restored Content, we allow McCoy to keep his speed (so that the player does not have to keep clicking); the stamina drain will still kick in but it will be at a slower rate and practically won't be noticeable most of the time.

Changed paths:
    engines/bladerunner/actor.cpp
    engines/bladerunner/actor.h
    engines/bladerunner/bladerunner.cpp
    engines/bladerunner/debugger.cpp


diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp
index 5b29a97..bd5a910 100644
--- a/engines/bladerunner/actor.cpp
+++ b/engines/bladerunner/actor.cpp
@@ -97,16 +97,18 @@ void Actor::setup(int actorId) {
 	_retiredHeight            = 0;
 	_scale                    = 1.0f;
 
-	_timer4RemainDefault      = 60000u;
+	_timer4RemainDefault      = 60000;
 
 	_movementTrackWalkingToWaypointId = -1;
 	_movementTrackDelayOnNextWaypoint = -1;
 
 	for (int i = 0; i != kActorTimers; ++i) {
-		_timersLeft[i] = 0u;
+		_timersLeft[i] = 0;
 		_timersLast[i] = _vm->_time->current();
 	}
-	_timersLeft[kActorTimerClueExchange] = _timer4RemainDefault; // This was in original code. We need to init this timer in order to kick off periodic updates for acquireCluesByRelations
+	// This was in original code.
+	// We need to init this timer in order to kick off periodic updates for acquireCluesByRelations
+	_timersLeft[kActorTimerClueExchange] = _timer4RemainDefault;
 
 	_honesty                     = 50;
 	_intelligence                = 50;
@@ -216,51 +218,76 @@ void Actor::setFPS(int fps) {
 }
 
 void Actor::increaseFPS() {
+#if BLADERUNNER_ORIGINAL_BUGS
+	int fps = MIN(_fps + 3, 30);
+	setFPS(fps);
+#else
+	int oldFps = _fps; // new aux variable
 	int fps = MIN(_fps + 3, 30);
 	setFPS(fps);
+
+	// Only McCoy is using the stamina timer in the game
+	if (_id == kActorMcCoy) {
+		if (_vm->_cutContent) {
+			if (_fps > 20 && oldFps < _fps) {
+				// only start the stamina timer
+				// when McCoy's fps are more than 20 fps and purely increased
+				// and only if the new drain interval is smaller than the previous one
+				// the start drain interval is supposed to be slow
+				// starting from 10 seconds and decreasing as low as 1 second
+				// (It will barely come into play basically)
+				int nextStaminaDrainInterval = (31 - _fps) * 1000;
+				if (nextStaminaDrainInterval < timerLeft(kActorTimerRunningStaminaFPS)) {
+					timerStart(kActorTimerRunningStaminaFPS, nextStaminaDrainInterval);
+				}
+			}
+		} else {
+			// just prevent any rogue state for stamina timer being 0
+			// at any time when McCoy's fps get increased
+			if (timerLeft(kActorTimerRunningStaminaFPS) == 0) {
+				timerStart(kActorTimerRunningStaminaFPS, 200);
+			}
+		}
+	}
+#endif // BLADERUNNER_ORIGINAL_BUGS
 }
 
 void Actor::timerStart(int timerId, int32 interval) {
 	assert(timerId >= 0 && timerId < kActorTimers);
-	if (interval < 0 ) {
-		interval = 0;
-	}
-	_timersLeft[timerId] = (uint32)interval;
+
+	_timersLeft[timerId] = interval;
 	_timersLast[timerId] = _vm->_time->current();
 }
 
 void Actor::timerReset(int timerId) {
 	assert(timerId >= 0 && timerId < kActorTimers);
-	_timersLeft[timerId] = 0u;
+	_timersLeft[timerId] = 0;
 }
 
-uint32 Actor::timerLeft(int timerId) {
+// timerLeft can be negative - This is required for
+// the actor's animation update timer mostly (timer kActorTimerAnimationFrame)
+int32 Actor::timerLeft(int timerId) {
 	assert(timerId >= 0 && timerId < kActorTimers);
 	return _timersLeft[timerId];
 }
 
 void Actor::timersUpdate() {
-	for (int i = 0; i <= 6; i++) {
+	for (int i = 0; i < kActorTimers; i++) {
 		timerUpdate(i);
 	}
 }
 
 void Actor::timerUpdate(int timerId) {
-	if (_timersLeft[timerId] == 0u) {
+	if (_timersLeft[timerId] == 0) {
 		return;
 	}
 
 	uint32 timeNow = _vm->_time->current();
 	uint32 timeDiff = timeNow - _timersLast[timerId]; // unsigned difference is intentional
 	_timersLast[timerId] = timeNow;
-	// new check is safe-guard against old saves, _timersLeft should never have very big value anyway
-	if ((int32)_timersLeft[timerId] < 0 ) {
-		// this will make it 0u in the next command below
-		_timersLeft[timerId] = 0u;
-	}
-	_timersLeft[timerId] = (_timersLeft[timerId] < timeDiff) ? 0u : (_timersLeft[timerId] - timeDiff);
 
-	if (_timersLeft[timerId] == 0u) { // original check was <= 0
+	_timersLeft[timerId] = _timersLeft[timerId] - timeDiff;
+	if (_timersLeft[timerId] <= 0) {
 		switch (timerId) {
 		case kActorTimerAIScriptCustomTask0:
 			// fall through
@@ -269,15 +296,15 @@ void Actor::timerUpdate(int timerId) {
 		case kActorTimerAIScriptCustomTask2:
 			if (!_vm->_aiScripts->isInsideScript() && !_vm->_sceneScript->isInsideScript()) {
 				_vm->_aiScripts->timerExpired(_id, timerId);
-				_timersLeft[timerId] = 0u;
+				_timersLeft[timerId] = 0;
 			} else {
-				_timersLeft[timerId] = 1u;
+				_timersLeft[timerId] = 1;
 			}
 			break;
 		case kActorTimerMovementTrack:
-			_timersLeft[kActorTimerMovementTrack] = 0u;
+			_timersLeft[kActorTimerMovementTrack] = 0;
 			if (_movementTrack->isPaused()) {
-				_timersLeft[kActorTimerMovementTrack] = 1u;
+				_timersLeft[kActorTimerMovementTrack] = 1;
 			} else {
 				movementTrackNext(false);
 			}
@@ -300,7 +327,21 @@ void Actor::timerUpdate(int timerId) {
 					setFPS(newFps);
 				}
 			}
-			_timersLeft[kActorTimerRunningStaminaFPS] = 200u;
+#if BLADERUNNER_ORIGINAL_BUGS
+			_timersLeft[kActorTimerRunningStaminaFPS] = 200;
+#else
+			if (_vm->_cutContent) {
+				if (isRunning()) {
+					// drain faster if closer to max fps (30), else slower
+					_timersLeft[kActorTimerRunningStaminaFPS] = (31 - _fps) * 200;
+				} else {
+					// not running - stop the timer
+					timerReset(kActorTimerRunningStaminaFPS);
+				}
+			} else {
+				_timersLeft[kActorTimerRunningStaminaFPS] = 200;
+			}
+#endif // BLADERUNNER_ORIGINAL_BUGS
 			break;
 		default:
 			break;
@@ -620,17 +661,17 @@ void Actor::run() {
 }
 
 bool Actor::tick(bool forceDraw, Common::Rect *screenRect) {
-	uint32 timeLeft = 0u;
+	int32 timeLeft = 0;
 	bool needsUpdate = false;
 	if (_fps > 0) {
 		timerUpdate(kActorTimerAnimationFrame);
 		timeLeft = timerLeft(kActorTimerAnimationFrame);
-		needsUpdate = (timeLeft == 0); // original was <= 0, with timeLeft int
+		needsUpdate = (timeLeft <= 0);
 	} else if (_fps == 0) {
 		needsUpdate = false;
 	} else if (forceDraw) {
 		needsUpdate = true;
-		timeLeft = 0u;
+		timeLeft = 0;
 	}
 
 	if (needsUpdate) {
@@ -751,7 +792,8 @@ bool Actor::tick(bool forceDraw, Common::Rect *screenRect) {
 	}
 
 	if (needsUpdate) {
-		int nextFrameTime = (int)(timeLeft + _frameMs); // Should be ok
+		// timeLeft is supposed to be negative or 0 here in the original!
+		int32 nextFrameTime = timeLeft + _frameMs;
 		if (nextFrameTime <= 0) {
 			nextFrameTime = 1;
 		}
@@ -1526,14 +1568,28 @@ void Actor::load(SaveFileReadStream &f) {
 	_scale = f.readFloat();
 
 	for (int i = 0; i < kActorTimers; ++i) {
-		_timersLeft[i] = f.readUint32LE();
+		_timersLeft[i] = (int32)f.readUint32LE();
 	}
+
 	// Bugfix: Special initialization case for timer 4 (kActorTimerClueExchange) when its value is restored as 0
 	// This should be harmless, but will remedy any broken save-games where the timer 4 was saved as 0.
-	if (_timersLeft[kActorTimerClueExchange] == 0u) {
+	if (_timersLeft[kActorTimerClueExchange] == 0) {
 		_timersLeft[kActorTimerClueExchange] = _timer4RemainDefault;
 	}
 
+	// Bugfix: Similar to the above
+	// Special initialization case for timer 6 (kActorTimerRunningStaminaFPS) when its value is restored as 0
+	// This was due to an original game bug and it concerns only McCoy (player's actor)
+	// This should be harmless, but will remedy any broken save-games where the timer 6 was saved as 0.
+	// Also, in restored content mode we allow this counter to be 0 and only start it
+	// when McCoy's FPS get increased (starts running with sufficient speed),
+	// so the fix is not needed for RC mode
+	if (!_vm->_cutContent) {
+		if (_id == kActorMcCoy && _timersLeft[kActorTimerRunningStaminaFPS] == 0) {
+			_timersLeft[kActorTimerClueExchange] = 200;
+		}
+	}
+
 	uint32 now = _vm->_time->getPauseStart();
 	for (int i = 0; i < kActorTimers; ++i) {
 		_timersLast[i] = now - f.readUint32LE(); // we require an unsigned difference here, since _timersLast is essentially keeping time
diff --git a/engines/bladerunner/actor.h b/engines/bladerunner/actor.h
index a73d863..bb1e4d3 100644
--- a/engines/bladerunner/actor.h
+++ b/engines/bladerunner/actor.h
@@ -110,7 +110,7 @@ private:
 	int _retiredWidth;
 	int _retiredHeight;
 
-	uint32 _timersLeft[kActorTimers]; // this keeps time difference, and it is stored during save() (saveInt actually saves a uint32)
+	int32 _timersLeft[kActorTimers];  // this keeps time difference, and it is stored during save() (saveInt actually saves a uint32)
 	uint32 _timersLast[kActorTimers]; // this keeps actual time, and is not stored during save(), so it can be a uint32
 
 	float _scale;
@@ -145,7 +145,7 @@ public:
 
 	void   timerStart(int timerId, int32 interval);
 	void   timerReset(int timerId);
-	uint32 timerLeft(int timerId);
+	int32 timerLeft(int timerId);
 	void   timersUpdate();
 	void   timerUpdate(int timerId);
 
diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp
index 3493c8a..12d7b42 100644
--- a/engines/bladerunner/bladerunner.cpp
+++ b/engines/bladerunner/bladerunner.cpp
@@ -393,7 +393,6 @@ Common::Error BladeRunnerEngine::run() {
 		//  else {
 		// 	newGame(kGameDifficultyMedium);
 		// }
-
 		gameLoop();
 
 		_mouse->disable();
@@ -466,7 +465,7 @@ bool BladeRunnerEngine::checkFiles(Common::Array<Common::String> &missingFiles)
 }
 
 bool BladeRunnerEngine::startup(bool hasSavegames) {
-		// Assign default values to the ScummVM configuration manager, in case settings are missing
+	// Assign default values to the ScummVM configuration manager, in case settings are missing
 	ConfMan.registerDefault("subtitles", "true");
 	ConfMan.registerDefault("sfx_volume", 192);
 	ConfMan.registerDefault("music_volume", 192);
@@ -609,8 +608,16 @@ bool BladeRunnerEngine::startup(bool hasSavegames) {
 	_actors[kActorVoiceOver] = new Actor(this, kActorVoiceOver);
 	_playerActor = _actors[_gameInfo->getPlayerId()];
 
-	_playerActor->setFPS(15);
+	_playerActor->setFPS(15); // this seems redundant
+#if BLADERUNNER_ORIGINAL_BUGS
 	_playerActor->timerStart(kActorTimerRunningStaminaFPS, 200);
+#else
+	// Make code here similar to the bugfix in newGame in that
+	// we only start the timer in vanilla game mode (not Restored Content mode)
+	if (!_cutContent) {
+		_playerActor->timerStart(kActorTimerRunningStaminaFPS, 200);
+	}
+#endif // BLADERUNNER_ORIGINAL_BUGS
 
 	_policeMaze = new PoliceMaze(this);
 
@@ -695,7 +702,6 @@ bool BladeRunnerEngine::startup(bool hasSavegames) {
 	_aiScripts = new AIScripts(this, actorCount);
 
 	initChapterAndScene();
-
 	return true;
 }
 
@@ -1145,8 +1151,8 @@ void BladeRunnerEngine::actorsUpdate() {
 #if BLADERUNNER_ORIGINAL_BUGS
 #else
 	uint32 timeNow = _time->current();
-	// Don't update actors more than 60 times per second
-	if (timeNow - _actorUpdateTimeLast < 1000 / 60) {
+	// Don't update actors more than 60 or 120 times per second
+	if (timeNow - _actorUpdateTimeLast < 1000 / ( _framesPerSecondMax? 120 : 60)) {
 		return;
 	}
 	_actorUpdateTimeLast = timeNow;
@@ -1673,7 +1679,7 @@ void BladeRunnerEngine::handleMouseClickEmpty(int x, int y, Vector3 &scenePositi
 		}
 
 		bool shouldRun = _playerActor->isRunning();
-		if (_mouseClickTimeDiff <= 10000 && xDist < 10 && yDist < 10) {
+		if (_mouseClickTimeDiff <= 10000 && xDist <= 10 && yDist <= 10) {
 			shouldRun = true;
 		}
 
@@ -2212,6 +2218,17 @@ void BladeRunnerEngine::newGame(int difficulty) {
 	}
 	_actors[kActorVoiceOver]->setup(kActorVoiceOver);
 
+#if BLADERUNNER_ORIGINAL_BUGS
+#else
+	// Special settings for McCoy that are in BladeRunnerEngine::startup()
+	// but are overridden here, resulting to the stamina counter
+	// never being initialized in the original game
+	_playerActor->setFPS(15); // this seems redundant
+	if (!_cutContent) {
+		_playerActor->timerStart(kActorTimerRunningStaminaFPS, 200);
+	}
+#endif // BLADERUNNER_ORIGINAL_BUGS
+
 	for (uint i = 0; i < _gameInfo->getSuspectCount(); ++i) {
 		_suspectsDatabase->get(i)->reset();
 	}
diff --git a/engines/bladerunner/debugger.cpp b/engines/bladerunner/debugger.cpp
index 2151917..e922a7d 100644
--- a/engines/bladerunner/debugger.cpp
+++ b/engines/bladerunner/debugger.cpp
@@ -863,7 +863,7 @@ bool Debugger::cmdTimer(int argc, const char **argv) {
 	}
 
 	for (int i = 0; i < 7; ++i) {
-		debugPrintf("actorTimer(%i, %i) = %u ms\n", actorId, i, actor->timerLeft(i));
+		debugPrintf("actorTimer(%i, %i) = %d ms\n", actorId, i, actor->timerLeft(i));
 	}
 
 	return true;




More information about the Scummvm-git-logs mailing list