[Scummvm-git-logs] scummvm master -> a23461e33f706250759f4bc9b6bc52ccbf8a4f5b
Strangerke
noreply at scummvm.org
Mon May 13 21:28:04 UTC 2024
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
a23461e33f BAGEL: More work on fatal errors
Commit: a23461e33f706250759f4bc9b6bc52ccbf8a4f5b
https://github.com/scummvm/scummvm/commit/a23461e33f706250759f4bc9b6bc52ccbf8a4f5b
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-13T22:27:50+01:00
Commit Message:
BAGEL: More work on fatal errors
Changed paths:
engines/bagel/dialogs/save_dialog.cpp
engines/bagel/dialogs/start_dialog.cpp
engines/bagel/spacebar/bibble_window.cpp
diff --git a/engines/bagel/dialogs/save_dialog.cpp b/engines/bagel/dialogs/save_dialog.cpp
index 99346b0ad1d..e935052784c 100644
--- a/engines/bagel/dialogs/save_dialog.cpp
+++ b/engines/bagel/dialogs/save_dialog.cpp
@@ -119,26 +119,24 @@ ErrorCode CBagSaveDialog::attach() {
assert(_pButtons[i] == nullptr);
_pButtons[i] = new CBofBmpButton;
- if (_pButtons[i] != nullptr) {
- CBofBitmap *pUp = loadBitmap(buildSysDir(g_stButtons[i]._up), pPal);
- CBofBitmap *pDown = loadBitmap(buildSysDir(g_stButtons[i]._down), pPal);
- CBofBitmap *pFocus = loadBitmap(buildSysDir(g_stButtons[i]._focus), pPal);
- CBofBitmap *pDis = loadBitmap(buildSysDir(g_stButtons[i]._disabled), pPal);
-
- _pButtons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
-
- _pButtons[i]->create(g_stButtons[i]._name, g_stButtons[i]._left, g_stButtons[i]._top, g_stButtons[i]._width, g_stButtons[i]._height, this, g_stButtons[i]._id);
- _pButtons[i]->show();
- } else {
- reportError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
- break;
- }
+ 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);
+ CBofBitmap *pFocus = loadBitmap(buildSysDir(g_stButtons[i]._focus), pPal);
+ CBofBitmap *pDis = loadBitmap(buildSysDir(g_stButtons[i]._disabled), pPal);
+
+ _pButtons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
+ _pButtons[i]->create(g_stButtons[i]._name, g_stButtons[i]._left, g_stButtons[i]._top, g_stButtons[i]._width, g_stButtons[i]._height, this, g_stButtons[i]._id);
+ _pButtons[i]->show();
}
// The edit text control must not be currently allocated
assert(_pEditText == nullptr);
- if ((_pEditText = new CBofEditText("", EDIT_X, EDIT_Y, EDIT_DX, EDIT_DY, this)) != nullptr) {
+ _pEditText = new CBofEditText("", EDIT_X, EDIT_Y, EDIT_DX, EDIT_DY, this);
+ if (_pEditText != nullptr) {
_pEditText->setText("");
_pEditText->show();
}
@@ -158,50 +156,47 @@ ErrorCode CBagSaveDialog::attach() {
// Create a list box for the user to choose the slot to save into
_pListBox = new CBofListBox();
- if (_pListBox != nullptr) {
- CBofRect cRect(LIST_X, LIST_Y, LIST_X + LIST_DX - 1, LIST_Y + LIST_DY - 1);
+ if (_pListBox == nullptr)
+ fatalError(ERR_MEMORY, "Unable to allocate a CBofListBox");
- _pListBox->create("SaveGameList", &cRect, this);
+ CBofRect cRect(LIST_X, LIST_Y, LIST_X + LIST_DX - 1, LIST_Y + LIST_DY - 1);
- _pListBox->setPointSize(LIST_FONT_SIZE);
- _pListBox->setItemHeight(LIST_TEXT_DY);
+ _pListBox->create("SaveGameList", &cRect, this);
+ _pListBox->setPointSize(LIST_FONT_SIZE);
+ _pListBox->setItemHeight(LIST_TEXT_DY);
- // Set a color for selection highlighting
- if (_pBackdrop != nullptr) {
- CBofPalette *pPal2 = _pBackdrop->getPalette();
- byte iPalIdx = pPal2->getNearestIndex(RGB(255, 0, 0));
+ // Set a color for selection highlighting
+ if (_pBackdrop != nullptr) {
+ CBofPalette *pPal2 = _pBackdrop->getPalette();
+ byte iPalIdx = pPal2->getNearestIndex(RGB(255, 0, 0));
- _pListBox->setHighlightColor(pPal2->getColor(iPalIdx));
- }
+ _pListBox->setHighlightColor(pPal2->getColor(iPalIdx));
+ }
+
+ // Fill the list box with save game entries
+ for (int i = 0; i < MAX_SAVED_GAMES; i++) {
+ char title[MAX_SAVE_TITLE];
+ Common::strcpy_s(title, "Empty"); // Default empty string
+
+ for (const auto &entry : _savesList) {
+ if (entry.getSaveSlot() == (i + 1)) {
+ Common::String desc = entry.getDescription();
+ Common::strcpy_s(title, desc.c_str());
- // Fill the list box with save game entries
- for (int i = 0; i < MAX_SAVED_GAMES; i++) {
- char title[MAX_SAVE_TITLE];
- Common::strcpy_s(title, "Empty"); // Default empty string
-
- for (const auto &entry : _savesList) {
- if (entry.getSaveSlot() == (i + 1)) {
- Common::String desc = entry.getDescription();
- Common::strcpy_s(title, desc.c_str());
-
- if (_nSelectedItem == -1) {
- _nSelectedItem = i;
- _pEditText->setText(desc.c_str());
- }
- break;
+ if (_nSelectedItem == -1) {
+ _nSelectedItem = i;
+ _pEditText->setText(desc.c_str());
}
+ break;
}
-
- _pListBox->addToTail(title, false);
}
- _pListBox->show();
- _pListBox->updateWindow();
-
- } else {
- reportError(ERR_MEMORY, "Unable to allocate a CBofListBox");
+ _pListBox->addToTail(title, false);
}
+ _pListBox->show();
+ _pListBox->updateWindow();
+
if (_nSelectedItem != -1) {
if (_pEditText != nullptr) {
_pEditText->setFocus();
diff --git a/engines/bagel/dialogs/start_dialog.cpp b/engines/bagel/dialogs/start_dialog.cpp
index 0f6ab85daef..e76d4a71b4c 100644
--- a/engines/bagel/dialogs/start_dialog.cpp
+++ b/engines/bagel/dialogs/start_dialog.cpp
@@ -76,20 +76,18 @@ void CBagStartDialog::onInitDialog() {
for (int i = 0; i < NUM_START_BTNS; i++) {
assert(_buttons[i] == nullptr);
- if ((_buttons[i] = new CBofBmpButton) != nullptr) {
- CBofBitmap *pUp = loadBitmap(buildSysDir(g_stStartButtons[i]._pszUp), pPal);
- CBofBitmap *pDown = loadBitmap(buildSysDir(g_stStartButtons[i]._pszDown), pPal);
- CBofBitmap *pFocus = loadBitmap(buildSysDir(g_stStartButtons[i]._pszFocus), pPal);
- CBofBitmap *pDis = loadBitmap(buildSysDir(g_stStartButtons[i]._pszDisabled), pPal);
-
- _buttons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
- _buttons[i]->create(g_stStartButtons[i]._pszName, g_stStartButtons[i]._nLeft, g_stStartButtons[i]._nTop, g_stStartButtons[i]._nWidth, g_stStartButtons[i]._nHeight, this, g_stStartButtons[i]._nID);
- _buttons[i]->show();
-
- } else {
- reportError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
- break;
- }
+ _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);
+ CBofBitmap *pFocus = loadBitmap(buildSysDir(g_stStartButtons[i]._pszFocus), pPal);
+ CBofBitmap *pDis = loadBitmap(buildSysDir(g_stStartButtons[i]._pszDisabled), pPal);
+
+ _buttons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
+ _buttons[i]->create(g_stStartButtons[i]._pszName, g_stStartButtons[i]._nLeft, g_stStartButtons[i]._nTop, g_stStartButtons[i]._nWidth, g_stStartButtons[i]._nHeight, this, g_stStartButtons[i]._nID);
+ _buttons[i]->show();
}
// Disable the restore button if there are no saved games
@@ -109,10 +107,8 @@ void CBagStartDialog::onClose() {
// Destroy all buttons
for (int i = 0; i < NUM_START_BTNS; i++) {
- if (_buttons[i] != nullptr) {
- delete _buttons[i];
- _buttons[i] = nullptr;
- }
+ delete _buttons[i];
+ _buttons[i] = nullptr;
}
killBackground();
@@ -125,7 +121,6 @@ void CBagStartDialog::onPaint(CBofRect *pRect) {
assert(isValidObject(this));
paintBackdrop(pRect);
-
validateAnscestors();
}
diff --git a/engines/bagel/spacebar/bibble_window.cpp b/engines/bagel/spacebar/bibble_window.cpp
index 4913591c481..7d4524fa329 100644
--- a/engines/bagel/spacebar/bibble_window.cpp
+++ b/engines/bagel/spacebar/bibble_window.cpp
@@ -283,7 +283,6 @@ ErrorCode CBibbleWindow::attach() {
// The sprite object start in the script at 500
CBagObject *pObj = pSDev->getObject(500 + i);
if (pObj != nullptr) {
-
int nPayOff = pObj->getState();
g_engine->g_cBetAreas[i]._nPayOff1 = PAY_OFFS[nPayOff]._nPay1;
g_engine->g_cBetAreas[i]._nPayOff2 = PAY_OFFS[nPayOff]._nPay2;
@@ -298,125 +297,105 @@ ErrorCode CBibbleWindow::attach() {
// Setup the text fields
_pCreditsText = new CBofText;
- if (_pCreditsText != nullptr) {
- CBofRect cRect(CREDITS_AREA_X1, CREDITS_AREA_Y1, CREDITS_AREA_X2, CREDITS_AREA_Y2);
+ if (_pCreditsText == nullptr)
+ fatalError(ERR_MEMORY, "Unable to allocate a CBofText");
- _pCreditsText->setupText(&cRect, JUSTIFY_RIGHT, FORMAT_CENTER_RIGHT);
- _pCreditsText->setColor(CTEXT_WHITE);
+ CBofRect cRect(CREDITS_AREA_X1, CREDITS_AREA_Y1, CREDITS_AREA_X2, CREDITS_AREA_Y2);
- _pCreditsText->SetSize(mapWindowsPointSize(20));
- _pCreditsText->setWeight(TEXT_BOLD);
- _pCreditsText->setText(buildString("%d", _nNumCredits));
- } else {
- reportError(ERR_MEMORY, "Unable to allocate a CBofText");
- }
+ _pCreditsText->setupText(&cRect, JUSTIFY_RIGHT, FORMAT_CENTER_RIGHT);
+ _pCreditsText->setColor(CTEXT_WHITE);
+ _pCreditsText->SetSize(mapWindowsPointSize(20));
+ _pCreditsText->setWeight(TEXT_BOLD);
+ _pCreditsText->setText(buildString("%d", _nNumCredits));
// 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) {
- reportError(ERR_MEMORY, "Unable to allocate a CBofSound");
- break;
- }
+ if (_pShouts[i] == nullptr)
+ fatalError(ERR_MEMORY, "Unable to allocate a CBofSound");
}
// Pre-load the ball
_pBall = new CBofSprite;
- if (_pBall != nullptr) {
- _pBall->loadSprite(BuildDir(BALL_BMP), BALL_CELS);
- _pBall->setMaskColor(MASK_COLOR);
- _pBall->setZOrder(SPRITE_HINDMOST);
- _pBall->setAnimated(true);
- _pBall->linkSprite();
-
- } else {
- reportError(ERR_MEMORY, "Unable to allocate a CBofSprite");
- }
+ if (_pBall == nullptr)
+ fatalError(ERR_MEMORY, "Unable to allocate a CBofSprite");
+
+ _pBall->loadSprite(BuildDir(BALL_BMP), BALL_CELS);
+ _pBall->setMaskColor(MASK_COLOR);
+ _pBall->setZOrder(SPRITE_HINDMOST);
+ _pBall->setAnimated(true);
+ _pBall->linkSprite();
// Pre-load the bibbles
_pMasterBibble = new CBofSprite;
- if (_pMasterBibble != nullptr) {
- _pMasterBibble->loadSprite(BuildDir(BIBBLE_BMP), BIBBLE_CELS);
- _pMasterBibble->setMaskColor(MASK_COLOR);
- _pMasterBibble->setZOrder(SPRITE_TOPMOST);
- _pMasterBibble->setAnimated(false);
-
- } else {
- reportError(ERR_MEMORY, "Unable to allocate a 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);
+ _pMasterBibble->setAnimated(false);
// Dup the bibbles
for (int i = 0; i < BIBBLE_NUM_BIBBLES; i++) {
_pBibble[i] = _pMasterBibble->duplicateSprite();
- if (_pBibble[i] != nullptr) {
- _pBibble[i]->setPosition(nBibbleXPos[i], nBibbleYPos[i]);
- _pBibble[i]->linkSprite();
+ if (_pBibble[i] == nullptr)
+ fatalError(ERR_MEMORY, "Unable to duplicate a CBofSprite");
- } else {
- reportError(ERR_MEMORY, "Unable to duplicate a CBofSprite");
- }
+ _pBibble[i]->setPosition(nBibbleXPos[i], nBibbleYPos[i]);
+ _pBibble[i]->linkSprite();
}
// Load the arch bitmaps that the ball needs to go behind
_pArch1 = new CBofSprite;
- if (_pArch1 != nullptr) {
- _pArch1->loadSprite(BuildDir(ARCH1_BMP));
- _pArch1->setMaskColor(MASK_COLOR);
- _pArch1->setZOrder(SPRITE_MIDDLE);
- _pArch1->linkSprite();
- } else {
- reportError(ERR_MEMORY, "Unable to allocate a 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) {
- _pArch2->loadSprite(BuildDir(ARCH2_BMP));
- _pArch2->setMaskColor(MASK_COLOR);
- _pArch2->setZOrder(SPRITE_MIDDLE);
- _pArch2->linkSprite();
-
- } else {
- reportError(ERR_MEMORY, "Unable to allocate a 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) {
- _pArch3->loadSprite(BuildDir(ARCH3_BMP));
- _pArch3->setMaskColor(MASK_COLOR);
- _pArch3->setZOrder(SPRITE_MIDDLE);
- _pArch3->linkSprite();
-
- } else {
- reportError(ERR_MEMORY, "Unable to allocate a 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) {
-
- CBofBitmap *pUp = loadBitmap(BuildDir(g_stButtons[i]._pszUp), pPal);
- CBofBitmap *pDown = loadBitmap(BuildDir(g_stButtons[i]._pszDown), pPal);
- CBofBitmap *pFocus = loadBitmap(BuildDir(g_stButtons[i]._pszFocus), pPal);
- CBofBitmap *pDis = loadBitmap(BuildDir(g_stButtons[i]._pszDisabled), pPal);
+ if (_pButtons[i] == nullptr)
+ fatalError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
- _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);
- _pButtons[i]->show();
+ CBofBitmap *pUp = loadBitmap(BuildDir(g_stButtons[i]._pszUp), pPal);
+ CBofBitmap *pDown = loadBitmap(BuildDir(g_stButtons[i]._pszDown), pPal);
+ CBofBitmap *pFocus = loadBitmap(BuildDir(g_stButtons[i]._pszFocus), pPal);
+ CBofBitmap *pDis = loadBitmap(BuildDir(g_stButtons[i]._pszDisabled), pPal);
- } else {
- reportError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
- break;
- }
+ _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);
+ _pButtons[i]->show();
}
_pBkgSnd = new CBofSound(this, BuildDir(CASINO_AUDIO), SOUND_MIX, 99999);
- if (_pBkgSnd != nullptr) {
- _pBkgSnd->play();
- } else {
- reportError(ERR_MEMORY, "Unable to allocate a CBofSound");
- }
+ if (_pBkgSnd == nullptr)
+ fatalError(ERR_MEMORY, "Unable to allocate a CBofSound");
+
+ _pBkgSnd->play();
// No bet area currently selected
_pSelected = nullptr;
More information about the Scummvm-git-logs
mailing list