[Scummvm-git-logs] scummvm master -> 9ae3cfbda42f7391f7b66d4cee5d1c2a0d0cb8cf

Strangerke noreply at scummvm.org
Sun May 12 20:18:50 UTC 2024


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:
5c9874fb02 BAGEL: More work on improving reportError() feedback, more assignments moved out of if statements
9ae3cfbda4 BAGEL: add error detail in all reportError calls, remove an unused function in CBofFile and in log


Commit: 5c9874fb02a4ece197a622da9e95510a93d78356
    https://github.com/scummvm/scummvm/commit/5c9874fb02a4ece197a622da9e95510a93d78356
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-12T21:18:25+01:00

Commit Message:
BAGEL: More work on improving reportError() feedback, more assignments moved out of if statements

Changed paths:
    engines/bagel/dialogs/next_cd_dialog.cpp
    engines/bagel/dialogs/opt_window.cpp
    engines/bagel/dialogs/quit_dialog.cpp
    engines/bagel/dialogs/restart_dialog.cpp
    engines/bagel/dialogs/restore_dialog.cpp
    engines/bagel/dialogs/save_dialog.cpp
    engines/bagel/spacebar/slot_wnd.cpp


diff --git a/engines/bagel/dialogs/next_cd_dialog.cpp b/engines/bagel/dialogs/next_cd_dialog.cpp
index e9eee578900..2971657f6bc 100644
--- a/engines/bagel/dialogs/next_cd_dialog.cpp
+++ b/engines/bagel/dialogs/next_cd_dialog.cpp
@@ -43,28 +43,24 @@ void CBagNextCDDialog::onInitDialog() {
 
 	setReturnValue(-1);
 
-	CBofPalette *pPal;
-
 	assert(_pBackdrop != nullptr);
-	pPal = _pBackdrop->getPalette();
+	CBofPalette *pPal = _pBackdrop->getPalette();
 	selectPalette(pPal);
 
 	// Build all our buttons
-	if ((_pButton = new CBofBmpButton) != nullptr) {
-		CBofBitmap *pUp, *pDown, *pFocus, *pDis;
-
-		pUp = loadBitmap(buildSysDir("CDOKUP.BMP"), pPal);
-		pDown = loadBitmap(buildSysDir("CDOKDN.BMP"), pPal);
-		pFocus = loadBitmap(buildSysDir("CDOKUP.BMP"), pPal);
-		pDis = loadBitmap(buildSysDir("CDOKUP.BMP"), pPal);
+	_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);
+		reportError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
 	}
 
 	// Show System cursor
@@ -77,10 +73,8 @@ void CBagNextCDDialog::onClose() {
 	CBagCursor::hideSystemCursor();
 
 	// Destroy my buttons
-	if (_pButton != nullptr) {
-		delete _pButton;
-		_pButton = nullptr;
-	}
+	delete _pButton;
+	_pButton = nullptr;
 
 	CBofDialog::onClose();
 }
