[Scummvm-git-logs] scummvm master -> 16c29c1169429f16a663743a27a468e9092a3510

neuromancer noreply at scummvm.org
Wed Nov 19 06:55:00 UTC 2025


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

Summary:
efec941454 PRIVATE: Fix wall safe initialization
16c29c1169 PRIVATE: Fix wall safe digit rendering


Commit: efec941454cc45bca1e1349f7ea402e10fd04a96
    https://github.com/scummvm/scummvm/commit/efec941454cc45bca1e1349f7ea402e10fd04a96
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2025-11-19T07:54:54+01:00

Commit Message:
PRIVATE: Fix wall safe initialization

Wall safe now behaves like the original:

- Wall safe is initialized from kWallSafeValue
- kWallSafeValue is initialized to random value when starting game
- Screen no longer flickers on each initial digit draw

Changed paths:
    engines/private/private.cpp
    engines/private/private.h


diff --git a/engines/private/private.cpp b/engines/private/private.cpp
index 3a49c0aabb0..7fad74201ab 100644
--- a/engines/private/private.cpp
+++ b/engines/private/private.cpp
@@ -119,7 +119,6 @@ PrivateEngine::PrivateEngine(OSystem *syst, const ADGameDescription *gd)
 	_safeNumberPath = "sg/search_s/sgsaf%d.bmp";
 	for (uint d = 0 ; d < 3; d++) {
 		_safeDigitArea[d].clear();
-		_safeDigit[d] = 0;
 		_safeDigitRect[d] = Common::Rect(0, 0);
 	}
 }
@@ -297,6 +296,7 @@ Common::Error PrivateEngine::run() {
 	initGraphics(_screenW, _screenH, &_pixelFormat);
 	_transparentColor = 250;
 
+	initializeWallSafeValue();
 	_safeColor = _pixelFormat.RGBToColor(65, 65, 65);
 	_screenRect = Common::Rect(0, 0, _screenW, _screenH);
 	loadCursors();
@@ -538,7 +538,6 @@ void PrivateEngine::clearAreas() {
 			delete _safeDigitArea[d].surf;
 		}
 		_safeDigitArea[d].clear();
-		_safeDigit[d] = 0;
 		_safeDigitRect[d] = Common::Rect(0, 0);
 	}
 }
@@ -1244,6 +1243,20 @@ bool PrivateEngine::selectDossierPrevSuspect(Common::Point mousePos) {
 	return false;
 }
 
