[Scummvm-git-logs] scummvm master -> e06f7ebc3d778a387f5755b943ed9bffb854431c
Strangerke
noreply at scummvm.org
Thu May 30 05:19:51 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:
a5c034763c BAGEL: Remove null checks before delete, remove useless assignment
e06f7ebc3d BAGEL: Remove some useless initializations (value directly overwritten), reduce variable scopes
Commit: a5c034763c034f9550b61675ad0965fa3a8e3671
https://github.com/scummvm/scummvm/commit/a5c034763c034f9550b61675ad0965fa3a8e3671
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-30T06:10:52+01:00
Commit Message:
BAGEL: Remove null checks before delete, remove useless assignment
(without using non-portable functions this time)
Changed paths:
engines/bagel/baglib/moo.cpp
engines/bagel/baglib/movie_object.cpp
engines/bagel/baglib/pan_window.cpp
engines/bagel/baglib/parse_object.cpp
diff --git a/engines/bagel/baglib/moo.cpp b/engines/bagel/baglib/moo.cpp
index d822c2dcea7..de0b89d277d 100644
--- a/engines/bagel/baglib/moo.cpp
+++ b/engines/bagel/baglib/moo.cpp
@@ -59,13 +59,9 @@ CBagMoo::~CBagMoo() {
}
ErrorCode CBagMoo::setPDAMovie(CBofString &s) {
- ErrorCode errorCode = ERR_NONE;
-
// Should never happen, but just make sure.
- if (_pMovie) {
- delete _pMovie;
- _pMovie = nullptr;
- }
+ delete _pMovie;
+ _pMovie = nullptr;
// Get a new movie object
_pMovie = new CBagCharacterObject();
@@ -73,7 +69,7 @@ ErrorCode CBagMoo::setPDAMovie(CBofString &s) {
_pMovie->setFileName(s);
// Attach this bad baby...
- errorCode = _pMovie->attach();
+ 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 1930382fcf0..e5edeaba10d 100644
--- a/engines/bagel/baglib/movie_object.cpp
+++ b/engines/bagel/baglib/movie_object.cpp
@@ -72,7 +72,6 @@ CBagMovieObject::~CBagMovieObject() {
}
bool CBagMovieObject::runObject() {
- CBagPDA *pPDA = nullptr;
CBofWindow *pNewWin = nullptr;
SBZoomPda *pPDAz = (SBZoomPda *)g_SDevManager->getStorageDevice("BPDAZ_WLD");
bool bZoomed = (pPDAz == nullptr ? false : pPDAz->getZoomed());
@@ -146,7 +145,7 @@ bool CBagMovieObject::runObject() {
CBagStorageDevWnd *pSDevWnd = (pWnd ? pWnd->getCurrentStorageDev() : nullptr);
// Get the pda here, we need it so much anyway.
- pPDA = (CBagPDA *)g_SDevManager->getStorageDevice("BPDA_WLD");
+ CBagPDA *pPDA = (CBagPDA *)g_SDevManager->getStorageDevice("BPDA_WLD");
assert(pPDA != nullptr);
diff --git a/engines/bagel/baglib/pan_window.cpp b/engines/bagel/baglib/pan_window.cpp
index 4558d9dcc8e..3e8db2605d6 100644
--- a/engines/bagel/baglib/pan_window.cpp
+++ b/engines/bagel/baglib/pan_window.cpp
@@ -45,8 +45,6 @@ void CBagPanWindow::initialize() {
}
CBagPanWindow::CBagPanWindow() : CBagStorageDevWnd() {
- CBofRect tmpRect;
-
_xViewPortPos = CBofPoint(0, 20);
_xMovementRect.setRectEmpty();
@@ -258,8 +256,7 @@ ErrorCode CBagPanWindow::onRender(CBofBitmap *pBmp, CBofRect *pRect) {
if (isFiltered()) {
uint16 nFilterId = getFilterId();
- bool bFiltered = false;
- bFiltered = (*_pBitmapFilter)(nFilterId, pBmp, pRect);
+ bool bFiltered = (*_pBitmapFilter)(nFilterId, pBmp, pRect);
if (bFiltered) {
setPreFilterPan(true);
@@ -560,10 +557,8 @@ void CBagPanWindow::onMouseMove(uint32 nFlags, CBofPoint *p, void *) {
}
}
- CBagObject *pObj = getLActiveObject();
-
if (_bDraggingObject) {
- pObj = _pFGObjectList->getNodeItem(_pFGObjectList->getCount() - 1);
+ CBagObject *pObj = _pFGObjectList->getNodeItem(_pFGObjectList->getCount() - 1);
pObj->setPosition(xPoint);
}
diff --git a/engines/bagel/baglib/parse_object.cpp b/engines/bagel/baglib/parse_object.cpp
index 60420eea6d4..196d1ace4c0 100644
--- a/engines/bagel/baglib/parse_object.cpp
+++ b/engines/bagel/baglib/parse_object.cpp
@@ -32,7 +32,7 @@ CBagParseObject::CBagParseObject() {
}
int CBagParseObject::getIntFromStream(CBagIfstream &istr, int &nNum) {
- char ch = 0;
+ char ch;
char szLocalStr[256];
int i = 0;
Commit: e06f7ebc3d778a387f5755b943ed9bffb854431c
https://github.com/scummvm/scummvm/commit/e06f7ebc3d778a387f5755b943ed9bffb854431c
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-30T06:19:42+01:00
Commit Message:
BAGEL: Remove some useless initializations (value directly overwritten), reduce variable scopes
Changed paths:
engines/bagel/baglib/parse_object.h
engines/bagel/baglib/rp_object.cpp
engines/bagel/baglib/sprite_object.cpp
engines/bagel/baglib/storage_dev_win.cpp
diff --git a/engines/bagel/baglib/parse_object.h b/engines/bagel/baglib/parse_object.h
index 6b52824d116..b0eed723e5b 100644
--- a/engines/bagel/baglib/parse_object.h
+++ b/engines/bagel/baglib/parse_object.h
@@ -27,7 +27,6 @@
#include "bagel/boflib/error.h"
#include "bagel/boflib/rect.h"
#include "bagel/boflib/string.h"
-#include "bagel/boflib/vector.h"
namespace Bagel {
diff --git a/engines/bagel/baglib/rp_object.cpp b/engines/bagel/baglib/rp_object.cpp
index ab16d275f1e..7613e48ad40 100644
--- a/engines/bagel/baglib/rp_object.cpp
+++ b/engines/bagel/baglib/rp_object.cpp
@@ -532,9 +532,8 @@ int CBagRPObject::runResiduePrintedQueue() {
return 0;
}
- CBagRPObject *pRPObj = _pRPList->getNodeItem(0);
for (int i = 0; i < nCount; i++) {
- pRPObj = _pRPList->getNodeItem(i);
+ CBagRPObject *pRPObj = _pRPList->getNodeItem(i);
// This could fail if we are not initialized properly
if (pRPObj->_bInitialized == false) {
@@ -1498,10 +1497,9 @@ bool CBagRPObject::initialize() {
// Scoff the dossier out of the LOG_WLD SDEV. If it's not there then hurl.
bool bDoUntouched = (_pTouchedList != _pUntouchedList);
int nCount = _pTouchedList->getCount();
- DossierObj *pDosObj = nullptr;
for (int i = 0; i < nCount; i++) {
- pDosObj = _pTouchedList->getNodeItem(i);
+ DossierObj *pDosObj = _pTouchedList->getNodeItem(i);
pDosObj->_pDossier = (CBagDossierObject *)pSDev->getObject(pDosObj->_sDossier);
if (pDosObj->_pDossier == nullptr) {
return false;
@@ -1516,7 +1514,7 @@ bool CBagRPObject::initialize() {
if (bDoUntouched) {
nCount = _pUntouchedList->getCount();
for (int i = 0; i < nCount; i++) {
- pDosObj = _pUntouchedList->getNodeItem(i);
+ DossierObj *pDosObj = _pUntouchedList->getNodeItem(i);
pDosObj->_pDossier = (CBagDossierObject *)pSDev->getObject(pDosObj->_sDossier);
if (pDosObj->_pDossier == nullptr) {
return false;
@@ -1624,12 +1622,10 @@ CBagDossierObject *CBagRPObject::getActiveDossier() {
// Used to set the currently active dossier when one is displayed to the user.
void CBagRPObject::setActiveDossier(CBagDossierObject *pDosObj) {
CBofList<DossierObj *> *pDosList = (_bTouched ? _pTouchedList : _pUntouchedList);
- DossierObj *p = nullptr;
int nCount = pDosList->getCount();
-
for (int i = 0; i < nCount; i++) {
- p = pDosList->getNodeItem(i);
+ DossierObj *p = pDosList->getNodeItem(i);
if (p->_pDossier == pDosObj) {
_nCurDossier = i;
saveResiduePrintedVars();
@@ -1652,10 +1648,8 @@ DossierObj::~DossierObj() {
_pDossier = nullptr;
// Expressions, however, we do own
- if (_xDosExp) {
- delete _xDosExp;
- _xDosExp = nullptr;
- }
+ delete _xDosExp;
+ _xDosExp = nullptr;
}
} // namespace Bagel
diff --git a/engines/bagel/baglib/sprite_object.cpp b/engines/bagel/baglib/sprite_object.cpp
index 6b943251624..fcd164f5571 100644
--- a/engines/bagel/baglib/sprite_object.cpp
+++ b/engines/bagel/baglib/sprite_object.cpp
@@ -210,7 +210,6 @@ ParseCodes CBagSpriteObject::setInfo(CBagIfstream &istr) {
ErrorCode CBagSpriteObject::update(CBofBitmap *pBmp, CBofPoint pt, CBofRect * /*pSrcRect*/, int) {
if (_xSprite) {
- bool b = true;
int nFrameInterval = getFrameRate();
if (nFrameInterval != 0) {
@@ -223,12 +222,12 @@ ErrorCode CBagSpriteObject::update(CBofBitmap *pBmp, CBofPoint pt, CBofRect * /*
}
}
- b = _xSprite->paintSprite(pBmp, pt.x, pt.y);
+ bool bPaintResult = _xSprite->paintSprite(pBmp, pt.x, pt.y);
// Don't have to redraw this item...
// setDirty (false);
- if (!b)
+ if (!bPaintResult)
return ERR_UNKNOWN;
}
return ERR_NONE;
diff --git a/engines/bagel/baglib/storage_dev_win.cpp b/engines/bagel/baglib/storage_dev_win.cpp
index 5023103afcd..c997729e225 100644
--- a/engines/bagel/baglib/storage_dev_win.cpp
+++ b/engines/bagel/baglib/storage_dev_win.cpp
@@ -275,9 +275,6 @@ CBofPoint CBagStorageDev::arrangeFloater(CBofPoint nPos, CBagObject *pObj) {
CBofPoint NextPos = nPos;
if (getBackground() != nullptr) {
-
- int nPageNum = 0;
-
int nBackWidth = getBackground()->width();
int nBackHeight = getBackground()->height();
int nObjWidth = pObj->getRect().width();
@@ -292,7 +289,7 @@ CBofPoint CBagStorageDev::arrangeFloater(CBofPoint nPos, CBagObject *pObj) {
// Always round this figure up...
- nPageNum = ((NextPos.y + nObjHeight) / nBackHeight);
+ int nPageNum = ((NextPos.y + nObjHeight) / nBackHeight);
if (((NextPos.y + nObjHeight) % nBackHeight) != 0) {
nPageNum++;
}
More information about the Scummvm-git-logs
mailing list