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

Strangerke noreply at scummvm.org
Sun May 12 09:04:24 UTC 2024


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

Summary:
ff8f74064b BAGEL: Split come assignments out of if statements, add error details in some reportError() calls


Commit: ff8f74064b8446eed0c1cc174c84cc7640734cc3
    https://github.com/scummvm/scummvm/commit/ff8f74064b8446eed0c1cc174c84cc7640734cc3
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-12T10:04:17+01:00

Commit Message:
BAGEL: Split come assignments out of if statements, add error details in some reportError() calls

Changed paths:
    engines/bagel/spacebar/nav_window.cpp
    engines/bagel/spacebar/slot_wnd.cpp
    engines/bagel/spacebar/spacebar.cpp
    engines/bagel/spacebar/sraf_computer.cpp


diff --git a/engines/bagel/spacebar/nav_window.cpp b/engines/bagel/spacebar/nav_window.cpp
index fee274f436a..875ba1d10be 100644
--- a/engines/bagel/spacebar/nav_window.cpp
+++ b/engines/bagel/spacebar/nav_window.cpp
@@ -188,7 +188,8 @@ ErrorCode CNavWindow::attach() {
 
 	_level = 0;
 
-	_pPortName = new CBofString("Yzore");      // always starts at Yzore
+	// always starts at Yzore
+	_pPortName = new CBofString("Yzore");
 	_ship = 120;
 	_cargo = 86 + 72 + 56;
 	_fuel = 40;
@@ -267,7 +268,7 @@ ErrorCode CNavWindow::attach() {
 		_pCurLoc->setPosition(_pCurPos->left, _pCurPos->top);
 
 	} else {
-		reportError(ERR_MEMORY);
+		reportError(ERR_MEMORY, "Unable to allocate a CBofSprite");
 	}
 
 	// Build all our buttons
@@ -284,7 +285,7 @@ ErrorCode CNavWindow::attach() {
 			_pButtons[i]->create(g_navButtons[i]._pszName, g_navButtons[i]._nLeft, g_navButtons[i]._nTop, g_navButtons[i]._nWidth, g_navButtons[i]._nHeight, this, g_navButtons[i]._nID);
 			_pButtons[i]->show();
 		} else {
-			reportError(ERR_MEMORY);
+			reportError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
 			break;
 		}
 	}
