[Scummvm-git-logs] scummvm master -> 74eca6975121fef90805a9dafdbb0d66e065b5b3

Strangerke noreply at scummvm.org
Wed May 15 06:51:45 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:
c180506d84 BAGEL: Make fataError static
74eca69751 BAGEL: Move lasst assignments out of if statements, some more cleanup


Commit: c180506d846c4797499830c976f8d450f1ab749d
    https://github.com/scummvm/scummvm/commit/c180506d846c4797499830c976f8d450f1ab749d
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-15T07:48:49+01:00

Commit Message:
BAGEL: Make fataError static

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


diff --git a/engines/bagel/boflib/error.cpp b/engines/bagel/boflib/error.cpp
index 48b6a97387c..86403498b1d 100644
--- a/engines/bagel/boflib/error.cpp
+++ b/engines/bagel/boflib/error.cpp
@@ -86,9 +86,7 @@ void CBofError::reportError(ErrorCode errCode, const char *format, ...) {
 }
 
 void CBofError::fatalError(ErrorCode errCode, const char *format, ...) {
-	_errCode = errCode;
-
-	if (_errCode == ERR_NONE)
+	if (errCode == ERR_NONE)
 		return;
 
 	Common::String buf;
diff --git a/engines/bagel/boflib/error.h b/engines/bagel/boflib/error.h
index b1169c1f995..7dcc8566253 100644
--- a/engines/bagel/boflib/error.h
+++ b/engines/bagel/boflib/error.h
@@ -72,12 +72,12 @@ public:
 	 * @param errCode       Error to report
 	 * @param format        printf style format string
 	 */
-	void fatalError(ErrorCode errCode, const char *format, ...);
+	static void fatalError(ErrorCode errCode, const char *format, ...);
 
-	bool errorOccurred() {
+	bool errorOccurred() const {
 		return _errCode != ERR_NONE;
 	}
-	ErrorCode getErrorCode() {
+	ErrorCode getErrorCode() const {
 		return _errCode;
 	}
 	void clearError() {


Commit: 74eca6975121fef90805a9dafdbb0d66e065b5b3
    https://github.com/scummvm/scummvm/commit/74eca6975121fef90805a9dafdbb0d66e065b5b3
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-15T07:51:36+01:00

Commit Message:
BAGEL: Move lasst assignments out of if statements, some more cleanup

Changed paths:
    engines/bagel/baglib/pan_window.cpp
    engines/bagel/baglib/pda.cpp
    engines/bagel/baglib/sound_object.cpp
    engines/bagel/baglib/storage_dev_bmp.cpp
    engines/bagel/boflib/options.cpp
    engines/bagel/boflib/string.cpp
    engines/bagel/spacebar/bib_odds_wnd.cpp
    engines/bagel/spacebar/master_win.cpp
    engines/bagel/spacebar/slot_wnd.cpp
    engines/bagel/spacebar/sraf_computer.cpp


diff --git a/engines/bagel/baglib/pan_window.cpp b/engines/bagel/baglib/pan_window.cpp
index aac9374149c..7c14dd96c04 100644
--- a/engines/bagel/baglib/pan_window.cpp
+++ b/engines/bagel/baglib/pan_window.cpp
@@ -416,10 +416,11 @@ void CBagPanWindow::disable() {
 
 ErrorCode CBagPanWindow::onCursorUpdate(int nCurrObj) {
 	assert(isValidObject(this));
-	CBagObject *pObj;
 
-	if ((nCurrObj >= 0) && ((pObj = getObjectByPos(nCurrObj)) != nullptr)) {
-		CBagMasterWin::setActiveCursor(pObj->getOverCursor());
+	if (nCurrObj >= 0) {
+		CBagObject *pObj = getObjectByPos(nCurrObj);
+		if (pObj != nullptr)
+			CBagMasterWin::setActiveCursor(pObj->getOverCursor());
 
 	} else if (CBagWield::getWieldCursor() >= 0) {
 		CBagMasterWin::setActiveCursor(CBagWield::getWieldCursor());
diff --git a/engines/bagel/baglib/pda.cpp b/engines/bagel/baglib/pda.cpp
index 15e887e0f2d..3f7fd7d2a16 100644
--- a/engines/bagel/baglib/pda.cpp
+++ b/engines/bagel/baglib/pda.cpp
@@ -133,7 +133,8 @@ ErrorCode CBagPDA::attach() {
 
 	// Should be allowed to not find one.
 	if (!_mooWnd) {
-		if ((pSDev = g_SDevManager->getStorageDevice(MOO_WLD)) != nullptr) {
+		pSDev = g_SDevManager->getStorageDevice(MOO_WLD);
+		if (pSDev != nullptr) {
 			_mooWnd = (CBagStorageDevBmp *)pSDev;
 			_mooWnd->setAssociateWnd(getAssociateWnd());
 			_mooWnd->setTransparent(false);
@@ -143,7 +144,8 @@ ErrorCode CBagPDA::attach() {
 	}
 
 	if (!_invWnd) {
-		if ((pSDev = g_SDevManager->getStorageDevice(INV_WLD)) != nullptr) {
+		pSDev = g_SDevManager->getStorageDevice(INV_WLD);
+		if (pSDev != nullptr) {
 			_invWnd = (CBagStorageDevBmp *)pSDev;
 			_invWnd->setAssociateWnd(getAssociateWnd());
 
@@ -157,7 +159,8 @@ ErrorCode CBagPDA::attach() {
 	}
 
 	if (!_mapWnd) {
-		if ((pSDev = g_SDevManager->getStorageDevice(MAP_WLD)) != nullptr) {
+		pSDev = g_SDevManager->getStorageDevice(MAP_WLD);
+		if (pSDev != nullptr) {
 			_mapWnd = (CBagStorageDevBmp *)pSDev;
 			_mapWnd->setAssociateWnd(getAssociateWnd());
 
@@ -170,7 +173,8 @@ ErrorCode CBagPDA::attach() {
 		}
 	}
 	if (!_logWnd) {
-		if ((pSDev = g_SDevManager->getStorageDevice(LOG_WLD)) != nullptr) {
+		pSDev = g_SDevManager->getStorageDevice(LOG_WLD);
+		if (pSDev != nullptr) {
 			_logWnd = (CBagStorageDevBmp *)pSDev;
 			_logWnd->setAssociateWnd(getAssociateWnd());
 
@@ -497,14 +501,15 @@ void CBagPDA::handleZoomButton(bool bButtonDown) {
 }
 
 void CBagPDA::removeFromMovieQueue(CBagMovieObject *pMObj) {
-	if (_movieList != nullptr) {
-		int nCount = _movieList->getCount();
-		for (int i = 0; i < nCount; i++) {
-			CBagMovieObject *p = _movieList->getNodeItem(i);
-			if (pMObj == p) {
-				_movieList->remove(i);
-				break;
-			}
+	if (_movieList == nullptr)
+		return;
+
+	int nCount = _movieList->getCount();
+	for (int i = 0; i < nCount; i++) {
+		CBagMovieObject *p = _movieList->getNodeItem(i);
+		if (pMObj == p) {
+			_movieList->remove(i);
+			break;
 		}
 	}
 }
@@ -532,16 +537,14 @@ void CBagPDA::runWaitingMovie() {
 	return;
 	
 	int nCount = _movieList->getCount();
-	if (nCount > 0) {
-		for (int i = 0; i < nCount; i++) {
-			CBagMovieObject *pMObj = _movieList->getNodeItem(i);
-			if (pMObj->asynchPDAMovieCanPlay()) {
-				_soundsPausedFl = true;
-				// pause all sounds
-				CSound::pauseSounds();
-				pMObj->runObject();
-				removeFromMovieQueue(pMObj);
-			}
+	for (int i = 0; i < nCount; i++) {
+		CBagMovieObject *pMObj = _movieList->getNodeItem(i);
+		if (pMObj->asynchPDAMovieCanPlay()) {
+			_soundsPausedFl = true;
+			// pause all sounds
+			CSound::pauseSounds();
+			pMObj->runObject();
+			removeFromMovieQueue(pMObj);
 		}
 	}
 }
diff --git a/engines/bagel/baglib/sound_object.cpp b/engines/bagel/baglib/sound_object.cpp
index d4de5b0af24..8a4eb4e5575 100644
--- a/engines/bagel/baglib/sound_object.cpp
+++ b/engines/bagel/baglib/sound_object.cpp
@@ -68,7 +68,8 @@ ErrorCode CBagSoundObject::newSound(CBofWindow *pWin) {
 
 	killSound();
 
-	if ((_pSound = new CBofSound(pWin, getFileName(), _wFlags, _nLoops)) != nullptr) {
+	_pSound = new CBofSound(pWin, getFileName(), _wFlags, _nLoops);
+	if (_pSound != nullptr) {
 		_pSound->setVolume(_nVol);
 		_pSound->setQSlot(getState());
 
@@ -80,10 +81,8 @@ ErrorCode CBagSoundObject::newSound(CBofWindow *pWin) {
 }
 
 void CBagSoundObject::killSound() {
-	if (_pSound != nullptr) {
-		delete _pSound;
-		_pSound = nullptr;
-	}
+	delete _pSound;
+	_pSound = nullptr;
 }
 
 ErrorCode CBagSoundObject::detach() {
diff --git a/engines/bagel/baglib/storage_dev_bmp.cpp b/engines/bagel/baglib/storage_dev_bmp.cpp
index 901c07322d3..f368917705a 100644
--- a/engines/bagel/baglib/storage_dev_bmp.cpp
+++ b/engines/bagel/baglib/storage_dev_bmp.cpp
@@ -132,12 +132,11 @@ const CBofPoint CBagStorageDevBmp::devPtToViewPort(const CBofPoint &xPoint) {
 }
 
 ErrorCode CBagStorageDevBmp::update(CBofBitmap *pBmp, CBofPoint /*xPoint*/, CBofRect * /*pSrcRect*/, int /*nMaskColor*/) {
-	CBofBitmap *pSrcBmp = nullptr;
-
 	// if this object is visible
 	if (isVisible() && isAttached()) {
 		// Paint the storage device
-		if ((pSrcBmp = getBitmap()) != nullptr) {
+		CBofBitmap *pSrcBmp = getBitmap();
+		if (pSrcBmp != nullptr) {
 			assert(getWorkBmp() != nullptr);
 			// Erase everything from the background
 			getWorkBmp()->paint(pSrcBmp);
diff --git a/engines/bagel/boflib/options.cpp b/engines/bagel/boflib/options.cpp
index e1988772b0c..79407c529b0 100644
--- a/engines/bagel/boflib/options.cpp
+++ b/engines/bagel/boflib/options.cpp
@@ -57,7 +57,6 @@ CBofOptions::~CBofOptions() {
 
 ErrorCode CBofOptions::loadOptionFile(const char *pszOptionFile) {
 	assert(isValidObject(this));
-
 	assert(pszOptionFile != nullptr);
 	assert(*pszOptionFile != '\0');
 	assert(strlen(pszOptionFile) < MAX_FNAME);
@@ -174,25 +173,23 @@ ErrorCode CBofOptions::writeSetting(const char *pszSection, const char *pszVar,
 			Common::sprintf_s(szSectionBuf, "[%s]", pszSection);
 
 			pSection = new COption(szSectionBuf);
-			if (pSection != nullptr) {
-				if (_pOptionList != nullptr) {
-					_pOptionList->addToTail(pSection);
-				} else {
-					_pOptionList = pSection;
-				}
+			if (pSection == nullptr)
+				CBofError::fatalError(ERR_MEMORY, "Unable to instantiate a new COption");
+
+			if (_pOptionList != nullptr) {
+				_pOptionList->addToTail(pSection);
 			} else {
-				errCode = ERR_MEMORY;
+				_pOptionList = pSection;
 			}
 		}
 
 		// Add this option to the specified section
 		pOption = new COption(szValueBuf);
-		if (pOption != nullptr) {
-			assert(pSection != nullptr);
-			pSection->Insert(pOption);
-		} else {
-			errCode = ERR_MEMORY;
-		}
+		if (pOption == nullptr)
+			CBofError::fatalError(ERR_MEMORY, "Unable to instantiate a new COption");
+
+		assert(pSection != nullptr);
+		pSection->Insert(pOption);
 	}
 
 	return errCode;
@@ -340,9 +337,9 @@ COption *CBofOptions::findOption(const char *pszSection, const char *pszVar) {
 	COption *pFound = nullptr;
 
 	int nLength = strlen(pszVar);
-	COption *pStart;
+	COption *pStart = findSection(pszSection);
 
-	if ((pStart = findSection(pszSection)) != nullptr) {
+	if (pStart != nullptr) {
 		COption *pOption = (COption *)pStart->getNext();
 		while (pOption != nullptr) {
 			if (pOption->_szBuf[0] == '[') {
diff --git a/engines/bagel/boflib/string.cpp b/engines/bagel/boflib/string.cpp
index f3575d01ee7..9817dc29cce 100644
--- a/engines/bagel/boflib/string.cpp
+++ b/engines/bagel/boflib/string.cpp
@@ -532,10 +532,12 @@ void CBofString::replaceStr(const char *pszOld, const char *pszNew) {
 			int nDiff = nNewLen - nOldLen;
 			int nNeedLength = _nLength + 1;
 			p = _pszData;
-			while ((pszSearch = strstr(p, pszOld)) != nullptr) {
+			pszSearch = strstr(p, pszOld);
+			while (pszSearch != nullptr) {
 				p = pszSearch + nOldLen;
 
 				nNeedLength += nDiff;
+				pszSearch = strstr(p, pszOld);
 			}
 
 			// If we need more storage space for the buffer, then get some
@@ -549,9 +551,11 @@ void CBofString::replaceStr(const char *pszOld, const char *pszNew) {
 		// of the token that we are searching for.
 
 		p = _pszData;
-		while ((pszSearch = strstr(p, pszOld)) != nullptr) {
+		pszSearch = strstr(p, pszOld);
+		while (pszSearch != nullptr) {
 			strreplaceStr(p, pszOld, pszNew);
 			p = pszSearch + nNewLen;
+			pszSearch = strstr(p, pszOld);
 		}
 
 		// Get new length
diff --git a/engines/bagel/spacebar/bib_odds_wnd.cpp b/engines/bagel/spacebar/bib_odds_wnd.cpp
index 30befcd33c7..b866387ef9c 100644
--- a/engines/bagel/spacebar/bib_odds_wnd.cpp
+++ b/engines/bagel/spacebar/bib_odds_wnd.cpp
@@ -121,7 +121,8 @@ ErrorCode SBarBibOddsWnd::attach() {
 
 	// If we have something wielded, put it on hold for now.
 	if (CBagPanWindow::_pWieldBmp != nullptr) {
-		if ((_wieldedObject = CBagPanWindow::_pWieldBmp->getCurrObj()) != nullptr) {
+		_wieldedObject = CBagPanWindow::_pWieldBmp->getCurrObj();
+		if (_wieldedObject != nullptr) {
 			g_SDevManager->removeObject(CBagPanWindow::_pWieldBmp->getName(), _wieldedObject->getRefName());
 		}
 	}
diff --git a/engines/bagel/spacebar/master_win.cpp b/engines/bagel/spacebar/master_win.cpp
index 1f31aa47d3f..89f14bce6c1 100644
--- a/engines/bagel/spacebar/master_win.cpp
+++ b/engines/bagel/spacebar/master_win.cpp
@@ -95,7 +95,6 @@ CBagStorageDev *CSBarMasterWin::onNewStorageDev(const CBofString &typestr) {
 	} else if (!typestr.find("BIBODDS")) {
 		pSDev = new SBarBibOddsWnd();
 		pSDev->setCloseup(true);
-		// pSDev->setExitOnEdge(10);
 		pSDev->setCustom(true);
 
 	} else if (!typestr.find("INVWLD")) {
@@ -117,22 +116,24 @@ CBagStorageDev *CSBarMasterWin::onNewStorageDev(const CBofString &typestr) {
 
 		// delineate cic's
 	} else if (!typestr.find("CIC")) {
-		if ((pSDev = new GAMEWINDOW()) != nullptr) {
+		pSDev = new GAMEWINDOW();
+		if (pSDev != nullptr) {
 			pSDev->setCloseup(true);
 			pSDev->setCIC(true);
 			pSDev->setExitOnEdge(80);
 		}
 
 	} else if (!typestr.find("CLOSEUP")) {
-		if ((pSDev = new GAMEWINDOW()) != nullptr) {
+		pSDev = new GAMEWINDOW();
+		if (pSDev != nullptr) {
 			pSDev->setCloseup(true);
 			pSDev->setExitOnEdge(80);
 		}
 
 	} else if (!typestr.find("CHAT")) {
-		if ((pSDev = new CBagChatWnd()) != nullptr) {
+		pSDev = new CBagChatWnd();
+		if (pSDev != nullptr) {
 			pSDev->setCloseup(true);
-			//          pSDev->setExitOnEdge(80);
 		}
 
 	} else if (!typestr.find("EVENT")) {        // EVT STUFF
diff --git a/engines/bagel/spacebar/slot_wnd.cpp b/engines/bagel/spacebar/slot_wnd.cpp
index 97e20935f3d..852b74acbaf 100644
--- a/engines/bagel/spacebar/slot_wnd.cpp
+++ b/engines/bagel/spacebar/slot_wnd.cpp
@@ -132,10 +132,10 @@ void SBarSlotWnd::onPaint(CBofRect *pRect) {
 	assert(isValidObject(this));
 
 	if (!errorOccurred()) {
-		CBofBitmap *pBackBmp;
+		CBofBitmap *pBackBmp = getBackdrop();
 
 		//Paint the storage device
-		if ((pBackBmp = getBackdrop()) != nullptr) {
+		if (pBackBmp != nullptr) {
 			assert(getWorkBmp() != nullptr);
 
 			// Erase everything from the background
diff --git a/engines/bagel/spacebar/sraf_computer.cpp b/engines/bagel/spacebar/sraf_computer.cpp
index 6d4afa3e2b3..466c7c68ed4 100644
--- a/engines/bagel/spacebar/sraf_computer.cpp
+++ b/engines/bagel/spacebar/sraf_computer.cpp
@@ -2830,7 +2830,8 @@ void SrafComputer::onListDispatchTeam() {
 					displayTextScreen(sStr);
 				} else if (cMeetMember.ptInRect(cPoint)) {         // if so, put a checkmark in that column.
 					// Uncheck any member we already have checked, this is a singular operation
-					if ((nMeetMember = getMeetMember(nListToCheck)) != -1) {
+					nMeetMember = getMeetMember(nListToCheck);
+					if (nMeetMember != -1) {
 						g_stOtherPartys[nMeetMember]._bMeetWith = false;
 					}
 
@@ -2881,7 +2882,8 @@ void SrafComputer::onListDispatchTeam() {
 					// If so, put a checkmark in that column.
 
 					// Uncheck any member we already have checked, this is a singular operation
-					if ((nMeetMember = getMeetMember(nListToCheck)) != -1) {
+					nMeetMember = getMeetMember(nListToCheck);
+					if (nMeetMember != -1) {
 						g_stSellerNames[nMeetMember]._bMeetWith = false;
 					}
 
@@ -2931,7 +2933,8 @@ void SrafComputer::onListDispatchTeam() {
 				} else if (cMeetMember.ptInRect(cPoint)) {
 					// if so, put a checkmark in that column.
 					// Uncheck any member we already have checked, this is a singular operation
-					if ((nMeetMember = getMeetMember(nListToCheck)) != -1) {
+					nMeetMember = getMeetMember(nListToCheck);
+					if (nMeetMember != -1) {
 						g_stBuyerBids[nMeetMember]._bMeetWith = false;
 					}
 
@@ -5119,7 +5122,8 @@ void SrafComputer::saveSraffanVars() {
 			break;
 		}
 
-		if ((pVar = g_VarManager->getVariable(pVarName)) != nullptr) {
+		pVar = g_VarManager->getVariable(pVarName);
+		if (pVar != nullptr) {
 			pVar->setValue(g_stOtherPartys[nOtherID]._nPaymentAmount);
 		}
 	}




More information about the Scummvm-git-logs mailing list