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

Strangerke noreply at scummvm.org
Thu May 9 09:07:02 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:
aede2ba742 BAGEL: Remove some useless null check prior to delete, some renaming and cleanup


Commit: aede2ba7420eea7ae9568fe88e4cfeb13739dde5
    https://github.com/scummvm/scummvm/commit/aede2ba7420eea7ae9568fe88e4cfeb13739dde5
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-09T10:06:54+01:00

Commit Message:
BAGEL: Remove some useless null check prior to delete, some renaming and cleanup

Changed paths:
    engines/bagel/baglib/pan_bitmap.cpp
    engines/bagel/baglib/text_object.cpp
    engines/bagel/baglib/var.cpp
    engines/bagel/baglib/var.h
    engines/bagel/baglib/wield.h
    engines/bagel/baglib/zoom_pda.cpp
    engines/bagel/baglib/zoom_pda.h


diff --git a/engines/bagel/baglib/pan_bitmap.cpp b/engines/bagel/baglib/pan_bitmap.cpp
index 60fc4b830cc..5aa27d7794c 100644
--- a/engines/bagel/baglib/pan_bitmap.cpp
+++ b/engines/bagel/baglib/pan_bitmap.cpp
@@ -104,10 +104,8 @@ CBagPanBitmap::CBagPanBitmap(const char *pszFileName, CBofPalette *pPalette, con
 CBagPanBitmap::~CBagPanBitmap() {
 	assert(isValidObject(this));
 
-	if (_pCosineTable) {
-		delete[] _pCosineTable;
-		_pCosineTable = nullptr;
-	}
+	delete[] _pCosineTable;
+	_pCosineTable = nullptr;
 }
 
 // This must be updated whenever the size, view size, or correction width changes
diff --git a/engines/bagel/baglib/text_object.cpp b/engines/bagel/baglib/text_object.cpp
index 56d3bb70c16..fc45037119a 100644
--- a/engines/bagel/baglib/text_object.cpp
+++ b/engines/bagel/baglib/text_object.cpp
@@ -52,10 +52,9 @@ CBagTextObject::CBagTextObject() : CBagObject() {
 }
 
 CBagTextObject::~CBagTextObject() {
-	if (_psInitInfo != nullptr) {
-		delete _psInitInfo;
-		_psInitInfo = nullptr;
-	}
+	delete _psInitInfo;
+	_psInitInfo = nullptr;
+
 	CBagTextObject::detach();
 }
 
@@ -159,7 +158,7 @@ ErrorCode CBagTextObject::attach() {
 						}
 					}
 
-					bofFree(pTextBuff); // Changed from delete.
+					bofFree(pTextBuff);
 
 				} else {
 					reportError(ERR_MEMORY);
diff --git a/engines/bagel/baglib/var.cpp b/engines/bagel/baglib/var.cpp
index 98caaa008ef..e771181811e 100644
--- a/engines/bagel/baglib/var.cpp
+++ b/engines/bagel/baglib/var.cpp
@@ -203,7 +203,7 @@ CBagVarManager::~CBagVarManager() {
 		releaseVariables();
 		_xVarList.removeAll();
 
-		for (int i = 0; i < VAR_HTABLE_SIZE; i++) {
+		for (int i = 0; i < VAR_HASH_TABLE_SIZE; i++) {
 			_xVarHashList[i].removeAll();
 		}
 	}
@@ -214,7 +214,7 @@ static int HASHVAR(const char *p, int l) {
 	for (int j = 0; j < l; j++) {
 		h += p[j];
 	}
-	h %= VAR_HTABLE_SIZE;
+	h %= VAR_HASH_TABLE_SIZE;
 
 	return h;
 }
diff --git a/engines/bagel/baglib/var.h b/engines/bagel/baglib/var.h
index 55f5f9a6355..27a47148f2b 100644
--- a/engines/bagel/baglib/var.h
+++ b/engines/bagel/baglib/var.h
@@ -48,7 +48,7 @@ public:
 	CBagVar(const CBofString &sName, const CBofString &sValue, bool bAddToList);
 	virtual ~CBagVar();
 
-	ParseCodes setInfo(CBagIfstream &);
+	ParseCodes setInfo(CBagIfstream &) override;
 
 	const CBofString &getName() {
 		return _sVarName;
@@ -118,7 +118,7 @@ public:
 };
 
 //  This could be templated with the storage device manager
-#define VAR_HTABLE_SIZE 131
+#define VAR_HASH_TABLE_SIZE 131
 
 class CBagVarManager : public CBagParseObject, public CBofObject {
 private:
@@ -145,7 +145,7 @@ public:
 	}
 
 	// Use a hash table to lookup variables.
-	CBofList<CBagVar *> _xVarHashList[VAR_HTABLE_SIZE];
+	CBofList<CBagVar *> _xVarHashList[VAR_HASH_TABLE_SIZE];
 };
 
 } // namespace Bagel
