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

Strangerke noreply at scummvm.org
Mon Jun 17 21:34:05 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:
cb624cb3f3 BAGEL: constify some more variables, change checks on _smk to return false asap in CBagFMovie
e9b6cc42f5 BAGEL: constify some more variables, add a default case in a switch


Commit: cb624cb3f3eb979f8cd1a961692221be9f5fb71d
    https://github.com/scummvm/scummvm/commit/cb624cb3f3eb979f8cd1a961692221be9f5fb71d
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-06-17T22:32:20+01:00

Commit Message:
BAGEL: constify some more variables, change checks on _smk to return false asap in CBagFMovie

Changed paths:
    engines/bagel/baglib/fmovie.cpp


diff --git a/engines/bagel/baglib/fmovie.cpp b/engines/bagel/baglib/fmovie.cpp
index e6be29c768b..2875a7e0c3e 100644
--- a/engines/bagel/baglib/fmovie.cpp
+++ b/engines/bagel/baglib/fmovie.cpp
@@ -136,7 +136,7 @@ bool CBagFMovie::openMovie(const char *sFilename) {
 			_bmpBuf->getSurface().blitFrom(*frame);
 		}
 	}
-	bool repaintFl = true;
+	const bool repaintFl = true;
 
 	_bounds = CBofRect(0, 0, (uint16)_bmpBuf->width() - 1, (uint16)_bmpBuf->height() - 1);
 	reSize(&_bounds, repaintFl);