diff --git a/engines/bagel/dialogs/opt_window.cpp b/engines/bagel/dialogs/opt_window.cpp
index e3bab267a51..2cc4cb51679 100644
--- a/engines/bagel/dialogs/opt_window.cpp
+++ b/engines/bagel/dialogs/opt_window.cpp
@@ -147,40 +147,27 @@ ErrorCode CBagOptWindow::detach() {
 
 	// Destroy all buttons
 	for (int i = 0; i < NUM_SYS_BUTTONS; i++) {
-		if (_pButtons[i] != nullptr) {
-			delete _pButtons[i];
-			_pButtons[i] = nullptr;
-		}
+		delete _pButtons[i];
+		_pButtons[i] = nullptr;
 	}
 
-	if (_pFlythroughs != nullptr) {
-		delete _pFlythroughs;
-		_pFlythroughs = nullptr;
-	}
-	if (_pPanimations != nullptr) {
-		delete _pPanimations;
-		_pPanimations = nullptr;
-	}
+	delete _pFlythroughs;
+	_pFlythroughs = nullptr;
 
-	if (_pMidiVolumeScroll != nullptr) {
-		delete _pMidiVolumeScroll;
-		_pMidiVolumeScroll = nullptr;
-	}
+	delete _pPanimations;
+	_pPanimations = nullptr;
 
-	if (_pWaveVolumeScroll != nullptr) {
-		delete _pWaveVolumeScroll;
-		_pWaveVolumeScroll = nullptr;
-	}
+	delete _pMidiVolumeScroll;
+	_pMidiVolumeScroll = nullptr;
 
-	if (_pCorrectionScroll != nullptr) {
-		delete _pCorrectionScroll;
-		_pCorrectionScroll = nullptr;
-	}
+	delete _pWaveVolumeScroll;
+	_pWaveVolumeScroll = nullptr;
 
-	if (_pPanSpeedScroll != nullptr) {
-		delete _pPanSpeedScroll;
-		_pPanSpeedScroll = nullptr;
-	}
+	delete _pCorrectionScroll;
+	_pCorrectionScroll = nullptr;
+
+	delete _pPanSpeedScroll;
+	_pPanSpeedScroll = nullptr;
 
 	CBofApp::getApp()->setPalette(_pSavePalette);
 
@@ -234,7 +221,8 @@ ErrorCode CBagOptWindow::attach() {
 	for (int i = 0; i < NUM_SYS_BUTTONS; i++) {
 		assert(_pButtons[i] == nullptr);
 
-		if ((_pButtons[i] = new CBofBmpButton) != nullptr) {
+		_pButtons[i] = new CBofBmpButton;
+		if (_pButtons[i] != nullptr) {
 			CBofBitmap *pUp, *pDown, *pFocus, *pDis;
 
 			pUp = loadBitmap(buildSysDir(g_stButtons[i]._pszUp), pPal);
@@ -247,7 +235,7 @@ ErrorCode CBagOptWindow::attach() {
 			_pButtons[i]->create(g_stButtons[i]._pszName, g_stButtons[i]._nLeft, g_stButtons[i]._nTop, g_stButtons[i]._nWidth, g_stButtons[i]._nHeight, this, g_stButtons[i]._nID);
 			_pButtons[i]->show();
 		} else {
-			reportError(ERR_MEMORY);
+			reportError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
 			break;
 		}
 	}
@@ -269,7 +257,8 @@ ErrorCode CBagOptWindow::attach() {
 	// Midi volume control
 	CBofRect cRect;
 	cRect.setRect(73, 48, 73 + 120 - 1, 48 + 20 - 1);
-	if ((_pMidiVolumeScroll = new CBofScrollBar) != nullptr) {
+	_pMidiVolumeScroll = new CBofScrollBar;
+	if (_pMidiVolumeScroll != nullptr) {
 		_pMidiVolumeScroll->create("", &cRect, this, MIDI_VOL_ID);
 
 		_pMidiVolumeScroll->loadBitmaps(szBuf1, szBuf2, szBuf3, szBuf4, szBuf5, szBuf6);
@@ -282,7 +271,8 @@ ErrorCode CBagOptWindow::attach() {
 
 	// Digital Audio volume control
 	cRect.setRect(73, 98, 73 + 120 - 1, 98 + 20 - 1);
-	if ((_pWaveVolumeScroll = new CBofScrollBar) != nullptr) {
+	_pWaveVolumeScroll = new CBofScrollBar;
+	if (_pWaveVolumeScroll != nullptr) {
 		_pWaveVolumeScroll->create("", &cRect, this, WAVE_VOL_ID);
 
 		_pWaveVolumeScroll->loadBitmaps(szBuf1, szBuf2, szBuf3, szBuf4, szBuf5, szBuf6);
@@ -295,7 +285,8 @@ ErrorCode CBagOptWindow::attach() {
 
 	// Pan Correction control
 	cRect.setRect(73, 268, 73 + 120 - 1, 268 + 20 - 1);
-	if ((_pCorrectionScroll = new CBofScrollBar) != nullptr) {
+	_pCorrectionScroll = new CBofScrollBar;
+	if (_pCorrectionScroll != nullptr) {
 		_pCorrectionScroll->create("", &cRect, this, CORRECTION_ID);
 
 		_pCorrectionScroll->loadBitmaps(szBuf1, szBuf2, szBuf3, szBuf4, szBuf5, szBuf6);
@@ -308,7 +299,8 @@ ErrorCode CBagOptWindow::attach() {
 
 	// Pan Speed control
 	cRect.setRect(73, 318, 73 + 120 - 1, 318 + 20 - 1);
-	if ((_pPanSpeedScroll = new CBofScrollBar) != nullptr) {
+	_pPanSpeedScroll = new CBofScrollBar;
+	if (_pPanSpeedScroll != nullptr) {
 		_pPanSpeedScroll->create("", &cRect, this, PANSPEED_ID);
 
 		_pPanSpeedScroll->loadBitmaps(szBuf1, szBuf2, szBuf3, szBuf4, szBuf5, szBuf6);
@@ -320,14 +312,16 @@ ErrorCode CBagOptWindow::attach() {
 	}
 
 	cRect.setRect(FLYTHROUGHS_LEFT, FLYTHROUGHS_TOP, FLYTHROUGHS_LEFT + CHECKBOX_WIDTH, FLYTHROUGHS_TOP + CHECKBOX_HEIGHT);
-	if ((_pFlythroughs = new CBofCheckButton()) != nullptr) {
+	_pFlythroughs = new CBofCheckButton();
+	if (_pFlythroughs != nullptr) {
 		_pFlythroughs->loadColorScheme(&_cColorScheme);
 		_errCode = _pFlythroughs->create("", &cRect, this, FLYTHROUGHS_ID);
 		_pFlythroughs->show();
 	}
 
 	cRect.setRect(PANIMATIONS_LEFT, PANIMATIONS_TOP, PANIMATIONS_LEFT + CHECKBOX_WIDTH, PANIMATIONS_TOP + CHECKBOX_HEIGHT);
-	if ((_pPanimations = new CBofCheckButton()) != nullptr) {
+	_pPanimations = new CBofCheckButton();
+	if (_pPanimations != nullptr) {
 		_pPanimations->loadColorScheme(&_cColorScheme);
 		_errCode = _pPanimations->create("", &cRect, this, PAN_CHECK_ID);
 		_pPanimations->show();
diff --git a/engines/bagel/dialogs/quit_dialog.cpp b/engines/bagel/dialogs/quit_dialog.cpp
index e7b65f0d7b3..6ed366fcc84 100644
--- a/engines/bagel/dialogs/quit_dialog.cpp
+++ b/engines/bagel/dialogs/quit_dialog.cpp
@@ -77,7 +77,8 @@ void CBagQuitDialog::onInitDialog() {
 	for (int i = 0; i < NUM_QUIT_BUTTONS; i++) {
 		assert(_pButtons[i] == nullptr);
 
-		if ((_pButtons[i] = new CBofBmpButton) != nullptr) {
+		_pButtons[i] = new CBofBmpButton;
+		if (_pButtons[i] != nullptr) {
 			CBofBitmap *pUp = loadBitmap(buildSysDir(g_stQuitButtons[i]._pszUp), pPal);
 			CBofBitmap *pDown = loadBitmap(buildSysDir(g_stQuitButtons[i]._pszDown), pPal);
 			CBofBitmap *pFocus = loadBitmap(buildSysDir(g_stQuitButtons[i]._pszFocus), pPal);
@@ -88,7 +89,7 @@ void CBagQuitDialog::onInitDialog() {
 			_pButtons[i]->create(g_stQuitButtons[i]._pszName, g_stQuitButtons[i]._nLeft, g_stQuitButtons[i]._nTop, g_stQuitButtons[i]._nWidth, g_stQuitButtons[i]._nHeight, this, g_stQuitButtons[i]._nID);
 			_pButtons[i]->show();
 		} else {
-			reportError(ERR_MEMORY);
+			reportError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
 			break;
 		}
 	}
@@ -105,10 +106,8 @@ void CBagQuitDialog::onClose() {
 
 	// Destroy all buttons
 	for (int i = 0; i < NUM_QUIT_BUTTONS; i++) {
-		if (_pButtons[i] != nullptr) {
-			delete _pButtons[i];
-			_pButtons[i] = nullptr;
-		}
+		delete _pButtons[i];
+		_pButtons[i] = nullptr;
 	}
 
 	if (_nReturnValue == QUIT_BTN || _nReturnValue == SAVE_BTN)
@@ -122,7 +121,6 @@ void CBagQuitDialog::onPaint(CBofRect *pRect) {
 	assert(isValidObject(this));
 
 	paintBackdrop(pRect);
-
 	validateAnscestors();
 }
 
@@ -158,7 +156,6 @@ void CBagQuitDialog::onBofButton(CBofObject *pObject, int nFlags) {
 			if (pApp != nullptr) {
 				CBagMasterWin *pWin = pApp->getMasterWnd();
 				if (pWin != nullptr) {
-
 					bQuit = pWin->showSaveDialog(this, false);
 				}
 			}
diff --git a/engines/bagel/dialogs/restart_dialog.cpp b/engines/bagel/dialogs/restart_dialog.cpp
index 225d472188f..e23b6bfed91 100644
--- a/engines/bagel/dialogs/restart_dialog.cpp
+++ b/engines/bagel/dialogs/restart_dialog.cpp
@@ -29,7 +29,7 @@
 
 namespace Bagel {
 
-#define LOADINGBMP          "$SBARDIR\\GENERAL\\SYSTEM\\LOADING.BMP"
+#define LOADING_BMP          "$SBARDIR\\GENERAL\\SYSTEM\\LOADING.BMP"
 
 struct ST_BUTTONS {
 	const char *_pszName;
@@ -87,19 +87,18 @@ void CBagRestartDialog::onInitDialog() {
 	for (int i = 0; i < NUM_RESTART_BTNS; i++) {
 		assert(_pButtons[i] == nullptr);
 
-		if ((_pButtons[i] = new CBofBmpButton) != nullptr) {
-
+		_pButtons[i] = new CBofBmpButton;
+		if (_pButtons[i] != nullptr) {
 			CBofBitmap *pUp = loadBitmap(buildSysDir(g_stRestartButtons[i]._pszUp), pPal);
 			CBofBitmap *pDown = loadBitmap(buildSysDir(g_stRestartButtons[i]._pszDown), pPal);
 			CBofBitmap *pFocus = loadBitmap(buildSysDir(g_stRestartButtons[i]._pszFocus), pPal);
 			CBofBitmap *pDis = loadBitmap(buildSysDir(g_stRestartButtons[i]._pszDisabled), pPal);
 
 			_pButtons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
-
 			_pButtons[i]->create(g_stRestartButtons[i]._pszName, g_stRestartButtons[i]._nLeft, g_stRestartButtons[i]._nTop, g_stRestartButtons[i]._nWidth, g_stRestartButtons[i]._nHeight, this, g_stRestartButtons[i]._nID);
 			_pButtons[i]->show();
 		} else {
-			reportError(ERR_MEMORY);
+			reportError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
 			break;
 		}
 	}
@@ -116,10 +115,8 @@ void CBagRestartDialog::onClose() {
 
 	// Destroy all buttons
 	for (int i = 0; i < NUM_RESTART_BTNS; i++) {
-		if (_pButtons[i] != nullptr) {
-			delete _pButtons[i];
-			_pButtons[i] = nullptr;
-		}
+		delete _pButtons[i];
+		_pButtons[i] = nullptr;
 	}
 
 	CBofDialog::onClose();
@@ -154,7 +151,7 @@ void CBagRestartDialog::onKeyHit(uint32 lKey, uint32 nRepCount) {
 			if (pWin != nullptr) {
 
 				char szBuf[256];
-				Common::strcpy_s(szBuf, LOADINGBMP);
+				Common::strcpy_s(szBuf, LOADING_BMP);
 				CBofString cStr(szBuf, 256);
 				MACROREPLACE(cStr);
 
@@ -215,7 +212,7 @@ void CBagRestartDialog::onBofButton(CBofObject *pObject, int nFlags) {
 			if (pWin != nullptr) {
 
 				char szBuf[256];
-				Common::strcpy_s(szBuf, LOADINGBMP);
+				Common::strcpy_s(szBuf, LOADING_BMP);
 				CBofString cStr(szBuf, 256);
 				MACROREPLACE(cStr);
 
diff --git a/engines/bagel/dialogs/restore_dialog.cpp b/engines/bagel/dialogs/restore_dialog.cpp
index c839d8ee1da..96f3240f240 100644
--- a/engines/bagel/dialogs/restore_dialog.cpp
+++ b/engines/bagel/dialogs/restore_dialog.cpp
@@ -31,8 +31,6 @@
 
 namespace Bagel {
 
-#define USE_CBAGDIALOG 0
-
 #define DIALOG_WIDTH    640
 #define DIALOG_HEIGHT   480
 
diff --git a/engines/bagel/dialogs/save_dialog.cpp b/engines/bagel/dialogs/save_dialog.cpp
index 2c07ed1e8bf..99346b0ad1d 100644
--- a/engines/bagel/dialogs/save_dialog.cpp
+++ b/engines/bagel/dialogs/save_dialog.cpp
@@ -28,8 +28,6 @@
 
 namespace Bagel {
 
-#define USE_CBAGDIALOG 0
-
 const char *buildSysDir(const char *pszFile);
 
 #define DIALOG_WIDTH    640
diff --git a/engines/bagel/spacebar/slot_wnd.cpp b/engines/bagel/spacebar/slot_wnd.cpp
index 4f5a2af6503..1d058f586aa 100644
--- a/engines/bagel/spacebar/slot_wnd.cpp
+++ b/engines/bagel/spacebar/slot_wnd.cpp
@@ -206,7 +206,7 @@ ErrorCode  SBarSlotWnd::attach() {
 		if (_pLoseBmp == nullptr) {
 			_pLoseBmp = new CBofBitmap(BuildSlotDir("BGNV.BMP"), pPal);
 			if (_pLoseBmp == nullptr) {
-				reportError(ERR_MEMORY);
+				reportError(ERR_MEMORY, "Unable to allocate a CBofBitmap");
 			}
 		}
 


Commit: 9ae3cfbda42f7391f7b66d4cee5d1c2a0d0cb8cf
    https://github.com/scummvm/scummvm/commit/9ae3cfbda42f7391f7b66d4cee5d1c2a0d0cb8cf
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-12T21:18:26+01:00

Commit Message:
BAGEL: add error detail in all reportError calls, remove an unused function in CBofFile and in log

Changed paths:
    engines/bagel/baglib/character_object.cpp
    engines/bagel/baglib/dev_dlg.cpp
    engines/bagel/baglib/help.cpp
    engines/bagel/baglib/master_win.cpp
    engines/bagel/baglib/pan_window.cpp
    engines/bagel/baglib/storage_dev_win.cpp
    engines/bagel/baglib/text_object.cpp
    engines/bagel/boflib/file.cpp
    engines/bagel/boflib/file.h
    engines/bagel/boflib/log.cpp
    engines/bagel/boflib/log.h
    engines/bagel/boflib/sound.cpp
    engines/bagel/dialogs/credits_dialog.cpp


diff --git a/engines/bagel/baglib/character_object.cpp b/engines/bagel/baglib/character_object.cpp
index 688a4bcb8d0..15408ffdbfd 100644
--- a/engines/bagel/baglib/character_object.cpp
+++ b/engines/bagel/baglib/character_object.cpp
@@ -103,12 +103,11 @@ ErrorCode CBagCharacterObject::attach() {
 		CBofFile cInputFile(filename.getBuffer());
 
 		_binBufLen = cInputFile.getLength();
-
-		if ((_binBuf = (char *)bofAlloc(_binBufLen + 1)) != nullptr) {
+		_binBuf = (char *)bofAlloc(_binBufLen + 1);
+		if (_binBuf != nullptr) {
 			cInputFile.read(_binBuf, _binBufLen);
-
 		} else {
-			reportError(ERR_MEMORY);
+			reportError(ERR_MEMORY, "Unable to allocate a buffer of %d bytes", _binBufLen + 1);
 		}
 	}
 
diff --git a/engines/bagel/baglib/dev_dlg.cpp b/engines/bagel/baglib/dev_dlg.cpp
index 364d9bb9a98..decaf2b64ea 100644
--- a/engines/bagel/baglib/dev_dlg.cpp
+++ b/engines/bagel/baglib/dev_dlg.cpp
@@ -75,7 +75,7 @@ ErrorCode CDevDlg::create(const char *bmp, CBofWindow *wnd, CBofPalette *pal, CB
 	if (bmp != nullptr) {
 		bitmap = new CBofBitmap(bmp, pal);
 		if (bitmap == nullptr) {
-			reportError(ERR_MEMORY);
+			reportError(ERR_MEMORY, "Unable to allocate a CBofBitmap");
 		}
 	}
 
@@ -92,7 +92,7 @@ ErrorCode CDevDlg::create(const char *bmp, CBofWindow *wnd, CBofPalette *pal, CB
 			bitmap->fillRect(rect, pal->getNearestIndex(RGB(255, 255, 255)));
 
 		} else {
-			reportError(ERR_MEMORY);
+			reportError(ERR_MEMORY, "Unable to allocate a CBofBitmap");
 		}
 	}
 
diff --git a/engines/bagel/baglib/help.cpp b/engines/bagel/baglib/help.cpp
index 0a9fca1751f..a113b1e9850 100644
--- a/engines/bagel/baglib/help.cpp
+++ b/engines/bagel/baglib/help.cpp
@@ -97,7 +97,7 @@ ErrorCode CBagHelp::attach() {
 		_okButton->create("OK", HELP_OK_X, HELP_OK_Y, HELP_OK_CX, HELP_OK_CY, this, HELP_OK_ID);
 		_okButton->show();
 	} else {
-		reportError(ERR_MEMORY);
+		reportError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
 	}
 
 	_pageUp = new CBofBmpButton;
@@ -113,7 +113,7 @@ ErrorCode CBagHelp::attach() {
 		_pageUp->create("PageUp", HELP_PAGE_UP_X, HELP_PAGE_UP_Y, HELP_PAGE_UP_CX, HELP_PAGE_UP_CY, this, HELP_PAGE_UP_ID);
 		_pageUp->show();
 	} else {
-		reportError(ERR_MEMORY);
+		reportError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
 	}
 
 	_pageDown = new CBofBmpButton;
@@ -129,7 +129,7 @@ ErrorCode CBagHelp::attach() {
 		_pageDown->create("PageDown", HELP_PAGE_DOWN_X, HELP_PAGE_DOWN_Y, HELP_PAGE_DOWN_CX, HELP_PAGE_DOWN_CY, this, HELP_PAGE_DOWN_ID);
 		_pageDown->show();
 	} else {
-		reportError(ERR_MEMORY);
+		reportError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
 	}
 
 	CBofFile file(_textFile, CBF_BINARY | CBF_READONLY);
diff --git a/engines/bagel/baglib/master_win.cpp b/engines/bagel/baglib/master_win.cpp
index da255949646..0c37b5265dd 100644
--- a/engines/bagel/baglib/master_win.cpp
+++ b/engines/bagel/baglib/master_win.cpp
@@ -1651,7 +1651,7 @@ void CBagMasterWin::doRestore(StBagelSave *saveBuf) {
 					memset(_objList, 0, MAX_OBJS * sizeof(StObj));
 
 				} else {
-					reportError(ERR_MEMORY);
+					reportError(ERR_MEMORY, "Unable to allocate a array of %d StObj", MAX_OBJS);
 				}
 			}
 
diff --git a/engines/bagel/baglib/pan_window.cpp b/engines/bagel/baglib/pan_window.cpp
index cc9578f47ac..aac9374149c 100644
--- a/engines/bagel/baglib/pan_window.cpp
+++ b/engines/bagel/baglib/pan_window.cpp
@@ -116,7 +116,7 @@ CBofPalette *CBagPanWindow::setSlideBitmap(const CBofString &xSlideBmp, const CB
 		// Make sure the file was found
 		if (_pSlideBitmap == nullptr || !_pSlideBitmap->isValid()) {
 			_pPalette = nullptr;
-			reportError(ERR_FOPEN);
+			reportError(ERR_FOPEN, "Unable to open file %s", xSlideBmp.getBuffer());
 		} else {
 			// Set the bagel crap
 			_pPalette = _pSlideBitmap->getPalette();
@@ -135,7 +135,7 @@ CBofPalette *CBagPanWindow::setSlideBitmap(const CBofString &xSlideBmp, const CB
 			}
 			_pViewPortBitmap = new CBofBitmap(DEF_WIDTH + 1, _pSlideBitmap->height() + 1, _pPalette);
 			if (!_pViewPortBitmap || !_pViewPortBitmap->height() || !_pViewPortBitmap->width()) {
-				reportError(ERR_FOPEN);
+				reportError(ERR_FOPEN, "Error opening bitmap");
 			}
 			setBackdrop(pBackDropBitmap);
 
diff --git a/engines/bagel/baglib/storage_dev_win.cpp b/engines/bagel/baglib/storage_dev_win.cpp
index 91a7563cac6..5d2ae64ddd9 100644
--- a/engines/bagel/baglib/storage_dev_win.cpp
+++ b/engines/bagel/baglib/storage_dev_win.cpp
@@ -1437,7 +1437,7 @@ ErrorCode CBagStorageDevWnd::loadFile(const CBofString &sFile) {
 	// is pre-loaded
 	int nLength = fileLength(sWldFile);
 	if (nLength <= 0)
-		reportError(ERR_FOPEN);
+		reportError(ERR_FOPEN, "Unable to open file %s", sWldFile.getBuffer());
 	else {
 		char *pBuf = (char *)bofAlloc(nLength);
 		if (pBuf != nullptr) {
@@ -1458,7 +1458,7 @@ ErrorCode CBagStorageDevWnd::loadFile(const CBofString &sFile) {
 			bofFree(pBuf);
 
 		} else {
-			reportError(ERR_MEMORY);
+			reportError(ERR_MEMORY, "Unable to allocate a buffer of %d bytes", nLength);
 		}
 	}
 
@@ -1718,7 +1718,7 @@ ErrorCode CBagStorageDevDlg::loadFile(const CBofString &sFile) {
 	// Force buffer to be big enough so that the entire script is pre-loaded
 	int nLength = fileLength(sWldFile);
 	if (nLength <= 0)
-		reportError(ERR_FOPEN);
+		reportError(ERR_FOPEN, "Unable to open file %s", sWldFile.getBuffer());
 	else {
 		char *pBuf = (char *)bofAlloc(nLength);
 		if (pBuf != nullptr) {
diff --git a/engines/bagel/baglib/text_object.cpp b/engines/bagel/baglib/text_object.cpp
index fc45037119a..126dcca289f 100644
--- a/engines/bagel/baglib/text_object.cpp
+++ b/engines/bagel/baglib/text_object.cpp
@@ -161,11 +161,11 @@ ErrorCode CBagTextObject::attach() {
 					bofFree(pTextBuff);
 
 				} else {
-					reportError(ERR_MEMORY);
+					reportError(ERR_MEMORY, "Unable to allocate a Text buffer of %u bytes", nFileLen + 1);
 				}
 
 			} else {
-				reportError(ERR_MEMORY);
+				reportError(ERR_FOPEN, "Failed to create a CBofFile for %s", getFileName().getBuffer());
 			}
 		}
 
@@ -190,7 +190,7 @@ ErrorCode CBagTextObject::attach() {
 			recalcTextRect(false);
 
 		} else {
-			reportError(ERR_MEMORY);
+			reportError(ERR_MEMORY, "Unable to allocate a CBofString");
 		}
 	}
 
diff --git a/engines/bagel/boflib/file.cpp b/engines/bagel/boflib/file.cpp
index ba13b2363b0..ce48ea7dfdb 100644
--- a/engines/bagel/boflib/file.cpp
+++ b/engines/bagel/boflib/file.cpp
@@ -222,13 +222,12 @@ ErrorCode CBofFile::setPosition(uint32 lPos) {
 	Common::SeekableReadStream *rs = dynamic_cast<Common::SeekableReadStream *>(_stream);
 	Common::SeekableWriteStream *ws = dynamic_cast<Common::SeekableWriteStream *>(_stream);
 
-	if (rs) {
-		if (!rs->seek(lPos))
-			reportError(ERR_FSEEK, "Unable to seek to %ld", lPos);
+	if (rs && !rs->seek(lPos)) {
+		reportError(ERR_FSEEK, "Unable to seek to %u in rs", lPos);
 	}
-	if (ws) {
-		if (!ws->seek(lPos))
-			reportError(ERR_FSEEK, "Unable to seek to %ld", lPos);
+
+	if (ws && !ws->seek(lPos)) {
+		reportError(ERR_FSEEK, "Unable to seek to %u in ws", lPos);
 	}
 
 	return _errCode;
@@ -242,6 +241,7 @@ uint32 CBofFile::getPosition() {
 
 	if (rs)
 		return rs->pos();
+	
 	if (ws)
 		return ws->pos();
 
@@ -264,14 +264,6 @@ ErrorCode CBofFile::seekToEnd() {
 	return _errCode;
 }
 
-ErrorCode CBofFile::setLength(uint32 /*lNewLength*/) {
-	assert(isValidObject(this));
-
-	logWarning("CBofFile::setLength() is not yet supported");
-
-	return _errCode;
-}
-
 uint32 CBofFile::getLength() {
 	assert(isValidObject(this));
 
diff --git a/engines/bagel/boflib/file.h b/engines/bagel/boflib/file.h
index 223aed49e35..d63c5ad95d8 100644
--- a/engines/bagel/boflib/file.h
+++ b/engines/bagel/boflib/file.h
@@ -194,11 +194,6 @@ public:
 	 */
 	uint32 getPosition();
 
-	/**
-	 * Set the length of a file
-	 */
-	ErrorCode setLength(uint32 lNewLength);
-
 	/**
 	 * Get the length of a file
 	 */
diff --git a/engines/bagel/boflib/log.cpp b/engines/bagel/boflib/log.cpp
index c190edd9079..80f5036dcf6 100644
--- a/engines/bagel/boflib/log.cpp
+++ b/engines/bagel/boflib/log.cpp
@@ -49,11 +49,6 @@ void logError(const char *msg) {
 		debug("%s%s", g_pszLogTypes[1], msg);
 }
 
-void logFatal(const char *msg) {
-	if (gDebugLevel > 0)
-		debug("%s%s", g_pszLogTypes[0], msg);
-}
-
 const char *buildString(const char *pszFormat, ...) {
 	static char szBuf[256];
 	va_list argptr;
diff --git a/engines/bagel/boflib/log.h b/engines/bagel/boflib/log.h
index 77372d263d2..29ae5330174 100644
--- a/engines/bagel/boflib/log.h
+++ b/engines/bagel/boflib/log.h
@@ -34,7 +34,6 @@ const char *buildString(const char *pszFormat, ...);
 extern void logInfo(const char *msg);
 extern void logWarning(const char *msg);
 extern void logError(const char *msg);
-extern void logFatal(const char *msg);
 
 } // namespace Bagel
 
diff --git a/engines/bagel/boflib/sound.cpp b/engines/bagel/boflib/sound.cpp
index 9802f227760..02d278b7302 100644
--- a/engines/bagel/boflib/sound.cpp
+++ b/engines/bagel/boflib/sound.cpp
@@ -673,7 +673,7 @@ bool BofPlaySound(const char *pszSoundFile, uint32 nFlags, int iQSlot) {
 		nFlags |= SOUND_AUTODELETE;
 
 		if (!fileExists(pszSoundFile)) {
-			logError(buildString("Warning: Sound File '%s' not found", pszSoundFile));
+			logWarning(buildString("Sound File '%s' not found", pszSoundFile));
 			return false;
 		}
 
@@ -714,7 +714,7 @@ bool BofPlaySoundEx(const char *pszSoundFile, uint32 nFlags, int iQSlot, bool bW
 		}
 
 		if (!fileExists(pszSoundFile)) {
-			logError(buildString("Warning: Sound File '%s' not found", pszSoundFile));
+			logWarning(buildString("Sound File '%s' not found", pszSoundFile));
 			return false;
 		}
 
diff --git a/engines/bagel/dialogs/credits_dialog.cpp b/engines/bagel/dialogs/credits_dialog.cpp
index 636ff7e57ef..2680b64db22 100644
--- a/engines/bagel/dialogs/credits_dialog.cpp
+++ b/engines/bagel/dialogs/credits_dialog.cpp
@@ -91,13 +91,11 @@ void CBagCreditsDialog::onInitDialog() {
 
 	setReturnValue(-1);
 
-	CBofPalette *pPal;
-
 	// Start at 1st credit screen
 	_iScreen = 0;
 
 	assert(_pBackdrop != nullptr);
-	pPal = _pBackdrop->getPalette();
+	CBofPalette *pPal = _pBackdrop->getPalette();
 	selectPalette(pPal);
 	g_b1 = true;
 
@@ -118,26 +116,23 @@ ErrorCode CBagCreditsDialog::loadNextTextFile() {
 	cRect.bottom = g_cScreen[_iScreen]._nBottom;
 
 	// Get rid of any previous work area
-	if (_pCreditsBmp != nullptr) {
-		delete _pCreditsBmp;
-		_pCreditsBmp = nullptr;
-	}
+	delete _pCreditsBmp;
+	_pCreditsBmp = nullptr;
 
 	// Create a new work area
-	if ((_pCreditsBmp = new CBofBitmap(cRect.width(), cRect.height() + LINE_HEIGHT + 2, _pBackdrop->getPalette())) != nullptr) {
+	_pCreditsBmp = new CBofBitmap(cRect.width(), cRect.height() + LINE_HEIGHT + 2, _pBackdrop->getPalette());
+	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) {
-			delete _pSaveBmp;
-		}
-
-		if ((_pSaveBmp = new CBofBitmap(_pCreditsBmp->width(), _pCreditsBmp->height(), _pBackdrop->getPalette())) != nullptr) {
 			CBofRect tmpRect = _pSaveBmp->getRect();
 			_pBackdrop->paint(_pSaveBmp, &tmpRect, &cRect);
 
 		} else {
-			reportError(ERR_MEMORY);
+			reportError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
 		}
 	}
 
@@ -150,13 +145,10 @@ ErrorCode CBagCreditsDialog::loadNextTextFile() {
 	CBofFile cFile(buildSysDir(g_cScreen[_iScreen]._pszTextFile), CBF_BINARY | CBF_READONLY);
 
 	if (!cFile.errorOccurred()) {
-		uint32 lSize;
-
 		// Read in text file
-		lSize = cFile.getLength();
+		uint32 lSize = cFile.getLength();
 		_pszText = (char *)bofCAlloc(lSize + 1, 1);
 		if (_pszText != nullptr) {
-
 			cFile.read(_pszText, lSize);
 
 			_pszNextLine = _pszText;
@@ -186,8 +178,7 @@ ErrorCode CBagCreditsDialog::loadNextTextFile() {
 int CBagCreditsDialog::linesPerPage() {
 	assert(isValidObject(this));
 
-	int n;
-	n = (g_cScreen[_iScreen]._nBottom - g_cScreen[_iScreen]._nTop) / (LINE_HEIGHT + 2) + 1;
+	int n = (g_cScreen[_iScreen]._nBottom - g_cScreen[_iScreen]._nTop) / (LINE_HEIGHT + 2) + 1;
 
 	return n;
 }
@@ -195,14 +186,11 @@ int CBagCreditsDialog::linesPerPage() {
 void CBagCreditsDialog::onClose() {
 	assert(isValidObject(this));
 
-	if (_pCreditsBmp != nullptr) {
-		delete _pCreditsBmp;
-		_pCreditsBmp = nullptr;
-	}
-	if (_pSaveBmp != nullptr) {
-		delete _pSaveBmp;
-		_pSaveBmp = nullptr;
-	}
+	delete _pCreditsBmp;
+	_pCreditsBmp = nullptr;
+
+	delete _pSaveBmp;
+	_pSaveBmp = nullptr;
 
 	if (_pszText != nullptr) {
 		bofFree(_pszText);
@@ -314,10 +302,9 @@ ErrorCode CBagCreditsDialog::nextScreen() {
 	assert(isValidObject(this));
 
 	if (++_iScreen < NUM_SCREENS) {
-		CBofBitmap *pBmp;
-
 		// Load next screen (flushes previous backdrop)
-		if ((pBmp = Bagel::loadBitmap(buildSysDir(g_cScreen[_iScreen]._pszBackground))) != nullptr) {
+		CBofBitmap *pBmp = Bagel::loadBitmap(buildSysDir(g_cScreen[_iScreen]._pszBackground));
+		if (pBmp != nullptr) {
 			setBackdrop(pBmp);
 			g_b1 = true;
 		}
@@ -341,7 +328,6 @@ ErrorCode CBagCreditsDialog::paintLine(int nLine, char *pszText) {
 	assert(_pCreditsBmp != nullptr);
 
 	CBofRect cRect;
-
 	cRect.setRect(0, nLine * LINE_HEIGHT, _pCreditsBmp->width() - 1, (nLine + 1) * LINE_HEIGHT - 1);
 
 	_pCreditsBmp->fillRect(&cRect, MY_MASK_COLOR);
@@ -355,7 +341,6 @@ ErrorCode CBagCreditsDialog::paintLine(int nLine, char *pszText) {
 
 void CBagCreditsDialog::nextLine() {
 	assert(isValidObject(this));
-
 	assert(_pszNextLine != nullptr);
 
 	if ((_pszNextLine != nullptr) && (_pszNextLine < _pszEnd)) {




More information about the Scummvm-git-logs mailing list