[Scummvm-git-logs] scummvm master -> 1e82d3dc7dc90e4284e700a9a759cd64231c515c
Strangerke
noreply at scummvm.org
Tue May 7 21:05:47 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:
1e82d3dc7d BAGEL: Reduce if block depth in CBagPDA::update() and runWaitingMovie(), fix 2 pointers to obsolete pointers (CID 154486
Commit: 1e82d3dc7dc90e4284e700a9a759cd64231c515c
https://github.com/scummvm/scummvm/commit/1e82d3dc7dc90e4284e700a9a759cd64231c515c
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-07T22:05:38+01:00
Commit Message:
BAGEL: Reduce if block depth in CBagPDA::update() and runWaitingMovie(), fix 2 pointers to obsolete pointers (CID 1544861)
Changed paths:
engines/bagel/baglib/pda.cpp
engines/bagel/baglib/storage_dev_win.cpp
engines/bagel/baglib/storage_dev_win.h
diff --git a/engines/bagel/baglib/pda.cpp b/engines/bagel/baglib/pda.cpp
index 53edcb9111b..15e887e0f2d 100644
--- a/engines/bagel/baglib/pda.cpp
+++ b/engines/bagel/baglib/pda.cpp
@@ -235,85 +235,88 @@ ErrorCode CBagPDA::update(CBofBitmap *pBmp, CBofPoint pt, CBofRect *pSrcRect, in
// Update the zoom button (it might need to blink).
handleZoomButton(false);
ErrorCode errCode = ERR_NONE;
- if (!_bHidePDA) {
- CBofRect *pr = pSrcRect;
-
- if (_activating) {
-
- CBofPoint loc = getPosition();
- _activating--;
-
- if (_activated) {
- if (loc.y > _activeHeight) {
- loc.y -= _moveDist;
- if (pSrcRect) {
- CBofRect r = *pSrcRect;
- pSrcRect->bottom += _moveDist;
- pr = &r;
- }
- }
- } else if (loc.y < _deactiveHeight) {
- loc.y += _moveDist;
+
+ if (_hidePdaFl)
+ return errCode;
+
+ CBofRect r;
+ CBofRect *pr = pSrcRect;
+
+ if (_activating) {
+
+ CBofPoint loc = getPosition();
+ _activating--;
+
+ if (_activated) {
+ if (loc.y > _activeHeight) {
+ loc.y -= _moveDist;
if (pSrcRect) {
- CBofRect r = *pSrcRect;
- pSrcRect->top -= _moveDist;
+ r = *pSrcRect;
+ pSrcRect->bottom += _moveDist;
pr = &r;
}
}
+ } else if (loc.y < _deactiveHeight) {
+ loc.y += _moveDist;
+ if (pSrcRect) {
+ r = *pSrcRect;
+ pSrcRect->top -= _moveDist;
+ pr = &r;
+ }
+ }
- setPosition(loc);
+ setPosition(loc);
- pt = loc;
- }
+ pt = loc;
+ }
- // We have gotten back from a zoom and we need to straighten up
- if (SBBasePda::_pdaMode == PDA_INV_MODE && _curDisplay != _invWnd) {
- showInventory();
+ // We have gotten back from a zoom and we need to straighten up
+ if (SBBasePda::_pdaMode == PDA_INV_MODE && _curDisplay != _invWnd) {
+ showInventory();
- } else if (SBBasePda::_pdaMode == PDA_MAP_MODE && _curDisplay != _mapWnd) {
+ } else if (SBBasePda::_pdaMode == PDA_MAP_MODE && _curDisplay != _mapWnd) {
- showMap();
- } else if (SBBasePda::_pdaMode == PDA_LOG_MODE && _curDisplay != _logWnd) {
- showLog();
- }
+ showMap();
+ } else if (SBBasePda::_pdaMode == PDA_LOG_MODE && _curDisplay != _logWnd) {
+ showLog();
+ }
- bool bUpdate = true;
- bool bIsMovieWaiting = isMovieWaiting();
- bool bMoviePlaying = false;
+ bool bUpdate = true;
+ bool bIsMovieWaiting = isMovieWaiting();
+ bool bMoviePlaying = false;
- if ((!isActivated()) && // Must be down
- ((_pdaMode == PDA_MAP_MODE) ||
- (bIsMovieWaiting && _pdaMode != PDA_MOO_MODE))) {
+ if ((!isActivated()) && // Must be down
+ ((_pdaMode == PDA_MAP_MODE) ||
+ (bIsMovieWaiting && _pdaMode != PDA_MOO_MODE))) {
- // Reset to reflect we know it happened
- setPreFiltered(false);
+ // Reset to reflect we know it happened
+ setPreFiltered(false);
- // Play the movie if it is ready.
- if (bIsMovieWaiting == true) {
- runWaitingMovie();
- }
- } else if (_pdaMode == PDA_MOO_MODE) {
- // If we're playing a pda movie, then make sure we continue to update.
- bMoviePlaying = true;
- bUpdate = true;
+ // Play the movie if it is ready.
+ if (bIsMovieWaiting == true) {
+ runWaitingMovie();
}
+ } else if (_pdaMode == PDA_MOO_MODE) {
+ // If we're playing a pda movie, then make sure we continue to update.
+ bMoviePlaying = true;
+ bUpdate = true;
+ }
- // If the official decree from on high has been given to update, do so!
- if (bUpdate) {
- errCode = CBagStorageDevBmp::update(pBmp, pt, pr, _nMaskColor);
- }
+ // If the official decree from on high has been given to update, do so!
+ if (bUpdate) {
+ errCode = CBagStorageDevBmp::update(pBmp, pt, pr, _nMaskColor);
+ }
- // If the PDA is activating then redraw our black background
- bool bWandAnimating = CBagCharacterObject::pdaWandAnimating();
+ // If the PDA is activating then redraw our black background
+ bool bWandAnimating = CBagCharacterObject::pdaWandAnimating();
- if (isActivating() || bWandAnimating || bMoviePlaying) {
- CBagStorageDevWnd *pMainWin = (CBagel::getBagApp()->getMasterWnd()->getCurrentStorageDev());
- ((CBagPanWindow *)pMainWin)->setPreFilterPan(true);
- } else if (!isActivated() && (SBBasePda::_pdaMode != PDA_MAP_MODE)) {
- // If it is not activated, then don't bother redrawing it or the objects
- // inside of it.
- setDirty(false);
- }
+ if (isActivating() || bWandAnimating || bMoviePlaying) {
+ CBagStorageDevWnd *pMainWin = (CBagel::getBagApp()->getMasterWnd()->getCurrentStorageDev());
+ ((CBagPanWindow *)pMainWin)->setPreFilterPan(true);
+ } else if (!isActivated() && (SBBasePda::_pdaMode != PDA_MAP_MODE)) {
+ // If it is not activated, then don't bother redrawing it or the objects
+ // inside of it.
+ setDirty(false);
}
return errCode;
@@ -412,10 +415,7 @@ void CBagPDA::onLButtonDown(uint32 nFlags, CBofPoint *xPoint, void *info) {
}
CBagObject *CBagPDA::onNewButtonObject(const CBofString &) {
- CBagButtonObject *PdaButtObj;
-
- PdaButtObj = new CBagButtonObject();
-
+ CBagButtonObject *PdaButtObj = new CBagButtonObject();
PdaButtObj->setCallBack(pdaButtonHandler, (SBBasePda *)this);
return PdaButtObj;
@@ -436,9 +436,7 @@ bool CBagPDA::paintFGObjects(CBofBitmap *pBmp) {
}
CBagObject *CBagPDA::onNewUserObject(const CBofString &sInit) {
- CBagTimeObject *pTimeObj;
-
- pTimeObj = nullptr;
+ CBagTimeObject *pTimeObj = nullptr;
if (sInit == "TIME") {
pTimeObj = new CBagTimeObject();
}
@@ -530,17 +528,19 @@ bool CBagPDA::isMovieWaiting() {
void CBagPDA::runWaitingMovie() {
// Will only run a movie if it is ready to be run
- if (_movieList) {
- int nCount = _movieList->getCount();
- if (nCount > 0) {
- for (int i = 0; i < nCount; i++) {
- CBagMovieObject *pMObj = _movieList->getNodeItem(i);
- if (pMObj->asynchPDAMovieCanPlay()) {
- _soundsPausedFl = true;
- CSound::pauseSounds(); // pause all sounds
- pMObj->runObject();
- removeFromMovieQueue(pMObj);
- }
+ if (!_movieList)
+ 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);
}
}
}
diff --git a/engines/bagel/baglib/storage_dev_win.cpp b/engines/bagel/baglib/storage_dev_win.cpp
index 26cf4b34d20..65bfff316e0 100644
--- a/engines/bagel/baglib/storage_dev_win.cpp
+++ b/engines/bagel/baglib/storage_dev_win.cpp
@@ -65,7 +65,7 @@ extern bool g_waitOKFl;
CBagEventSDev *CBagStorageDevWnd::_pEvtSDev = nullptr; // Pointer to the EventSDev
CBofPoint *CBagStorageDev::_xCursorLocation;
CBofRect *CBagStorageDev::gRepaintRect;
-bool CBagStorageDev::_bHidePDA = false;
+bool CBagStorageDev::_hidePdaFl = false;
bool CBagStorageDev::_bHandledUpEvent = false;
// Dirty object variables
@@ -88,7 +88,7 @@ void CBagStorageDev::initialize() {
_xCursorLocation = new CBofPoint();
gRepaintRect = new CBofRect();
- _bHidePDA = false;
+ _hidePdaFl = false;
_bHandledUpEvent = false;
_bPanPreFiltered = false;
diff --git a/engines/bagel/baglib/storage_dev_win.h b/engines/bagel/baglib/storage_dev_win.h
index 833a3d0e78f..30f1747fefd 100644
--- a/engines/bagel/baglib/storage_dev_win.h
+++ b/engines/bagel/baglib/storage_dev_win.h
@@ -108,7 +108,7 @@ protected:
static CBofPoint *_xCursorLocation; // Current cursor location in bmp.
static CBofRect *gRepaintRect;
static bool _bHandledUpEvent; // Hack to stop
- static bool _bHidePDA;
+ static bool _hidePdaFl;
FilterFunction _pBitmapFilter; // Pointer to the bitmap filter.
bool _bForiegnList : 1; // True if setObjectList has been called
More information about the Scummvm-git-logs
mailing list