[Scummvm-git-logs] scummvm master -> c26b99ae9d59868b4b19bd29f43a3d1450d73fd3
Strangerke
noreply at scummvm.org
Sun May 19 12:13:13 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:
b5698f8f76 BAGEL: Remove useless null checks after variable creation by new (as it's covered by an exception)
c26b99ae9d BAGEL: More work on null checks after new
Commit: b5698f8f76156e7b556cd12bdcb45b9cdf79cd09
https://github.com/scummvm/scummvm/commit/b5698f8f76156e7b556cd12bdcb45b9cdf79cd09
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-19T13:12:55+01:00
Commit Message:
BAGEL: Remove useless null checks after variable creation by new (as it's covered by an exception)
Changed paths:
engines/bagel/baglib/bmp_object.cpp
engines/bagel/baglib/character_object.cpp
engines/bagel/baglib/dev_dlg.cpp
engines/bagel/baglib/expression_object.cpp
engines/bagel/baglib/help.cpp
diff --git a/engines/bagel/baglib/bmp_object.cpp b/engines/bagel/baglib/bmp_object.cpp
index c2017c7ab3e..57c532186d9 100644
--- a/engines/bagel/baglib/bmp_object.cpp
+++ b/engines/bagel/baglib/bmp_object.cpp
@@ -39,9 +39,7 @@ CBagBmpObject::~CBagBmpObject() {
ErrorCode CBagBmpObject::attach(CBofPalette *palette) {
_bmp = new CBofBitmap(getFileName(), palette);
- if (_bmp == nullptr) {
- bofMessageBox(_bmp->getFileName(), __FILE__);
- }
+
return CBagObject::attach();
}
diff --git a/engines/bagel/baglib/character_object.cpp b/engines/bagel/baglib/character_object.cpp
index d1b3bd6de43..0187522d21b 100644
--- a/engines/bagel/baglib/character_object.cpp
+++ b/engines/bagel/baglib/character_object.cpp
@@ -85,7 +85,7 @@ ErrorCode CBagCharacterObject::attach() {
_bmpBuf = new CBofBitmap(_smacker->getWidth(), _smacker->getHeight(), smackPal);
- if ((smackPal != nullptr) && (_bmpBuf != nullptr)) {
+ if (smackPal != nullptr) {
_bmpBuf->fillRect(nullptr, smackPal->getNearestIndex(RGB(255, 255, 255)));
}
diff --git a/engines/bagel/baglib/dev_dlg.cpp b/engines/bagel/baglib/dev_dlg.cpp
index 7a6d388605d..5b050d60af1 100644
--- a/engines/bagel/baglib/dev_dlg.cpp
+++ b/engines/bagel/baglib/dev_dlg.cpp
@@ -63,9 +63,7 @@ ErrorCode CDevDlg::create(const char *bmp, CBofWindow *wnd, CBofPalette *pal, CB
}
_guessText = new CBofText();
- if (_guessText != nullptr) {
- _guessText->setupText(rect, JUSTIFY_LEFT);
- }
+ _guessText->setupText(rect, JUSTIFY_LEFT);
_guessCount = 0;
Common::fill(_achGuess, _achGuess + ACH_GUESS_MAX_CHARS, 0);
@@ -78,21 +76,15 @@ ErrorCode CDevDlg::create(const char *bmp, CBofWindow *wnd, CBofPalette *pal, CB
// Fall back to original dialog on failure
if (bitmap == nullptr) {
bitmap = new CBofBitmap(200, 100, pal);
- if (bitmap != nullptr) {
- assert(pal != nullptr);
-
- bitmap->fillRect(nullptr, pal->getNearestIndex(RGB(92, 92, 92)));
+ assert(pal != nullptr);
- CBofRect bmpRect(bitmap->getRect());
- bitmap->drawRect(&bmpRect, pal->getNearestIndex(RGB(0, 0, 0)));
- bitmap->fillRect(rect, pal->getNearestIndex(RGB(255, 255, 255)));
+ bitmap->fillRect(nullptr, pal->getNearestIndex(RGB(92, 92, 92)));
- } else {
- reportError(ERR_MEMORY, "Unable to allocate a CBofBitmap");
- }
+ CBofRect bmpRect(bitmap->getRect());
+ bitmap->drawRect(&bmpRect, pal->getNearestIndex(RGB(0, 0, 0)));
+ bitmap->fillRect(rect, pal->getNearestIndex(RGB(255, 255, 255)));
}
- assert(bitmap != nullptr);
CBofRect bmpRect(bitmap->getRect());
CBofString className = "CDevDlg";
CBagStorageDevDlg::create(className, &bmpRect, wnd, 0);
@@ -189,10 +181,6 @@ void CDevDlg::setText(CBofString &text, CBofRect *textRect) {
assert(isValidObject(this));
_titleText = new CBofText;
-
- if (_titleText == nullptr)
- fatalError(ERR_MEMORY, "Unable to instantiate a new CBofText");
-
_titleText->setupText(textRect, JUSTIFY_CENTER, FORMAT_DEFAULT);
_titleText->setColor(CTEXT_WHITE);
_titleText->SetSize(FONT_14POINT);
diff --git a/engines/bagel/baglib/expression_object.cpp b/engines/bagel/baglib/expression_object.cpp
index 72aead0de45..cbd58f78b7b 100644
--- a/engines/bagel/baglib/expression_object.cpp
+++ b/engines/bagel/baglib/expression_object.cpp
@@ -78,15 +78,11 @@ ParseCodes CBagExpressionObject::setInfo(CBagIfstream &istr) {
//
// AS - n number of slides in sprite
//
- case '(': {
+ case '(':
_expression = new CBagExpression();
- if (_expression) {
- _expression->setInfo(istr);
- objectUpdatedFl = true;
- } else {
- // there was an error
- }
- } break;
+ _expression->setInfo(istr);
+ objectUpdatedFl = true;
+ break;
//
// No match return from function
//
diff --git a/engines/bagel/baglib/help.cpp b/engines/bagel/baglib/help.cpp
index a113b1e9850..2c15644dd6c 100644
--- a/engines/bagel/baglib/help.cpp
+++ b/engines/bagel/baglib/help.cpp
@@ -85,76 +85,55 @@ ErrorCode CBagHelp::attach() {
CBofApp::getApp()->setPalette(backPal);
_okButton = new CBofBmpButton;
- if (_okButton != nullptr) {
- CBofBitmap *upBmp = loadBitmap(buildHelpDir(HELP_OK_UP), backPal);
- CBofBitmap *downBmp = loadBitmap(buildHelpDir(HELP_OK_DOWN), backPal);
- CBofBitmap *focusBmp = loadBitmap(buildHelpDir(HELP_OK_FOCUS), backPal);
- CBofBitmap *disableBmp = loadBitmap(buildHelpDir(HELP_OK_DISABLED), backPal);
+ CBofBitmap *upBmp = loadBitmap(buildHelpDir(HELP_OK_UP), backPal);
+ CBofBitmap *downBmp = loadBitmap(buildHelpDir(HELP_OK_DOWN), backPal);
+ CBofBitmap *focusBmp = loadBitmap(buildHelpDir(HELP_OK_FOCUS), backPal);
+ CBofBitmap *disableBmp = loadBitmap(buildHelpDir(HELP_OK_DISABLED), backPal);
- _okButton->loadBitmaps(upBmp, downBmp, focusBmp, disableBmp);
-
- _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, "Unable to allocate a CBofBmpButton");
- }
+ _okButton->loadBitmaps(upBmp, downBmp, focusBmp, disableBmp);
+ _okButton->create("OK", HELP_OK_X, HELP_OK_Y, HELP_OK_CX, HELP_OK_CY, this, HELP_OK_ID);
+ _okButton->show();
_pageUp = new CBofBmpButton;
- if (_pageUp != nullptr) {
- CBofBitmap *upBmp = loadBitmap(buildHelpDir(HELP_PAGE_UP_UP), backPal);
- CBofBitmap *downBmp = loadBitmap(buildHelpDir(HELP_PAGE_UP_DOWN), backPal);
- CBofBitmap *focusBmp = loadBitmap(buildHelpDir(HELP_PAGE_UP_FOCUS), backPal);
- CBofBitmap *disableBmp = loadBitmap(buildHelpDir(HELP_PAGE_UP_DISABLED), backPal);
+ upBmp = loadBitmap(buildHelpDir(HELP_PAGE_UP_UP), backPal);
+ downBmp = loadBitmap(buildHelpDir(HELP_PAGE_UP_DOWN), backPal);
+ focusBmp = loadBitmap(buildHelpDir(HELP_PAGE_UP_FOCUS), backPal);
+ disableBmp = loadBitmap(buildHelpDir(HELP_PAGE_UP_DISABLED), backPal);
- _pageUp->loadBitmaps(upBmp, downBmp, focusBmp, disableBmp);
-
- _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, "Unable to allocate a CBofBmpButton");
- }
+ _pageUp->loadBitmaps(upBmp, downBmp, focusBmp, disableBmp);
+ _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();
_pageDown = new CBofBmpButton;
- if (_pageDown != nullptr) {
- CBofBitmap *upBmp = loadBitmap(buildHelpDir(HELP_PAGE_DOWN_UP), backPal);
- CBofBitmap *downBmp = loadBitmap(buildHelpDir(HELP_PAGE_DOWN_DOWN), backPal);
- CBofBitmap *focusBmp = loadBitmap(buildHelpDir(HELP_PAGE_DOWN_FOCUS), backPal);
- CBofBitmap *disableBmp = loadBitmap(buildHelpDir(HELP_PAGE_DOWN_DISABLED), backPal);
+ upBmp = loadBitmap(buildHelpDir(HELP_PAGE_DOWN_UP), backPal);
+ downBmp = loadBitmap(buildHelpDir(HELP_PAGE_DOWN_DOWN), backPal);
+ focusBmp = loadBitmap(buildHelpDir(HELP_PAGE_DOWN_FOCUS), backPal);
+ disableBmp = loadBitmap(buildHelpDir(HELP_PAGE_DOWN_DISABLED), backPal);
- _pageDown->loadBitmaps(upBmp, downBmp, focusBmp, disableBmp);
+ _pageDown->loadBitmaps(upBmp, downBmp, focusBmp, disableBmp);
- _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, "Unable to allocate a CBofBmpButton");
- }
+ _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();
CBofFile file(_textFile, CBF_BINARY | CBF_READONLY);
uint32 size = file.getLength();
char *buffer = (char *)bofCAlloc(size + 1, 1);
- if (buffer != nullptr) {
- file.read(buffer, size);
+ if (buffer == nullptr)
+ fatalError(ERR_MEMORY, "Unable to allocate %d bytes to read %s.", size, _textFile.getBuffer());
- CBofRect cRect;
- cRect.setRect(120, 100, 550, 348);
+ file.read(buffer, size);
- _textBox = new CBofTextBox(this, &cRect, buffer);
- if (_textBox != nullptr) {
- _textBox->setPageLength(18);
-
- } else {
- reportError(ERR_MEMORY, "Unable to allocate a CBofTextBox");
- }
+ CBofRect cRect;
+ cRect.setRect(120, 100, 550, 348);
- bofFree(buffer);
+ _textBox = new CBofTextBox(this, &cRect, buffer);
+ _textBox->setPageLength(18);
- } else {
- reportError(ERR_MEMORY, "Unable to allocate %d bytes to read %s.", size, _textFile.getBuffer());
- }
+ bofFree(buffer);
CBagCursor::showSystemCursor();
Commit: c26b99ae9d59868b4b19bd29f43a3d1450d73fd3
https://github.com/scummvm/scummvm/commit/c26b99ae9d59868b4b19bd29f43a3d1450d73fd3
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-19T13:12:56+01:00
Commit Message:
BAGEL: More work on null checks after new
Changed paths:
engines/bagel/baglib/master_win.cpp
engines/bagel/baglib/menu_dlg.cpp
engines/bagel/baglib/moo.cpp
engines/bagel/baglib/movie_object.cpp
engines/bagel/baglib/object.cpp
engines/bagel/baglib/pan_window.cpp
diff --git a/engines/bagel/baglib/master_win.cpp b/engines/bagel/baglib/master_win.cpp
index c60ec1e3401..80f70942d66 100644
--- a/engines/bagel/baglib/master_win.cpp
+++ b/engines/bagel/baglib/master_win.cpp
@@ -563,64 +563,61 @@ ErrorCode CBagMasterWin::loadGlobalVars(const CBofString &wldName) {
delete _variableList;
_variableList = new CBagVarManager();
- if (_variableList != nullptr) {
-
- fixPathName(wldFileName);
+ fixPathName(wldFileName);
- if (fileExists(wldFileName) && (fileLength(wldFileName) > 0)) {
- // Force buffer to be big enough so that the entire script
- // is pre-loaded
- int length = fileLength(wldFileName);
- char *buffer = (char *)bofAlloc(length);
- if (buffer != nullptr) {
- CBagIfstream fpInput(buffer, length);
+ if (fileExists(wldFileName) && (fileLength(wldFileName) > 0)) {
+ // Force buffer to be big enough so that the entire script
+ // is pre-loaded
+ int length = fileLength(wldFileName);
+ char *buffer = (char *)bofAlloc(length);
+ if (buffer != nullptr) {
+ CBagIfstream fpInput(buffer, length);
- CBofFile file;
- file.open(wldFileName);
- file.read(buffer, length);
- file.close();
+ CBofFile file;
+ file.open(wldFileName);
+ file.read(buffer, length);
+ file.close();
- while (!fpInput.eof()) {
- fpInput.eatWhite();
+ while (!fpInput.eof()) {
+ fpInput.eatWhite();
- if (!fpInput.eatWhite()) {
- break;
- }
-
- KEYWORDS keyword;
- getKeywordFromStream(fpInput, keyword);
+ if (!fpInput.eatWhite()) {
+ break;
+ }
- switch (keyword) {
- case VARIABLE: {
- CBagVar *var = new CBagVar;
- fpInput.eatWhite();
- var->setInfo(fpInput);
- var->setGlobal();
- break;
- }
+ KEYWORDS keyword;
+ getKeywordFromStream(fpInput, keyword);
- case REMARK: {
- char dummyStr[256];
- fpInput.getCh(dummyStr, 255);
- break;
- }
+ switch (keyword) {
+ case VARIABLE: {
+ CBagVar *var = new CBagVar;
+ fpInput.eatWhite();
+ var->setInfo(fpInput);
+ var->setGlobal();
+ break;
+ }
- case STORAGEDEV:
- case START_WLD:
- case SYSSCREEN:
- case DISKID:
- case DISKAUDIO:
- case SHAREDPAL:
- case PDASTATE:
- default: {
- parseAlertBox(fpInput, "Syntax Error: Unexpected Type in Global Var Wld:", __FILE__, __LINE__);
- break;
- }
- }
+ case REMARK: {
+ char dummyStr[256];
+ fpInput.getCh(dummyStr, 255);
+ break;
}
- bofFree(buffer);
+ case STORAGEDEV:
+ case START_WLD:
+ case SYSSCREEN:
+ case DISKID:
+ case DISKAUDIO:
+ case SHAREDPAL:
+ case PDASTATE:
+ default: {
+ parseAlertBox(fpInput, "Syntax Error: Unexpected Type in Global Var Wld:", __FILE__, __LINE__);
+ break;
+ }
+ }
}
+
+ bofFree(buffer);
}
}
@@ -791,9 +788,6 @@ ErrorCode CBagMasterWin::loadFileFromStream(CBagIfstream &input, const CBofStrin
}
CBagCursor *cursor = new CBagCursor(str, bUseShared);
- if (cursor == nullptr)
- fatalError(ERR_MEMORY, "Could not allocate a CBagCursor");
-
cursor->setHotspot(x, y);
assert(id >= 0 && id < MAX_CURSORS);
@@ -909,7 +903,6 @@ ErrorCode CBagMasterWin::loadFileFromStream(CBagIfstream &input, const CBofStrin
case VARIABLE: {
CBagVar *var = new CBagVar;
- // logInfo("New global variable");
input.eatWhite();
var->setInfo(input);
break;
diff --git a/engines/bagel/baglib/menu_dlg.cpp b/engines/bagel/baglib/menu_dlg.cpp
index a2f505de5c7..f4d2e0cb40c 100644
--- a/engines/bagel/baglib/menu_dlg.cpp
+++ b/engines/bagel/baglib/menu_dlg.cpp
@@ -591,13 +591,12 @@ ErrorCode CBagMenuDlg::create(CBofWindow *pWnd, CBofPalette *pPal, const CBofRec
CBagStorageDevDlg::create("Menu", &r, pWnd, 0);
CBofBitmap *pBmp = new CBofBitmap(r.width(), r.height(), pPal);
- if (pBmp != nullptr) {
- r.offsetRect(-r.left, -r.top);
- assert(pPal != nullptr);
- pBmp->fillRect(&r, pPal->getNearestIndex(RGB(82, 82, 82)));
- pBmp->drawRect(&r, pPal->getNearestIndex(RGB(0, 0, 0)));
- setBackdrop(pBmp);
- }
+
+ r.offsetRect(-r.left, -r.top);
+ assert(pPal != nullptr);
+ pBmp->fillRect(&r, pPal->getNearestIndex(RGB(82, 82, 82)));
+ pBmp->drawRect(&r, pPal->getNearestIndex(RGB(0, 0, 0)));
+ setBackdrop(pBmp);
return _errCode;
}
diff --git a/engines/bagel/baglib/moo.cpp b/engines/bagel/baglib/moo.cpp
index 4f3c2b1d095..d822c2dcea7 100644
--- a/engines/bagel/baglib/moo.cpp
+++ b/engines/bagel/baglib/moo.cpp
@@ -69,17 +69,14 @@ ErrorCode CBagMoo::setPDAMovie(CBofString &s) {
// Get a new movie object
_pMovie = new CBagCharacterObject();
- assert(_pMovie != nullptr);
- if (_pMovie) {
- _pMovie->setFileName(s);
+ _pMovie->setFileName(s);
- // Attach this bad baby...
- errorCode = _pMovie->attach();
- if (errorCode == ERR_NONE) {
- _pMovie->setModal(false);
- _pMovie->setNumOfLoops(1);
- }
+ // Attach this bad baby...
+ errorCode = _pMovie->attach();
+ if (errorCode == ERR_NONE) {
+ _pMovie->setModal(false);
+ _pMovie->setNumOfLoops(1);
}
return errorCode;
diff --git a/engines/bagel/baglib/movie_object.cpp b/engines/bagel/baglib/movie_object.cpp
index 832ce8a5ed9..ef1f3c19665 100644
--- a/engines/bagel/baglib/movie_object.cpp
+++ b/engines/bagel/baglib/movie_object.cpp
@@ -76,7 +76,7 @@ bool CBagMovieObject::runObject() {
CBofWindow *pNewWin = nullptr;
SBZoomPda *pPDAz = (SBZoomPda *)g_SDevManager->getStorageDevice("BPDAZ_WLD");
bool bZoomed = (pPDAz == nullptr ? false : pPDAz->getZoomed());
-
+
// Get a pointer to the current game window
CBagStorageDevWnd *pMainWin = CBagel::getBagApp()->getMasterWnd()->getCurrentStorageDev();
@@ -176,27 +176,25 @@ bool CBagMovieObject::runObject() {
// on the mac (prevents a palette shift).
CBagExam *pMovie = new CBagExam(CBagel::getBagApp()->getMasterWnd()->getCurrentGameWindow(), sFileName, &r);
- if (pMovie) {
- // If there is an associated sound file, then start it up here.
- CBagSoundObject *pSObj = getAssociatedSound();
- if (pSObj) {
- if (pSObj->isAttached() == false) {
- pSObj->attach();
- }
- pSObj->runObject();
+ // If there is an associated sound file, then start it up here.
+ CBagSoundObject *pSObj = getAssociatedSound();
+ if (pSObj) {
+ if (pSObj->isAttached() == false) {
+ pSObj->attach();
}
+ pSObj->runObject();
+ }
- CBofWindow *wnd = CBagel::getBagApp()->getMasterWnd();
- pMovie->show();
- CBofApp::getApp()->getMainWindow()->flushAllMessages();
- wnd->flushAllMessages();
- pMovie->initExam();
- delete pMovie;
+ CBofWindow *wnd = CBagel::getBagApp()->getMasterWnd();
+ pMovie->show();
+ CBofApp::getApp()->getMainWindow()->flushAllMessages();
+ wnd->flushAllMessages();
+ pMovie->initExam();
+ delete pMovie;
- // As soon as we're done, detach (this will also stop the sound).
- if (pSObj) {
- pSObj->detach();
- }
+ // As soon as we're done, detach (this will also stop the sound).
+ if (pSObj) {
+ pSObj->detach();
}
} else {
bool bActivated = false;
@@ -247,15 +245,13 @@ bool CBagMovieObject::runObject() {
if (isFiltered) {
if (bZoomed) {
pNewWin = new CBofWindow();
- if (pNewWin) {
- pNewWin->create("BLACK", 0, 0, 640, 480, CBofApp::getApp()->getMainWindow(), 0);
- pNewWin->fillWindow(COLOR_BLACK);
- }
+ pNewWin->create("BLACK", 0, 0, 640, 480, CBofApp::getApp()->getMainWindow(), 0);
+ pNewWin->fillWindow(COLOR_BLACK);
}
CBagFMovie *pMovie = new CBagFMovie(CBofApp::getApp()->getMainWindow(), sFileName, &r);
- if (pMovie != nullptr && pMovie->errorOccurred() == false) {
+ if (pMovie->errorOccurred() == false) {
pMovie->show();
CBofApp::getApp()->getMainWindow()->flushAllMessages();
pWnd->flushAllMessages();
@@ -265,10 +261,8 @@ bool CBagMovieObject::runObject() {
logError(buildString("Movie file could not be read: %s. How? You removed that CD again didn't you", sFileName.getBuffer()));
}
- if (pNewWin) {
- delete pNewWin;
- pNewWin = nullptr;
- }
+ delete pNewWin;
+ pNewWin = nullptr;
} else {
// Hack.. allow script to override some other movies.
if ((_xDisplayType == dispType::PDA_MSG) && pMainWin->isCIC() && isDontOverride() == false) {
@@ -297,11 +291,9 @@ bool CBagMovieObject::runObject() {
if (bZoomed && _xDisplayType != dispType::ASYNCH_PDA_MSG && _xDisplayType != dispType::PDA_MSG) {
pNewWin = new CBofWindow();
- if (pNewWin) {
- pNewWin->create("BLACK", 0, 0, 640, 480, CBofApp::getApp()->getMainWindow(), 0);
- pNewWin->show();
- pNewWin->fillWindow(COLOR_BLACK);
- }
+ pNewWin->create("BLACK", 0, 0, 640, 480, CBofApp::getApp()->getMainWindow(), 0);
+ pNewWin->show();
+ pNewWin->fillWindow(COLOR_BLACK);
}
// If playing a PDA message while the PDA is zoomed
@@ -356,12 +348,8 @@ bool CBagMovieObject::runObject() {
} else if (nMovFileType == MovieFileType::SOUND) {
CBofSound *pSound = new CBofSound(CBofApp::getApp()->getMainWindow(), sFileName, SOUND_WAVE);
- if (pSound) {
- pSound->play();
- delete pSound;
- } else {
- logError(buildString("Movie SOUND file could not be read: %s. Where? Not in Kansas ...", sFileName.getBuffer()));
- }
+ pSound->play();
+ delete pSound;
} else if (nMovFileType == MovieFileType::TEXT) {
Common::File f;
if (f.open(sFileName.getBuffer())) {
@@ -480,7 +468,7 @@ ParseCodes CBagMovieObject::setInfo(CBagIfstream &istr) {
nObjectUpdated = true;
_pSndObj = new CBagSoundObject();
- if (_pSndObj && _pSndObj->setInfo(istr) == PARSING_DONE) {
+ if (_pSndObj->setInfo(istr) == PARSING_DONE) {
return PARSING_DONE;
}
} else {
diff --git a/engines/bagel/baglib/object.cpp b/engines/bagel/baglib/object.cpp
index 12baae72f09..17a77e608f6 100644
--- a/engines/bagel/baglib/object.cpp
+++ b/engines/bagel/baglib/object.cpp
@@ -187,8 +187,6 @@ ParseCodes CBagObject::setInfo(CBagIfstream &istr) {
parseCode = UPDATED_OBJECT;
if (!_pMenu) {
_pMenu = new CBagMenu;
- if (_pMenu == nullptr)
- fatalError(ERR_MEMORY, "Unable to allocate a new CBagMenu");
// Try to cut down the number of Storage Devices by
// removing these unused ones from the list.
diff --git a/engines/bagel/baglib/pan_window.cpp b/engines/bagel/baglib/pan_window.cpp
index 191f583fb57..4558d9dcc8e 100644
--- a/engines/bagel/baglib/pan_window.cpp
+++ b/engines/bagel/baglib/pan_window.cpp
@@ -114,7 +114,7 @@ CBofPalette *CBagPanWindow::setSlideBitmap(const CBofString &xSlideBmp, const CB
_pSlideBitmap = new CBagPanBitmap(xSlideBmp, nullptr, viewRect);
// Make sure the file was found
- if (_pSlideBitmap == nullptr || !_pSlideBitmap->isValid()) {
+ if (!_pSlideBitmap->isValid()) {
_pPalette = nullptr;
reportError(ERR_FOPEN, "Unable to open file %s", xSlideBmp.getBuffer());
} else {
@@ -130,11 +130,11 @@ CBofPalette *CBagPanWindow::setSlideBitmap(const CBofString &xSlideBmp, const CB
_pSlideBitmap->setCorrWidth(_nCorrection);
CBofBitmap *pBackDropBitmap = new CBofBitmap(DEF_WIDTH + 1, DEF_HEIGHT + 1, _pPalette);
- if (!pBackDropBitmap || pBackDropBitmap->height() <= 0 || pBackDropBitmap->width() <= 0) {
+ if (pBackDropBitmap->height() <= 0 || pBackDropBitmap->width() <= 0) {
reportError(ERR_FOPEN, "Error opening bitmap");
}
_pViewPortBitmap = new CBofBitmap(DEF_WIDTH + 1, _pSlideBitmap->height() + 1, _pPalette);
- if (!_pViewPortBitmap || !_pViewPortBitmap->height() || !_pViewPortBitmap->width()) {
+ if (!_pViewPortBitmap->height() || !_pViewPortBitmap->width()) {
reportError(ERR_FOPEN, "Error opening bitmap");
}
setBackdrop(pBackDropBitmap);
More information about the Scummvm-git-logs
mailing list