[Scummvm-git-logs] scummvm master -> 44512970468dde37571b5c9c82233d71e91276db

Strangerke noreply at scummvm.org
Tue May 14 05:03:50 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:
4451297046 BAGEL: Some more work on fatal errors


Commit: 44512970468dde37571b5c9c82233d71e91276db
    https://github.com/scummvm/scummvm/commit/44512970468dde37571b5c9c82233d71e91276db
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-14T06:03:42+01:00

Commit Message:
BAGEL: Some more work on fatal errors

Changed paths:
    engines/bagel/boflib/sound.cpp
    engines/bagel/boflib/sound.h
    engines/bagel/dialogs/credits_dialog.cpp
    engines/bagel/dialogs/next_cd_dialog.cpp


diff --git a/engines/bagel/boflib/sound.cpp b/engines/bagel/boflib/sound.cpp
index 02d278b7302..48b1027cfbb 100644
--- a/engines/bagel/boflib/sound.cpp
+++ b/engines/bagel/boflib/sound.cpp
@@ -44,8 +44,8 @@ CBofSound  *CBofSound::_pSoundChain = nullptr;  // Pointer to chain of linked So
 int     CBofSound::_nCount = 0;                 // Count of currently active Sounds
 int     CBofSound::_nWavCount = 0;              // Available wave sound devices
 int     CBofSound::_nMidiCount = 0;             // Available midi sound devices
-bool    CBofSound::_bsoundAvailable = false;    // Whether wave sound is available
-bool    CBofSound::_bmidiAvailable = false;     // Whether midi sound is available
+bool    CBofSound::_bSoundAvailable = false;    // Whether wave sound is available
+bool    CBofSound::_bMidiAvailable = false;     // Whether midi sound is available
 bool    CBofSound::_bWaveVolume = false;        // Whether wave volume can be set
 bool    CBofSound::_bMidiVolume = false;        // Whether midi volume can be set
 CBofWindow   *CBofSound::_pMainWnd = nullptr;   // Window for message processing
@@ -87,8 +87,7 @@ CBofSound::CBofSound(CBofWindow *pWnd, const char *pszPathName, uint16 wFlags, c
 	_bInQueue = false;
 	_iQSlot = 0;
 
-	int i;
-	for (i = 0; i < NUM_QUEUES; i++) {
+	for (int i = 0; i < NUM_QUEUES; i++) {
 		_nSlotVol[i] = VOLUME_INDEX_DEFAULT;
 	}
 
@@ -122,19 +121,17 @@ CBofSound::CBofSound(CBofWindow *pWnd, const char *pszPathName, uint16 wFlags, c
 				}
 			}
 
-		} else {
+		} else if (_wFlags & SOUND_MIDI) {
 			// Try both MIDI formats
-			if (_wFlags & SOUND_MIDI) {
-				strreplaceStr(szTempPath, ".MID", ".MOV");
-				if (fileExists(szTempPath)) {
-					fileGetFullPath(_szFileName, szTempPath);
-					_chType = SOUND_TYPE_QT;
-				} else {
-					reportError(ERR_FFIND, szTempPath);
-				}
+			strreplaceStr(szTempPath, ".MID", ".MOV");
+			if (fileExists(szTempPath)) {
+				fileGetFullPath(_szFileName, szTempPath);
+				_chType = SOUND_TYPE_QT;
 			} else {
 				reportError(ERR_FFIND, szTempPath);
 			}
+		} else {
+			reportError(ERR_FFIND, szTempPath);
 		}
 	}
 