+void PrivateEngine::initializeWallSafeValue() {
+	if (isDemo()) {
+		return;
+	}
+
+	// initialize to a random value that is not the combination
+	Private::Symbol *sym = maps.variables.getVal(getWallSafeValueVariable());
+	int value;
+	do {
+		value = _rnd->getRandomNumber(999);
+	} while (value == 426);
+	sym->u.val = value;
+}
+
 bool PrivateEngine::selectSafeDigit(Common::Point mousePos) {
 	if (_safeDigitArea[0].surf == nullptr)
 		return false;
@@ -1254,10 +1267,8 @@ bool PrivateEngine::selectSafeDigit(Common::Point mousePos) {
 
 	for (uint d = 0 ; d < 3; d ++)
 		if (_safeDigitRect[d].contains(mousePos)) {
-			_safeDigit[d] = (_safeDigit[d] + 1) % 10;
+			incrementSafeDigit(d);
 			renderSafeDigit(d);
-			Private::Symbol *sym = maps.variables.getVal(getWallSafeValueVariable());
-			sym->u.val = 100*_safeDigit[0] + 10*_safeDigit[1] + _safeDigit[2];
 			return true;
 		}
 
@@ -1269,16 +1280,15 @@ void PrivateEngine::addSafeDigit(uint32 d, Common::Rect *rect) {
 	MaskInfo m;
 	_safeDigitRect[d] = *rect;
 	fillRect(_safeColor, _safeDigitRect[d]);
-	m.surf = loadMask(Common::String::format(_safeNumberPath.c_str(), _safeDigit[d]), _safeDigitRect[d].left, _safeDigitRect[d].top, true);
+	int digitValue = getSafeDigit(d);
+	m.surf = loadMask(Common::String::format(_safeNumberPath.c_str(), digitValue), _safeDigitRect[d].left, _safeDigitRect[d].top, true);
 	m.cursor = g_private->getExitCursor();
 	m.nextSetting = "";
 	m.flag1 = nullptr;
 	m.flag2 = nullptr;
 	_safeDigitArea[d] = m;
-	drawScreen();
 }
 
-
 void PrivateEngine::renderSafeDigit(uint32 d) {
 
 	if (_safeDigitArea[d].surf != nullptr) {
@@ -1287,8 +1297,9 @@ void PrivateEngine::renderSafeDigit(uint32 d) {
 		_safeDigitArea[d].clear();
 	}
 	fillRect(_safeColor, _safeDigitRect[d]);
+	int digitValue = getSafeDigit(d);
 	MaskInfo m;
-	m.surf = loadMask(Common::String::format(_safeNumberPath.c_str(), _safeDigit[d]), _safeDigitRect[d].left, _safeDigitRect[d].top, true);
+	m.surf = loadMask(Common::String::format(_safeNumberPath.c_str(), digitValue), _safeDigitRect[d].left, _safeDigitRect[d].top, true);
 	m.cursor = g_private->getExitCursor();
 	m.nextSetting = "";
 	m.flag1 = nullptr;
@@ -1297,6 +1308,36 @@ void PrivateEngine::renderSafeDigit(uint32 d) {
 	drawScreen();
 }
 
+int PrivateEngine::getSafeDigit(uint32 d) {
+	assert(d < 3);
+
+	Private::Symbol *sym = maps.variables.getVal(getWallSafeValueVariable());
+	int value = sym->u.val;
+
+	byte digits[3];
+	digits[0] = value / 100;
+	digits[1] = (value / 10) % 10;
+	digits[2] = value % 10;
+
+	return digits[d];
+}
+
+void PrivateEngine::incrementSafeDigit(uint32 d) {
+	assert(d < 3);
+
+	Private::Symbol *sym = maps.variables.getVal(getWallSafeValueVariable());
+	int value = sym->u.val;
+
+	byte digits[3];
+	digits[0] = value / 100;
+	digits[1] = (value / 10) % 10;
+	digits[2] = value % 10;
+
+	digits[d] = (digits[d] + 1) % 10;
+	
+	sym->u.val = (100 * digits[0]) + (10 * digits[1]) + digits[2];
+}
+
 void PrivateEngine::selectLoadGame(Common::Point mousePos) {
 	if (_loadGameMask.surf == nullptr)
 		return;
@@ -1353,6 +1394,9 @@ void PrivateEngine::restartGame() {
 
 	// VSPicture
 	_nextVS = "";
+
+	// Wall Safe
+	initializeWallSafeValue();
 }
 
 Common::Error PrivateEngine::loadGameStream(Common::SeekableReadStream *stream) {
diff --git a/engines/private/private.h b/engines/private/private.h
index ab44e929479..148d8f1fb2b 100644
--- a/engines/private/private.h
+++ b/engines/private/private.h
@@ -405,11 +405,13 @@ public:
 	Common::String _safeNumberPath;
 	MaskInfo _safeDigitArea[3];
 	Common::Rect _safeDigitRect[3];
-	uint32 _safeDigit[3];
 
+	void initializeWallSafeValue();
 	bool selectSafeDigit(Common::Point);
 	void addSafeDigit(uint32, Common::Rect*);
 	void renderSafeDigit(uint32);
+	int getSafeDigit(uint32 d);
+	void incrementSafeDigit(uint32 d);
 
 	// Random values
 	bool getRandomBool(uint);


Commit: 16c29c1169429f16a663743a27a468e9092a3510
    https://github.com/scummvm/scummvm/commit/16c29c1169429f16a663743a27a468e9092a3510
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2025-11-19T07:54:54+01:00

Commit Message:
PRIVATE: Fix wall safe digit rendering

The digits are masks with transparent backgrounds meant to be drawn on
top of the safe graphic. We have been drawing a solid black rectangle
first in order to update digits on the screen. This is not original
behavior, and it's only needed because we're attempting to partially
update the screen instead of redrawing it.

Now the original effect is achieved by drawing the digits as regular
masks without a solid black rectangle, and by responding to digit clicks
by reloading the current setting.

Changed paths:
    engines/private/private.cpp
    engines/private/private.h


diff --git a/engines/private/private.cpp b/engines/private/private.cpp
index 7fad74201ab..e5492e3d0e8 100644
--- a/engines/private/private.cpp
+++ b/engines/private/private.cpp
@@ -290,14 +290,13 @@ Common::Error PrivateEngine::run() {
 	delete file;
 	if (maps.constants.size() == 0)
 		error("Failed to parse game script");
+	initializeWallSafeValue();
 
 	// Initialize graphics
 	_pixelFormat = Graphics::PixelFormat::createFormatCLUT8();
 	initGraphics(_screenW, _screenH, &_pixelFormat);
 	_transparentColor = 250;
 
-	initializeWallSafeValue();
-	_safeColor = _pixelFormat.RGBToColor(65, 65, 65);
 	_screenRect = Common::Rect(0, 0, _screenW, _screenH);
 	loadCursors();
 	changeCursor("default");
@@ -1268,7 +1267,7 @@ bool PrivateEngine::selectSafeDigit(Common::Point mousePos) {
 	for (uint d = 0 ; d < 3; d ++)
 		if (_safeDigitRect[d].contains(mousePos)) {
 			incrementSafeDigit(d);
-			renderSafeDigit(d);
+			_nextSetting = _safeDigitArea[d].nextSetting;
 			return true;
 		}
 
@@ -1279,33 +1278,13 @@ void PrivateEngine::addSafeDigit(uint32 d, Common::Rect *rect) {
 
 	MaskInfo m;
 	_safeDigitRect[d] = *rect;
-	fillRect(_safeColor, _safeDigitRect[d]);
-	int digitValue = getSafeDigit(d);
-	m.surf = loadMask(Common::String::format(_safeNumberPath.c_str(), digitValue), _safeDigitRect[d].left, _safeDigitRect[d].top, true);
-	m.cursor = g_private->getExitCursor();
-	m.nextSetting = "";
-	m.flag1 = nullptr;
-	m.flag2 = nullptr;
-	_safeDigitArea[d] = m;
-}
-
-void PrivateEngine::renderSafeDigit(uint32 d) {
-
-	if (_safeDigitArea[d].surf != nullptr) {
-		_safeDigitArea[d].surf->free();
-		delete _safeDigitArea[d].surf;
-		_safeDigitArea[d].clear();
-	}
-	fillRect(_safeColor, _safeDigitRect[d]);
 	int digitValue = getSafeDigit(d);
-	MaskInfo m;
 	m.surf = loadMask(Common::String::format(_safeNumberPath.c_str(), digitValue), _safeDigitRect[d].left, _safeDigitRect[d].top, true);
 	m.cursor = g_private->getExitCursor();
-	m.nextSetting = "";
+	m.nextSetting = _currentSetting;
 	m.flag1 = nullptr;
 	m.flag2 = nullptr;
 	_safeDigitArea[d] = m;
-	drawScreen();
 }
 
 int PrivateEngine::getSafeDigit(uint32 d) {
diff --git a/engines/private/private.h b/engines/private/private.h
index 148d8f1fb2b..fb45db8b4d0 100644
--- a/engines/private/private.h
+++ b/engines/private/private.h
@@ -401,7 +401,6 @@ public:
 	void checkPhoneCall();
 
 	// Safe
-	uint32 _safeColor;
 	Common::String _safeNumberPath;
 	MaskInfo _safeDigitArea[3];
 	Common::Rect _safeDigitRect[3];
@@ -409,7 +408,6 @@ public:
 	void initializeWallSafeValue();
 	bool selectSafeDigit(Common::Point);
 	void addSafeDigit(uint32, Common::Rect*);
-	void renderSafeDigit(uint32);
 	int getSafeDigit(uint32 d);
 	void incrementSafeDigit(uint32 d);
 




More information about the Scummvm-git-logs mailing list