@@ -145,8 +145,8 @@ bool CBagFMovie::openMovie(const char *sFilename) {
 	if (curWin != nullptr) {
 		CBagStorageDevWnd *curSDev = curWin->getCurrentStorageDev();
 		if ((curSDev != nullptr) && curSDev->isFiltered()) {
-			uint16 filterId = curSDev->getFilterId();
-			FilterFunction filterFunction = curSDev->getFilter();
+			const uint16 filterId = curSDev->getFilterId();
+			const FilterFunction filterFunction = curSDev->getFilter();
 			_bmpBuf->paint(_filterBmp);
 			(*filterFunction)(filterId, _filterBmp, &_bounds);
 		}
@@ -185,8 +185,8 @@ void CBagFMovie::onMainLoop() {
 	if (curWin != nullptr) {
 		CBagStorageDevWnd *curSDev = curWin->getCurrentStorageDev();
 		if ((curSDev != nullptr) && curSDev->isFiltered()) {
-			uint16 filterId = curSDev->getFilterId();
-			FilterFunction filterFunction = curSDev->getFilter();
+			const uint16 filterId = curSDev->getFilterId();
+			const FilterFunction filterFunction = curSDev->getFilter();
 			(*filterFunction)(filterId, _filterBmp, &_bounds);
 		}
 	}
@@ -264,7 +264,7 @@ bool CBagFMovie::play(bool loop, bool escCanStop) {
 	_escCanStopFl = escCanStop;
 	_loopFl = loop;
 
-	bool retVal = play();
+	const bool retVal = play();
 
 	getParent()->disable();
 	getParent()->flushAllMessages();
@@ -280,22 +280,21 @@ bool CBagFMovie::play(bool loop, bool escCanStop) {
 
 
 bool CBagFMovie::play() {
-	if (_smk) {
-		_smk->pauseVideo(false);
-		// _smk->setReverse(false); // TODO: Not supported by SMK
-		_smk->start();
-		_movieStatus = MOVIE_FOREWARD;
-		return true;
-	}
+	if (!_smk)
+		return false;
 
-	return false;
+	_smk->pauseVideo(false);
+	// _smk->setReverse(false); // TODO: Not supported by SMK
+	_smk->start();
+	_movieStatus = MOVIE_FOREWARD;
+	return true;
 }
 
 bool CBagFMovie::reverse(bool loop, bool escCanStop) {
 	_escCanStopFl = escCanStop;
 	_loopFl = loop;
 
-	bool retVal = reverse();
+	const bool retVal = reverse();
 
 	getParent()->disable();
 	getParent()->flushAllMessages();
@@ -305,57 +304,49 @@ bool CBagFMovie::reverse(bool loop, bool escCanStop) {
 }
 
 bool CBagFMovie::reverse() {
-	if (_smk) {
-		_smk->pauseVideo(false);
-		// _smk->setReverse(true); // TODO: Not supported by SMK
-		_smk->start();
-		_movieStatus = MOVIE_REVERSE;
-		return true;
-	}
-
-	return false;
+	if (!_smk)
+		return false;
 
+	_smk->pauseVideo(false);
+	// _smk->setReverse(true); // TODO: Not supported by SMK
+	_smk->start();
+	_movieStatus = MOVIE_REVERSE;
+	return true;
 }
 
 bool CBagFMovie::stop() {
-	if (_smk) {
-		_smk->stop();
-		_movieStatus = MOVIE_STOPPED;
-		return true;
-	}
-	return false;
+	if (!_smk)
+		return false;
 
+	_smk->stop();
+	_movieStatus = MOVIE_STOPPED;
+	return true;
 }
 
 bool CBagFMovie::pause() {
-	if (_smk) {
-		_smk->pauseVideo(true);
-		_movieStatus = MOVIE_PAUSED;
-		return true;
-	}
+	if (!_smk)
+		return false;
 
-	return false;
+	_smk->pauseVideo(true);
+	_movieStatus = MOVIE_PAUSED;
+	return true;
 
 }
 
 bool CBagFMovie::seekToStart() {
-	if (_smk) {
-		_smk->rewind();
-		return true;
-	}
-
-	return false;
+	if (!_smk)
+		return false;
 
+	_smk->rewind();
+	return true;
 }
 
 bool CBagFMovie::seekToEnd() {
-	if (_smk) {
-		setFrame(_smk->getFrameCount() - 2); // HACK: Reverse rewind
-		return true;
-	}
-
-	return false;
+	if (!_smk)
+		return false;
 
+	setFrame(_smk->getFrameCount() - 2); // HACK: Reverse rewind
+	return true;
 }
 
 uint32 CBagFMovie::getFrame() {
@@ -367,24 +358,23 @@ uint32 CBagFMovie::getFrame() {
 }
 
 bool CBagFMovie::setFrame(uint32 frameNum) {
-	if (_smk) {
-		frameNum = CLIP<uint32>(frameNum, 0, _smk->getFrameCount() - 1);
-		_smk->forceSeekToFrame(frameNum);
-		return true;
-	}
+	if (!_smk)
+		return false;
 
-	return false;
+	frameNum = CLIP<uint32>(frameNum, 0, _smk->getFrameCount() - 1);
+	_smk->forceSeekToFrame(frameNum);
+	return true;
 }
 
 bool CBagFMovie::centerRect() {
 	CBofRect clientRect = getParent()->getClientRect();
-	RECT parentRect = clientRect.getWinRect();
-	int clientWidth = parentRect.right - parentRect.left;
-	int clientHeight = parentRect.bottom - parentRect.top;
+	const RECT parentRect = clientRect.getWinRect();
+	const int clientWidth = parentRect.right - parentRect.left;
+	const int clientHeight = parentRect.bottom - parentRect.top;
 
 	// Get Movies width and height
-	int movieWidth = _smk->getWidth();
-	int movieHeight = _smk->getHeight();
+	const int movieWidth = _smk->getWidth();
+	const int movieHeight = _smk->getHeight();
 
 	RECT movieBounds;
 	movieBounds.left = (clientWidth - movieWidth) / 2;


Commit: e9b6cc42f5a367d725e1608d6d105cd3719049f5
    https://github.com/scummvm/scummvm/commit/e9b6cc42f5a367d725e1608d6d105cd3719049f5
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-06-17T22:33:58+01:00

Commit Message:
BAGEL: constify some more variables, add a default case in a switch

Changed paths:
    engines/bagel/baglib/help.cpp
    engines/bagel/baglib/ifstream.cpp
    engines/bagel/baglib/inv.cpp
    engines/bagel/baglib/link_object.cpp
    engines/bagel/baglib/log_msg.cpp
    engines/bagel/baglib/log_msg.h
    engines/bagel/baglib/master_win.cpp
    engines/bagel/baglib/menu_dlg.cpp
    engines/bagel/baglib/menu_dlg.h
    engines/bagel/baglib/moo.cpp
    engines/bagel/baglib/movie_object.cpp
    engines/bagel/baglib/object.cpp
    engines/bagel/baglib/paint_table.cpp


diff --git a/engines/bagel/baglib/help.cpp b/engines/bagel/baglib/help.cpp
index 0ebc58f7e88..a1f39b53801 100644
--- a/engines/bagel/baglib/help.cpp
+++ b/engines/bagel/baglib/help.cpp
@@ -120,7 +120,7 @@ ErrorCode CBagHelp::attach() {
 
 	CBofFile file(_textFile, CBF_BINARY | CBF_READONLY);
 
-	uint32 size = file.getLength();
+	const uint32 size = file.getLength();
 	char *buffer = (char *)bofCleanAlloc(size + 1);
 
 	file.read(buffer, size);
diff --git a/engines/bagel/baglib/ifstream.cpp b/engines/bagel/baglib/ifstream.cpp
index 55623b7e2e5..a069a1b17ea 100644
--- a/engines/bagel/baglib/ifstream.cpp
+++ b/engines/bagel/baglib/ifstream.cpp
@@ -36,7 +36,7 @@ CBagIfstream::CBagIfstream(char *buffer, int length) {
 }
 
 int CBagIfstream::getCh() {
-	int ch = get();
+	const int ch = get();
 	return ch;
 }
 
diff --git a/engines/bagel/baglib/inv.cpp b/engines/bagel/baglib/inv.cpp
index afe33c76f75..b22ebc101b4 100644
--- a/engines/bagel/baglib/inv.cpp
+++ b/engines/bagel/baglib/inv.cpp
@@ -44,7 +44,7 @@ ErrorCode CBagInv::activateLocalObject(const CBofString &objectName) {
 	// Don't do any wand animation if we are zoomed.
 	SBZoomPda *zoomPda = (SBZoomPda *)g_SDevManager->getStorageDevice("BPDAZ_WLD");
 	assert(zoomPda != nullptr);
-	bool zoomedFl = (zoomPda ? zoomPda->getZoomed() : false);
+	const bool zoomedFl = (zoomPda ? zoomPda->getZoomed() : false);
 
 	if (pdaSDev && zoomedFl == false) {
 		CBagCharacterObject *wand = (CBagCharacterObject *)pdaSDev->getObject("WANDANIM");
@@ -98,7 +98,7 @@ ErrorCode CBagInv::deactivateLocalObject(const CBofString &objectName) {
 	// Don't do any wand animation if we are zoomed.
 	SBZoomPda *zoomPDA = (SBZoomPda *)g_SDevManager->getStorageDevice("BPDAZ_WLD");
 	assert(zoomPDA != nullptr);
-	bool zoomedFl = (zoomPDA ? zoomPDA->getZoomed() : false);
+	const bool zoomedFl = (zoomPDA ? zoomPDA->getZoomed() : false);
 
 	if (pdaSDev && zoomedFl == false) {
 		CBagCharacterObject *wand = (CBagCharacterObject *)pdaSDev->getObject("WANDANIM");
diff --git a/engines/bagel/baglib/link_object.cpp b/engines/bagel/baglib/link_object.cpp
index 8ff3201901c..8a47068895a 100644
--- a/engines/bagel/baglib/link_object.cpp
+++ b/engines/bagel/baglib/link_object.cpp
@@ -43,8 +43,8 @@ CBagLinkObject::~CBagLinkObject() {
 }
 
 CBofRect CBagLinkObject::getRect() {
-	CBofPoint p = getPosition();
-	CBofSize  s = getSize();
+	const CBofPoint p = getPosition();
+	const CBofSize  s = getSize();
 	CBofRect r = CBofRect(p, s);
 	return r;
 }
@@ -56,7 +56,7 @@ ParseCodes CBagLinkObject::setInfo(CBagIfstream &istr) {
 	bool doneFl = false;
 
 	while (!doneFl && !istr.eof()) {
-		char ch = (char)istr.peek();
+		const char ch = (char)istr.peek();
 		switch (ch) {
 		//
 		//  @[x,y]  - destination of a flythru.  start point in next world
@@ -134,7 +134,7 @@ ParseCodes CBagLinkObject::setInfo(CBagIfstream &istr) {
 		//  No match return from function
 		//
 		default: {
-			ParseCodes parseCode = CBagObject::setInfo(istr);
+			const ParseCodes parseCode = CBagObject::setInfo(istr);
 
 			if (parseCode == PARSING_DONE) {
 				returnCode = PARSING_DONE;
diff --git a/engines/bagel/baglib/log_msg.cpp b/engines/bagel/baglib/log_msg.cpp
index 3a96f16faf5..230d26ef0a0 100644
--- a/engines/bagel/baglib/log_msg.cpp
+++ b/engines/bagel/baglib/log_msg.cpp
@@ -60,7 +60,7 @@ CBofPoint CBagLog::arrangeFloater(CBofPoint &pos, CBagObject *bagObj) {
 	// so we will not require a backdrop.
 
 	if (getBackground() != nullptr) {
-		CBofString sdevName = getName();
+		const CBofString sdevName = getName();
 		int borderSize = 0;
 
 		// Get this from script, allows individual log states to set border.
@@ -89,7 +89,7 @@ CBofPoint CBagLog::arrangeFloater(CBofPoint &pos, CBagObject *bagObj) {
 		pageNum++;
 		setNumFloatPages(pageNum);
 
-		int totalPages = getCurFltPage();
+		const int totalPages = getCurFltPage();
 		// Now position this object int the sdev
 		// if it fell on this page, show it
 		if (pageNum == totalPages) {
@@ -136,9 +136,9 @@ void CBagLog::arrangePages() {
 	}
 
 	// Get current page number and last page number
-	int lastPage = lastFloat->getNumFloatPages();
-	int curPage = lastFloat->getCurFltPage();
-	int firstPage = 1;
+	const int lastPage = lastFloat->getNumFloatPages();
+	const int curPage = lastFloat->getCurFltPage();
+	const int firstPage = 1;
 
 	if (curPage > firstPage && curPage < lastPage) {
 		if (upObj->isAttached() == false) {
@@ -205,8 +205,8 @@ void CBagLog::setCurFltPage(int fltPage) {
 }
 
 ErrorCode CBagLog::releaseMsg() {
-	ErrorCode errorCode = ERR_NONE;
-	int count = _queuedMsgList->getCount();
+	const ErrorCode errorCode = ERR_NONE;
+	const int count = _queuedMsgList->getCount();
 
 	for (int i = 0; i < count; ++i) {
 		CBagObject *curObj = _queuedMsgList->removeHead();
@@ -227,8 +227,8 @@ ErrorCode CBagLog::releaseMsg() {
 
 CBagObject *CBagLog::onNewUserObject(const CBofString &initStr) {
 	CBagTextObject *retLogObj = nullptr;
-	CBofRect sdevRect = getRect();
-	CBofString  sdevName = getName();
+	const CBofRect sdevRect = getRect();
+	const CBofString  sdevName = getName();
 	int     pointSize = 10;
 
 	if (sdevName == "LOG_WLD")
@@ -269,7 +269,7 @@ CBagObject *CBagLog::onNewUserObject(const CBofString &initStr) {
 
 bool CBagLog::removeFromMsgQueue(CBagObject *deletedObj) {
 	bool removedFl = false;
-	int count = _queuedMsgList->getCount();
+	const int count = _queuedMsgList->getCount();
 
 	for (int i = 0; i < count; i++) {
 		CBagObject *curObj = _queuedMsgList->getNodeItem(i);
@@ -297,7 +297,7 @@ ErrorCode CBagLog::activateLocalObject(CBagObject *bagObj) {
 		// Since zoomed pda doesn't  have a message light, only set this thing
 		// as waiting if we are in the  regular PDA, otherwise, we get superfluous
 		// blinking of the PDA light.
-		CBofString  sdevName = getName();
+		const CBofString  sdevName = getName();
 		if (sdevName == "LOG_WLD") {
 			bagObj->setMsgWaiting(true);
 		}
@@ -437,7 +437,7 @@ ParseCodes CBagLogMsg::setInfo(CBagIfstream &istr) {
 	while (!istr.eof()) {
 		istr.eatWhite();
 
-		char ch = (char)istr.peek();
+		const char ch = (char)istr.peek();
 		switch (ch) {
 		//
 		//  SENDEE FRANK - Sets the sendee name of the message to FRANK
@@ -469,7 +469,7 @@ ParseCodes CBagLogMsg::setInfo(CBagIfstream &istr) {
 
 			if (!string1.find("TIME")) {
 				istr.eatWhite();
-				char nextCh = (char)istr.peek();
+				const char nextCh = (char)istr.peek();
 				int msgTime = 0;
 				if (Common::isDigit(nextCh)) {
 					getIntFromStream(istr, msgTime);
@@ -486,7 +486,7 @@ ParseCodes CBagLogMsg::setInfo(CBagIfstream &istr) {
 		}
 
 		default: {
-			ParseCodes parseCode = CBagObject::setInfo(istr);
+			const ParseCodes parseCode = CBagObject::setInfo(istr);
 			if (parseCode == PARSING_DONE) {
 				return PARSING_DONE;
 			}
@@ -523,7 +523,7 @@ int CBagLogMsg::getProperty(const CBofString &prop) {
 
 	// Played requires a 1 or a 0 (don't use true or false).
 	if (!prop.find("PLAYED")) {
-		bool playedFl = getMsgPlayed();
+		const bool playedFl = getMsgPlayed();
 		return (playedFl ? 1 : 0);
 	}
 
@@ -538,9 +538,9 @@ ErrorCode CBagLogMsg::update(CBofBitmap *bmp, CBofPoint pt, CBofRect *srcRect, i
 		setMsgTime(nMsgTime);
 	}
 
-	int msgTime = getMsgTime();
-	int hour = msgTime / 100;
-	int minutes = msgTime - (hour * 100);
+	const int msgTime = getMsgTime();
+	const int hour = msgTime / 100;
+	const int minutes = msgTime - (hour * 100);
 
 	setFont(FONT_MONO);
 	setText(buildString("%-30s%02d:%02d", _msgSendee.getBuffer(), hour, minutes));
@@ -573,7 +573,7 @@ ParseCodes CBagLogSuspect::setInfo(CBagIfstream &istr) {
 	while (!istr.eof()) {
 		istr.eatWhite();
 
-		char ch = (char)istr.peek();
+		const char ch = (char)istr.peek();
 		switch (ch) {
 		//
 		//  NAME FRANK - Sets the sendee name of the message to FRANK
@@ -634,7 +634,7 @@ ParseCodes CBagLogSuspect::setInfo(CBagIfstream &istr) {
 		}
 
 		default: {
-			ParseCodes parseCode = CBagObject::setInfo(istr);
+			const ParseCodes parseCode = CBagObject::setInfo(istr);
 			if (parseCode == PARSING_DONE) {
 				return PARSING_DONE;
 			}
@@ -790,7 +790,7 @@ ParseCodes CBagEnergyDetectorObject::setInfo(CBagIfstream &istr) {
 	while (!istr.eof()) {
 		istr.eatWhite();
 
-		char ch = (char)istr.peek();
+		const char ch = (char)istr.peek();
 		switch (ch) {
 		//
 		//  ZHAPS - NUMBER OF ZHAPS (ENERGY UNITS)
@@ -871,7 +871,7 @@ ParseCodes CBagEnergyDetectorObject::setInfo(CBagIfstream &istr) {
 		}
 
 		default: {
-			ParseCodes parseCode = CBagObject::setInfo(istr);
+			const ParseCodes parseCode = CBagObject::setInfo(istr);
 			if (parseCode == PARSING_DONE) {
 				return PARSING_DONE;
 			}
@@ -919,8 +919,8 @@ ErrorCode CBagEnergyDetectorObject::attach() {
 		nMsgTime = atoi(_energyTimeStr.getBuffer());
 	}
 
-	int hour = nMsgTime / 100;
-	int minute = nMsgTime - (hour * 100);
+	const int hour = nMsgTime / 100;
+	const int minute = nMsgTime - (hour * 100);
 
 	// Get the number of zhaps.
 	curVar = g_VarManager->getVariable(_zhapsStr);
@@ -975,7 +975,7 @@ ErrorCode CBagLogClue::attach() {
 
 	assert(isValidObject(this));
 
-	ErrorCode errorCode = CBagTextObject::attach();
+	const ErrorCode errorCode = CBagTextObject::attach();
 
 	// Get what is defined in the script.
 	cFormat = getFileName();
@@ -1005,13 +1005,12 @@ ParseCodes CBagLogClue::setInfo(CBagIfstream &istr) {
 
 	while (!istr.eof()) {
 		istr.eatWhite();
-		char ch = (char)istr.peek();
-		switch (ch) {
-		//
-		//  STRINGVAR - This will be a variable used to display some information that
-		//  is contained in script in a clue statement.
-		//
-		case 'S': {
+		const char ch = (char)istr.peek();
+		if (ch == 'S') {
+			//
+			//  STRINGVAR - This will be a variable used to display some information that
+			//  is contained in script in a clue statement.
+			//
 			getAlphaNumFromStream(istr, sStr);
 
 			if (!sStr.find("STRINGVAR")) {
@@ -1039,11 +1038,8 @@ ParseCodes CBagLogClue::setInfo(CBagIfstream &istr) {
 			} else {
 				putbackStringOnStream(istr, sStr);
 			}
-			break;
-		}
-
-		default: {
-			ParseCodes parseCode = CBagObject::setInfo(istr);
+		} else {
+			const ParseCodes parseCode = CBagObject::setInfo(istr);
 			if (parseCode == PARSING_DONE) {
 				return PARSING_DONE;
 			}
@@ -1056,8 +1052,6 @@ ParseCodes CBagLogClue::setInfo(CBagIfstream &istr) {
 
 				return UNKNOWN_TOKEN;
 			}
-			break;
-		}
 		}
 
 	}
diff --git a/engines/bagel/baglib/log_msg.h b/engines/bagel/baglib/log_msg.h
index 0e4a9105989..95645018ed6 100644
--- a/engines/bagel/baglib/log_msg.h
+++ b/engines/bagel/baglib/log_msg.h
@@ -75,7 +75,7 @@ public:
 	}
 
 	void setMsgTime(int &msgTime) {
-		int state = getState();
+		const int state = getState();
 		setState((state & MSG_PLAYED_MASK) | (msgTime & MSG_TIME_MASK));
 	}
 
@@ -84,7 +84,7 @@ public:
 	}
 
 	void setMsgPlayed(bool playedFl) {
-		int state = getState();
+		const int state = getState();
 		setState((state & MSG_TIME_MASK) | (playedFl == true ? MSG_PLAYED_MASK : 0));
 	}
 	bool getMsgPlayed() {
diff --git a/engines/bagel/baglib/master_win.cpp b/engines/bagel/baglib/master_win.cpp
index 4139e8e78ad..8bb23aeacfe 100644
--- a/engines/bagel/baglib/master_win.cpp
+++ b/engines/bagel/baglib/master_win.cpp
@@ -161,7 +161,7 @@ ErrorCode CBagMasterWin::showSystemDialog(bool bSaveBackground) {
 		CBagOptWindow optionDialog;
 		optionDialog.setBackdrop(dialogBmp);
 
-		CBofRect dialogRect = optionDialog.getBackdrop()->getRect();
+		const CBofRect dialogRect = optionDialog.getBackdrop()->getRect();
 
 		if (!bSaveBackground) {
 			optionDialog.setFlags(optionDialog.getFlags() & ~BOFDLG_SAVEBACKGND);
@@ -174,7 +174,7 @@ ErrorCode CBagMasterWin::showSystemDialog(bool bSaveBackground) {
 		g_hackWindow = &optionDialog;
 
 		g_pauseTimerFl = true;
-		int dialogReturnValue = optionDialog.doModal();
+		const int dialogReturnValue = optionDialog.doModal();
 		g_pauseTimerFl = false;
 		optionDialog.detach();
 
@@ -202,11 +202,11 @@ ErrorCode CBagMasterWin::showCreditsDialog(CBofWindow *win, bool bSaveBkg) {
 	CBagCreditsDialog creditsDialog;
 	creditsDialog.setBackdrop(barBmp);
 
-	CBofRect dialogRect = creditsDialog.getBackdrop()->getRect();
+	const CBofRect dialogRect = creditsDialog.getBackdrop()->getRect();
 
 	// Don't allow save of background?
 	if (!bSaveBkg) {
-		int flags = creditsDialog.getFlags();
+		const int flags = creditsDialog.getFlags();
 
 		creditsDialog.setFlags(flags & ~BOFDLG_SAVEBACKGND);
 	}
@@ -219,7 +219,7 @@ ErrorCode CBagMasterWin::showCreditsDialog(CBofWindow *win, bool bSaveBkg) {
 	// Create the dialog box
 	creditsDialog.create("Save Dialog", dialogRect.left, dialogRect.top, dialogRect.width(), dialogRect.height(), win);
 
-	bool saveTimerFl = g_pauseTimerFl;
+	const bool saveTimerFl = g_pauseTimerFl;
 	g_pauseTimerFl = true;
 	creditsDialog.doModal();
 	g_pauseTimerFl = saveTimerFl;
@@ -250,7 +250,7 @@ bool CBagMasterWin::showQuitDialog(CBofWindow *win, bool bSaveBackground) {
 		CBagQuitDialog quitDialog;
 		quitDialog.setBackdrop(dialogBmp);
 
-		CBofRect dialogRect = quitDialog.getBackdrop()->getRect();
+		const CBofRect dialogRect = quitDialog.getBackdrop()->getRect();
 
 		if (!bSaveBackground) {
 			quitDialog.setFlags(quitDialog.getFlags() & ~BOFDLG_SAVEBACKGND);
@@ -259,9 +259,9 @@ bool CBagMasterWin::showQuitDialog(CBofWindow *win, bool bSaveBackground) {
 		// Create the dialog box
 		quitDialog.create("Quit Dialog", dialogRect.left, dialogRect.top, dialogRect.width(), dialogRect.height(), win);
 
-		bool saveTimerFl = g_pauseTimerFl;
+		const bool saveTimerFl = g_pauseTimerFl;
 		g_pauseTimerFl = true;
-		int dialogReturnValue = quitDialog.doModal();
+		const int dialogReturnValue = quitDialog.doModal();
 		g_pauseTimerFl = saveTimerFl;
 
 		switch (dialogReturnValue) {
@@ -277,6 +277,9 @@ bool CBagMasterWin::showQuitDialog(CBofWindow *win, bool bSaveBackground) {
 		case CANCEL_BTN:
 			quitFl = false;
 			break;
+
+		default:
+			break;
 		}
 
 		if (!quitFl) {
@@ -420,7 +423,7 @@ ErrorCode CBagMasterWin::loadFile(const CBofString &wldName, const CBofString &s
 	if (fileExists(wldFileName) && (fileLength(wldFileName) > 0)) {
 		// Force buffer to be big enough so that the entire script
 		// is pre-loaded
-		int length = fileLength(wldFileName);
+		const int length = fileLength(wldFileName);
 		char *fileBuf = (char *)bofAlloc(length);
 		CBagIfstream fpInput(fileBuf, length);
 
@@ -562,7 +565,7 @@ ErrorCode CBagMasterWin::loadGlobalVars(const CBofString &wldName) {
 	if (fileExists(wldFileName) && (fileLength(wldFileName) > 0)) {
 		// Force buffer to be big enough so that the entire script
 		// is pre-loaded
-		int length = fileLength(wldFileName);
+		const int length = fileLength(wldFileName);
 		char *buffer = (char *)bofAlloc(length);
 		CBagIfstream fpInput(buffer, length);
 
@@ -992,7 +995,7 @@ ErrorCode CBagMasterWin::onHelp(const CBofString &helpFile, bool /*bSaveBkg*/, C
 		CBagHelp help;
 		help.setBackdrop(bmp);
 
-		CBofRect backRect = help.getBackdrop()->getRect();
+		const CBofRect backRect = help.getBackdrop()->getRect();
 
 		if (parent == nullptr)
 			parent = this;
@@ -1186,7 +1189,7 @@ ErrorCode CBagMasterWin::gotoNewWindow(const CBofString *str) {
 		_gameWindow = (CBagStorageDevWnd *)sdev;
 		setCICStatus(sdev);
 
-		uint16 oldFadeId = sdev->getFadeId();
+		const uint16 oldFadeId = sdev->getFadeId();
 
 		if (_fadeIn != 0)
 			sdev->setFadeId((uint16)_fadeIn);
@@ -1225,13 +1228,13 @@ bool CBagMasterWin::showRestartDialog(CBofWindow *win, bool saveBkgFl) {
 
 		// Don't allow save of background
 		if (!saveBkgFl) {
-			int lFlags = restartDialog.getFlags();
+			const int lFlags = restartDialog.getFlags();
 			restartDialog.setFlags(lFlags & ~BOFDLG_SAVEBACKGND);
 		}
 
-		bool saveTimerFl = g_pauseTimerFl;
+		const bool saveTimerFl = g_pauseTimerFl;
 		g_pauseTimerFl = true;
-		int dialogReturn = restartDialog.doModal();
+		const int dialogReturn = restartDialog.doModal();
 		g_pauseTimerFl = saveTimerFl;
 
 		g_hackWindow = pLastWin;
@@ -1456,7 +1459,7 @@ void CBagMasterWin::fillSaveBuffer(StBagelSave *saveBuf) {
 				// Remember the pan's position
 				if (saveBuf->_nLocType == SDEV_GAMEWIN) {
 					CBagPanWindow *panWin = (CBagPanWindow *)sdevWin;
-					CBofRect cPos = panWin->getViewPort();
+					const CBofRect cPos = panWin->getViewPort();
 
 					saveBuf->_nLocX = (uint16)cPos.left;
 					saveBuf->_nLocY = (uint16)cPos.top;
@@ -1518,20 +1521,20 @@ bool CBagMasterWin::showSaveDialog(CBofWindow *win, bool bSaveBkg) {
 
 		saveDialog.setBackdrop(bmp);
 
-		CBofRect backRect = saveDialog.getBackdrop()->getRect();
+		const CBofRect backRect = saveDialog.getBackdrop()->getRect();
 
 		// Don't allow save of background
 		if (!bSaveBkg) {
-			int fllags = saveDialog.getFlags();
-			saveDialog.setFlags(fllags & ~BOFDLG_SAVEBACKGND);
+			const int dlgFlags = saveDialog.getFlags();
+			saveDialog.setFlags(dlgFlags & ~BOFDLG_SAVEBACKGND);
 		}
 
 		// Create the dialog box
 		saveDialog.create("Save Dialog", backRect.left, backRect.top, backRect.width(), backRect.height(), win);
 
-		bool saveTimerFl = g_pauseTimerFl;
+		const bool saveTimerFl = g_pauseTimerFl;
 		g_pauseTimerFl = true;
-		int btnId = saveDialog.doModal();
+		const int btnId = saveDialog.doModal();
 		g_pauseTimerFl = saveTimerFl;
 
 		savedFl = (btnId == SAVE_BTN);
@@ -1564,7 +1567,7 @@ void CBagMasterWin::doRestore(StBagelSave *saveBuf) {
 	CBofString closeUpString(stringBuf, 256);
 	int i;
 
-	// Rebuild the stack of locations (Could be 3 closups deep)
+	// Rebuild the stack of locations (Could be 3 closeups deep)
 	closeUpBuf[0] = '\0';
 	for (i = MAX_CLOSEUP_DEPTH - 1; i >= 0; i--) {
 		if (saveBuf->_szLocStack[i][0] != '\0') {
@@ -1678,11 +1681,11 @@ bool CBagMasterWin::showRestoreDialog(CBofWindow *win, bool bSaveBkg) {
 
 		restoreDialog.setBackdrop(pBmp);
 
-		CBofRect backRect = restoreDialog.getBackdrop()->getRect();
+		const CBofRect backRect = restoreDialog.getBackdrop()->getRect();
 
 		// Don't allow save of background
 		if (!bSaveBkg) {
-			int flags = restoreDialog.getFlags();
+			const int flags = restoreDialog.getFlags();
 			restoreDialog.setFlags(flags & ~BOFDLG_SAVEBACKGND);
 		}
 
@@ -1692,7 +1695,7 @@ bool CBagMasterWin::showRestoreDialog(CBofWindow *win, bool bSaveBkg) {
 		CBofWindow *lastWin = g_hackWindow;
 		g_hackWindow = &restoreDialog;
 
-		bool saveTimerFl = g_pauseTimerFl;
+		const bool saveTimerFl = g_pauseTimerFl;
 		g_pauseTimerFl = true;
 		restoreDialog.doModal();
 		g_pauseTimerFl = saveTimerFl;
diff --git a/engines/bagel/baglib/menu_dlg.cpp b/engines/bagel/baglib/menu_dlg.cpp
index 6a26a9500d7..bcb2d9559fd 100644
--- a/engines/bagel/baglib/menu_dlg.cpp
+++ b/engines/bagel/baglib/menu_dlg.cpp
@@ -82,7 +82,7 @@ CBagMenu::CBagMenu() {
 CBagObject *CBagMenu::onNewSpriteObject(const CBofString &) {
 	CBagSpriteObject *pObj = new CBagSpriteObject();
 
-	CBofPoint pt(0, _nY);
+	const CBofPoint pt(0, _nY);
 	pObj->setPosition(pt);
 	pObj->setTransparent(false);
 
@@ -506,8 +506,8 @@ bool CBagMenu::deleteItem(const CBofString & /*sLabel*/) {
 }
 
 bool CBagMenu::isChecked(const CBofString & /*sLabel*/, const CBofString & /*sSubLabel*/) {
-	int nRow = 0;
-	int nCol = 0;
+	const int nRow = 0;
+	const int nCol = 0;
 
 	return isCheckedPos(nRow, nCol);
 }
@@ -618,7 +618,7 @@ void CBagMenuDlg::onLButtonUp(uint32 nFlags, CBofPoint *pPoint, void *) {
 			}
 
 		} else {
-			CBofPoint pt = devPtToViewPort(*pPoint);
+			const CBofPoint pt = devPtToViewPort(*pPoint);
 			_pSelectedObject = getObject(pt);
 			if (_pSelectedObject != nullptr) {
 				_pSelectedObject->onLButtonUp(nFlags, pPoint);
diff --git a/engines/bagel/baglib/menu_dlg.h b/engines/bagel/baglib/menu_dlg.h
index edbef5e1fd6..d635d2c51ae 100644
--- a/engines/bagel/baglib/menu_dlg.h
+++ b/engines/bagel/baglib/menu_dlg.h
@@ -60,7 +60,7 @@ public:
 	bool unCheck(const CBofString &sLabel, const CBofString &sSubLabel = CBofString());
 	bool unCheck(int nRefId);
 
-	bool trackPopupMenu(uint32 nFlags, int x, int y, CBofWindow *pWnd, CBofPalette *pPal, CBofRect *lpRect = 0);
+	bool trackPopupMenu(uint32 nFlags, int x, int y, CBofWindow *pWnd, CBofPalette *pPal, CBofRect *lpRect = nullptr);
 
 	static bool removeUniversalObjectList();
 	static bool setUniversalObjectList(CBofList<CBagObject *> *pObjList);
diff --git a/engines/bagel/baglib/moo.cpp b/engines/bagel/baglib/moo.cpp
index de0b89d277d..0ca824ae9e8 100644
--- a/engines/bagel/baglib/moo.cpp
+++ b/engines/bagel/baglib/moo.cpp
@@ -40,7 +40,7 @@ ErrorCode CBagMoo::update(CBofBitmap *pBmp, CBofPoint /*pt*/, CBofRect *pSrcRect
 
 	if (_pMovie) {
 		// Update the movie, assume only unzoomed pda right now
-		CBofPoint cPos(116, 61);
+		const CBofPoint cPos(116, 61);
 		errorCode = _pMovie->update(pBmp, cPos, pSrcRect, nMaskColor);
 
 		// If we're done or we encountered an error, then roll over and die.
@@ -69,7 +69,7 @@ ErrorCode CBagMoo::setPDAMovie(CBofString &s) {
 	_pMovie->setFileName(s);
 
 	// Attach this bad baby...
-	ErrorCode errorCode = _pMovie->attach();
+	const ErrorCode errorCode = _pMovie->attach();
 	if (errorCode == ERR_NONE) {
 		_pMovie->setModal(false);
 		_pMovie->setNumOfLoops(1);
diff --git a/engines/bagel/baglib/movie_object.cpp b/engines/bagel/baglib/movie_object.cpp
index e5edeaba10d..af0a88c1002 100644
--- a/engines/bagel/baglib/movie_object.cpp
+++ b/engines/bagel/baglib/movie_object.cpp
@@ -74,7 +74,7 @@ CBagMovieObject::~CBagMovieObject() {
 bool CBagMovieObject::runObject() {
 	CBofWindow *pNewWin = nullptr;
 	SBZoomPda *pPDAz = (SBZoomPda *)g_SDevManager->getStorageDevice("BPDAZ_WLD");
-	bool bZoomed = (pPDAz == nullptr ? false : pPDAz->getZoomed());
+	const bool bZoomed = (pPDAz == nullptr ? false : pPDAz->getZoomed());
 	
 	// Get a pointer to the current game window
 	CBagStorageDevWnd *pMainWin = CBagel::getBagApp()->getMasterWnd()->getCurrentStorageDev();
@@ -84,7 +84,7 @@ bool CBagMovieObject::runObject() {
 		rc = false;
 
 		CBofString sFileName = getFileName();
-		int nExt = sFileName.getLength() - 4; // ".EXT"
+		const int nExt = sFileName.getLength() - 4; // ".EXT"
 
 		if (nExt <= 0) {
 			logError("Movie does not have a file name or proper extension.  Please write better scripts.");
@@ -100,7 +100,7 @@ bool CBagMovieObject::runObject() {
 		                   SOUND = 2,
 		                   MOVIE = 3
 		                 } nMovFileType;
-		CBofString sBaseStr = sFileName.left(nExt);
+		const CBofString sBaseStr = sFileName.left(nExt);
 
 		if (sFileName.find(".smk") > 0 || sFileName.find(".SMK") > 0) {
 			nMovFileType = MovieFileType::MOVIE;
@@ -369,7 +369,7 @@ ParseCodes CBagMovieObject::setInfo(CBagIfstream &istr) {
 	while (!istr.eof()) {
 		istr.eatWhite(); // Eat any white space between script elements
 
-		char ch = (char)istr.peek();
+		const char ch = (char)istr.peek();
 		switch (ch) {
 		//
 		//  AS  - n number of slides in sprite
@@ -474,7 +474,7 @@ ParseCodes CBagMovieObject::setInfo(CBagIfstream &istr) {
 		//  No match return from funtion
 		//
 		default: {
-			ParseCodes parseCode = CBagObject::setInfo(istr);
+			const ParseCodes parseCode = CBagObject::setInfo(istr);
 			if (parseCode == PARSING_DONE) {
 				return PARSING_DONE;
 			}
diff --git a/engines/bagel/baglib/object.cpp b/engines/bagel/baglib/object.cpp
index 771b0d90862..e7add159001 100644
--- a/engines/bagel/baglib/object.cpp
+++ b/engines/bagel/baglib/object.cpp
@@ -212,7 +212,7 @@ ParseCodes CBagObject::setInfo(CBagIfstream &istr) {
 
 	while (!istr.eof()) {
 		istr.eatWhite();
-		char ch = (char)istr.getCh();
+		const char ch = (char)istr.getCh();
 		switch (ch) {
 		//
 		//  =filename.ext
@@ -255,7 +255,7 @@ ParseCodes CBagObject::setInfo(CBagIfstream &istr) {
 		//
 		case '^': {
 			parseCode = UPDATED_OBJECT;
-			char c = (char)istr.peek();
+			const char c = (char)istr.peek();
 			if (Common::isDigit(c)) {
 				int nId;
 				getIntFromStream(istr, nId);
@@ -280,7 +280,7 @@ ParseCodes CBagObject::setInfo(CBagIfstream &istr) {
 			break;
 		}
 		//
-		//  %cusror;  - Set cursor
+		//  %cursor;  - Set cursor
 		//
 		case '%': {
 			parseCode = UPDATED_OBJECT;
diff --git a/engines/bagel/baglib/paint_table.cpp b/engines/bagel/baglib/paint_table.cpp
index a36ba7fa4d7..32224b4dae5 100644
--- a/engines/bagel/baglib/paint_table.cpp
+++ b/engines/bagel/baglib/paint_table.cpp
@@ -40,7 +40,7 @@ void PaintTable::initialize(Common::SeekableReadStream &src) {
 			for (int pointNum = 0; pointNum < 10; ++pointNum, ++pointIndex) {
 				// Get the point
 				int y1 = 0, y2 = 0;
-				int result = sscanf(line.c_str(), "{ %d,%d}", &y1, &y2);
+				const int result = sscanf(line.c_str(), "{ %d,%d}", &y1, &y2);
 				assert(result == 2);
 
 				STRIP_POINTS[stripNum][pointIndex]._top = y1;




More information about the Scummvm-git-logs mailing list