@@ -164,8 +161,8 @@ CBofSound::~CBofSound() {
 
 
 void CBofSound::initialize() {
-	_bsoundAvailable = true;
-	_bmidiAvailable = false;
+	_bSoundAvailable = true;
+	_bMidiAvailable = false;
 
 	for (int i = 0; i < NUM_QUEUES; ++i)
 		_cQueue[i] = new CQueue();
@@ -546,12 +543,12 @@ void CBofSound::clearMidiSounds() {
 
 
 bool CBofSound::soundAvailable() {
-	return _bsoundAvailable;                     // Return requested info
+	return _bSoundAvailable;                     // Return requested info
 }
 
 
 bool CBofSound::midiAvailable() {
-	return _bmidiAvailable;                      // Return requested info
+	return _bMidiAvailable;                      // Return requested info
 }
 
 
diff --git a/engines/bagel/boflib/sound.h b/engines/bagel/boflib/sound.h
index a1f5feea705..63157a9e581 100644
--- a/engines/bagel/boflib/sound.h
+++ b/engines/bagel/boflib/sound.h
@@ -205,8 +205,8 @@ private:
 	static int _nCount;                    // Count of active sounds
 	static int _nWavCount;                 // Number of wave sound devices
 	static int _nMidiCount;                // Number of midi sound devices
-	static bool _bsoundAvailable;          // Whether wave sound is available
-	static bool _bmidiAvailable;           // Whether midi sound is available
+	static bool _bSoundAvailable;          // Whether wave sound is available
+	static bool _bMidiAvailable;           // Whether midi sound is available
 	static bool _bWaveVolume;              // Whether wave volume can be set
 	static bool _bMidiVolume;              // Whether midi volume can be set
 	static CBofWindow *_pMainWnd;          // Window for message processing
diff --git a/engines/bagel/dialogs/credits_dialog.cpp b/engines/bagel/dialogs/credits_dialog.cpp
index 2680b64db22..15cc53fd555 100644
--- a/engines/bagel/dialogs/credits_dialog.cpp
+++ b/engines/bagel/dialogs/credits_dialog.cpp
@@ -121,19 +121,18 @@ ErrorCode CBagCreditsDialog::loadNextTextFile() {
 
 	// Create a new work area
 	_pCreditsBmp = new CBofBitmap(cRect.width(), cRect.height() + LINE_HEIGHT + 2, _pBackdrop->getPalette());
-	if (_pCreditsBmp != nullptr) {
+	if (_pCreditsBmp != nullptr)
+	{
 		_pCreditsBmp->fillRect(nullptr, MY_MASK_COLOR);
 
 		// Kill any previous work area
 		delete _pSaveBmp;
 		_pSaveBmp = new CBofBitmap(_pCreditsBmp->width(), _pCreditsBmp->height(), _pBackdrop->getPalette());
-		if (_pSaveBmp != nullptr) {
-			CBofRect tmpRect = _pSaveBmp->getRect();
-			_pBackdrop->paint(_pSaveBmp, &tmpRect, &cRect);
+		if (_pSaveBmp == nullptr)
+			fatalError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
 
-		} else {
-			reportError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
-		}
+		CBofRect tmpRect = _pSaveBmp->getRect();
+		_pBackdrop->paint(_pSaveBmp, &tmpRect, &cRect);
 	}
 
 	// Get rid of any previous credits screen
@@ -148,28 +147,26 @@ ErrorCode CBagCreditsDialog::loadNextTextFile() {
 		// Read in text file
 		uint32 lSize = cFile.getLength();
 		_pszText = (char *)bofCAlloc(lSize + 1, 1);
-		if (_pszText != nullptr) {
-			cFile.read(_pszText, lSize);
+		if (_pszText == nullptr)
+			fatalError(ERR_MEMORY, "Unable to allocate %d bytes for Credits.", lSize);
 
-			_pszNextLine = _pszText;
-			_pszEnd = _pszText + lSize;
-			_nNumPixels = 0;
+		cFile.read(_pszText, lSize);
 
-			// Determine the number of lines of text in credits
-			_nLines = strCharCount(_pszText, '\n');
-			strreplaceChar(_pszText, '\r', ' ');
-			strreplaceChar(_pszText, '\n', '\0');
+		_pszNextLine = _pszText;
+		_pszEnd = _pszText + lSize;
+		_nNumPixels = 0;
 
-			paintLine(linesPerPage() - 1, _pszNextLine);
-			nextLine();
-			paintLine(linesPerPage(), _pszNextLine);
-			nextLine();
+		// Determine the number of lines of text in credits
+		_nLines = strCharCount(_pszText, '\n');
+		strreplaceChar(_pszText, '\r', ' ');
+		strreplaceChar(_pszText, '\n', '\0');
 
-			_bDisplay = true;
+		paintLine(linesPerPage() - 1, _pszNextLine);
+		nextLine();
+		paintLine(linesPerPage(), _pszNextLine);
+		nextLine();
 
-		} else {
-			reportError(ERR_MEMORY, "Unable to allocate %d bytes for Credits.", lSize);
-		}
+		_bDisplay = true;
 	}
 
 	return _errCode;
@@ -178,9 +175,9 @@ ErrorCode CBagCreditsDialog::loadNextTextFile() {
 int CBagCreditsDialog::linesPerPage() {
 	assert(isValidObject(this));
 
-	int n = (g_cScreen[_iScreen]._nBottom - g_cScreen[_iScreen]._nTop) / (LINE_HEIGHT + 2) + 1;
+	int retVal = (g_cScreen[_iScreen]._nBottom - g_cScreen[_iScreen]._nTop) / (LINE_HEIGHT + 2) + 1;
 
-	return n;
+	return retVal;
 }
 
 void CBagCreditsDialog::onClose() {
@@ -276,8 +273,7 @@ ErrorCode CBagCreditsDialog::displayCredits() {
 
 
 			// Strip off top layer so it won't wrap around
-			int i;
-			for (i = 0; i < PIX_SCROLL_DY; i++) {
+			for (int i = 0; i < PIX_SCROLL_DY; i++) {
 				_pCreditsBmp->line(0, i, _pCreditsBmp->width() - 1, i, MY_MASK_COLOR);
 			}
 
diff --git a/engines/bagel/dialogs/next_cd_dialog.cpp b/engines/bagel/dialogs/next_cd_dialog.cpp
index 2971657f6bc..4567288651f 100644
--- a/engines/bagel/dialogs/next_cd_dialog.cpp
+++ b/engines/bagel/dialogs/next_cd_dialog.cpp
@@ -49,19 +49,17 @@ void CBagNextCDDialog::onInitDialog() {
 
 	// Build all our buttons
 	_pButton = new CBofBmpButton;
-	if (_pButton != nullptr) {
-		CBofBitmap *pUp = loadBitmap(buildSysDir("CDOKUP.BMP"), pPal);
-		CBofBitmap *pDown = loadBitmap(buildSysDir("CDOKDN.BMP"), pPal);
-		CBofBitmap *pFocus = loadBitmap(buildSysDir("CDOKUP.BMP"), pPal);
-		CBofBitmap *pDis = loadBitmap(buildSysDir("CDOKUP.BMP"), pPal);
-
-		_pButton->loadBitmaps(pUp, pDown, pFocus, pDis);
-		_pButton->create("NextCD", 77, 127, 60, 30, this, OK_BTN);
-		_pButton->show();
-
-	} else {
-		reportError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
-	}
+	if (_pButton == nullptr)
+		fatalError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
+
+	CBofBitmap *pUp = loadBitmap(buildSysDir("CDOKUP.BMP"), pPal);
+	CBofBitmap *pDown = loadBitmap(buildSysDir("CDOKDN.BMP"), pPal);
+	CBofBitmap *pFocus = loadBitmap(buildSysDir("CDOKUP.BMP"), pPal);
+	CBofBitmap *pDis = loadBitmap(buildSysDir("CDOKUP.BMP"), pPal);
+
+	_pButton->loadBitmaps(pUp, pDown, pFocus, pDis);
+	_pButton->create("NextCD", 77, 127, 60, 30, this, OK_BTN);
+	_pButton->show();
 
 	// Show System cursor
 	CBagCursor::showSystemCursor();




More information about the Scummvm-git-logs mailing list