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

Strangerke noreply at scummvm.org
Sun May 19 21:21:28 UTC 2024


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

Summary:
d120d3822f BAGEL: Remove some more useless checks in boflib
dbe6620007 BAGEL: Remove 3 unused includes and a constant in boflib
5e47f541f7 BAGEL: Remove some more useless checks in dialogs
7c4cb6f3c2 BAGEL: start working on useless null checks after new in spacebar folder
e6257e1e32 BAGEL finish removing useless null checks and asserts after new in spacebar folder


Commit: d120d3822f81d3de51162ea5571e8bfdfe3ae29d
    https://github.com/scummvm/scummvm/commit/d120d3822f81d3de51162ea5571e8bfdfe3ae29d
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-19T22:20:55+01:00

Commit Message:
BAGEL: Remove some more useless checks in boflib

Changed paths:
    engines/bagel/boflib/app.cpp
    engines/bagel/boflib/dat_file.cpp
    engines/bagel/boflib/options.cpp
    engines/bagel/boflib/queue.cpp
    engines/bagel/boflib/res.cpp
    engines/bagel/boflib/sound.cpp


diff --git a/engines/bagel/boflib/app.cpp b/engines/bagel/boflib/app.cpp
index d99ddbfcf1e..0fe77daef7c 100644
--- a/engines/bagel/boflib/app.cpp
+++ b/engines/bagel/boflib/app.cpp
@@ -66,9 +66,7 @@ void CBofApp::StartupCode() {
 
 	// Open the Boffo debug options file (BOFFO.INI)
 	g_pDebugOptions = new CBofDebugOptions(DEBUG_INI);
-	if (g_pDebugOptions != nullptr) {
-		g_pDebugOptions->readSetting("DebugOptions", "MainLoops", &_nIterations, DEFAULT_MAINLOOPS);
-	}
+	g_pDebugOptions->readSetting("DebugOptions", "MainLoops", &_nIterations, DEFAULT_MAINLOOPS);
 
 	//
 	// Initialize the boffo libraries
@@ -102,10 +100,8 @@ void CBofApp::ShutDownCode() {
 ErrorCode CBofApp::preInit() {
 	if ((_pPalette == nullptr) && (_pDefPalette == nullptr)) {
 		_pDefPalette = new CBofPalette();
-		if (_pDefPalette != nullptr) {
-			_pDefPalette->createDefault();
-			setPalette(_pDefPalette);
-		}
+		_pDefPalette->createDefault();
+		setPalette(_pDefPalette);
 	}
 
 	return _errCode;
diff --git a/engines/bagel/boflib/dat_file.cpp b/engines/bagel/boflib/dat_file.cpp
index e6db4b7f022..ab98cf173c9 100644
--- a/engines/bagel/boflib/dat_file.cpp
+++ b/engines/bagel/boflib/dat_file.cpp
@@ -243,8 +243,6 @@ ErrorCode CBofDataFile::readHeader() {
 					if (_lHeaderLength != 0) {
 						// Allocate buffer to hold header
 						_pHeader = new HeaderRec[(int)_lNumRecs];
-						if (_pHeader == nullptr)
-							fatalError(ERR_MEMORY, buildString("Could not allocate footer for file '%s'", _szFileName));
 
 						// Seek to start of header
 						seek(_lHeaderStart);
@@ -652,8 +650,6 @@ ErrorCode CBofDataFile::addRecord(void *pBuf, int32 lLength, bool bUpdateHeader,
 				_lNumRecs++;
 
 				HeaderRec *pTmpHeader = new HeaderRec[(int)_lNumRecs];
-				if (pTmpHeader == nullptr)
-					fatalError(ERR_MEMORY, "Could not allocate a data file header");
 
 				for (int i = 0; i < _lNumRecs; ++i) {
 					pTmpHeader[i]._lOffset = pTmpHeader[i]._lLength = 0;
diff --git a/engines/bagel/boflib/options.cpp b/engines/bagel/boflib/options.cpp
index 98f3b308a0c..75d21760b6e 100644
--- a/engines/bagel/boflib/options.cpp
+++ b/engines/bagel/boflib/options.cpp
@@ -85,16 +85,10 @@ ErrorCode CBofOptions::load() {
 
 		while (readLine(&f, szBuf)) {
 			COption *pNewOption = new COption(szBuf);
-			if (pNewOption != nullptr) {
-				if (_pOptionList != nullptr) {
-					_pOptionList->addToTail(pNewOption);
-				} else {
-					_pOptionList = pNewOption;
-				}
-
+			if (_pOptionList != nullptr) {
+				_pOptionList->addToTail(pNewOption);
 			} else {
-				errorCode = ERR_MEMORY;
-				break;
+				_pOptionList = pNewOption;
 			}
 		}
 
@@ -173,8 +167,6 @@ ErrorCode CBofOptions::writeSetting(const char *pszSection, const char *pszVar,
 			Common::sprintf_s(szSectionBuf, "[%s]", pszSection);
 
 			pSection = new COption(szSectionBuf);
-			if (pSection == nullptr)
-				CBofError::fatalError(ERR_MEMORY, "Unable to instantiate a new COption");
 
 			if (_pOptionList != nullptr) {
 				_pOptionList->addToTail(pSection);
@@ -185,10 +177,6 @@ ErrorCode CBofOptions::writeSetting(const char *pszSection, const char *pszVar,
 
 		// Add this option to the specified section
 		pOption = new COption(szValueBuf);
-		if (pOption == nullptr)
-			CBofError::fatalError(ERR_MEMORY, "Unable to instantiate a new COption");
-
-		assert(pSection != nullptr);
 		pSection->Insert(pOption);
 	}
 
diff --git a/engines/bagel/boflib/queue.cpp b/engines/bagel/boflib/queue.cpp
index 17c057a7b3d..d88ee107a65 100644
--- a/engines/bagel/boflib/queue.cpp
+++ b/engines/bagel/boflib/queue.cpp
@@ -70,15 +70,13 @@ void CQueue::addItem(void *pObject) {
 	assert(isValidObject(this));
 
 	CLList *pNewItem = new CLList(pObject);
-	if (pNewItem != nullptr) {
-		if (_pQueueList != nullptr) {
-			_pQueueList->addToTail(pNewItem);
-		} else {
-			_pQueueList = pNewItem;
-		}
-
-		assert(pNewItem->getHead() == _pQueueList);
+	if (_pQueueList != nullptr) {
+		_pQueueList->addToTail(pNewItem);
+	} else {
+		_pQueueList = pNewItem;
 	}
+
+	assert(pNewItem->getHead() == _pQueueList);
 }
 
 void *CQueue::removeItem() {
diff --git a/engines/bagel/boflib/res.cpp b/engines/bagel/boflib/res.cpp
index efc778b8855..aba885800dd 100644
--- a/engines/bagel/boflib/res.cpp
+++ b/engines/bagel/boflib/res.cpp
@@ -117,8 +117,6 @@ ErrorCode CBofStringTable::buildTable() {
 		pBuf++;
 
 		CResString *pString = new CResString(nId, (const char *)pBuf);
-		if (pString == nullptr)
-			fatalError(ERR_MEMORY, "Unable to allocate a CResString");
 
 		// Add this string to the table
 		if (_pStringTable == nullptr) {
diff --git a/engines/bagel/boflib/sound.cpp b/engines/bagel/boflib/sound.cpp
index a7a5126fe37..8555fecbbbb 100644
--- a/engines/bagel/boflib/sound.cpp
+++ b/engines/bagel/boflib/sound.cpp
@@ -643,14 +643,11 @@ bool BofPlaySound(const char *pszSoundFile, uint32 nFlags, int iQSlot) {
 		CBofSound::stopWaveSounds();
 
 		CBofSound *pSound = new CBofSound(pWnd, pszSoundFile, (uint16)nFlags);
-		if (pSound != nullptr) {
-			if ((nFlags & SOUND_QUEUE) == SOUND_QUEUE) {
-				pSound->setQSlot(iQSlot);
-			}
-
-			bSuccess = pSound->play();
+		if ((nFlags & SOUND_QUEUE) == SOUND_QUEUE) {
+			pSound->setQSlot(iQSlot);
 		}
 
+		bSuccess = pSound->play();
 	} else {
 		bSuccess = true;
 		CBofSound::stopWaveSounds();
@@ -683,19 +680,17 @@ bool BofPlaySoundEx(const char *pszSoundFile, uint32 nFlags, int iQSlot, bool bW
 		CBofSound::audioTask();
 
 		CBofSound *pSound = new CBofSound(pWnd, pszSoundFile, (uint16)nFlags);
-		if (pSound != nullptr) {
-			if ((nFlags & SOUND_QUEUE) == SOUND_QUEUE) {
-				pSound->setQSlot(iQSlot);
-			}
+		if ((nFlags & SOUND_QUEUE) == SOUND_QUEUE) {
+			pSound->setQSlot(iQSlot);
+		}
 
-			bSuccess = pSound->play();
+		bSuccess = pSound->play();
 
-			if (bWait) {
-				while (pSound->isPlaying()) {
-					CBofSound::audioTask();
-				}
-				delete pSound;
+		if (bWait) {
+			while (pSound->isPlaying()) {
+				CBofSound::audioTask();
 			}
+			delete pSound;
 		}
 	}
 


Commit: dbe66200071e2bc0504f6b94ad3adb7a96f5a29d
    https://github.com/scummvm/scummvm/commit/dbe66200071e2bc0504f6b94ad3adb7a96f5a29d
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-19T22:20:56+01:00

Commit Message:
BAGEL: Remove 3 unused includes and a constant in boflib

Changed paths:
    engines/bagel/boflib/debug.cpp
    engines/bagel/boflib/log.cpp
    engines/bagel/boflib/string_functions.cpp
    engines/bagel/boflib/vector.cpp


diff --git a/engines/bagel/boflib/debug.cpp b/engines/bagel/boflib/debug.cpp
index 28253ac4d62..efb66eb4c9d 100644
--- a/engines/bagel/boflib/debug.cpp
+++ b/engines/bagel/boflib/debug.cpp
@@ -21,7 +21,6 @@
 
 #include "common/config-manager.h"
 #include "common/debug.h"
-#include "common/textconsole.h"
 #include "bagel/boflib/debug.h"
 #include "bagel/bagel.h"
 
diff --git a/engines/bagel/boflib/log.cpp b/engines/bagel/boflib/log.cpp
index 80f5036dcf6..bf330b9317e 100644
--- a/engines/bagel/boflib/log.cpp
+++ b/engines/bagel/boflib/log.cpp
@@ -23,7 +23,6 @@
 #include "common/savefile.h"
 #include "common/debug.h"
 #include "bagel/boflib/log.h"
-#include "bagel/boflib/stdinc.h"
 
 namespace Bagel {
 
diff --git a/engines/bagel/boflib/string_functions.cpp b/engines/bagel/boflib/string_functions.cpp
index e2821fc450a..b0c63707558 100644
--- a/engines/bagel/boflib/string_functions.cpp
+++ b/engines/bagel/boflib/string_functions.cpp
@@ -22,7 +22,6 @@
 #include "common/str.h"
 
 #include "bagel/boflib/string_functions.h"
-#include "bagel/boflib/misc.h"
 
 namespace Bagel {
 
diff --git a/engines/bagel/boflib/vector.cpp b/engines/bagel/boflib/vector.cpp
index 5cb470edcbc..c9fe8ae1df2 100644
--- a/engines/bagel/boflib/vector.cpp
+++ b/engines/bagel/boflib/vector.cpp
@@ -23,8 +23,6 @@
 
 namespace Bagel {
 
-#define UNIT_Vector_LENGTH 1
-
 CVector::CVector() {
 	this->x = 0;
 	this->y = 0;


Commit: 5e47f541f74304f735e5458a7afc30100aae2889
    https://github.com/scummvm/scummvm/commit/5e47f541f74304f735e5458a7afc30100aae2889
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-19T22:20:56+01:00

Commit Message:
BAGEL: Remove some more useless checks in dialogs

Changed paths:
    engines/bagel/dialogs/credits_dialog.cpp
    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/dialogs/start_dialog.cpp


diff --git a/engines/bagel/dialogs/credits_dialog.cpp b/engines/bagel/dialogs/credits_dialog.cpp
index 15cc53fd555..c7361da8c16 100644
--- a/engines/bagel/dialogs/credits_dialog.cpp
+++ b/engines/bagel/dialogs/credits_dialog.cpp
@@ -121,19 +121,14 @@ ErrorCode CBagCreditsDialog::loadNextTextFile() {
 
 	// Create a new work area
 	_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)
-			fatalError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
-
-		CBofRect tmpRect = _pSaveBmp->getRect();
-		_pBackdrop->paint(_pSaveBmp, &tmpRect, &cRect);
-	}
+	_pCreditsBmp->fillRect(nullptr, MY_MASK_COLOR);
+
+	// Kill any previous work area
+	delete _pSaveBmp;
+	_pSaveBmp = new CBofBitmap(_pCreditsBmp->width(), _pCreditsBmp->height(), _pBackdrop->getPalette());
+
+	CBofRect tmpRect = _pSaveBmp->getRect();
+	_pBackdrop->paint(_pSaveBmp, &tmpRect, &cRect);
 
 	// Get rid of any previous credits screen
 	if (_pszText != nullptr) {
diff --git a/engines/bagel/dialogs/next_cd_dialog.cpp b/engines/bagel/dialogs/next_cd_dialog.cpp
index 4567288651f..526c970e7f1 100644
--- a/engines/bagel/dialogs/next_cd_dialog.cpp
+++ b/engines/bagel/dialogs/next_cd_dialog.cpp
@@ -49,8 +49,6 @@ void CBagNextCDDialog::onInitDialog() {
 
 	// Build all our buttons
 	_pButton = new 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);
diff --git a/engines/bagel/dialogs/opt_window.cpp b/engines/bagel/dialogs/opt_window.cpp
index caf5b798950..751e9f77e6a 100644
--- a/engines/bagel/dialogs/opt_window.cpp
+++ b/engines/bagel/dialogs/opt_window.cpp
@@ -227,8 +227,6 @@ ErrorCode CBagOptWindow::attach() {
 		assert(_pButtons[i] == nullptr);
 
 		_pButtons[i] = new CBofBmpButton;
-		if (_pButtons[i] == nullptr)
-			fatalError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
 
 		CBofBitmap *pUp = loadBitmap(buildSysDir(g_stButtons[i]._pszUp), pPal);
 		CBofBitmap *pDown = loadBitmap(buildSysDir(g_stButtons[i]._pszDown), pPal);
@@ -258,9 +256,6 @@ ErrorCode CBagOptWindow::attach() {
 	CBofRect cRect;
 	cRect.setRect(73, 48, 73 + 120 - 1, 48 + 20 - 1);
 	_pMidiVolumeScroll = new CBofScrollBar;
-	if (_pMidiVolumeScroll == nullptr)
-		fatalError(ERR_MEMORY, "Could not allocate the Midi Volume Scroll Bar");
-
 	_pMidiVolumeScroll->create("", &cRect, this, MIDI_VOL_ID);
 	_pMidiVolumeScroll->loadBitmaps(szBuf1, szBuf2, szBuf3, szBuf4, szBuf5, szBuf6);
 	_pMidiVolumeScroll->setScrollRange(VOLUME_MIN, VOLUME_MAX, true);
@@ -269,9 +264,6 @@ ErrorCode CBagOptWindow::attach() {
 	// Digital Audio volume control
 	cRect.setRect(73, 98, 73 + 120 - 1, 98 + 20 - 1);
 	_pWaveVolumeScroll = new CBofScrollBar;
-	if (_pWaveVolumeScroll == nullptr)
-		fatalError(ERR_MEMORY, "Could not allocate the Wave Volume Scroll Bar");
-
 	_pWaveVolumeScroll->create("", &cRect, this, WAVE_VOL_ID);
 	_pWaveVolumeScroll->loadBitmaps(szBuf1, szBuf2, szBuf3, szBuf4, szBuf5, szBuf6);
 	_pWaveVolumeScroll->setScrollRange(VOLUME_MIN, VOLUME_MAX, true);
@@ -280,9 +272,6 @@ ErrorCode CBagOptWindow::attach() {
 	// Pan Correction control
 	cRect.setRect(73, 268, 73 + 120 - 1, 268 + 20 - 1);
 	_pCorrectionScroll = new CBofScrollBar;
-	if (_pCorrectionScroll == nullptr)
-		fatalError(ERR_MEMORY, "Could not allocate the Pan Correction Scroll Bar");
-
 	_pCorrectionScroll->create("", &cRect, this, CORRECTION_ID);
 	_pCorrectionScroll->loadBitmaps(szBuf1, szBuf2, szBuf3, szBuf4, szBuf5, szBuf6);
 	_pCorrectionScroll->setScrollRange(0, 6, true);
@@ -291,9 +280,6 @@ ErrorCode CBagOptWindow::attach() {
 	// Pan Speed control
 	cRect.setRect(73, 318, 73 + 120 - 1, 318 + 20 - 1);
 	_pPanSpeedScroll = new CBofScrollBar;
-	if (_pPanSpeedScroll == nullptr)
-		fatalError(ERR_MEMORY, "Could not allocate the Pan Speed Scroll Bar");
-
 	_pPanSpeedScroll->create("", &cRect, this, PANSPEED_ID);
 	_pPanSpeedScroll->loadBitmaps(szBuf1, szBuf2, szBuf3, szBuf4, szBuf5, szBuf6);
 	_pPanSpeedScroll->setScrollRange(0, 5, true);
@@ -301,18 +287,12 @@ ErrorCode CBagOptWindow::attach() {
 
 	cRect.setRect(FLYTHROUGHS_LEFT, FLYTHROUGHS_TOP, FLYTHROUGHS_LEFT + CHECKBOX_WIDTH, FLYTHROUGHS_TOP + CHECKBOX_HEIGHT);
 	_pFlythroughs = new CBofCheckButton();
-	if (_pFlythroughs == nullptr)
-		fatalError(ERR_MEMORY, "Unable to allocate a CBofCheckButton");
-
 	_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);
 	_pPanimations = new CBofCheckButton();
-	if (_pPanimations == nullptr)
-		fatalError(ERR_MEMORY, "Unable to allocate a CBofCheckButton");
-
 	_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 01b96aa2d92..ad0c4912c61 100644
--- a/engines/bagel/dialogs/quit_dialog.cpp
+++ b/engines/bagel/dialogs/quit_dialog.cpp
@@ -78,8 +78,6 @@ void CBagQuitDialog::onInitDialog() {
 		assert(_pButtons[i] == nullptr);
 
 		_pButtons[i] = new CBofBmpButton;
-		if (_pButtons[i] == nullptr)
-			fatalError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
 
 		CBofBitmap *pUp = loadBitmap(buildSysDir(g_stQuitButtons[i]._pszUp), pPal);
 		CBofBitmap *pDown = loadBitmap(buildSysDir(g_stQuitButtons[i]._pszDown), pPal);
diff --git a/engines/bagel/dialogs/restart_dialog.cpp b/engines/bagel/dialogs/restart_dialog.cpp
index 71363663fbd..f141371c9d4 100644
--- a/engines/bagel/dialogs/restart_dialog.cpp
+++ b/engines/bagel/dialogs/restart_dialog.cpp
@@ -88,8 +88,6 @@ void CBagRestartDialog::onInitDialog() {
 		assert(_pButtons[i] == nullptr);
 
 		_pButtons[i] = new CBofBmpButton;
-		if (_pButtons[i] == nullptr)
-			fatalError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
 
 		CBofBitmap *pUp = loadBitmap(buildSysDir(g_stRestartButtons[i]._pszUp), pPal);
 		CBofBitmap *pDown = loadBitmap(buildSysDir(g_stRestartButtons[i]._pszDown), pPal);
diff --git a/engines/bagel/dialogs/restore_dialog.cpp b/engines/bagel/dialogs/restore_dialog.cpp
index 35f965910c6..dfc0a114c64 100644
--- a/engines/bagel/dialogs/restore_dialog.cpp
+++ b/engines/bagel/dialogs/restore_dialog.cpp
@@ -118,8 +118,6 @@ ErrorCode CBagRestoreDialog::attach() {
 		assert(_pButtons[i] == nullptr);
 
 		_pButtons[i] = new CBofBmpButton;
-		if (_pButtons[i] == nullptr)
-			fatalError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
 
 		CBofBitmap *pUp = loadBitmap(buildSysDir(g_stButtons[i]._pszUp), pPal);
 		CBofBitmap *pDown = loadBitmap(buildSysDir(g_stButtons[i]._pszDown), pPal);
@@ -155,9 +153,6 @@ ErrorCode CBagRestoreDialog::attach() {
 	CBofRect cRect(LIST_X, LIST_Y, LIST_X + LIST_DX - 1, LIST_Y + LIST_DY - 1);
 
 	_pListBox = new CBofListBox();
-	if (_pListBox == nullptr)
-		fatalError(ERR_MEMORY, "Unable to allocate a CBofListBox");
-
 	_pListBox->create("SaveGameList", &cRect, this);
 	_pListBox->setPointSize(LIST_FONT_SIZE);
 	_pListBox->setItemHeight(LIST_TEXT_DY);
@@ -197,8 +192,6 @@ ErrorCode CBagRestoreDialog::attach() {
 		assert(_pText == nullptr);
 
 		_pText = new CBofText;
-		if (_pText == nullptr)
-			fatalError(ERR_MEMORY, "Could not allocate a CBofText for the Restore Dialog");
 
 		cRect.setRect(170, 405, 470, 435);
 		_pText->setupText(&cRect, JUSTIFY_LEFT, FORMAT_CENTER_LEFT);
diff --git a/engines/bagel/dialogs/save_dialog.cpp b/engines/bagel/dialogs/save_dialog.cpp
index c6a1f78798a..3f7cc13c285 100644
--- a/engines/bagel/dialogs/save_dialog.cpp
+++ b/engines/bagel/dialogs/save_dialog.cpp
@@ -124,8 +124,6 @@ ErrorCode CBagSaveDialog::attach() {
 		assert(_pButtons[i] == nullptr);
 
 		_pButtons[i] = new CBofBmpButton;
-		if (_pButtons[i] == nullptr)
-			fatalError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
 
 		CBofBitmap *pUp = loadBitmap(buildSysDir(g_stButtons[i]._up), pPal);
 		CBofBitmap *pDown = loadBitmap(buildSysDir(g_stButtons[i]._down), pPal);
@@ -141,10 +139,8 @@ ErrorCode CBagSaveDialog::attach() {
 	assert(_pEditText == nullptr);
 
 	_pEditText = new CBofEditText("", EDIT_X, EDIT_Y, EDIT_DX, EDIT_DY, this);
-	if (_pEditText != nullptr) {
-		_pEditText->setText("");
-		_pEditText->show();
-	}
+	_pEditText->setText("");
+	_pEditText->show();
 
 	// Get a list of saves, and filter out the autosave entry if present
 	// (we don't show the autosave slot in the original UI)
@@ -161,8 +157,6 @@ ErrorCode CBagSaveDialog::attach() {
 
 	// Create a list box for the user to choose the slot to save into
 	_pListBox = new CBofListBox();
-	if (_pListBox == nullptr)
-		fatalError(ERR_MEMORY, "Unable to allocate a CBofListBox");
 
 	CBofRect cRect(LIST_X, LIST_Y, LIST_X + LIST_DX - 1, LIST_Y + LIST_DY - 1);
 
diff --git a/engines/bagel/dialogs/start_dialog.cpp b/engines/bagel/dialogs/start_dialog.cpp
index e76d4a71b4c..4bede05f569 100644
--- a/engines/bagel/dialogs/start_dialog.cpp
+++ b/engines/bagel/dialogs/start_dialog.cpp
@@ -77,8 +77,6 @@ void CBagStartDialog::onInitDialog() {
 		assert(_buttons[i] == nullptr);
 
 		_buttons[i] = new CBofBmpButton;
-		if (_buttons[i] == nullptr)
-			fatalError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
 
 		CBofBitmap *pUp = loadBitmap(buildSysDir(g_stStartButtons[i]._pszUp), pPal);
 		CBofBitmap *pDown = loadBitmap(buildSysDir(g_stStartButtons[i]._pszDown), pPal);


Commit: 7c4cb6f3c2ee88e619d491c5a49ee84509ac6898
    https://github.com/scummvm/scummvm/commit/7c4cb6f3c2ee88e619d491c5a49ee84509ac6898
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-19T22:20:56+01:00

Commit Message:
BAGEL: start working on useless null checks after new in spacebar folder

Changed paths:
    engines/bagel/spacebar/bibble_window.cpp
    engines/bagel/spacebar/computer.cpp
    engines/bagel/spacebar/filter.cpp
    engines/bagel/spacebar/master_win.cpp
    engines/bagel/spacebar/slot_wnd.cpp
    engines/bagel/spacebar/spacebar.cpp


diff --git a/engines/bagel/spacebar/bibble_window.cpp b/engines/bagel/spacebar/bibble_window.cpp
index e14fadec0b7..3c44333945a 100644
--- a/engines/bagel/spacebar/bibble_window.cpp
+++ b/engines/bagel/spacebar/bibble_window.cpp
@@ -298,8 +298,6 @@ ErrorCode CBibbleWindow::attach() {
 
 	// Setup the text fields
 	_pCreditsText = new CBofText;
-	if (_pCreditsText == nullptr)
-		fatalError(ERR_MEMORY, "Unable to allocate a CBofText");
 
 	CBofRect cRect(CREDITS_AREA_X1, CREDITS_AREA_Y1, CREDITS_AREA_X2, CREDITS_AREA_Y2);
 
@@ -312,14 +310,10 @@ ErrorCode CBibbleWindow::attach() {
 	// Pre-load the "One", "Two", "Three", and "Four" shouts
 	for (int i = 0; i < BIBBLE_NUM_SHOUTS; i++) {
 		_pShouts[i] = new CBofSound(this, BuildDir(pszShouts[i]), SOUND_MIX);
-		if (_pShouts[i] == nullptr)
-			fatalError(ERR_MEMORY, "Unable to allocate a CBofSound");
 	}
 
 	// Pre-load the ball
 	_pBall = new CBofSprite;
-	if (_pBall == nullptr)
-		fatalError(ERR_MEMORY, "Unable to allocate a CBofSprite");
 
 	_pBall->loadSprite(BuildDir(BALL_BMP), BALL_CELS);
 	_pBall->setMaskColor(MASK_COLOR);
@@ -329,9 +323,6 @@ ErrorCode CBibbleWindow::attach() {
 
 	// Pre-load the bibbles
 	_pMasterBibble = new CBofSprite;
-	if (_pMasterBibble == nullptr)
-		fatalError(ERR_MEMORY, "Unable to allocate a CBofSprite");
-
 	_pMasterBibble->loadSprite(BuildDir(BIBBLE_BMP), BIBBLE_CELS);
 	_pMasterBibble->setMaskColor(MASK_COLOR);
 	_pMasterBibble->setZOrder(SPRITE_TOPMOST);
@@ -349,38 +340,26 @@ ErrorCode CBibbleWindow::attach() {
 
 	// Load the arch bitmaps that the ball needs to go behind
 	_pArch1 = new CBofSprite;
-	if (_pArch1 == nullptr)
-		fatalError(ERR_MEMORY, "Unable to allocate a CBofSprite");
-
 	_pArch1->loadSprite(BuildDir(ARCH1_BMP));
 	_pArch1->setMaskColor(MASK_COLOR);
 	_pArch1->setZOrder(SPRITE_MIDDLE);
 	_pArch1->linkSprite();
 
 	_pArch2 = new CBofSprite;
-	if (_pArch2 == nullptr)
-		fatalError(ERR_MEMORY, "Unable to allocate a CBofSprite");
-
 	_pArch2->loadSprite(BuildDir(ARCH2_BMP));
 	_pArch2->setMaskColor(MASK_COLOR);
 	_pArch2->setZOrder(SPRITE_MIDDLE);
 	_pArch2->linkSprite();
 
 	_pArch3 = new CBofSprite;
-	if (_pArch3 == nullptr)
-		fatalError(ERR_MEMORY, "Unable to allocate a CBofSprite");
-
 	_pArch3->loadSprite(BuildDir(ARCH3_BMP));
 	_pArch3->setMaskColor(MASK_COLOR);
 	_pArch3->setZOrder(SPRITE_MIDDLE);
 	_pArch3->linkSprite();
 
-
 	// Build all our buttons
 	for (int i = 0; i < BIBBLE_NUM_BUTTONS; i++) {
 		_pButtons[i] = new CBofBmpButton;
-		if (_pButtons[i] == nullptr)
-			fatalError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
 
 		CBofBitmap *pUp = loadBitmap(BuildDir(g_stButtons[i]._pszUp), pPal);
 		CBofBitmap *pDown = loadBitmap(BuildDir(g_stButtons[i]._pszDown), pPal);
@@ -393,9 +372,6 @@ ErrorCode CBibbleWindow::attach() {
 	}
 
 	_pBkgSnd = new CBofSound(this, BuildDir(CASINO_AUDIO), SOUND_MIX, 99999);
-	if (_pBkgSnd == nullptr)
-		fatalError(ERR_MEMORY, "Unable to allocate a CBofSound");
-
 	_pBkgSnd->play();
 
 	// No bet area currently selected
diff --git a/engines/bagel/spacebar/computer.cpp b/engines/bagel/spacebar/computer.cpp
index dc800ecdbec..8c413f3799b 100644
--- a/engines/bagel/spacebar/computer.cpp
+++ b/engines/bagel/spacebar/computer.cpp
@@ -153,8 +153,6 @@ ErrorCode SBarComputer::attach() {
 		// Build all our buttons
 		for (int i = 0; i < NUM_COMPBUTT; i++) {
 			_pButtons[i] = new CBofBmpButton;
-			if (_pButtons[i] == nullptr)
-				fatalError(ERR_MEMORY, "unable to allocate new CBofBmpButton");
 
 			CBofBitmap *pUp = loadBitmap(BuildBarcDir(g_stButtons[i]._pszUp), pPal);
 			CBofBitmap *pDown = loadBitmap(BuildBarcDir(g_stButtons[i]._pszDown), pPal);
@@ -251,9 +249,6 @@ ErrorCode SBarComputer::readDrnkFile() {
 	char *pPosInBuff = _pDrinkBuff;
 	while (pPosInBuff < _pDrinkBuff + fpDrinkFile.getLength()) {
 		SBarCompItem *pCompItem = new SBarCompItem();
-		if (!pCompItem)
-			fatalError(ERR_MEMORY, "Couldn't allocate a new SBarCompItem");
-
 		pCompItem->_pList = nullptr;
 		pCompItem->_pDrink = nullptr;
 
@@ -323,9 +318,6 @@ ErrorCode SBarComputer::readIngFile() {
 	char *pPosInBuff = _pIngBuff;
 	while (pPosInBuff < _pIngBuff + fpIngFile.getLength()) {
 		SBarCompItem *pCompItem = new SBarCompItem();
-		if (!pCompItem)
-			fatalError(ERR_MEMORY, "Couldn't allocate a new SBarCompItem");
-
 		pCompItem->_pList = nullptr;
 		pCompItem->_pDrink = nullptr;
 
@@ -364,7 +356,6 @@ ErrorCode SBarComputer::readIngFile() {
 void SBarComputer::createTextBox(CBofString &newText) {
 	if (_pTBox == nullptr) {
 		_pTBox = new CBofTextBox(getBackdrop(), &_compDisplay, newText);
-		assert(_pTBox != nullptr);
 		_pTBox->setTextAttribs(12, TEXT_NORMAL, RGB(0, 0, 0));
 	} else {
 		eraseBackdrop();
@@ -404,12 +395,9 @@ ErrorCode SBarComputer::createDrinksListBox() {
 		return errorCode;
 	
 	// We need to create one
-
 	_pDrinkBox = new CBofListBox();
-	if (_pDrinkBox == nullptr)
-		fatalError(ERR_MEMORY, "Couldn't allocate a new CBofListBox");
-
 	errorCode = _pDrinkBox->create("ListBox", &_compDisplay, this);
+
 	if (errorCode != ERR_NONE) {
 		return errorCode;
 	}
@@ -441,10 +429,8 @@ ErrorCode SBarComputer::createIngListBox() {
 
 	// We need to create one
 	_pIngBox = new CBofListBox();
-	if (_pIngBox == nullptr)
-		fatalError(ERR_MEMORY, "Couldn't allocate a new CBofListBox");
-
 	errorCode = _pIngBox->create("ListBox", &_compDisplay, this);
+
 	if (errorCode != ERR_NONE) {
 		return errorCode;
 	}
diff --git a/engines/bagel/spacebar/filter.cpp b/engines/bagel/spacebar/filter.cpp
index ddac4a099e4..37ff0b49100 100644
--- a/engines/bagel/spacebar/filter.cpp
+++ b/engines/bagel/spacebar/filter.cpp
@@ -638,33 +638,31 @@ static bool ZzazzlFilter(CBofBitmap *pBmp, CBofRect *pRect) {
 
 			CBofBitmap *pMiniBitmap = new CBofBitmap(dx, dy, pPal);
 
-			if (pMiniBitmap != nullptr) {
-				CBofRect dstRect(g_engine->viewRect);
-				CBofRect srcRect = pMiniBitmap->getRect();
-				pBmp->paint(pMiniBitmap, &srcRect, &dstRect);
-
-				CBofRect &filterRect = CMainWindow::getFilterRect();
-				filterRect.setRect(g_engine->viewRect.left, g_engine->viewRect.top, g_engine->viewRect.left + dx, g_engine->viewRect.top + dy);
-
-				int j, x;
-				int y = g_engine->viewRect.top;
-				for (int i = 0; i < 3; ++i) {
-					if (i == 1) {
-						j = 0;
-						x = g_engine->viewRect.left;
-					} else {
-						j = 1;
-						x = g_engine->viewRect.left + (dx >> 1);
-					}
-					for (; j < 3; ++j) {
-						pMiniBitmap->paint(pBmp, x, y);
-						x += dx;
-					}
-					y += dy;
+			CBofRect dstRect(g_engine->viewRect);
+			CBofRect srcRect = pMiniBitmap->getRect();
+			pBmp->paint(pMiniBitmap, &srcRect, &dstRect);
+
+			CBofRect &filterRect = CMainWindow::getFilterRect();
+			filterRect.setRect(g_engine->viewRect.left, g_engine->viewRect.top, g_engine->viewRect.left + dx, g_engine->viewRect.top + dy);
+
+			int j, x;
+			int y = g_engine->viewRect.top;
+			for (int i = 0; i < 3; ++i) {
+				if (i == 1) {
+					j = 0;
+					x = g_engine->viewRect.left;
+				} else {
+					j = 1;
+					x = g_engine->viewRect.left + (dx >> 1);
 				}
-
-				delete pMiniBitmap;
+				for (; j < 3; ++j) {
+					pMiniBitmap->paint(pBmp, x, y);
+					x += dx;
+				}
+				y += dy;
 			}
+
+			delete pMiniBitmap;
 		}
 	}
 
diff --git a/engines/bagel/spacebar/master_win.cpp b/engines/bagel/spacebar/master_win.cpp
index 89f14bce6c1..b85a3bda88a 100644
--- a/engines/bagel/spacebar/master_win.cpp
+++ b/engines/bagel/spacebar/master_win.cpp
@@ -117,24 +117,18 @@ CBagStorageDev *CSBarMasterWin::onNewStorageDev(const CBofString &typestr) {
 		// delineate cic's
 	} else if (!typestr.find("CIC")) {
 		pSDev = new GAMEWINDOW();
-		if (pSDev != nullptr) {
-			pSDev->setCloseup(true);
-			pSDev->setCIC(true);
-			pSDev->setExitOnEdge(80);
-		}
+		pSDev->setCloseup(true);
+		pSDev->setCIC(true);
+		pSDev->setExitOnEdge(80);
 
 	} else if (!typestr.find("CLOSEUP")) {
 		pSDev = new GAMEWINDOW();
-		if (pSDev != nullptr) {
-			pSDev->setCloseup(true);
-			pSDev->setExitOnEdge(80);
-		}
+		pSDev->setCloseup(true);
+		pSDev->setExitOnEdge(80);
 
 	} else if (!typestr.find("CHAT")) {
 		pSDev = new CBagChatWnd();
-		if (pSDev != nullptr) {
-			pSDev->setCloseup(true);
-		}
+		pSDev->setCloseup(true);
 
 	} else if (!typestr.find("EVENT")) {        // EVT STUFF
 		pSDev = new CBagEventSDev();
diff --git a/engines/bagel/spacebar/slot_wnd.cpp b/engines/bagel/spacebar/slot_wnd.cpp
index a212dee5ea3..cb4aee40997 100644
--- a/engines/bagel/spacebar/slot_wnd.cpp
+++ b/engines/bagel/spacebar/slot_wnd.cpp
@@ -176,8 +176,6 @@ ErrorCode  SBarSlotWnd::attach() {
 	_bFixBet = false;
 
 	_pSlotSound = new CBofSound(this, BuildSlotDir(SLOT_AUDIO), SOUND_MIX, 1);
-	if (_pSlotSound == nullptr)
-		fatalError(ERR_MEMORY, "Unable to allocate a CBofSound");
 
 	if (CBagStorageDevWnd::attach() == ERR_NONE) {
 		// Must have a valid backdrop by now
@@ -190,23 +188,18 @@ ErrorCode  SBarSlotWnd::attach() {
 		for (int i = 0; i < NUM_SLOTBUTT; i++) {
 
 			_pSlotButs[i] = new CBofBmpButton;
-			if (_pSlotButs[i] != nullptr) {
-				CBofBitmap *pUp = loadBitmap(BuildSlotDir(g_stButtons[i]._pszUp), pPal);
-				CBofBitmap *pDown = loadBitmap(BuildSlotDir(g_stButtons[i]._pszDown), pPal);
-				CBofBitmap *pFocus = loadBitmap(BuildSlotDir(g_stButtons[i]._pszFocus), pPal);
-				CBofBitmap *pDis = loadBitmap(BuildSlotDir(g_stButtons[i]._pszDisabled), pPal);
-
-				_pSlotButs[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
-				_pSlotButs[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);
-				_pSlotButs[i]->show();
-			}
+			CBofBitmap *pUp = loadBitmap(BuildSlotDir(g_stButtons[i]._pszUp), pPal);
+			CBofBitmap *pDown = loadBitmap(BuildSlotDir(g_stButtons[i]._pszDown), pPal);
+			CBofBitmap *pFocus = loadBitmap(BuildSlotDir(g_stButtons[i]._pszFocus), pPal);
+			CBofBitmap *pDis = loadBitmap(BuildSlotDir(g_stButtons[i]._pszDisabled), pPal);
+
+			_pSlotButs[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
+			_pSlotButs[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);
+			_pSlotButs[i]->show();
 		}
 
 		if (_pLoseBmp == nullptr) {
 			_pLoseBmp = new CBofBitmap(BuildSlotDir("BGNV.BMP"), pPal);
-			if (_pLoseBmp == nullptr) {
-				fatalError(ERR_MEMORY, "Unable to allocate a CBofBitmap");
-			}
 		}
 
 		// Hide the GO, LOSE Button until a bet is made
@@ -233,8 +226,6 @@ ErrorCode  SBarSlotWnd::attach() {
 
 		// Setup the Credit text fields
 		_pCredText = new CBofText;
-		if (_pCredText == nullptr)
-			fatalError(ERR_MEMORY, "Unable to allocate a CBofText");
 
 		CBofRect cRect(CreditRect.left, CreditRect.top, CreditRect.right, CreditRect.bottom);
 		_pCredText->setupText(&cRect, JUSTIFY_RIGHT, FORMAT_CENTER_RIGHT);
@@ -249,8 +240,6 @@ ErrorCode  SBarSlotWnd::attach() {
 		assert(_pBetText == nullptr);
 
 		_pBetText = new CBofText;
-		if (_pBetText == nullptr)
-			fatalError(ERR_MEMORY, "Unable to allocate a CBofText");
 
 		cRect.setRect(BetRect.left, BetRect.top, BetRect.right, BetRect.bottom);
 		_pBetText->setupText(&cRect, JUSTIFY_RIGHT, FORMAT_CENTER_RIGHT);
@@ -265,8 +254,6 @@ ErrorCode  SBarSlotWnd::attach() {
 		assert(_pOddsText == nullptr);
 
 		_pOddsText = new CBofText;
-		if (_pOddsText == nullptr)
-			fatalError(ERR_MEMORY, "Unable to allocate a CBofText");
 
 		cRect.setRect(OddRect.left, OddRect.top, OddRect.right, OddRect.bottom);
 		_pOddsText->setupText(&cRect, JUSTIFY_RIGHT, FORMAT_CENTER_RIGHT);
@@ -281,9 +268,6 @@ ErrorCode  SBarSlotWnd::attach() {
 	}
 
 	_pBkgSnd = new CBofSound(this, BuildSlotDir(CASINO_AUDIO), SOUND_MIX, 99999);
-	if (_pBkgSnd == nullptr)
-		fatalError(ERR_MEMORY, "Unable to allocate a CBofSound");
-
 	_pBkgSnd->play();
 
 	CBofCursor::show();
@@ -520,9 +504,6 @@ void SBarSlotWnd::calcOutcome() {
 	if (_nPayOff1 > 0) {
 		// Play winning audio
 		_pWinSound = new CBofSound(this, BuildSlotDir(WIN_AUDIO), SOUND_MIX, 1);
-		if (_pWinSound == nullptr)
-			fatalError(ERR_MEMORY, "Unable to allocate a CBofSound");
-
 		_pWinSound->play();
 
 		// Calc new credit
diff --git a/engines/bagel/spacebar/spacebar.cpp b/engines/bagel/spacebar/spacebar.cpp
index 5ef04abc87b..ad5144199cc 100644
--- a/engines/bagel/spacebar/spacebar.cpp
+++ b/engines/bagel/spacebar/spacebar.cpp
@@ -90,9 +90,6 @@ ErrorCode SpaceBarEngine::initialize() {
 
 		_masterWin = new CSBarMasterWin();
 		
-		if (_masterWin == nullptr)
-			fatalError(ERR_MEMORY, "Unable to allocate the main SpaceBar Window");
-
 		// This is the primary game window
 		setMainWindow(_masterWin);
 
@@ -100,9 +97,6 @@ ErrorCode SpaceBarEngine::initialize() {
 		InitializeSoundSystem(1, 22050, 8);
 
 		pBmp = new CBofBitmap(_masterWin->width(), _masterWin->height(), _pPalette);
-		if (pBmp == nullptr)
-			fatalError(ERR_MEMORY, "Unable to allocate a CBofBitmap");
-
 		pBmp->fillRect(nullptr, COLOR_BLACK);
 
 		_masterWin->show();


Commit: e6257e1e32edae9a9f9e348764ca10d01ec1f6ad
    https://github.com/scummvm/scummvm/commit/e6257e1e32edae9a9f9e348764ca10d01ec1f6ad
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-19T22:20:57+01:00

Commit Message:
BAGEL finish removing useless null checks and asserts after new in spacebar folder

Changed paths:
    engines/bagel/spacebar/sraf_computer.cpp
    engines/bagel/spacebar/thud.cpp
    engines/bagel/spacebar/vid_wnd.cpp


diff --git a/engines/bagel/spacebar/sraf_computer.cpp b/engines/bagel/spacebar/sraf_computer.cpp
index fcd286eb01d..8e6736a16e9 100644
--- a/engines/bagel/spacebar/sraf_computer.cpp
+++ b/engines/bagel/spacebar/sraf_computer.cpp
@@ -545,7 +545,6 @@ void SrafComputer::recalcSellerSummaryList() {
 	// initialize the initial state of the seller summary
 	if (_pSellerSummaryList == nullptr) {
 		_pSellerSummaryList = new CBofList<DealSummarySellerItem>;
-		assert(_pSellerSummaryList != nullptr);
 	} else {
 		delete _pSellerSummaryList;
 		_pSellerSummaryList = nullptr;
@@ -554,7 +553,6 @@ void SrafComputer::recalcSellerSummaryList() {
 	// Lets verify that its all set before we go to use it
 	if (_pSellerSummaryList == nullptr) {
 		_pSellerSummaryList = new CBofList<DealSummarySellerItem>;
-		assert(_pSellerSummaryList != nullptr);
 	}
 
 	int i = 0;
@@ -574,7 +572,6 @@ void SrafComputer::recalcBuyerSummaryList() {
 	// initialize the initial state of the deal summary
 	if (_pBuyerSummaryList == nullptr) {
 		_pBuyerSummaryList = new CBofList<DealSummaryBuyerItem>;
-		assert(_pBuyerSummaryList != nullptr);
 	} else {
 		delete _pBuyerSummaryList;
 		_pBuyerSummaryList = nullptr;
@@ -583,14 +580,12 @@ void SrafComputer::recalcBuyerSummaryList() {
 	// Lets verify that its all set before we go to use it
 	if (_pBuyerSummaryList == nullptr) {
 		_pBuyerSummaryList = new CBofList<DealSummaryBuyerItem>;
-		assert(_pBuyerSummaryList != nullptr);
 	}
 
 	int i = 0;
 	while (i < NUM_BUYERS) {
 		if (g_stBuyerBids[i]._bAccept) {
 			DealSummaryBuyerItem *pBuyerItem = new DealSummaryBuyerItem();
-			assert(pBuyerItem != nullptr);
 
 			pBuyerItem->_eBuyerID = g_stBuyerBids[i]._nBuyerID;
 			pBuyerItem->_nBuyerOffer = g_stBuyerBids[i]._nBidSum;
@@ -737,12 +732,9 @@ bool SrafComputer::verifyDispatchTeam() {
 
 		if (_pTeamList == nullptr) {
 			_pTeamList = new CBofList<DispatchedTeamItem>;
-			assert(_pTeamList != nullptr);
 		}
 
 		pTeamItem = new DispatchedTeamItem();
-		assert(pTeamItem != nullptr);
-
 		pTeamItem->_nFlags = nTeam | nDispatchFlags;
 		pTeamItem->_nMeetWithID = nMeetingWith;
 		CBagVar *pVar = g_VarManager->getVariable("SRATURNCOUNT");
@@ -901,7 +893,6 @@ ErrorCode SrafComputer::attach() {
 		assert(_pMainList == nullptr);
 
 		_pMainList = new CBofList<SrafCompItem>;
-		assert(_pMainList != nullptr);
 		fillMain();
 
 		// If we're on the Mac version, slot in the Chicken Dance song
@@ -912,7 +903,6 @@ ErrorCode SrafComputer::attach() {
 		for (int i = 0; i < (NUM_MUSICAL_SCORES - 1); i++) {
 			if (g_stAudioSetting[i]->_pMidiTrack == nullptr) {
 				g_stAudioSetting[i]->_pMidiTrack = new CBofSound(this, buildAudioDir(g_stAudioSetting[i]->_pszAudioFile), SOUND_MIDI | SOUND_ASYNCH | SOUND_LOOP, 32000);
-				assert(g_stAudioSetting[i]->_pMidiTrack != nullptr);
 			}
 		}
 
@@ -922,18 +912,15 @@ ErrorCode SrafComputer::attach() {
 
 		for (int i = 0; i < NUM_SRAFCOMPBUTT; i++) {
 			_pButtons[i] = new CBofBmpButton;
-			if (_pButtons[i] != nullptr) {
-
-				CBofBitmap *pUp = loadBitmap(buildSrafDir(g_stButtons[i]._pszUp), pPal);
-				CBofBitmap *pDown = loadBitmap(buildSrafDir(g_stButtons[i]._pszDown), pPal);
-				CBofBitmap *pFocus = loadBitmap(buildSrafDir(g_stButtons[i]._pszFocus), pPal);
-				CBofBitmap *pDis = loadBitmap(buildSrafDir(g_stButtons[i]._pszDisabled), pPal);
+			CBofBitmap *pUp = loadBitmap(buildSrafDir(g_stButtons[i]._pszUp), pPal);
+			CBofBitmap *pDown = loadBitmap(buildSrafDir(g_stButtons[i]._pszDown), pPal);
+			CBofBitmap *pFocus = loadBitmap(buildSrafDir(g_stButtons[i]._pszFocus), pPal);
+			CBofBitmap *pDis = loadBitmap(buildSrafDir(g_stButtons[i]._pszDisabled), pPal);
 
-				_pButtons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
-				_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);
-				if (i != QUIT_BUTTON)
-					_pButtons[i]->hide();
-			}
+			_pButtons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
+			_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);
+			if (i != QUIT_BUTTON)
+				_pButtons[i]->hide();
 		}
 
 		// Get our code words
@@ -947,11 +934,7 @@ ErrorCode SrafComputer::attach() {
 			_nStartingTime = pVar->getNumValue();
 		}
 
-		assert(_pszGroup1Word != nullptr);
-		assert(_pszGroup2Word != nullptr);
-
 		setOn();
-
 		show();
 		updateWindow();
 
@@ -1148,18 +1131,12 @@ ErrorCode SrafComputer::createListBox() {
 	if (_pLBox == nullptr) {
 		// We need to create one
 		_pLBox = new CBofListBox;
-		if (_pLBox != nullptr) {
-
-			errorCode = _pLBox->create("ListBox", &gCompDisplay, this);
-			if (errorCode != ERR_NONE) {
-				return errorCode;
-			}
+		errorCode = _pLBox->create("ListBox", &gCompDisplay, this);
+		if (errorCode != ERR_NONE) {
+			return errorCode;
 		}
 	}
 
-	if (_pLBox == nullptr)
-		return ERR_MEMORY;
-
 	_pLBox->setPointSize(_nListPointSize);
 	_pLBox->setItemHeight(_nListItemHeight);
 	_pLBox->setTextColor(_cTextColor);
@@ -1182,7 +1159,6 @@ void SrafComputer::fillMain() {
 
 	while (i < NUM_MAIN_ITEMS) {
 		SrafCompItem *pCompItem = new SrafCompItem();
-		assert(pCompItem != nullptr);
 
 		pCompItem->_pItem = g_stMainItems[i];
 
@@ -3747,13 +3723,9 @@ void SrafComputer::displayTextScreen(CBofString &sStr) {
 	gTextScreenFrontmost = true;
 
 	_pTextOnlyScreen = new SrafTextScreen(sStr);
-
-	if (_pTextOnlyScreen == nullptr)
-		return;
-
 	_pTextOnlyScreen->createTextScreen(this);
-
 	_pTextOnlyScreen->doModal();
+
 	delete _pTextOnlyScreen;
 	_pTextOnlyScreen = nullptr;
 
@@ -4127,12 +4099,6 @@ void SrafComputer::notifyBoss(CBofString &sSoundFile, int nStafferID) {
 	// Allow for no staffer screen
 	if (nStafferID != -1) {
 		pSaveBackground = new CBofBitmap(gTextWindow.width(), gTextWindow.height(), (CBofPalette *)nullptr, false);
-		assert(pSaveBackground != nullptr);
-
-		if (pSaveBackground == nullptr) {
-			return;
-		}
-
 		pSaveBackground->captureScreen(this, &gTextWindow);
 
 		if (_pStafferBmp[nStafferID] == nullptr) {
@@ -4143,10 +4109,6 @@ void SrafComputer::notifyBoss(CBofString &sSoundFile, int nStafferID) {
 			sStr = buildSrafDir(g_staffers[nStafferID]._pszStafferBmp);
 
 			_pStafferBmp[nStafferID] = new CBofBitmap(szLocalBuff);
-			assert(_pStafferBmp[nStafferID] != nullptr);
-			if (_pStafferBmp[nStafferID] == nullptr) {
-				return;
-			}
 		}
 
 		// Guaranteed to have it now.  Paste it to the screen.
@@ -4371,22 +4333,19 @@ void SrafComputer::displayMessage(const char *szMsg) {
 	gTextScreenFrontmost = true;
 
 	_pTextOnlyScreen = new SrafTextScreen(szMsg, true);
+	_pTextOnlyScreen->createTextScreen(this);
+	_pTextOnlyScreen->doModal();
 
-	if (_pTextOnlyScreen != nullptr) {
-		_pTextOnlyScreen->createTextScreen(this);
-
-		_pTextOnlyScreen->doModal();
-		delete _pTextOnlyScreen;
-		_pTextOnlyScreen = nullptr;
-
-		// if we have a list, then return focus to it.
-		if (_pLBox) {
-			_pLBox->setFocus();
-		}
+	delete _pTextOnlyScreen;
+	_pTextOnlyScreen = nullptr;
 
-		gTextScreenFrontmost = false;
+	// if we have a list, then return focus to it.
+	if (_pLBox) {
+		_pLBox->setFocus();
 	}
 
+	gTextScreenFrontmost = false;
+
 	updateWindow();
 }
 
@@ -4578,33 +4537,26 @@ int SrafTextScreen::createTextScreen(CBofWindow *pParent) {
 	// Create our OK button
 
 	_pOKButton = new CBofBmpButton;
-	if (_pOKButton != nullptr) {
-
-		CBofBitmap *pUp = loadBitmap(buildSrafDir(g_stButtons[DONE_BUTTON]._pszUp), pPal);
-		CBofBitmap *pDown = loadBitmap(buildSrafDir(g_stButtons[DONE_BUTTON]._pszDown), pPal);
-		CBofBitmap *pFocus = loadBitmap(buildSrafDir(g_stButtons[DONE_BUTTON]._pszFocus), pPal);
-		CBofBitmap *pDis = loadBitmap(buildSrafDir(g_stButtons[DONE_BUTTON]._pszDisabled), pPal);
 
-		_pOKButton->loadBitmaps(pUp, pDown, pFocus, pDis);
+	CBofBitmap *pUp = loadBitmap(buildSrafDir(g_stButtons[DONE_BUTTON]._pszUp), pPal);
+	CBofBitmap *pDown = loadBitmap(buildSrafDir(g_stButtons[DONE_BUTTON]._pszDown), pPal);
+	CBofBitmap *pFocus = loadBitmap(buildSrafDir(g_stButtons[DONE_BUTTON]._pszFocus), pPal);
+	CBofBitmap *pDis = loadBitmap(buildSrafDir(g_stButtons[DONE_BUTTON]._pszDisabled), pPal);
 
-		_pOKButton->create(g_stButtons[DONE_BUTTON]._pszName,
-		                    g_stButtons[DONE_BUTTON]._nLeft,
-		                    g_stButtons[DONE_BUTTON]._nTop,
-		                    g_stButtons[DONE_BUTTON]._nWidth,
-		                    g_stButtons[DONE_BUTTON]._nHeight,
-		                    this,
-		                    g_stButtons[DONE_BUTTON]._nID);
-	}
+	_pOKButton->loadBitmaps(pUp, pDown, pFocus, pDis);
 
-	assert(_pOKButton != nullptr);
+	_pOKButton->create(g_stButtons[DONE_BUTTON]._pszName,
+	                    g_stButtons[DONE_BUTTON]._nLeft,
+	                    g_stButtons[DONE_BUTTON]._nTop,
+	                    g_stButtons[DONE_BUTTON]._nWidth,
+	                    g_stButtons[DONE_BUTTON]._nHeight,
+	                    this,
+	                    g_stButtons[DONE_BUTTON]._nID);
 
 	//  Create our text box.
 	cRect.setRect(gCompDisplay.left, gCompDisplay.top, gCompDisplay.right, gCompDisplay.bottom);
 
 	_pTextBox = new CBofTextBox(this, &cRect, _text);
-	if (_pTextBox == nullptr)
-		fatalError(ERR_MEMORY, "Unable to allocate a CBofTextBox");
-
 	_pTextBox->setPageLength(24);
 	_pTextBox->setColor(CTEXT_WHITE);
 	_pTextBox->setFont(FONT_MONO);
@@ -4912,7 +4864,6 @@ void SrafComputer::restoreSraffanVars() {
 		// there.
 		if (_pTeamList == nullptr) {
 			_pTeamList = new CBofList<DispatchedTeamItem>;
-			assert(_pTeamList != nullptr);
 		}
 
 		if (teamListItem._nFlags != 0) {
diff --git a/engines/bagel/spacebar/thud.cpp b/engines/bagel/spacebar/thud.cpp
index da522a6658f..1e10fe07f5c 100644
--- a/engines/bagel/spacebar/thud.cpp
+++ b/engines/bagel/spacebar/thud.cpp
@@ -52,7 +52,7 @@ ErrorCode SBarThud::attach() {
 	// save a copy of the you icon
 	_xYouBmp = new CBofBitmap(getBackgroundName());
 
-	if ((_xYouBmp == nullptr) || (_xYouBmp->height() <= 0) || (_xYouBmp->width() <= 0)) {
+	if ((_xYouBmp->height() <= 0) || (_xYouBmp->width() <= 0)) {
 		bofMessageBox("You icon in Thud: Background Opened Failed", __FILE__);
 		return ERR_FOPEN;
 	}
diff --git a/engines/bagel/spacebar/vid_wnd.cpp b/engines/bagel/spacebar/vid_wnd.cpp
index 9e0a5b0a768..01941c4994a 100644
--- a/engines/bagel/spacebar/vid_wnd.cpp
+++ b/engines/bagel/spacebar/vid_wnd.cpp
@@ -107,9 +107,6 @@ ErrorCode SBarVidWnd::attach() {
 		}
 
 		_pMovie = new CBagCharacterObject;
-		if (_pMovie == nullptr)
-			fatalError(ERR_MEMORY, "Unable to allocate a CBagCharacterObject");
-
 		_pMovie->setFileName(BuildVidDir("BRNL.SMK"));
 		_pMovie->setPosition(CBofPoint(209, 10));
 		_pMovie->attach();




More information about the Scummvm-git-logs mailing list