diff --git a/engines/bagel/baglib/wield.h b/engines/bagel/baglib/wield.h
index 23c664775c7..b43d91e0b29 100644
--- a/engines/bagel/baglib/wield.h
+++ b/engines/bagel/baglib/wield.h
@@ -55,16 +55,16 @@ public:
 		_nWieldCursor = n;
 	}
 
-	virtual ErrorCode update(CBofBitmap *pBmp, CBofPoint pt, CBofRect *pSrcRect = nullptr, int nMaskColor = -1);
+	ErrorCode update(CBofBitmap *pBmp, CBofPoint pt, CBofRect *pSrcRect = nullptr, int nMaskColor = -1) override;
 
-	virtual ErrorCode loadFile(const CBofString &sFile);
-	virtual bool onObjInteraction(CBagObject *pObj, CBagStorageDev *pSDev);
+	ErrorCode loadFile(const CBofString &sFile) override;
+	bool onObjInteraction(CBagObject *pObj, CBagStorageDev *pSDev) override;
 
-	virtual ErrorCode attach();
-	virtual ErrorCode detach();
+	ErrorCode attach() override;
+	ErrorCode detach() override;
 
-	virtual ErrorCode activateLocalObject(CBagObject *pObj);
-	virtual ErrorCode deactivateLocalObject(CBagObject *pObj);
+	ErrorCode activateLocalObject(CBagObject *pObj) override;
+	ErrorCode deactivateLocalObject(CBagObject *pObj) override;
 };
 
 } // namespace Bagel
diff --git a/engines/bagel/baglib/zoom_pda.cpp b/engines/bagel/baglib/zoom_pda.cpp
index a0818b4a402..e269341a191 100644
--- a/engines/bagel/baglib/zoom_pda.cpp
+++ b/engines/bagel/baglib/zoom_pda.cpp
@@ -25,14 +25,13 @@
 #include "bagel/baglib/rp_object.h"
 #include "bagel/baglib/wield.h"
 #include "bagel/baglib/zoom_pda.h"