diff --git a/engines/bagel/spacebar/slot_wnd.cpp b/engines/bagel/spacebar/slot_wnd.cpp
index 878cf10d436..065eca27128 100644
--- a/engines/bagel/spacebar/slot_wnd.cpp
+++ b/engines/bagel/spacebar/slot_wnd.cpp
@@ -120,7 +120,7 @@ SBarSlotWnd::SBarSlotWnd() : CBagStorageDevWnd() {
 	_pSlotSound = nullptr;
 	_pLoseBmp = nullptr;
 
-	setHelpFilename(BuildSlotDir("SLOT.TXT"));
+	CBagStorageDevWnd::setHelpFilename(BuildSlotDir("SLOT.TXT"));
 
 	// Call this thing a closeup so that time won't go
 	// by when entering the closeup
@@ -174,9 +174,8 @@ ErrorCode  SBarSlotWnd::attach() {
 	_bLose = false;
 	_bFixBet = false;
 
-	if ((_pSlotSound = new CBofSound(this, BuildSlotDir(SLOT_AUDIO), SOUND_MIX, 1)) != nullptr) {
-
-	} else {
+	_pSlotSound = new CBofSound(this, BuildSlotDir(SLOT_AUDIO), SOUND_MIX, 1);
+	if (_pSlotSound == nullptr) {
 		reportError(ERR_MEMORY, "Could not allocate a CBofSound");
 	}
 
@@ -205,9 +204,8 @@ ErrorCode  SBarSlotWnd::attach() {
 		}
 
 		if (_pLoseBmp == nullptr) {
-			if ((_pLoseBmp = new CBofBitmap(BuildSlotDir("BGNV.BMP"), pPal)) != nullptr) {
-
-			} else {
+			_pLoseBmp = new CBofBitmap(BuildSlotDir("BGNV.BMP"), pPal);
+			if (_pLoseBmp == nullptr) {
 				reportError(ERR_MEMORY);
 			}
 		}
@@ -244,7 +242,7 @@ ErrorCode  SBarSlotWnd::attach() {
 			_pCredText->setWeight(TEXT_BOLD);
 			_pCredText->setText(buildString("%d", _nCredit));
 		} else {
-			reportError(ERR_MEMORY);
+			reportError(ERR_MEMORY, "Unable to allocate a CBofText");
 		}
 
 		// Setup the Bet text fields
@@ -261,7 +259,7 @@ ErrorCode  SBarSlotWnd::attach() {
 			_pBetText->setWeight(TEXT_BOLD);
 			_pBetText->setText(buildString("%d", _nBet));
 		} else {
-			reportError(ERR_MEMORY);
+			reportError(ERR_MEMORY, "Unable to allocate a CBofText");
 		}
 
 		// Setup the Odds text fields
@@ -279,7 +277,7 @@ ErrorCode  SBarSlotWnd::attach() {
 			_pOddsText->setWeight(TEXT_BOLD);
 			_pOddsText->setText("");
 		} else {
-			reportError(ERR_MEMORY);
+			reportError(ERR_MEMORY, "Unable to allocate a CBofText");
 		}
 
 		show();
@@ -292,7 +290,7 @@ ErrorCode  SBarSlotWnd::attach() {
 	if (_pBkgSnd != nullptr) {
 		_pBkgSnd->play();
 	} else {
-		reportError(ERR_MEMORY);
+		reportError(ERR_MEMORY, "Unable to allocate a CBofSound");
 	}
 
 	CBofCursor::show();
@@ -541,7 +539,7 @@ void SBarSlotWnd::calcOutcome() {
 		if (_pWinSound != nullptr) {
 			_pWinSound->play();
 		} else {
-			reportError(ERR_MEMORY);
+			reportError(ERR_MEMORY, "Unable to allocate a CBofSound");
 		}
 
 		// Calc new credit
diff --git a/engines/bagel/spacebar/spacebar.cpp b/engines/bagel/spacebar/spacebar.cpp
index 1e6333d01da..adb040487cf 100644
--- a/engines/bagel/spacebar/spacebar.cpp
+++ b/engines/bagel/spacebar/spacebar.cpp
@@ -38,10 +38,10 @@
 namespace Bagel {
 namespace SpaceBar {
 
-#define LOGOSMK1        "$SBARDIR\\INTRO\\LOGO1.SMK"
-#define LOGOSMK2        "$SBARDIR\\INTRO\\LOGO2.SMK"
-#define LOGOSMK3        "$SBARDIR\\INTRO\\LOGO3.SMK"
-#define LOGOSMK3EX      "$SBARDIR\\INTRO\\LOGO3EX.SMK"
+#define SMK_LOGO1        "$SBARDIR\\INTRO\\LOGO1.SMK"
+#define SMK_LOGO2        "$SBARDIR\\INTRO\\LOGO2.SMK"
+#define SMK_LOGO3        "$SBARDIR\\INTRO\\LOGO3.SMK"
+#define SMK_LOGO3EX      "$SBARDIR\\INTRO\\LOGO3EX.SMK"
 
 static const BagelReg SPACEBAR_REG = {
 	"The Space Bar",
@@ -88,7 +88,8 @@ ErrorCode SpaceBarEngine::initialize() {
 	if (!errorOccurred()) {
 		bool bShowLogo = true;
 
-		if ((_masterWin = new CSBarMasterWin()) != nullptr) {
+		_masterWin = new CSBarMasterWin();
+		if (_masterWin != nullptr) {
 			// This is the primary game window
 			setMainWindow(_masterWin);
 
@@ -159,7 +160,7 @@ ErrorCode SpaceBarEngine::initialize() {
 
 				// Play intro movies, logo screens, etc...
 				if (bShowLogo) {
-					CBofString cString(LOGOSMK1);
+					CBofString cString(SMK_LOGO1);
 					MACROREPLACE(cString);
 
 					// Play the movie only if it exists
@@ -172,7 +173,7 @@ ErrorCode SpaceBarEngine::initialize() {
 					if (shouldQuit())
 						goto exit;
 
-					cString = LOGOSMK2;
+					cString = SMK_LOGO2;
 					MACROREPLACE(cString);
 					if (fileExists(cString.getBuffer())) {
 						bofPlayMovie(_masterWin, cString.getBuffer());
@@ -184,7 +185,7 @@ ErrorCode SpaceBarEngine::initialize() {
 						goto exit;
 
 					// Use hi-res movie if user has a fast machine
-					cString = (getMachineSpeed() < 100) ? LOGOSMK3EX : LOGOSMK3;
+					cString = (getMachineSpeed() < 100) ? SMK_LOGO3EX : SMK_LOGO3;
 					MACROREPLACE(cString);
 
 					if (fileExists(cString.getBuffer())) {
diff --git a/engines/bagel/spacebar/sraf_computer.cpp b/engines/bagel/spacebar/sraf_computer.cpp
index 5b259ea018c..f63e5bc94b6 100644
--- a/engines/bagel/spacebar/sraf_computer.cpp
+++ b/engines/bagel/spacebar/sraf_computer.cpp
@@ -4613,7 +4613,8 @@ int SrafTextScreen::createTextScreen(CBofWindow *pParent) {
 	//  Create our text box.
 	cRect.setRect(gCompDisplay.left, gCompDisplay.top, gCompDisplay.right, gCompDisplay.bottom);
 
-	if ((_pTextBox = new CBofTextBox(this, &cRect, _text)) != nullptr) {
+	_pTextBox = new CBofTextBox(this, &cRect, _text);
+	if (_pTextBox != nullptr) {
 		_pTextBox->setPageLength(24);
 		_pTextBox->setColor(CTEXT_WHITE);
 		_pTextBox->setFont(FONT_MONO);




More information about the Scummvm-git-logs mailing list