[Scummvm-git-logs] scummvm master -> 79eab5bc788ce0e01c5f3e90da321b40834fc950

Strangerke noreply at scummvm.org
Wed May 15 05:38:42 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:
f4f81baf5e BAGEL: Move constructor of COption to the cpp file, remove a useless define
79eab5bc78 BAGEL: Finish first pass of cleanup of fatal errors


Commit: f4f81baf5e77a6ec389e0b901de35e1e8d68041f
    https://github.com/scummvm/scummvm/commit/f4f81baf5e77a6ec389e0b901de35e1e8d68041f
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-15T06:36:06+01:00

Commit Message:
BAGEL: Move constructor of COption to the cpp file, remove a useless define

Changed paths:
    engines/bagel/boflib/options.cpp
    engines/bagel/boflib/options.h


diff --git a/engines/bagel/boflib/options.cpp b/engines/bagel/boflib/options.cpp
index c6027084618..e1988772b0c 100644
--- a/engines/bagel/boflib/options.cpp
+++ b/engines/bagel/boflib/options.cpp
@@ -28,7 +28,14 @@
 
 namespace Bagel {
 
-#define USE_REGISTRY 1
+COption::COption(const char *pszInit) {
+	_szBuf[0] = '\0';
+
+	if (pszInit != nullptr) {
+		assert(strlen(pszInit) < MAX_OPTION_LEN);
+		Common::strcpy_s(_szBuf, pszInit);
+	}
+}
 
 CBofOptions::CBofOptions(const char *pszOptionFile) {
 	_szFileName[0] = '\0';
diff --git a/engines/bagel/boflib/options.h b/engines/bagel/boflib/options.h
index a6317d3a55e..3ea5b39fe85 100644
--- a/engines/bagel/boflib/options.h
+++ b/engines/bagel/boflib/options.h
@@ -36,14 +36,7 @@ namespace Bagel {
 
 class COption : public CLList, public CBofObject {
 public:
-	COption(const char *pszInit = nullptr) {
-		_szBuf[0] = '\0';
-
-		if (pszInit != nullptr) {
-			assert(strlen(pszInit) < MAX_OPTION_LEN);
-			Common::strcpy_s(_szBuf, pszInit);
-		}
-	}
+	COption(const char *pszInit = nullptr);
 
 	char _szBuf[MAX_OPTION_LEN];
 };


Commit: 79eab5bc788ce0e01c5f3e90da321b40834fc950
    https://github.com/scummvm/scummvm/commit/79eab5bc788ce0e01c5f3e90da321b40834fc950
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-15T06:38:31+01:00

Commit Message:
BAGEL: Finish first pass of cleanup of fatal errors

Changed paths:
    engines/bagel/baglib/master_win.cpp
    engines/bagel/baglib/save_game_file.cpp
    engines/bagel/baglib/sprite_object.cpp


diff --git a/engines/bagel/baglib/master_win.cpp b/engines/bagel/baglib/master_win.cpp
index 0c37b5265dd..2bfb067bf80 100644
--- a/engines/bagel/baglib/master_win.cpp
+++ b/engines/bagel/baglib/master_win.cpp
@@ -373,13 +373,11 @@ ErrorCode CBagMasterWin::loadFile(const CBofString &wldName, const CBofString &s
 			// Only allocate the object list when we really need it...
 			if (_objList == nullptr) {
 				_objList = (StObj *)bofAlloc(MAX_OBJS * sizeof(StObj));
-				if (_objList != nullptr) {
-					// Init to zero (we might not use all slots)
-					memset(_objList, 0, MAX_OBJS * sizeof(StObj));
+				if (_objList == nullptr)
+					fatalError(ERR_MEMORY, "Could not allocate Object list");
 
-				} else {
-					reportError(ERR_MEMORY, "Could not allocate Object list");
-				}
+				// Init to zero (we might not use all slots)
+				memset(_objList, 0, MAX_OBJS * sizeof(StObj));
 			}
 
 			_storageDeviceList->saveObjList(_objList, MAX_OBJS); // xxx
@@ -793,22 +791,20 @@ ErrorCode CBagMasterWin::loadFileFromStream(CBagIfstream &input, const CBofStrin
 				}
 
 				CBagCursor *cursor = new CBagCursor(str, bUseShared);
-				if (cursor != nullptr) {
-					cursor->setHotspot(x, y);
+				if (cursor == nullptr)
+					fatalError(ERR_MEMORY, "Could not allocate a CBagCursor");
 
-					assert(id >= 0 && id < MAX_CURSORS);
+				cursor->setHotspot(x, y);
 
-					// Delete any previous cursor
-					delete _cursorList[id];
-					_cursorList[id] = cursor;
+				assert(id >= 0 && id < MAX_CURSORS);
 
-					// Set the wielded cursor status (needed for
-					// a load time optimization)
-					cursor->setWieldCursor(isWieldCursorFl);
+				// Delete any previous cursor
+				delete _cursorList[id];
+				_cursorList[id] = cursor;
 
-				} else {
-					reportError(ERR_MEMORY, "Could not allocate a CBagCursor");
-				}
+				// Set the wielded cursor status (needed for
+				// a load time optimization)
+				cursor->setWieldCursor(isWieldCursorFl);
 
 			} else {
 				reportError(ERR_UNKNOWN, "Bad cursor syntax");
@@ -1528,40 +1524,39 @@ bool CBagMasterWin::showSaveDialog(CBofWindow *win, bool bSaveBkg) {
 		CBofSound::pauseSounds();
 		StBagelSave *saveBuf = (StBagelSave *)bofAlloc(sizeof(StBagelSave));
 
-		if (saveBuf != nullptr) {
-			fillSaveBuffer(saveBuf);
-			CBagSaveDialog saveDialog;
-			saveDialog.setSaveGameBuffer((byte *)saveBuf, sizeof(StBagelSave));
+		if (saveBuf == nullptr)
+			fatalError(ERR_MEMORY, "Unable to allocate the Save Game Buffer");
 
-			// Use specified bitmap as this dialog's image
-			CBofBitmap *bmp = Bagel::loadBitmap(_sysScreen.getBuffer());
+		fillSaveBuffer(saveBuf);
+		CBagSaveDialog saveDialog;
+		saveDialog.setSaveGameBuffer((byte *)saveBuf, sizeof(StBagelSave));
 
-			saveDialog.setBackdrop(bmp);
+		// Use specified bitmap as this dialog's image
+		CBofBitmap *bmp = Bagel::loadBitmap(_sysScreen.getBuffer());
 
-			CBofRect backRect = saveDialog.getBackdrop()->getRect();
+		saveDialog.setBackdrop(bmp);
 
-			// Don't allow save of background
-			if (!bSaveBkg) {
-				int fllags = saveDialog.getFlags();
-				saveDialog.setFlags(fllags & ~BOFDLG_SAVEBACKGND);
-			}
+		CBofRect backRect = saveDialog.getBackdrop()->getRect();
+
+		// Don't allow save of background
+		if (!bSaveBkg) {
+			int fllags = saveDialog.getFlags();
+			saveDialog.setFlags(fllags & ~BOFDLG_SAVEBACKGND);
+		}
 
-			// Create the dialog box
-			saveDialog.create("Save Dialog", backRect.left, backRect.top, backRect.width(), backRect.height(), win);
+		// Create the dialog box
+		saveDialog.create("Save Dialog", backRect.left, backRect.top, backRect.width(), backRect.height(), win);
 
-			bool saveTimerFl = g_pauseTimerFl;
-			g_pauseTimerFl = true;
-			int btnId = saveDialog.doModal();
-			g_pauseTimerFl = saveTimerFl;
+		bool saveTimerFl = g_pauseTimerFl;
+		g_pauseTimerFl = true;
+		int btnId = saveDialog.doModal();
+		g_pauseTimerFl = saveTimerFl;
 
-			savedFl = (btnId == SAVE_BTN);
+		savedFl = (btnId == SAVE_BTN);
 
-			saveDialog.detach();
+		saveDialog.detach();
 
-			bofFree(saveBuf);
-		} else {
-			reportError(ERR_MEMORY, "Unable to allocate the Save Game Buffer");
-		}
+		bofFree(saveBuf);
 
 		CBofSound::resumeSounds();
 
@@ -1646,13 +1641,11 @@ void CBagMasterWin::doRestore(StBagelSave *saveBuf) {
 			// Restore any extra obj list info (for .WLD swapping)
 			if (_objList == nullptr) {
 				_objList = (StObj *)bofAlloc(MAX_OBJS * sizeof(StObj));
-				if (_objList != nullptr) {
-					// Init to nullptr (might not use all slots)
-					memset(_objList, 0, MAX_OBJS * sizeof(StObj));
+				if (_objList == nullptr)
+					fatalError(ERR_MEMORY, "Unable to allocate a array of %d StObj", MAX_OBJS);
 
-				} else {
-					reportError(ERR_MEMORY, "Unable to allocate a array of %d StObj", MAX_OBJS);
-				}
+				// Init to nullptr (might not use all slots)
+				memset(_objList, 0, MAX_OBJS * sizeof(StObj));
 			}
 
 			memcpy(getObjList(), &saveBuf->_stObjListEx[0], sizeof(StObj) * MAX_OBJS);
diff --git a/engines/bagel/baglib/save_game_file.cpp b/engines/bagel/baglib/save_game_file.cpp
index dbce48aa2d5..80645f358a8 100644
--- a/engines/bagel/baglib/save_game_file.cpp
+++ b/engines/bagel/baglib/save_game_file.cpp
@@ -233,16 +233,14 @@ ErrorCode CBagSaveGameFile::readTitle(int32 lSlot, StSavegameHeader *pSavedGame)
 		int32 lSize = getRecSize(lRecNum);
 
 		byte *pBuf = (byte *)bofAlloc(lSize);
-		if (pBuf != nullptr) {
-			readRecord(lRecNum, pBuf);
+		if (pBuf == nullptr)
+			fatalError(ERR_MEMORY, "Could not allocate %ld bytes to read a saved game title", lSize);
 
-			// Fill StSavegameHeader structure with this game's saved info
-			memcpy(pSavedGame, pBuf, sizeof(StSavegameHeader));
-			bofFree(pBuf);
+		readRecord(lRecNum, pBuf);
 
-		} else {
-			reportError(ERR_MEMORY, "Could not allocate %ld bytes to read a saved game title", lSize);
-		}
+		// Fill StSavegameHeader structure with this game's saved info
+		memcpy(pSavedGame, pBuf, sizeof(StSavegameHeader));
+		bofFree(pBuf);
 
 	} else {
 		reportError(ERR_UNKNOWN, "Unable to find saved game #%ld in %s", lSlot, _szFileName);
diff --git a/engines/bagel/baglib/sprite_object.cpp b/engines/bagel/baglib/sprite_object.cpp
index 85979131f56..3d4eb3e5ede 100644
--- a/engines/bagel/baglib/sprite_object.cpp
+++ b/engines/bagel/baglib/sprite_object.cpp
@@ -53,38 +53,37 @@ ErrorCode CBagSpriteObject::attach() {
 		// Could not already have a sprite
 		assert(_xSprite == nullptr);
 
-		if ((_xSprite = new CBofSprite()) != nullptr) {
-			if (_xSprite->loadSprite(getFileName(), getCels()) != false && (_xSprite->width() != 0) && (_xSprite->height() != 0)) {
-				if (isTransparent()) {
-					int nMaskColor = CBagel::getBagApp()->getChromaColor();
+		_xSprite = new CBofSprite();
+		if (_xSprite == nullptr)
+			fatalError(ERR_MEMORY, "Could not allocate sprite");
 
-					_xSprite->setMaskColor(nMaskColor);
-				}
+		if (_xSprite->loadSprite(getFileName(), getCels()) != false && (_xSprite->width() != 0) && (_xSprite->height() != 0)) {
+			if (isTransparent()) {
+				int nMaskColor = CBagel::getBagApp()->getChromaColor();
 
-				// Set animated of the sprite to be the same as it's parent
-				_xSprite->setAnimated(isAnimated());
+				_xSprite->setMaskColor(nMaskColor);
+			}
 
-				CBofPoint p = CBagObject::getPosition();
+			// Set animated of the sprite to be the same as it's parent
+			_xSprite->setAnimated(isAnimated());
 
-				if (p.x == -1 && p.y == -1) // Fixed to allow for [0,0] positioning
-					setFloating();
-				else
-					_xSprite->setPosition(p.x, p.y);
+			CBofPoint p = CBagObject::getPosition();
 
-				setProperty("CURR_CEL", getState());
+			if (p.x == -1 && p.y == -1) // Fixed to allow for [0,0] positioning
+				setFloating();
+			else
+				_xSprite->setPosition(p.x, p.y);
 
-				// This might add something to the PDA, make sure it gets redrawn.
-				CBagStorageDevWnd *pMainWin = (CBagel::getBagApp()->getMasterWnd()->getCurrentStorageDev());
+			setProperty("CURR_CEL", getState());
 
-				if (pMainWin != nullptr) {
-					pMainWin->setPreFilterPan(true);
-				}
-			} else {
-				reportError(ERR_FOPEN, "Could Not Open Sprite: %s", _xSprite->getFileName());
-			}
+			// This might add something to the PDA, make sure it gets redrawn.
+			CBagStorageDevWnd *pMainWin = (CBagel::getBagApp()->getMasterWnd()->getCurrentStorageDev());
 
+			if (pMainWin != nullptr) {
+				pMainWin->setPreFilterPan(true);
+			}
 		} else {
-			reportError(ERR_MEMORY, "Could not allocate sprite");
+			reportError(ERR_FOPEN, "Could Not Open Sprite: %s", _xSprite->getFileName());
 		}
 	}
 




More information about the Scummvm-git-logs mailing list