-#include "bagel/boflib/app.h"
 
 namespace Bagel {
 
-#define ZOOMMOOWLD      "MOOZ_WLD"
-#define ZOOMINVWLD      "INVZ_WLD"
-#define ZOOMMAPWLD      "MAPZ_WLD"
-#define ZOOMLOGWLD      "LOGZ_WLD"
+#define ZOOM_MOO_WLD      "MOOZ_WLD"
+#define ZOOM_INV_WLD      "INVZ_WLD"
+#define ZOOM_MAP_WLD      "MAPZ_WLD"
+#define ZOOM_LOG_WLD      "LOGZ_WLD"
 
 // Keep track of updates...
 static uint32 g_lZoomPDALastUpdate;
@@ -76,24 +75,21 @@ ErrorCode SBZoomPda::onRender(CBofBitmap *pBmp, CBofRect *pRect) {
 		paintStorageDevice(nullptr, pBmp, pRect);
 
 		// Paint the inventory or Map to backdrop
-		if (bUpdate) {
-			if (_curDisplay != nullptr) {
-				_curDisplay->update(pBmp, _curDisplay->getPosition(), pRect);
-			}
-		}
+		if (bUpdate && (_curDisplay != nullptr))
+			_curDisplay->update(pBmp, _curDisplay->getPosition(), pRect);
 	}
-
+	
 	return _errCode;
 }
 
 ErrorCode SBZoomPda::loadFile(const CBofString &sFile) {
-	ErrorCode error = CBagStorageDev::loadFile(sFile);
+	ErrorCode errorCode = CBagStorageDev::loadFile(sFile);
 	removeObject(_mooWnd);
 	removeObject(_invWnd);
 	removeObject(_mapWnd);
 	removeObject(_logWnd);
 
-	return error;
+	return errorCode;
 }
 
 ErrorCode SBZoomPda::detach() {
@@ -124,8 +120,8 @@ ErrorCode SBZoomPda::detach() {
 	// Since the regular PDA does not have a detach method (it doesn't get
 	// flushed out until you go to a flashback or quit the game), go through
 	// the entire list of RPO's (residue print objects) and restore the saved
-	// varible values.  We do this so that any values that were changed in
-	// the zoomed version are propagated down to the unzoomed pda.
+	// variable values.  We do this so that any values that were changed in
+	// the zoomed version are propagated down to the un-zoomed pda.
 
 	CBagRPObject::synchronizeResiduePrintedObjects(bLogZoomed);
 
@@ -142,7 +138,7 @@ ErrorCode SBZoomPda::attach() {
 	if (rc == ERR_NONE) {
 		CBagStorageDev *pSDev;
 		if (!_mooWnd) {
-			pSDev = g_SDevManager->getStorageDevice(ZOOMMOOWLD);
+			pSDev = g_SDevManager->getStorageDevice(ZOOM_MOO_WLD);
 
 			if (pSDev != nullptr) {
 				_mooWnd = (CBagStorageDevBmp *)pSDev;
@@ -157,7 +153,7 @@ ErrorCode SBZoomPda::attach() {
 		}
 
 		if (!_invWnd) {
-			pSDev = g_SDevManager->getStorageDevice(ZOOMINVWLD);
+			pSDev = g_SDevManager->getStorageDevice(ZOOM_INV_WLD);
 			if (pSDev != nullptr) {
 				_invWnd = (CBagStorageDevBmp *)pSDev;
 				_invWnd->setAssociateWnd(getAssociateWnd());
@@ -175,7 +171,7 @@ ErrorCode SBZoomPda::attach() {
 		}
 
 		if (!_mapWnd) {
-			pSDev = g_SDevManager->getStorageDevice(ZOOMMAPWLD);
+			pSDev = g_SDevManager->getStorageDevice(ZOOM_MAP_WLD);
 			if (pSDev != nullptr) {
 				_mapWnd = (CBagStorageDevBmp *)pSDev;
 				_mapWnd->setAssociateWnd(getAssociateWnd());
@@ -193,7 +189,7 @@ ErrorCode SBZoomPda::attach() {
 		}
 
 		if (!_logWnd) {
-			pSDev = g_SDevManager->getStorageDevice(ZOOMLOGWLD);
+			pSDev = g_SDevManager->getStorageDevice(ZOOM_LOG_WLD);
 			if (pSDev != nullptr) {
 				_logWnd = (CBagStorageDevBmp *)pSDev;
 				_logWnd->setAssociateWnd(getAssociateWnd());
diff --git a/engines/bagel/baglib/zoom_pda.h b/engines/bagel/baglib/zoom_pda.h
index ab565ca4493..aabb3eb793e 100644
--- a/engines/bagel/baglib/zoom_pda.h
+++ b/engines/bagel/baglib/zoom_pda.h
@@ -33,31 +33,31 @@ public:
 	/**
 	 * Constructor
 	 * @param pParent       Pointer to the parent window
-	 * @param xPoint        Upper-left corner of PDA in parent window
+	 * @param xRect         Pda in parent window
 	 * @param bActivated    State of PDA whe constructed (optional)
 	 */
 	SBZoomPda(CBofWindow *pParent = nullptr, const CBofRect &xRect = CBofRect(), bool bActivated = true);
 	static void initialize();
 
-	virtual ErrorCode attach();
-	virtual ErrorCode detach();
+	ErrorCode attach() override;
+	ErrorCode detach() override;
 
-	virtual ErrorCode loadFile(const CBofString &sFile);
-	virtual void onMouseMove(uint32 nFlags, CBofPoint *, void * = nullptr);
+	ErrorCode loadFile(const CBofString &sFile) override;
+	void onMouseMove(uint32 nFlags, CBofPoint *, void * = nullptr) override;
 
 	/**
 	 * Called to overload specific types of sprite objects
 	 * @retrn       Pointer to the new object
 	 */
-	CBagObject *onNewButtonObject(const CBofString &sInit);
+	CBagObject *onNewButtonObject(const CBofString &sInit) override;
 
-	virtual void onMainLoop();
+	void onMainLoop() override;
 
-	void onLButtonUp(uint32 nFlags, CBofPoint *xPoint, void * = nullptr);
-	virtual ErrorCode onRender(CBofBitmap *pBmp, CBofRect *pRect = nullptr);
+	void onLButtonUp(uint32 nFlags, CBofPoint *xPoint, void * = nullptr) override;
+	ErrorCode onRender(CBofBitmap *pBmp, CBofRect *pRect = nullptr) override;
 
-	virtual ErrorCode attachActiveObjects();
-	virtual ErrorCode detachActiveObjects();
+	ErrorCode attachActiveObjects() override;
+	ErrorCode detachActiveObjects() override;
 };
 
 } // namespace Bagel




More information about the Scummvm-git-logs mailing list