[Scummvm-git-logs] scummvm master -> 74f2df71c30f4f1e0bb9419bedb8b6b222708212
bluegr
noreply at scummvm.org
Sun Jan 2 10:26:24 UTC 2022
This automated email contains information about 20 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
1ccf15f34a BURIED: Allow pausing the game in the demo version
781191166a BURIED: Move common code in playTransition() into a separate function
18a52a5850 BURIED: Pass global flag by reference to the SetFlagOnEntry() callback
13afbe2792 BURIED: Pass global flag by reference to the PlaySoundEnteringScene() callback
69c3fc4092 BURIED: Rewrite the pod and pod item flag logic in RetrieveFromPods()
b583326c5e BURIED: Pass global flag by reference to the GenericItemAcquire() callback
f750b97687 BURIED: Rewrite the head opened time code for the Mayan arrow god scene
1552759e62 BURIED: Improve code readability
ebf110d98f BURIED: Rewrite the handling of head flags for the arrow god scenes
fdf43e51ac BURIED: Pass global flag by ref to the ViewSingleTranslation() callback
259572f50b BURIED: Adapt hardcoded flag in the OpenFirstItemAcquire() callback
a900070a07 BURIED: Rewrite the post box slot flag logic in KitchenUnitPostBox
d2b3bbd968 BURIED: Adapt the global flag parameters in the rest of the callbacks
660ce11b10 BURIED: Rewrite the AI comment info data into an array
9c81f95440 BURIED: Add console command aicommentinfo
8a62864d28 BURIED: Remove offset access to globals in checkAICommentDependencies
654cf83018 BURIED: Rewrite the logic for biochip evidence access to global vars
3e595eedda BURIED: Adjust comments
c4d40efd72 BURIED: Add constant for the intro video filename
74f2df71c3 BURIED: Fix Arthur being visible after AI biochip is lost - bug #313193
Commit: 1ccf15f34ab0fec44f155828839862e6366945d3
https://github.com/scummvm/scummvm/commit/1ccf15f34ab0fec44f155828839862e6366945d3
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-02T12:20:46+02:00
Commit Message:
BURIED: Allow pausing the game in the demo version
Changed paths:
engines/buried/buried.cpp
diff --git a/engines/buried/buried.cpp b/engines/buried/buried.cpp
index 2c25af6d43b..6b83fe126ca 100644
--- a/engines/buried/buried.cpp
+++ b/engines/buried/buried.cpp
@@ -586,9 +586,6 @@ bool BuriedEngine::isControlDown() const {
}
void BuriedEngine::pauseGame() {
- if (isDemo())
- return;
-
// TODO: Would be nice to load the translated text from IDS_APP_MESSAGE_PAUSED_TEXT (9023)
GUI::MessageDialog dialog(_("Your game is now Paused. Click OK to continue."));
runDialog(dialog);
Commit: 781191166ab9fe53200b740b38c05d950954f428
https://github.com/scummvm/scummvm/commit/781191166ab9fe53200b740b38c05d950954f428
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-02T12:20:46+02:00
Commit Message:
BURIED: Move common code in playTransition() into a separate function
Changed paths:
engines/buried/scene_view.cpp
engines/buried/scene_view.h
diff --git a/engines/buried/scene_view.cpp b/engines/buried/scene_view.cpp
index 22bffc9edb9..99d593a734c 100644
--- a/engines/buried/scene_view.cpp
+++ b/engines/buried/scene_view.cpp
@@ -913,24 +913,28 @@ bool SceneViewWindow::timeSuitJump(int destination) {
return true;
}
+bool SceneViewWindow::moveToDestination(const DestinationScene &destinationData, int navFrame) {
+ if (navFrame >= 0) {
+ LocationStaticData destinationStaticData;
+ if (!getSceneStaticData(destinationData.destinationScene, destinationStaticData))
+ return false;
+
+ changeStillFrameMovie(_vm->getFilePath(destinationStaticData.location.timeZone, destinationStaticData.location.environment, SF_STILLS));
+
+ Graphics::Surface *newBackground = getStillFrameCopy(navFrame);
+ _vm->_gfx->crossBlit(_preBuffer, 0, 0, 432, 189, newBackground, 0, 0);
+ newBackground->free();
+ delete newBackground;
+ }
+ return true;
+}
+
bool SceneViewWindow::playTransition(const DestinationScene &destinationData, int navFrame) {
// Call the appropriate function for the transition type
switch (destinationData.transitionType) {
case TRANSITION_PUSH:
if (_vm->isControlDown()) {
- if (navFrame >= 0) {
- LocationStaticData destinationStaticData;
- if (!getSceneStaticData(destinationData.destinationScene, destinationStaticData))
- return false;
-
- changeStillFrameMovie(_vm->getFilePath(destinationStaticData.location.timeZone, destinationStaticData.location.environment, SF_STILLS));
-
- Graphics::Surface *newBackground = getStillFrameCopy(navFrame);
- _vm->_gfx->crossBlit(_preBuffer, 0, 0, 432, 189, newBackground, 0, 0);
- newBackground->free();
- delete newBackground;
- }
- return true;
+ return moveToDestination(destinationData, navFrame);
} else {
LocationStaticData destinationStaticData;
if (!getSceneStaticData(destinationData.destinationScene, destinationStaticData))
@@ -951,19 +955,7 @@ bool SceneViewWindow::playTransition(const DestinationScene &destinationData, in
}
case TRANSITION_WALK:
if (_vm->isControlDown()) {
- if (navFrame >= 0) {
- LocationStaticData destinationStaticData;
- if (!getSceneStaticData(destinationData.destinationScene, destinationStaticData))
- return false;
-
- changeStillFrameMovie(_vm->getFilePath(destinationStaticData.location.timeZone, destinationStaticData.location.environment, SF_STILLS));
-
- Graphics::Surface *newBackground = getStillFrameCopy(navFrame);
- _vm->_gfx->crossBlit(_preBuffer, 0, 0, 432, 189, newBackground, 0, 0);
- newBackground->free();
- delete newBackground;
- }
- return true;
+ return moveToDestination(destinationData, navFrame);
} else {
// The demo has a hardcoded door open sound
// This, and the code below the walkTransition call, are glue around the
@@ -998,19 +990,7 @@ bool SceneViewWindow::playTransition(const DestinationScene &destinationData, in
}
case TRANSITION_VIDEO:
if (_vm->isControlDown() && false) { // TODO: debug mode check (maybe?)
- if (navFrame >= 0) {
- LocationStaticData destinationStaticData;
- if (!getSceneStaticData(destinationData.destinationScene, destinationStaticData))
- return false;
-
- changeStillFrameMovie(_vm->getFilePath(destinationStaticData.location.timeZone, destinationStaticData.location.environment, SF_STILLS));
-
- Graphics::Surface *newBackground = getStillFrameCopy(navFrame);
- _vm->_gfx->crossBlit(_preBuffer, 0, 0, 432, 189, newBackground, 0, 0);
- newBackground->free();
- delete newBackground;
- }
- return true;
+ return moveToDestination(destinationData, navFrame);
} else {
return videoTransition(_currentScene->_staticData.location, destinationData, navFrame);
}
diff --git a/engines/buried/scene_view.h b/engines/buried/scene_view.h
index 340b95dccb8..7302d413712 100644
--- a/engines/buried/scene_view.h
+++ b/engines/buried/scene_view.h
@@ -209,6 +209,8 @@ private:
Common::Array<AnimEvent> getAnimationDatabase(int timeZone, int environment);
Common::Array<AIComment> getAICommentDatabase(int timeZone, int environment);
+ bool moveToDestination(const DestinationScene &destinationData, int navFrame);
+
// AI Lab
bool initializeAILabTimeZoneAndEnvironment(Window *viewWindow, int environment);
bool startAILabAmbient(int oldTimeZone, int oldEnvironment, int environment, bool fade);
Commit: 18a52a585046cfa069d4c2a9583ebfaf21e1bee6
https://github.com/scummvm/scummvm/commit/18a52a585046cfa069d4c2a9583ebfaf21e1bee6
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-02T12:20:47+02:00
Commit Message:
BURIED: Pass global flag by reference to the SetFlagOnEntry() callback
This reduces the usage of setGlobalFlagByte()
Changed paths:
engines/buried/environ/castle.cpp
engines/buried/environ/scene_common.cpp
engines/buried/environ/scene_common.h
diff --git a/engines/buried/environ/castle.cpp b/engines/buried/environ/castle.cpp
index 6bae492e97f..d2e16ed5d40 100644
--- a/engines/buried/environ/castle.cpp
+++ b/engines/buried/environ/castle.cpp
@@ -1153,6 +1153,9 @@ bool SceneViewWindow::checkCustomCastleAICommentDependencies(const Location &com
}
SceneBase *SceneViewWindow::constructCastleSceneObject(Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation) {
+ SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
+ GlobalFlags &globalFlags = sceneView->getGlobalFlags();
+
// Special scene for the trial version
if (_vm->isTrial())
return new TrialRecallScene(_vm, viewWindow, sceneStaticData, priorLocation);
@@ -1278,7 +1281,7 @@ SceneBase *SceneViewWindow::constructCastleSceneObject(Window *viewWindow, const
case 60:
return new MainWallCatapultService(_vm, viewWindow, sceneStaticData, priorLocation);
case 61:
- return new SetFlagOnEntry(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, cgMBCrossedMoat), 1);
+ return new SetFlagOnEntry(_vm, viewWindow, sceneStaticData, priorLocation, globalFlags.cgMBCrossedMoat, 1);
case 62:
return new MiddleBaileyFootprintCapture(_vm, viewWindow, sceneStaticData, priorLocation);
case 63:
@@ -1289,7 +1292,7 @@ SceneBase *SceneViewWindow::constructCastleSceneObject(Window *viewWindow, const
return new TreasureRoomSwordCapture(_vm, viewWindow, sceneStaticData, priorLocation);
case 66:
// Original incremented the flag each time, but it's expected that the code will never go above 1
- return new SetFlagOnEntry(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, cgViewedKeepPlans), 1);
+ return new SetFlagOnEntry(_vm, viewWindow, sceneStaticData, priorLocation, globalFlags.cgViewedKeepPlans, 1);
case 67:
return new ClickChangeSceneSetFlag(_vm, viewWindow, sceneStaticData, priorLocation, 10, 0, 376, 189, kCursorPutDown, 1, 6, 5, 1, 0, 0, TRANSITION_VIDEO, 5, -1, -1, offsetof(GlobalFlags, cgFoundChestPanel));
case 70:
@@ -1305,7 +1308,7 @@ SceneBase *SceneViewWindow::constructCastleSceneObject(Window *viewWindow, const
case 75:
return new DeliverLightMessage(_vm, viewWindow, sceneStaticData, priorLocation);
case 76:
- return new SetFlagOnEntry(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, cgSROpenedChest), 1);
+ return new SetFlagOnEntry(_vm, viewWindow, sceneStaticData, priorLocation, globalFlags.cgSROpenedChest, 1);
case 77:
return new ClickPlaySound(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, cgTSTriedDoorB), 14, kCursorFinger, 72, 0, 372, 189);
default:
diff --git a/engines/buried/environ/scene_common.cpp b/engines/buried/environ/scene_common.cpp
index 0a259355faa..337d279918c 100644
--- a/engines/buried/environ/scene_common.cpp
+++ b/engines/buried/environ/scene_common.cpp
@@ -442,10 +442,9 @@ int PlaySoundEnteringFromScene::postEnterRoom(Window *viewWindow, const Location
}
SetFlagOnEntry::SetFlagOnEntry(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int flagOffset, byte flagNewValue) :
+ byte &flag, byte flagNewValue) :
SceneBase(vm, viewWindow, sceneStaticData, priorLocation) {
- if (flagOffset >= 0)
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(flagOffset, flagNewValue);
+ flag = flagNewValue;
}
InteractiveNewsNetwork::InteractiveNewsNetwork(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
diff --git a/engines/buried/environ/scene_common.h b/engines/buried/environ/scene_common.h
index c6bd7ce0e6c..6711bcd564f 100644
--- a/engines/buried/environ/scene_common.h
+++ b/engines/buried/environ/scene_common.h
@@ -201,7 +201,7 @@ private:
class SetFlagOnEntry : public SceneBase {
public:
SetFlagOnEntry(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int flagOffset = -1, byte flagNewValue = 1);
+ byte &flag, byte flagNewValue);
};
class InteractiveNewsNetwork : public SceneBase {
Commit: 13afbe2792012e3f7bd206f34fd2e8b4f9a80cb6
https://github.com/scummvm/scummvm/commit/13afbe2792012e3f7bd206f34fd2e8b4f9a80cb6
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-02T12:20:47+02:00
Commit Message:
BURIED: Pass global flag by reference to the PlaySoundEnteringScene() callback
This reduces the usage of getGlobalFlagByte() and setGlobalFlagByte()
Changed paths:
engines/buried/environ/ai_lab.cpp
engines/buried/environ/da_vinci.cpp
engines/buried/environ/scene_common.cpp
engines/buried/environ/scene_common.h
diff --git a/engines/buried/environ/ai_lab.cpp b/engines/buried/environ/ai_lab.cpp
index 27f6e0be405..3d28470598b 100644
--- a/engines/buried/environ/ai_lab.cpp
+++ b/engines/buried/environ/ai_lab.cpp
@@ -3735,6 +3735,9 @@ bool SceneViewWindow::checkCustomSpaceStationAICommentDependencies(const Locatio
}
SceneBase *SceneViewWindow::constructAILabSceneObject(Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation) {
+ SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
+ GlobalFlags &globalFlags = sceneView->getGlobalFlags();
+
// Special scene for the trial version
if (_vm->isTrial())
return new TrialRecallScene(_vm, viewWindow, sceneStaticData, priorLocation);
@@ -3782,7 +3785,7 @@ SceneBase *SceneViewWindow::constructAILabSceneObject(Window *viewWindow, const
case 28:
return new PlayArthurOffsetCapacitance(_vm, viewWindow, sceneStaticData, priorLocation, 127, 4, 11, 1, 66, 241, 25);
case 30:
- return new PlaySoundEnteringScene(_vm, viewWindow, sceneStaticData, priorLocation, 5, offsetof(GlobalFlags, aiDBPlayedFirstArthur));
+ return new PlaySoundEnteringScene(_vm, viewWindow, sceneStaticData, priorLocation, 5, globalFlags.aiDBPlayedFirstArthur);
case 31:
return new SpaceDoor(_vm, viewWindow, sceneStaticData, priorLocation, 174, 70, 256, 152, 166, -1, 1, TRANSITION_VIDEO, 0, -1, -1);
case 32:
@@ -3792,11 +3795,11 @@ SceneBase *SceneViewWindow::constructAILabSceneObject(Window *viewWindow, const
case 35:
return new DockingBayPlaySoundEntering(_vm, viewWindow, sceneStaticData, priorLocation, 4);
case 36:
- return new PlaySoundEnteringScene(_vm, viewWindow, sceneStaticData, priorLocation, 6, offsetof(GlobalFlags, aiDBPlayedSecondArthur));
+ return new PlaySoundEnteringScene(_vm, viewWindow, sceneStaticData, priorLocation, 6, globalFlags.aiDBPlayedSecondArthur);
case 37:
- return new PlaySoundEnteringScene(_vm, viewWindow, sceneStaticData, priorLocation, 7, offsetof(GlobalFlags, aiDBPlayedThirdArthur));
+ return new PlaySoundEnteringScene(_vm, viewWindow, sceneStaticData, priorLocation, 7, globalFlags.aiDBPlayedThirdArthur);
case 38:
- return new PlaySoundEnteringScene(_vm, viewWindow, sceneStaticData, priorLocation, 8, offsetof(GlobalFlags, aiDBPlayedFourthArthur));
+ return new PlaySoundEnteringScene(_vm, viewWindow, sceneStaticData, priorLocation, 8, globalFlags.aiDBPlayedFourthArthur);
case 39:
return new DisableForwardMovement(_vm, viewWindow, sceneStaticData, priorLocation, 1);
case 40:
diff --git a/engines/buried/environ/da_vinci.cpp b/engines/buried/environ/da_vinci.cpp
index ac51fb68c95..db3a30d1fd2 100644
--- a/engines/buried/environ/da_vinci.cpp
+++ b/engines/buried/environ/da_vinci.cpp
@@ -2592,6 +2592,9 @@ bool SceneViewWindow::checkCustomDaVinciAICommentDependencies(const Location &co
}
SceneBase *SceneViewWindow::constructDaVinciSceneObject(Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation) {
+ SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
+ GlobalFlags &globalFlags = sceneView->getGlobalFlags();
+
// Special scene for the trial version
if (_vm->isTrial())
return new TrialRecallScene(_vm, viewWindow, sceneStaticData, priorLocation);
@@ -2751,7 +2754,7 @@ SceneBase *SceneViewWindow::constructDaVinciSceneObject(Window *viewWindow, cons
case 75:
return new ClickPlaySound(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, dsCYTriedElevator), 13, kCursorFinger, 140, 130, 432, 189);
case 76:
- return new PlaySoundEnteringScene(_vm, viewWindow, sceneStaticData, priorLocation, 12, offsetof(GlobalFlags, dsCTPlayedBallistaFalling));
+ return new PlaySoundEnteringScene(_vm, viewWindow, sceneStaticData, priorLocation, 12, globalFlags.dsCTPlayedBallistaFalling);
case 77:
return new CodexFormulaeNotify(_vm, viewWindow, sceneStaticData, priorLocation);
default:
diff --git a/engines/buried/environ/scene_common.cpp b/engines/buried/environ/scene_common.cpp
index 337d279918c..e3bf0436a20 100644
--- a/engines/buried/environ/scene_common.cpp
+++ b/engines/buried/environ/scene_common.cpp
@@ -208,16 +208,15 @@ int PlaySoundExitingFromSceneDeux::postExitRoom(Window *viewWindow, const Locati
}
PlaySoundEnteringScene::PlaySoundEnteringScene(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int soundFileNameID, int flagOffset) :
- SceneBase(vm, viewWindow, sceneStaticData, priorLocation) {
+ int soundFileNameID, byte &flag) :
+ SceneBase(vm, viewWindow, sceneStaticData, priorLocation), _flag(flag) {
_soundFileNameID = soundFileNameID;
- _flagOffset = flagOffset;
}
int PlaySoundEnteringScene::postEnterRoom(Window *viewWindow, const Location &priorLocation) {
- if (_flagOffset >= 0 && ((SceneViewWindow *)viewWindow)->getGlobalFlagByte(_flagOffset) == 0) {
+ if (_flag == 0) {
_vm->_sound->playSynchronousSoundEffect(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, _soundFileNameID));
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(_flagOffset, 1);
+ _flag = 1;
}
return SC_TRUE;
diff --git a/engines/buried/environ/scene_common.h b/engines/buried/environ/scene_common.h
index 6711bcd564f..debbbb30768 100644
--- a/engines/buried/environ/scene_common.h
+++ b/engines/buried/environ/scene_common.h
@@ -95,12 +95,12 @@ private:
class PlaySoundEnteringScene : public SceneBase {
public:
PlaySoundEnteringScene(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int soundFileNameID = -1, int flagOffset = -1);
+ int soundFileNameID, byte &flag);
int postEnterRoom(Window *viewWindow, const Location &priorLocation);
private:
int _soundFileNameID;
- int _flagOffset;
+ byte &_flag;
};
class ClickChangeScene : public SceneBase {
Commit: 69c3fc40924a38ca154f8b498f9cadce53662e29
https://github.com/scummvm/scummvm/commit/69c3fc40924a38ca154f8b498f9cadce53662e29
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-02T12:20:47+02:00
Commit Message:
BURIED: Rewrite the pod and pod item flag logic in RetrieveFromPods()
This simplifies the code significantly and reduces the usage of
getGlobalFlagByte() and setGlobalFlagByte()
Changed paths:
engines/buried/environ/alien.cpp
diff --git a/engines/buried/environ/alien.cpp b/engines/buried/environ/alien.cpp
index 39128e88945..75c02050c05 100644
--- a/engines/buried/environ/alien.cpp
+++ b/engines/buried/environ/alien.cpp
@@ -44,8 +44,8 @@ public:
RetrieveFromPods(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
int doorLeft = -1, int doorTop = -1, int doorRight = -1, int doorBottom = -1, int openAnim = -1, int openNormFrame = -1,
int popAnim = -1, int openPoppedAnim = -1, int openPoppedFrame = -1, int grabLeft = -1, int grabTop = -1, int grabRight = -1,
- int grabBottom = -1, int openEmptyAnim = -1, int openEmptyFrame = -1, int itemID = -1, int takenFlagOffset = -1,
- int podStatusFlagOffset = -1, int returnDepth = -1, int popSwordAnim = -1);
+ int grabBottom = -1, int openEmptyAnim = -1, int openEmptyFrame = -1, byte pod = 0, int itemID = -1, int returnDepth = -1,
+ int popSwordAnim = -1);
int mouseDown(Window *viewWindow, const Common::Point &pointLocation) override;
int mouseUp(Window *viewWindow, const Common::Point &pointLocation) override;
int draggingItem(Window *viewWindow, int itemID, const Common::Point &pointLocation, int itemFlags) override;
@@ -56,8 +56,6 @@ protected:
Common::Rect _openDoor;
Common::Rect _grabObject;
int _itemID;
- int _itemFlagOffset;
- int _podStatusFlagOffset;
int _openNormFrame;
int _openPoppedFrame;
int _openEmptyFrame;
@@ -68,19 +66,27 @@ protected:
int _popSwordAnim;
int _returnDepth;
bool _doorOpen;
+ byte _pod;
+ GlobalFlags &_globalFlags;
+
+ byte *podStatusFlag(byte pod);
+ byte *podItemFlag();
+ byte getPodStatus();
+ void setPodStatus(byte status);
+ void setPodStatus(byte pod, byte status);
+ byte getPodItemFlag();
+ void setPodItemFlag(byte value);
};
RetrieveFromPods::RetrieveFromPods(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
int doorLeft, int doorTop, int doorRight, int doorBottom, int openAnim, int openNormFrame,
int popAnim, int openPoppedAnim, int openPoppedFrame, int grabLeft, int grabTop, int grabRight,
- int grabBottom, int openEmptyAnim, int openEmptyFrame, int itemID, int takenFlagOffset,
- int podStatusFlagOffset, int returnDepth, int popSwordAnim) :
- SceneBase(vm, viewWindow, sceneStaticData, priorLocation) {
+ int grabBottom, int openEmptyAnim, int openEmptyFrame, byte pod, int itemID, int returnDepth, int popSwordAnim) :
+ SceneBase(vm, viewWindow, sceneStaticData, priorLocation),
+ _globalFlags(((SceneViewWindow *)viewWindow)->getGlobalFlags()) {
_openDoor = Common::Rect(doorLeft, doorTop, doorRight, doorBottom);
_grabObject = Common::Rect(grabLeft, grabTop, grabRight, grabBottom);
_itemID = itemID;
- _itemFlagOffset = takenFlagOffset;
- _podStatusFlagOffset = podStatusFlagOffset;
_openNormFrame = openNormFrame;
_openPoppedFrame = openPoppedFrame;
_openEmptyFrame = openEmptyFrame;
@@ -91,13 +97,79 @@ RetrieveFromPods::RetrieveFromPods(BuriedEngine *vm, Window *viewWindow, const L
_returnDepth = returnDepth;
_doorOpen = false;
_popSwordAnim = popSwordAnim;
+ _pod = pod;
+}
+
+byte *RetrieveFromPods::podStatusFlag(byte pod) {
+ switch (pod) {
+ case 1:
+ return &_globalFlags.asRBPodAStatus;
+ case 2:
+ return &_globalFlags.asRBPodBStatus;
+ case 3:
+ return &_globalFlags.asRBPodCStatus;
+ case 4:
+ return &_globalFlags.asRBPodDStatus;
+ case 5:
+ return &_globalFlags.asRBPodEStatus;
+ case 6:
+ return &_globalFlags.asRBPodFStatus;
+ default:
+ return nullptr;
+ }
+}
+
+byte RetrieveFromPods::getPodStatus() {
+ byte *flag = podStatusFlag(_pod);
+ return flag ? *flag : 0;
+}
+
+void RetrieveFromPods::setPodStatus(byte status) {
+ byte *flag = podStatusFlag(_pod);
+ if (flag)
+ *flag = status;
+}
+
+void RetrieveFromPods::setPodStatus(byte pod, byte status) {
+ byte *flag = podStatusFlag(pod);
+ if (flag)
+ *flag = status;
+}
+
+byte *RetrieveFromPods::podItemFlag() {
+ switch (_pod) {
+ case 1:
+ return &_globalFlags.asRBPodATakenEnvironCart;
+ case 2:
+ return &_globalFlags.asRBPodBTakenPuzzleBox;
+ case 3:
+ return &_globalFlags.asRBPodCTakenCodex;
+ case 4:
+ return &_globalFlags.asRBPodDTakenSculpture;
+ case 5:
+ return &_globalFlags.asRBPodETakenSword;
+ default:
+ // Cheese girl in pod 6 cannot be picked up
+ return nullptr;
+ }
+}
+
+byte RetrieveFromPods::getPodItemFlag() {
+ byte *flag = podItemFlag();
+ return flag ? *flag : 0;
+}
+
+void RetrieveFromPods::setPodItemFlag(byte value) {
+ byte *flag = podStatusFlag(_pod);
+ if (flag)
+ *flag = value;
}
int RetrieveFromPods::mouseDown(Window *viewWindow, const Common::Point &pointLocation) {
- if (_doorOpen && _grabObject.contains(pointLocation) && ((SceneViewWindow *)viewWindow)->getGlobalFlagByte(_podStatusFlagOffset) == 1 && ((SceneViewWindow *)viewWindow)->getGlobalFlagByte(_itemFlagOffset) == 0) {
+ if (_doorOpen && _grabObject.contains(pointLocation) && getPodStatus() == 1 && getPodItemFlag() == 0) {
_staticData.navFrameIndex = _openEmptyFrame;
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(_itemFlagOffset, 1);
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(_podStatusFlagOffset, 2);
+ setPodItemFlag(1);
+ setPodStatus(2);
// Begin dragging
Common::Point ptInventoryWindow = viewWindow->convertPointToGlobal(pointLocation);
@@ -116,7 +188,7 @@ int RetrieveFromPods::mouseUp(Window *viewWindow, const Common::Point &pointLoca
if (!_doorOpen && _openDoor.contains(pointLocation)) {
_doorOpen = true;
- switch (((SceneViewWindow *)viewWindow)->getGlobalFlagByte(_podStatusFlagOffset)) {
+ switch (getPodStatus()) {
case 0:
((SceneViewWindow *)viewWindow)->playSynchronousAnimation(_openAnim);
_staticData.navFrameIndex = _openNormFrame;
@@ -151,20 +223,20 @@ int RetrieveFromPods::mouseUp(Window *viewWindow, const Common::Point &pointLoca
int RetrieveFromPods::draggingItem(Window *viewWindow, int itemID, const Common::Point &pointLocation, int itemFlags) {
if (itemID == kItemExplosiveCharge || itemID == kItemRichardsSword) {
- if (_doorOpen && _openDoor.contains(pointLocation) && ((SceneViewWindow *)viewWindow)->getGlobalFlagByte(_podStatusFlagOffset) == 0)
+ if (_doorOpen && _openDoor.contains(pointLocation) && getPodStatus() == 0)
return 1;
return 0;
}
- if (itemID == _itemID && _doorOpen && _grabObject.contains(pointLocation) && ((SceneViewWindow *)viewWindow)->getGlobalFlagByte(_itemFlagOffset) == 1 && ((SceneViewWindow *)viewWindow)->getGlobalFlagByte(_podStatusFlagOffset) == 2)
+ if (itemID == _itemID && _doorOpen && _grabObject.contains(pointLocation) && getPodItemFlag() == 1 && getPodStatus() == 2)
return 1;
return 0;
}
int RetrieveFromPods::droppedItem(Window *viewWindow, int itemID, const Common::Point &pointLocation, int itemFlags) {
- if ((itemID == kItemExplosiveCharge || itemID == kItemRichardsSword) && _doorOpen && _openDoor.contains(pointLocation) && ((SceneViewWindow *)viewWindow)->getGlobalFlagByte(_podStatusFlagOffset) == 0) {
+ if ((itemID == kItemExplosiveCharge || itemID == kItemRichardsSword) && _doorOpen && _openDoor.contains(pointLocation) && getPodStatus() == 0) {
// Play the popping movie and change the still frame
if (itemID == kItemRichardsSword && _popSwordAnim >= 0)
((SceneViewWindow *)viewWindow)->playSynchronousAnimation(_popSwordAnim);
@@ -173,16 +245,12 @@ int RetrieveFromPods::droppedItem(Window *viewWindow, int itemID, const Common::
_staticData.navFrameIndex = _openPoppedFrame;
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(_podStatusFlagOffset, 1);
+ setPodStatus(1);
// If in walkthrough mode, open all the pods
- if (((SceneViewWindow *)viewWindow)->getGlobalFlags().generalWalkthroughMode == 1) {
- ((SceneViewWindow *)viewWindow)->getGlobalFlags().asRBPodAStatus = 1;
- ((SceneViewWindow *)viewWindow)->getGlobalFlags().asRBPodBStatus = 1;
- ((SceneViewWindow *)viewWindow)->getGlobalFlags().asRBPodCStatus = 1;
- ((SceneViewWindow *)viewWindow)->getGlobalFlags().asRBPodDStatus = 1;
- ((SceneViewWindow *)viewWindow)->getGlobalFlags().asRBPodEStatus = 1;
- ((SceneViewWindow *)viewWindow)->getGlobalFlags().asRBPodFStatus = 1;
+ if (_globalFlags.generalWalkthroughMode == 1) {
+ for (int i = 1; i <= 6; i++)
+ setPodStatus(i, 1);
}
// Explosive charge doesn't get returned
@@ -195,19 +263,19 @@ int RetrieveFromPods::droppedItem(Window *viewWindow, int itemID, const Common::
if (itemID == _itemID && _doorOpen) {
if (pointLocation.x == -1 && pointLocation.y == -1) {
- ((SceneViewWindow *)viewWindow)->getGlobalFlags().asTakenEvidenceThisTrip = 1;
+ _globalFlags.asTakenEvidenceThisTrip = 1;
InventoryWindow *invWindow = ((GameUIWindow *)viewWindow->getParent())->_inventoryWindow;
if (invWindow->isItemInInventory(kItemEnvironCart) && invWindow->isItemInInventory(kItemMayanPuzzleBox) && invWindow->isItemInInventory(kItemCodexAtlanticus) && invWindow->isItemInInventory(kItemInteractiveSculpture) && invWindow->isItemInInventory(kItemRichardsSword))
- ((SceneViewWindow *)viewWindow)->getGlobalFlags().scoreGotKrynnArtifacts = 1;
- } else if (_grabObject.contains(pointLocation) && ((SceneViewWindow *)viewWindow)->getGlobalFlagByte(_itemFlagOffset) == 1 && ((SceneViewWindow *)viewWindow)->getGlobalFlagByte(_podStatusFlagOffset) == 2) {
+ _globalFlags.scoreGotKrynnArtifacts = 1;
+ } else if (_grabObject.contains(pointLocation) && getPodItemFlag() == 1 && getPodStatus() == 2) {
// Change the still frame to reflect the return of the inventory item
_staticData.navFrameIndex = _openPoppedFrame;
viewWindow->invalidateWindow(false);
// Reset flags
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(_itemFlagOffset, 0);
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(_podStatusFlagOffset, 1);
+ setPodItemFlag(0);
+ setPodStatus(1);
return SIC_ACCEPT;
}
}
@@ -265,7 +333,7 @@ int RetrieveFromPods::specifyCursor(Window *viewWindow, const Common::Point &poi
if (_openDoor.contains(pointLocation) && !_doorOpen)
return kCursorFinger;
- if (_grabObject.contains(pointLocation) && _itemFlagOffset >= 0 && ((SceneViewWindow *)viewWindow)->getGlobalFlagByte(_podStatusFlagOffset) == 1 && ((SceneViewWindow *)viewWindow)->getGlobalFlagByte(_itemFlagOffset) == 0)
+ if (_grabObject.contains(pointLocation) && getPodStatus() == 1 && getPodItemFlag() == 0)
return kCursorOpenHand;
if (_returnDepth >= 0)
@@ -981,11 +1049,11 @@ public:
};
CheeseGirlPod::CheeseGirlPod(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation) :
- RetrieveFromPods(vm, viewWindow, sceneStaticData, priorLocation, 128, 0, 352, 189, 20, 76, 21, 22, 77, 170, 54, 252, 156, 23, 78, -1, -1, offsetof(GlobalFlags, asRBPodFStatus), 0, 28) {
+ RetrieveFromPods(vm, viewWindow, sceneStaticData, priorLocation, 128, 0, 352, 189, 20, 76, 21, 22, 77, 170, 54, 252, 156, 23, 78, 6, -1, 0, 28) {
}
int CheeseGirlPod::mouseDown(Window *viewWindow, const Common::Point &pointLocation) {
- if (_doorOpen && _grabObject.contains(pointLocation) && ((SceneViewWindow *)viewWindow)->getGlobalFlagByte(_podStatusFlagOffset) == 1) {
+ if (_doorOpen && _grabObject.contains(pointLocation) && getPodStatus() == 1) {
((SceneViewWindow *)viewWindow)->playSynchronousAnimation(23);
return SC_TRUE;
}
@@ -998,7 +1066,7 @@ int CheeseGirlPod::specifyCursor(Window *viewWindow, const Common::Point &pointL
return kCursorFinger;
// If we're over the grab region, use the finger cursor so we can click on Frank
- if (_grabObject.contains(pointLocation) && ((SceneViewWindow *)viewWindow)->getGlobalFlagByte(_podStatusFlagOffset) == 1)
+ if (_grabObject.contains(pointLocation) && getPodStatus() == 1)
return kCursorFinger;
if (_returnDepth >= 0)
@@ -1085,17 +1153,15 @@ int TransporterStatusRead::specifyCursor(Window *viewWindow, const Common::Point
bool SceneViewWindow::initializeAlienTimeZoneAndEnvironment(Window *viewWindow, int environment) {
if (environment == -1) {
- GlobalFlags &flags = ((SceneViewWindow *)viewWindow)->getGlobalFlags();
-
- flags.asInitialGuardsPass = 0;
- flags.asRBPodAStatus = 0;
- flags.asRBPodBStatus = 0;
- flags.asRBPodCStatus = 0;
- flags.asRBPodDStatus = 0;
- flags.asRBPodEStatus = 0;
- flags.asRBPodFStatus = 0;
+ _globalFlags.asInitialGuardsPass = 0;
+ _globalFlags.asRBPodAStatus = 0;
+ _globalFlags.asRBPodBStatus = 0;
+ _globalFlags.asRBPodCStatus = 0;
+ _globalFlags.asRBPodDStatus = 0;
+ _globalFlags.asRBPodEStatus = 0;
+ _globalFlags.asRBPodFStatus = 0;
} else if (environment == 1) {
- ((SceneViewWindow *)viewWindow)->getGlobalFlags().scoreTransportToKrynn = 1;
+ _globalFlags.scoreTransportToKrynn = 1;
}
return true;
@@ -1138,19 +1204,19 @@ SceneBase *SceneViewWindow::constructAlienSceneObject(Window *viewWindow, const
case 13:
return new EntryWithoutLensFilter(_vm, viewWindow, sceneStaticData, priorLocation);
case 20:
- return new RetrieveFromPods(_vm, viewWindow, sceneStaticData, priorLocation, 172, 46, 272, 166, 0, 61, 1, 2, 62, 198, 78, 248, 116, 3, 63, kItemEnvironCart, offsetof(GlobalFlags, asRBPodATakenEnvironCart), offsetof(GlobalFlags, asRBPodAStatus), -1, 29);
+ return new RetrieveFromPods(_vm, viewWindow, sceneStaticData, priorLocation, 172, 46, 272, 166, 0, 61, 1, 2, 62, 198, 78, 248, 116, 3, 63, 1, kItemEnvironCart, -1, 29);
case 21:
return new DoubleZoomIn(_vm, viewWindow, sceneStaticData, priorLocation, 240, 88, 300, 178, 1, 100, 0, 160, 98, 2);
case 22:
- return new RetrieveFromPods(_vm, viewWindow, sceneStaticData, priorLocation, 150, 0, 394, 189, 4, 64, 5, 6, 65, 190, 74, 312, 142, 7, 66, kItemMayanPuzzleBox, offsetof(GlobalFlags, asRBPodBTakenPuzzleBox), offsetof(GlobalFlags, asRBPodBStatus), 0, 25);
+ return new RetrieveFromPods(_vm, viewWindow, sceneStaticData, priorLocation, 150, 0, 394, 189, 4, 64, 5, 6, 65, 190, 74, 312, 142, 7, 66, 2, kItemMayanPuzzleBox, 0, 25);
case 23:
- return new RetrieveFromPods(_vm, viewWindow, sceneStaticData, priorLocation, 140, 8, 274, 189, 8, 67, 9, 10, 68, 176, 42, 232, 124, 11, 69, kItemCodexAtlanticus, offsetof(GlobalFlags, asRBPodCTakenCodex), offsetof(GlobalFlags, asRBPodCStatus), 0, 26);
+ return new RetrieveFromPods(_vm, viewWindow, sceneStaticData, priorLocation, 140, 8, 274, 189, 8, 67, 9, 10, 68, 176, 42, 232, 124, 11, 69, 3, kItemCodexAtlanticus, 0, 26);
case 24:
- return new RetrieveFromPods(_vm, viewWindow, sceneStaticData, priorLocation, 100, 0, 280, 189, 12, 70, 13, 14, 71, 146, 60, 252, 156, 15, 72, kItemInteractiveSculpture, offsetof(GlobalFlags, asRBPodDTakenSculpture), offsetof(GlobalFlags, asRBPodDStatus), -1, 27);
+ return new RetrieveFromPods(_vm, viewWindow, sceneStaticData, priorLocation, 100, 0, 280, 189, 12, 70, 13, 14, 71, 146, 60, 252, 156, 15, 72, 4, kItemInteractiveSculpture, -1, 27);
case 25:
return new DoubleZoomIn(_vm, viewWindow, sceneStaticData, priorLocation, 256, 0, 322, 100, 1, 106, 84, 172, 189, 2);
case 26:
- return new RetrieveFromPods(_vm, viewWindow, sceneStaticData, priorLocation, 134, 0, 276, 189, 16, 73, 17, 18, 74, 190, 4, 224, 166, 19, 75, kItemRichardsSword, offsetof(GlobalFlags, asRBPodETakenSword), offsetof(GlobalFlags, asRBPodEStatus), 0);
+ return new RetrieveFromPods(_vm, viewWindow, sceneStaticData, priorLocation, 134, 0, 276, 189, 16, 73, 17, 18, 74, 190, 4, 224, 166, 19, 75, 5, kItemRichardsSword, 0);
case 27:
return new CheeseGirlPod(_vm, viewWindow, sceneStaticData, priorLocation);
case 30:
Commit: b583326c5e48f0d4927238745eb9a5db39685569
https://github.com/scummvm/scummvm/commit/b583326c5e48f0d4927238745eb9a5db39685569
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-02T12:20:48+02:00
Commit Message:
BURIED: Pass global flag by reference to the GenericItemAcquire() callback
This reduces the usage of getGlobalFlagByte() and setGlobalFlagByte()
Changed paths:
engines/buried/environ/agent3_lair.cpp
engines/buried/environ/castle.cpp
engines/buried/environ/da_vinci.cpp
engines/buried/environ/future_apartment.cpp
engines/buried/environ/mayan.cpp
engines/buried/environ/scene_common.cpp
engines/buried/environ/scene_common.h
diff --git a/engines/buried/environ/agent3_lair.cpp b/engines/buried/environ/agent3_lair.cpp
index d9b44018010..f9d26fe6d7d 100644
--- a/engines/buried/environ/agent3_lair.cpp
+++ b/engines/buried/environ/agent3_lair.cpp
@@ -970,12 +970,15 @@ bool SceneViewWindow::startAgent3LairAmbient(int oldTimeZone, int oldEnvironment
}
SceneBase *SceneViewWindow::constructAgent3LairSceneObject(Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation) {
+ SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
+ GlobalFlags &globalFlags = sceneView->getGlobalFlags();
+
switch (sceneStaticData.classID) {
case 0:
// Default scene
break;
case 1:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 177, 96, 231, 184, kItemGeneratorCore, 15, offsetof(GlobalFlags, alRDTakenLiveCore));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 177, 96, 231, 184, kItemGeneratorCore, 15, globalFlags.alRDTakenLiveCore);
case 2:
return new GeneratorCoreZoom(_vm, viewWindow, sceneStaticData, priorLocation);
case 3:
diff --git a/engines/buried/environ/castle.cpp b/engines/buried/environ/castle.cpp
index d2e16ed5d40..b339d48ec1d 100644
--- a/engines/buried/environ/castle.cpp
+++ b/engines/buried/environ/castle.cpp
@@ -1203,13 +1203,13 @@ SceneBase *SceneViewWindow::constructCastleSceneObject(Window *viewWindow, const
case 21:
return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, cgHookPresent), 0, 1, 0, 0, 0);
case 22:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 163, 83, 236, 162, kItemGrapplingHook, 75, offsetof(GlobalFlags, cgHookPresent));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 163, 83, 236, 162, kItemGrapplingHook, 75, globalFlags.cgHookPresent);
case 23:
return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, cgArrowPresent), 0, 0, 1, 0, 0);
case 24:
return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, cgArrowPresent), 0, 1, 0, 0, 0);
case 25:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 241, 7, 284, 92, kItemBloodyArrow, 57, offsetof(GlobalFlags, cgArrowPresent));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 241, 7, 284, 92, kItemBloodyArrow, 57, globalFlags.cgArrowPresent);
case 26:
if (_vm->isDemo())
return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, cgHammerPresent), 0, 0, 1, 0, 0);
@@ -1220,7 +1220,7 @@ SceneBase *SceneViewWindow::constructCastleSceneObject(Window *viewWindow, const
else
return new PlaySoundExitingFromScene(_vm, viewWindow, sceneStaticData, priorLocation, 14);
case 28:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 184, 111, 237, 189, kItemHammer, 3, offsetof(GlobalFlags, cgHammerPresent));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 184, 111, 237, 189, kItemHammer, 3, globalFlags.cgHammerPresent);
case 29:
if (_vm->isDemo())
return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, cgHammerPresent), 0, 0, 0, 1, 0);
@@ -1240,7 +1240,7 @@ SceneBase *SceneViewWindow::constructCastleSceneObject(Window *viewWindow, const
case 36:
return new ClickPlayVideoSwitch(_vm, viewWindow, sceneStaticData, priorLocation, 4, kCursorFinger, offsetof(GlobalFlags, cgTapestryFlag), 0, 0, 330, 189);
case 37:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 175, 64, 237, 126, kItemBurnedLetter, 84, offsetof(GlobalFlags, cgBurnedLetterPresent));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 175, 64, 237, 126, kItemBurnedLetter, 84, globalFlags.cgBurnedLetterPresent);
case 38:
return new StorageRoomCheckUnlock(_vm, viewWindow, sceneStaticData, priorLocation, kItemCopperKey, 51, 1, 2, 1, 258, 100, 320, 185);
case 39:
diff --git a/engines/buried/environ/da_vinci.cpp b/engines/buried/environ/da_vinci.cpp
index db3a30d1fd2..0eb321b4b9a 100644
--- a/engines/buried/environ/da_vinci.cpp
+++ b/engines/buried/environ/da_vinci.cpp
@@ -991,7 +991,7 @@ public:
};
CodexTowerGrabLens::CodexTowerGrabLens(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation) :
- GenericItemAcquire(vm, viewWindow, sceneStaticData, priorLocation, 200, 78, 262, 123, kItemLensFilter, 169, offsetof(GlobalFlags, dsCTRetrievedLens)) {
+ GenericItemAcquire(vm, viewWindow, sceneStaticData, priorLocation, 200, 78, 262, 123, kItemLensFilter, 169, ((SceneViewWindow *)viewWindow)->getGlobalFlags().dsCTRetrievedLens) {
}
int CodexTowerGrabLens::droppedItem(Window *viewWindow, int itemID, const Common::Point &pointLocation, int itemFlags) {
@@ -2666,9 +2666,9 @@ SceneBase *SceneViewWindow::constructDaVinciSceneObject(Window *viewWindow, cons
case 31:
return new ClickChangeScene(_vm, viewWindow, sceneStaticData, priorLocation, 0, 0, 432, 189, kCursorPutDown, 5, 4, 7, 3, 1, 0, TRANSITION_VIDEO, 12, -1, -1);
case 32:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 158, 90, 328, 162, kItemDriveAssembly, 145, offsetof(GlobalFlags, dsWSPickedUpGearAssembly));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 158, 90, 328, 162, kItemDriveAssembly, 145, globalFlags.dsWSPickedUpGearAssembly);
case 33:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 164, 126, 276, 160, kItemWoodenPegs, 96, offsetof(GlobalFlags, dsWSPickedUpPegs));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 164, 126, 276, 160, kItemWoodenPegs, 96, globalFlags.dsWSPickedUpPegs);
case 34:
return new WheelAssemblyItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 150, 150, 276, 189, kItemWheelAssembly, 100);
case 35:
@@ -2678,7 +2678,7 @@ SceneBase *SceneViewWindow::constructDaVinciSceneObject(Window *viewWindow, cons
case 37:
return new SiegeCycleTopView(_vm, viewWindow, sceneStaticData, priorLocation);
case 38:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 130, 74, 182, 120, kItemCoilOfRope, 48, offsetof(GlobalFlags, dsGDTakenCoilOfRope));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 130, 74, 182, 120, kItemCoilOfRope, 48, globalFlags.dsGDTakenCoilOfRope);
case 39:
return new UnlockCodexTowerDoor(_vm, viewWindow, sceneStaticData, priorLocation);
case 40:
diff --git a/engines/buried/environ/future_apartment.cpp b/engines/buried/environ/future_apartment.cpp
index f18e97779bc..b861e25e36e 100644
--- a/engines/buried/environ/future_apartment.cpp
+++ b/engines/buried/environ/future_apartment.cpp
@@ -1958,6 +1958,9 @@ bool SceneViewWindow::startFutureApartmentAmbient(int oldTimeZone, int oldEnviro
}
SceneBase *SceneViewWindow::constructFutureApartmentSceneObject(Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation) {
+ SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
+ GlobalFlags &globalFlags = sceneView->getGlobalFlags();
+
switch (sceneStaticData.classID) {
case 0:
// Default scene
@@ -1983,11 +1986,11 @@ SceneBase *SceneViewWindow::constructFutureApartmentSceneObject(Window *viewWind
case 10:
return new KitchenUnitAutoChef(_vm, viewWindow, sceneStaticData, priorLocation);
case 11:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 200, 83, 230, 116, kItemBioChipTranslate, 61, offsetof(GlobalFlags, faKITakenPostboxItem));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 200, 83, 230, 116, kItemBioChipTranslate, 61, globalFlags.faKITakenPostboxItem);
case 12:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 202, 80, 227, 155, kItemCheeseGirl, 59, offsetof(GlobalFlags, faKITakenPostboxItem));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 202, 80, 227, 155, kItemCheeseGirl, 59, globalFlags.faKITakenPostboxItem);
case 13:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 203, 111, 225, 129, kItemGenoSingleCart, 63, offsetof(GlobalFlags, faKITakenPostboxItem));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 203, 111, 225, 129, kItemGenoSingleCart, 63, globalFlags.faKITakenPostboxItem);
case 15:
return new ClickChangeScene(_vm, viewWindow, sceneStaticData, priorLocation, 134, 0, 300, 189, kCursorFinger, 4, 2, 2, 0, 1, 1, TRANSITION_VIDEO, 0, -1, -1);
case 16:
@@ -2005,7 +2008,7 @@ SceneBase *SceneViewWindow::constructFutureApartmentSceneObject(Window *viewWind
case 22:
return new InteractiveNewsNetwork(_vm, viewWindow, sceneStaticData, priorLocation, -1, 4, 2, 2, 0, 1, 1, TRANSITION_VIDEO, 4, -1, -1);
case 23:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 81, 146, 134, 189, kItemRemoteControl, 45, offsetof(GlobalFlags, faERTakenRemoteControl));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 81, 146, 134, 189, kItemRemoteControl, 45, globalFlags.faERTakenRemoteControl);
case 24:
return new FlagChangeBackground(_vm, viewWindow, sceneStaticData, priorLocation, 1, 33);
case 25:
diff --git a/engines/buried/environ/mayan.cpp b/engines/buried/environ/mayan.cpp
index 917e8bf28e3..6a0e428f938 100644
--- a/engines/buried/environ/mayan.cpp
+++ b/engines/buried/environ/mayan.cpp
@@ -2507,6 +2507,9 @@ bool SceneViewWindow::checkCustomMayanAICommentDependencies(const Location &comm
}
SceneBase *SceneViewWindow::constructMayanSceneObject(Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation) {
+ SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
+ GlobalFlags &globalFlags = sceneView->getGlobalFlags();
+
// Special scene for the trial version
if (_vm->isTrial())
return new TrialRecallScene(_vm, viewWindow, sceneStaticData, priorLocation);
@@ -2518,7 +2521,7 @@ SceneBase *SceneViewWindow::constructMayanSceneObject(Window *viewWindow, const
case 1:
return new VideoDeath(_vm, viewWindow, sceneStaticData, priorLocation, 10, IDS_HUMAN_PRESENCE_500METERS);
case 2:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 60, 134, 118, 180, kItemCeramicBowl, 96, offsetof(GlobalFlags, myPickedUpCeramicBowl));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 60, 134, 118, 180, kItemCeramicBowl, 96, globalFlags.myPickedUpCeramicBowl);
case 3:
return new PlaceCeramicBowl(_vm, viewWindow, sceneStaticData, priorLocation);
case 4:
@@ -2540,7 +2543,7 @@ SceneBase *SceneViewWindow::constructMayanSceneObject(Window *viewWindow, const
case 12:
return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYTP_OUTER_NORTH_TRANS_TEXT, 6, 38, 428, 76, offsetof(GlobalFlags, myTPTextTranslated));
case 13:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 140, 124, 174, 158, kItemCavernSkull, 3, offsetof(GlobalFlags, myMCPickedUpSkull));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 140, 124, 174, 158, kItemCavernSkull, 3, globalFlags.myMCPickedUpSkull);
case 14:
return new GenericCavernDoorMainView(_vm, viewWindow, sceneStaticData, priorLocation, 1, 126, 1, 306, 30, 2, 287, 30, 379, 82, 3, 275, 84, 401, 174);
case 15:
@@ -2576,11 +2579,11 @@ SceneBase *SceneViewWindow::constructMayanSceneObject(Window *viewWindow, const
case 30:
return new WealthGodRopeDrop(_vm, viewWindow, sceneStaticData, priorLocation);
case 31:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 194, 106, 278, 126, kItemJadeBlock, 105, offsetof(GlobalFlags, myWGRetrievedJadeBlock));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 194, 106, 278, 126, kItemJadeBlock, 105, globalFlags.myWGRetrievedJadeBlock);
case 32:
return new BasicDoor(_vm, viewWindow, sceneStaticData, priorLocation, 140, 22, 306, 189, 2, 3, 0, 3, 1, 1, TRANSITION_WALK, -1, 264, 14, 14);
case 33:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 158, 88, 288, 116, kItemLimestoneBlock, 84, offsetof(GlobalFlags, myWTRetrievedLimestoneBlock));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 158, 88, 288, 116, kItemLimestoneBlock, 84, globalFlags.myWTRetrievedLimestoneBlock);
case 34:
return new BasicDoor(_vm, viewWindow, sceneStaticData, priorLocation, 80, 0, 332, 189, 2, 4, 0, 2, 1, 1, TRANSITION_WALK, -1, 401, 14, 14);
case 35:
@@ -2612,13 +2615,13 @@ SceneBase *SceneViewWindow::constructMayanSceneObject(Window *viewWindow, const
case 50:
return new BasicDoor(_vm, viewWindow, sceneStaticData, priorLocation,106, 0, 294, 189, 2, 5, 0, 1, 1, 1, TRANSITION_WALK, -1, 427, 13, 11);
case 51:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 235, 144, 285, 181, kItemEntrySkull, 3, offsetof(GlobalFlags, myAGRetrievedEntrySkull));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 235, 144, 285, 181, kItemEntrySkull, 3, globalFlags.myAGRetrievedEntrySkull);
case 52:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 200, 138, 231, 185, kItemSpearSkull, 46, offsetof(GlobalFlags, myAGRetrievedSpearSkull));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 200, 138, 231, 185, kItemSpearSkull, 46, globalFlags.myAGRetrievedSpearSkull);
case 53:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 201, 4, 235, 22, kItemCopperMedallion, 45, offsetof(GlobalFlags, myAGRetrievedCopperMedal));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 201, 4, 235, 22, kItemCopperMedallion, 45, globalFlags.myAGRetrievedCopperMedal);
case 54:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 206, 110, 280, 142, kItemObsidianBlock, 72, offsetof(GlobalFlags, myAGRetrievedObsidianBlock));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 206, 110, 280, 142, kItemObsidianBlock, 72, globalFlags.myAGRetrievedObsidianBlock);
case 55:
return new ArrowGodHead(_vm, viewWindow, sceneStaticData, priorLocation, 0, 182, 87, 242, 189, 4, 75, 83, 79, 0, 2, 1, 3);
case 56:
@@ -2638,7 +2641,7 @@ SceneBase *SceneViewWindow::constructMayanSceneObject(Window *viewWindow, const
case 67:
return new DeathGodPuzzleBox(_vm, viewWindow, sceneStaticData, priorLocation);
case 68:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 206, 76, 246, 116, kItemEnvironCart, 53, offsetof(GlobalFlags, takenEnvironCart));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 206, 76, 246, 116, kItemEnvironCart, 53, globalFlags.takenEnvironCart);
case 69:
return new PlaySoundExitingFromScene(_vm, viewWindow, sceneStaticData, priorLocation, 10);
case 70:
@@ -2696,7 +2699,7 @@ SceneBase *SceneViewWindow::constructMayanSceneObject(Window *viewWindow, const
case 121:
return new PlaySoundExitingFromScene(_vm, viewWindow, sceneStaticData, priorLocation, 14);
case 125:
- return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 226, 90, 256, 104, kItemCopperMedallion, 15, offsetof(GlobalFlags, myAGRetrievedCopperMedal));
+ return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 226, 90, 256, 104, kItemCopperMedallion, 15, globalFlags.myAGRetrievedCopperMedal);
case 126:
return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDS_MY_AG_ALTAR_TEXT, 120, 44, 330, 72, -1, -1, offsetof(GlobalFlags, myAGVisitedAltar));
case 127:
diff --git a/engines/buried/environ/scene_common.cpp b/engines/buried/environ/scene_common.cpp
index e3bf0436a20..c7d16798db5 100644
--- a/engines/buried/environ/scene_common.cpp
+++ b/engines/buried/environ/scene_common.cpp
@@ -114,16 +114,15 @@ TurnDepthPreChange::TurnDepthPreChange(BuriedEngine *vm, Window *viewWindow, con
}
GenericItemAcquire::GenericItemAcquire(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int left, int top, int right, int bottom, int itemID, int clearStillFrame, int itemFlagOffset) :
- SceneBase(vm, viewWindow, sceneStaticData, priorLocation) {
+ int left, int top, int right, int bottom, int itemID, int clearStillFrame, byte &itemFlag) :
+ SceneBase(vm, viewWindow, sceneStaticData, priorLocation), _itemFlag(itemFlag) {
_itemPresent = true;
_itemID = itemID;
_acquireRegion = Common::Rect(left, top, right, bottom);
_fullFrameIndex = sceneStaticData.navFrameIndex;
_clearFrameIndex = clearStillFrame;
- _itemFlagOffset = itemFlagOffset;
- if (((SceneViewWindow *)viewWindow)->getGlobalFlagByte(_itemFlagOffset) != 0) {
+ if (_itemFlag != 0) {
_itemPresent = false;
_staticData.navFrameIndex = _clearFrameIndex;
}
@@ -134,8 +133,7 @@ int GenericItemAcquire::mouseDown(Window *viewWindow, const Common::Point &point
_itemPresent = false;
_staticData.navFrameIndex = _clearFrameIndex;
- if (_itemFlagOffset >= 0)
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(_itemFlagOffset, 1);
+ _itemFlag = 1;
// Call inventory drag start function
Common::Point ptInventoryWindow = viewWindow->convertPointToGlobal(pointLocation);
@@ -160,8 +158,7 @@ int GenericItemAcquire::droppedItem(Window *viewWindow, int itemID, const Common
_itemPresent = true;
_staticData.navFrameIndex = _fullFrameIndex;
- if (_itemFlagOffset >= 0)
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(_itemFlagOffset, 0);
+ _itemFlag = 0;
viewWindow->invalidateWindow();
diff --git a/engines/buried/environ/scene_common.h b/engines/buried/environ/scene_common.h
index debbbb30768..80cb7c7a5b0 100644
--- a/engines/buried/environ/scene_common.h
+++ b/engines/buried/environ/scene_common.h
@@ -58,7 +58,7 @@ public:
class GenericItemAcquire : public SceneBase {
public:
GenericItemAcquire(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int left = 0, int top = 0, int right = 0, int bottom = 0, int itemID = 0, int clearStillFrame = 0, int itemFlagOffset = 0);
+ int left, int top, int right, int bottom, int itemID, int clearStillFrame, byte &itemFlag);
int mouseDown(Window *viewWindow, const Common::Point &pointLocation);
virtual int droppedItem(Window *viewWindow, int itemID, const Common::Point &pointLocation, int itemFlags);
int specifyCursor(Window *viewWindow, const Common::Point &pointLocation);
@@ -69,7 +69,7 @@ protected:
int _fullFrameIndex;
int _clearFrameIndex;
int _itemID;
- int _itemFlagOffset;
+ byte &_itemFlag;
};
class PlaySoundExitingFromScene : public SceneBase {
Commit: f750b9768703d8481dcee65e85ce0c78dd90b948
https://github.com/scummvm/scummvm/commit/f750b9768703d8481dcee65e85ce0c78dd90b948
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-02T12:20:48+02:00
Commit Message:
BURIED: Rewrite the head opened time code for the Mayan arrow god scene
This allows us to remove the last usage of getGlobalFlagDWord() and
setGlobalFlagDWord()
Changed paths:
engines/buried/environ/mayan.cpp
engines/buried/scene_view.cpp
engines/buried/scene_view.h
diff --git a/engines/buried/environ/mayan.cpp b/engines/buried/environ/mayan.cpp
index 6a0e428f938..396a5f25145 100644
--- a/engines/buried/environ/mayan.cpp
+++ b/engines/buried/environ/mayan.cpp
@@ -1183,13 +1183,18 @@ private:
int _stillFrames[4];
int _soundID;
int _headAnimations[4];
+ GlobalFlags &_globalFlags;
+
+ uint32 getHeadOpenedTime(byte headId) const;
+ void setHeadOpenedTime(byte headId, uint32 value);
};
ArrowGodHead::ArrowGodHead(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
int headID, int clickLeft, int clickTop, int clickRight, int clickBottom,
int emptyClosedStill, int emptyOpenStill, int fullClosedStill, int fullOpenStill,
int emptyClosedAnim, int emptyOpenAnim, int fullClosedAnim, int fullOpenAnim) :
- SceneBase(vm, viewWindow, sceneStaticData, priorLocation) {
+ SceneBase(vm, viewWindow, sceneStaticData, priorLocation),
+ _globalFlags(((SceneViewWindow *)viewWindow)->getGlobalFlags()) {
SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
_soundID = -1;
@@ -1257,6 +1262,40 @@ int ArrowGodHead::mouseDown(Window *viewWindow, const Common::Point &pointLocati
return SC_FALSE;
}
+uint32 ArrowGodHead::getHeadOpenedTime(byte headId) const {
+ switch (headId) {
+ case 0:
+ return _globalFlags.myAGHeadAOpenedTime;
+ case 1:
+ return _globalFlags.myAGHeadBOpenedTime;
+ case 2:
+ return _globalFlags.myAGHeadCOpenedTime;
+ case 3:
+ return _globalFlags.myAGHeadDOpenedTime;
+ default:
+ return 0;
+ }
+}
+
+void ArrowGodHead::setHeadOpenedTime(byte headId, uint32 value) {
+ switch (headId) {
+ case 0:
+ _globalFlags.myAGHeadAOpenedTime = value;
+ break;
+ case 1:
+ _globalFlags.myAGHeadBOpenedTime = value;
+ break;
+ case 2:
+ _globalFlags.myAGHeadCOpenedTime = value;
+ break;
+ case 3:
+ _globalFlags.myAGHeadDOpenedTime = value;
+ break;
+ default:
+ break;
+ }
+}
+
int ArrowGodHead::mouseUp(Window *viewWindow, const Common::Point &pointLocation) {
SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
GlobalFlags &globalFlags = sceneView->getGlobalFlags();
@@ -1324,7 +1363,7 @@ int ArrowGodHead::mouseUp(Window *viewWindow, const Common::Point &pointLocation
_vm->_sound->playSoundEffect(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, 11), 96);
if (headStatus & 1)
- sceneView->setGlobalFlagDWord(offsetof(GlobalFlags, myAGHeadAOpenedTime) + _headID * 4, g_system->getMillis());
+ setHeadOpenedTime(_headID, g_system->getMillis());
bioChipRightWindow->sceneChanged();
return SC_TRUE;
@@ -1418,10 +1457,10 @@ int ArrowGodHead::timerCallback(Window *viewWindow) {
BioChipRightWindow *bioChipRightWindow = ((GameUIWindow *)viewWindow->getParent())->_bioChipRightWindow;
for (int i = 0; i < 4; i++) {
- uint32 lastStartedTimer = sceneView->getGlobalFlagDWord(offsetof(GlobalFlags, myAGHeadAOpenedTime) + i * 4);
+ uint32 lastStartedTimer = getHeadOpenedTime(i);
if (lastStartedTimer > 0 && g_system->getMillis() > (lastStartedTimer + WAR_GOD_HEAD_TIMER_VALUE)) {
- sceneView->setGlobalFlagDWord(offsetof(GlobalFlags, myAGHeadAOpenedTime) + i * 4, 0);
+ setHeadOpenedTime(i, 0);
TempCursorChange cursorChange(kCursorWait);
@@ -1529,12 +1568,16 @@ public:
private:
bool _scheduledDepthChange;
int _soundID;
+ GlobalFlags &_globalFlags;
bool adjustSpearVolume(Window *viewWindow);
+ uint32 getHeadOpenedTime(byte headId) const;
+ void setHeadOpenedTime(byte headId, uint32 value);
};
ArrowGodDepthChange::ArrowGodDepthChange(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation) :
- SceneBase(vm, viewWindow, sceneStaticData, priorLocation) {
+ SceneBase(vm, viewWindow, sceneStaticData, priorLocation),
+ _globalFlags(((SceneViewWindow *)viewWindow)->getGlobalFlags()) {
SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
GlobalFlags &globalFlags = sceneView->getGlobalFlags();
@@ -1662,6 +1705,40 @@ int ArrowGodDepthChange::postExitRoom(Window *viewWindow, const Location &newLoc
return SC_TRUE;
}
+uint32 ArrowGodDepthChange::getHeadOpenedTime(byte headId) const {
+ switch (headId) {
+ case 0:
+ return _globalFlags.myAGHeadAOpenedTime;
+ case 1:
+ return _globalFlags.myAGHeadBOpenedTime;
+ case 2:
+ return _globalFlags.myAGHeadCOpenedTime;
+ case 3:
+ return _globalFlags.myAGHeadDOpenedTime;
+ default:
+ return 0;
+ }
+}
+
+void ArrowGodDepthChange::setHeadOpenedTime(byte headId, uint32 value) {
+ switch (headId) {
+ case 0:
+ _globalFlags.myAGHeadAOpenedTime = value;
+ break;
+ case 1:
+ _globalFlags.myAGHeadBOpenedTime = value;
+ break;
+ case 2:
+ _globalFlags.myAGHeadCOpenedTime = value;
+ break;
+ case 3:
+ _globalFlags.myAGHeadDOpenedTime = value;
+ break;
+ default:
+ break;
+ }
+}
+
int ArrowGodDepthChange::timerCallback(Window *viewWindow) {
SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
GlobalFlags &globalFlags = sceneView->getGlobalFlags();
@@ -1696,13 +1773,13 @@ int ArrowGodDepthChange::timerCallback(Window *viewWindow) {
// Loop through the four heads
for (int i = 0; i < 4; i++) {
- uint32 lastStartedTimer = sceneView->getGlobalFlagDWord(offsetof(GlobalFlags, myAGHeadAOpenedTime) + i * 4);
+ uint32 lastStartedTimer = getHeadOpenedTime(i);
// Check if there is a timer going for this head
if (lastStartedTimer > 0 && (g_system->getMillis() > (lastStartedTimer + WAR_GOD_HEAD_TIMER_VALUE) ||
i == 0 || (globalFlags.generalWalkthroughMode == 1 && i == 1) ||
(sceneView->getGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatus) + i) == 2 && i == 3))) {
- sceneView->setGlobalFlagDWord(offsetof(GlobalFlags, myAGHeadAOpenedTime) + i * 4, 0);
+ setHeadOpenedTime(i, 0);
TempCursorChange cursorChange(kCursorWait);
byte status = sceneView->getGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatus) + i);
diff --git a/engines/buried/scene_view.cpp b/engines/buried/scene_view.cpp
index 99d593a734c..f613b8b90b9 100644
--- a/engines/buried/scene_view.cpp
+++ b/engines/buried/scene_view.cpp
@@ -1434,20 +1434,6 @@ bool SceneViewWindow::setGlobalFlagByte(int offset, byte value) {
return true;
}
-uint32 SceneViewWindow::getGlobalFlagDWord(int offset) {
- // TODO: Verify the offset
- const byte *data = (const byte *)&_globalFlags;
- return READ_UINT32(data + offset);
-}
-
-bool SceneViewWindow::setGlobalFlagDWord(int offset, uint32 value) {
- // TODO: Verify the offset
-
- byte *data = (byte *)&_globalFlags;
- WRITE_UINT32(data + offset, value);
- return true;
-}
-
bool SceneViewWindow::addNumberToGlobalFlagTable(int tableOffset, int curItemCountOffset, int maxItems, byte numberToAdd) {
// TODO: Rewrite this
byte *data = (byte *)&_globalFlags;
diff --git a/engines/buried/scene_view.h b/engines/buried/scene_view.h
index 7302d413712..73b2d83eadd 100644
--- a/engines/buried/scene_view.h
+++ b/engines/buried/scene_view.h
@@ -100,8 +100,6 @@ public:
byte getGlobalFlagByte(int offset);
bool setGlobalFlagByte(int offset, byte value);
- bool setGlobalFlagDWord(int offset, uint32 value);
- uint32 getGlobalFlagDWord(int offset);
bool addNumberToGlobalFlagTable(int offset, int curItemCountOffset, int maxItems, byte numberToAdd);
byte getNumberFromGlobalFlagTable(int offset, int tableIndex);
bool isNumberInGlobalFlagTable(int offset, int curItemCountOffset, byte numberToCheck);
Commit: 1552759e62ab8a6f71170f41dc66735aba21ff15
https://github.com/scummvm/scummvm/commit/1552759e62ab8a6f71170f41dc66735aba21ff15
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-02T12:20:48+02:00
Commit Message:
BURIED: Improve code readability
Changed paths:
engines/buried/environ/mayan.cpp
diff --git a/engines/buried/environ/mayan.cpp b/engines/buried/environ/mayan.cpp
index 396a5f25145..6b971eb55d7 100644
--- a/engines/buried/environ/mayan.cpp
+++ b/engines/buried/environ/mayan.cpp
@@ -551,11 +551,12 @@ GenericCavernDoorMainView::GenericCavernDoorMainView(BuriedEngine *vm, Window *v
int GenericCavernDoorMainView::postEnterRoom(Window *viewWindow, const Location &priorLocation) {
SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
+ Location &loc = _staticData.location;
- if (_staticData.location.node == 7 && (_staticData.location.timeZone != priorLocation.timeZone ||
- _staticData.location.environment != priorLocation.environment || _staticData.location.node != priorLocation.node ||
- _staticData.location.facing != priorLocation.facing || _staticData.location.orientation != priorLocation.orientation ||
- _staticData.location.depth != priorLocation.depth) && !sceneView->isNumberInGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), MAYAN_EVIDENCE_BROKEN_GLASS_PYRAMID))
+ if (loc.node == 7 && (loc.timeZone != priorLocation.timeZone ||
+ loc.environment != priorLocation.environment || loc.node != priorLocation.node ||
+ loc.facing != priorLocation.facing || loc.orientation != priorLocation.orientation ||
+ loc.depth != priorLocation.depth) && !sceneView->isNumberInGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), MAYAN_EVIDENCE_BROKEN_GLASS_PYRAMID))
sceneView->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_PRESENT));
return SC_TRUE;
}
@@ -1300,6 +1301,7 @@ int ArrowGodHead::mouseUp(Window *viewWindow, const Common::Point &pointLocation
SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
GlobalFlags &globalFlags = sceneView->getGlobalFlags();
BioChipRightWindow *bioChipRightWindow = ((GameUIWindow *)viewWindow->getParent())->_bioChipRightWindow;
+ Location &loc = _staticData.location;
// For walkthrough mode, don't allow input
if (globalFlags.generalWalkthroughMode == 1 && (_headID == 0 || _headID == 3))
@@ -1320,15 +1322,15 @@ int ArrowGodHead::mouseUp(Window *viewWindow, const Common::Point &pointLocation
// Play the proper movie
int currentSoundID = -1;
if (headStatus == 2)
- currentSoundID = _vm->_sound->playSoundEffect(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, 14), 128, false, true);
+ currentSoundID = _vm->_sound->playSoundEffect(_vm->getFilePath(loc.timeZone, loc.environment, 14), 128, false, true);
else
- currentSoundID = _vm->_sound->playSoundEffect(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, 13), 128, false, true);
+ currentSoundID = _vm->_sound->playSoundEffect(_vm->getFilePath(loc.timeZone, loc.environment, 13), 128, false, true);
if ((_headID == 1 || _headID == 2) && headStatus == 0) {
- if (_staticData.location.node == 0)
- _vm->_sound->playSoundEffect(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, 11), 127);
+ if (loc.node == 0)
+ _vm->_sound->playSoundEffect(_vm->getFilePath(loc.timeZone, loc.environment, 11), 127);
else
- _vm->_sound->playSoundEffect(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, 11), 96);
+ _vm->_sound->playSoundEffect(_vm->getFilePath(loc.timeZone, loc.environment, 11), 96);
}
sceneView->playSynchronousAnimation(_headAnimations[headStatus]);
@@ -1341,14 +1343,14 @@ int ArrowGodHead::mouseUp(Window *viewWindow, const Common::Point &pointLocation
byte headCStatus = globalFlags.myAGHeadCStatus;
byte headDStatus = globalFlags.myAGHeadDStatus;
- if (_staticData.location.node == 0) {
+ if (loc.node == 0) {
if (headAStatus == 0)
_vm->_sound->adjustSecondaryAmbientSoundVolume(128, false, 0, 0);
else if (headDStatus == 0)
_vm->_sound->adjustSecondaryAmbientSoundVolume(64, false, 0, 0);
else
_vm->_sound->adjustSecondaryAmbientSoundVolume(0, false, 0, 0);
- } else if (_staticData.location.node == 2) {
+ } else if (loc.node == 2) {
if (headAStatus == 0 || headDStatus == 0)
_vm->_sound->adjustSecondaryAmbientSoundVolume(128, false, 0, 0);
else
@@ -1357,10 +1359,10 @@ int ArrowGodHead::mouseUp(Window *viewWindow, const Common::Point &pointLocation
_vm->_sound->stopSoundEffect(currentSoundID);
- if (_staticData.location.node == 0 && (headBStatus < 3 && headCStatus < 3))
- _vm->_sound->playSoundEffect(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, 11), 127);
- else if (_staticData.location.node == 2 && (headBStatus < 3 && headCStatus < 3))
- _vm->_sound->playSoundEffect(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, 11), 96);
+ if (loc.node == 0 && (headBStatus < 3 && headCStatus < 3))
+ _vm->_sound->playSoundEffect(_vm->getFilePath(loc.timeZone, loc.environment, 11), 127);
+ else if (loc.node == 2 && (headBStatus < 3 && headCStatus < 3))
+ _vm->_sound->playSoundEffect(_vm->getFilePath(loc.timeZone, loc.environment, 11), 96);
if (headStatus & 1)
setHeadOpenedTime(_headID, g_system->getMillis());
@@ -1455,6 +1457,7 @@ int ArrowGodHead::timerCallback(Window *viewWindow) {
SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
GlobalFlags &globalFlags = sceneView->getGlobalFlags();
BioChipRightWindow *bioChipRightWindow = ((GameUIWindow *)viewWindow->getParent())->_bioChipRightWindow;
+ Location &loc = _staticData.location;
for (int i = 0; i < 4; i++) {
uint32 lastStartedTimer = getHeadOpenedTime(i);
@@ -1473,9 +1476,9 @@ int ArrowGodHead::timerCallback(Window *viewWindow) {
int currentSoundID = -1;
if (status == 2)
- currentSoundID = _vm->_sound->playSoundEffect(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, 14), 128, false, true);
+ currentSoundID = _vm->_sound->playSoundEffect(_vm->getFilePath(loc.timeZone, loc.environment, 14), 128, false, true);
else
- currentSoundID = _vm->_sound->playSoundEffect(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, 13), 128, false, true);
+ currentSoundID = _vm->_sound->playSoundEffect(_vm->getFilePath(loc.timeZone, loc.environment, 13), 128, false, true);
sceneView->playSynchronousAnimation(_headAnimations[status]);
@@ -1489,14 +1492,14 @@ int ArrowGodHead::timerCallback(Window *viewWindow) {
byte headCStatus = globalFlags.myAGHeadCStatus;
byte headDStatus = globalFlags.myAGHeadDStatus;
- if (_staticData.location.node == 0) {
+ if (loc.node == 0) {
if (headAStatus == 0)
_vm->_sound->adjustSecondaryAmbientSoundVolume(128, false, 0, 0);
else if (headDStatus == 0)
_vm->_sound->adjustSecondaryAmbientSoundVolume(64, false, 0, 0);
else
_vm->_sound->adjustSecondaryAmbientSoundVolume(0, false, 0, 0);
- } else if (_staticData.location.node == 2) {
+ } else if (loc.node == 2) {
if (headAStatus == 0 || headDStatus == 0)
_vm->_sound->adjustSecondaryAmbientSoundVolume(128, false, 0, 0);
else
@@ -1505,10 +1508,10 @@ int ArrowGodHead::timerCallback(Window *viewWindow) {
// Play the door closing sound, if applicable
if (i == 1 || i == 2) {
- if (_staticData.location.node == 0 && (headBStatus == 0 || headCStatus == 0))
- _vm->_sound->playSoundEffect(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, 11), 127);
- else if (_staticData.location.node == 2 && (headBStatus == 0 || headCStatus == 0))
- _vm->_sound->playSoundEffect(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, 11), 96);
+ if (loc.node == 0 && (headBStatus == 0 || headCStatus == 0))
+ _vm->_sound->playSoundEffect(_vm->getFilePath(loc.timeZone, loc.environment, 11), 127);
+ else if (loc.node == 2 && (headBStatus == 0 || headCStatus == 0))
+ _vm->_sound->playSoundEffect(_vm->getFilePath(loc.timeZone, loc.environment, 11), 96);
}
}
@@ -1521,21 +1524,21 @@ int ArrowGodHead::timerCallback(Window *viewWindow) {
sceneView->setGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatus) + i, status);
if (status == 2)
- _vm->_sound->playSynchronousSoundEffect(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, 14), 128);
+ _vm->_sound->playSynchronousSoundEffect(_vm->getFilePath(loc.timeZone, loc.environment, 14), 128);
else
- _vm->_sound->playSynchronousSoundEffect(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, 13), 128);
+ _vm->_sound->playSynchronousSoundEffect(_vm->getFilePath(loc.timeZone, loc.environment, 13), 128);
byte headAStatus = globalFlags.myAGHeadAStatus;
byte headDStatus = globalFlags.myAGHeadDStatus;
- if (_staticData.location.node == 0) {
+ if (loc.node == 0) {
if (headAStatus == 0)
_vm->_sound->adjustSecondaryAmbientSoundVolume(128, false, 0, 0);
else if (headDStatus == 0)
_vm->_sound->adjustSecondaryAmbientSoundVolume(64, false, 0, 0);
else
_vm->_sound->adjustSecondaryAmbientSoundVolume(0, false, 0, 0);
- } else if (_staticData.location.node == 2) {
+ } else if (loc.node == 2) {
if (headAStatus == 0 || headDStatus == 0)
_vm->_sound->adjustSecondaryAmbientSoundVolume(128, false, 0, 0);
else
@@ -1546,10 +1549,10 @@ int ArrowGodHead::timerCallback(Window *viewWindow) {
bioChipRightWindow->sceneChanged();
if (_headID == 1 || _headID == 2) {
- if (_staticData.location.node == 0)
- _vm->_sound->playSoundEffect(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, 11), 127);
- else if (_staticData.location.node == 2)
- _vm->_sound->playSoundEffect(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, 11), 96);
+ if (loc.node == 0)
+ _vm->_sound->playSoundEffect(_vm->getFilePath(loc.timeZone, loc.environment, 11), 127);
+ else if (loc.node == 2)
+ _vm->_sound->playSoundEffect(_vm->getFilePath(loc.timeZone, loc.environment, 11), 96);
}
}
}
@@ -1689,13 +1692,14 @@ int ArrowGodDepthChange::postEnterRoom(Window *viewWindow, const Location &prior
int ArrowGodDepthChange::postExitRoom(Window *viewWindow, const Location &newLocation) {
SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
-
- if (_staticData.location.timeZone == newLocation.timeZone &&
- _staticData.location.environment == newLocation.environment &&
- _staticData.location.node == newLocation.node &&
- _staticData.location.facing == newLocation.facing &&
- _staticData.location.orientation == newLocation.orientation &&
- _staticData.location.depth == newLocation.depth &&
+ Location &loc = _staticData.location;
+
+ if (loc.timeZone == newLocation.timeZone &&
+ loc.environment == newLocation.environment &&
+ loc.node == newLocation.node &&
+ loc.facing == newLocation.facing &&
+ loc.orientation == newLocation.orientation &&
+ loc.depth == newLocation.depth &&
!_scheduledDepthChange) {
// Notify the player of his gruesome death
sceneView->showDeathScene(13);
@@ -1743,29 +1747,28 @@ int ArrowGodDepthChange::timerCallback(Window *viewWindow) {
SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
GlobalFlags &globalFlags = sceneView->getGlobalFlags();
BioChipRightWindow *bioChipRightWindow = ((GameUIWindow *)viewWindow->getParent())->_bioChipRightWindow;
+ Location &loc = _staticData.location;
SceneBase::timerCallback(viewWindow);
// Check to see if we moved into a death scene
- if (_staticData.location.timeZone == 2 && _staticData.location.environment == 5 &&
- _staticData.location.node == 1 && _staticData.location.facing == 3 &&
- _staticData.location.orientation == 1 && (_staticData.location.depth == 1 ||
- _staticData.location.depth == 3 || _staticData.location.depth == 11 ||
- _staticData.location.depth == 7 || _staticData.location.depth == 5 ||
- _staticData.location.depth == 9)) {
- if (_staticData.location.depth == 1)
+ if (loc.timeZone == 2 && loc.environment == 5 &&
+ loc.node == 1 && loc.facing == 3 &&
+ loc.orientation == 1 && (
+ loc.depth == 1 || loc.depth == 3 || loc.depth == 11 ||
+ loc.depth == 7 || loc.depth == 5 || loc.depth == 9)) {
+ if (loc.depth == 1)
sceneView->playSynchronousAnimation(19);
sceneView->showDeathScene(13);
return SC_DEATH;
}
- if (_staticData.location.timeZone == 2 && _staticData.location.environment == 5 &&
- _staticData.location.node == 3 && _staticData.location.facing == 3 &&
- _staticData.location.orientation == 1 && (_staticData.location.depth == 2 ||
- _staticData.location.depth == 3 || _staticData.location.depth == 11 ||
- _staticData.location.depth == 10 || _staticData.location.depth == 6 ||
- _staticData.location.depth == 7)) {
+ if (loc.timeZone == 2 && loc.environment == 5 &&
+ loc.node == 3 && loc.facing == 3 &&
+ loc.orientation == 1 && (
+ loc.depth == 2 || loc.depth == 3 || loc.depth == 11 ||
+ loc.depth == 10 || loc.depth == 6 || loc.depth == 7)) {
sceneView->playSynchronousAnimation(17);
sceneView->showDeathScene(13);
return SC_DEATH;
@@ -1786,7 +1789,7 @@ int ArrowGodDepthChange::timerCallback(Window *viewWindow) {
if (status & 1) {
status--;
sceneView->setGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatus) + i, status);
- _vm->_sound->playSynchronousSoundEffect(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, (status == 2) ? 14 : 13), 128);
+ _vm->_sound->playSynchronousSoundEffect(_vm->getFilePath(loc.timeZone, loc.environment, (status == 2) ? 14 : 13), 128);
_scheduledDepthChange = true;
adjustSpearVolume(viewWindow);
}
@@ -1797,8 +1800,7 @@ int ArrowGodDepthChange::timerCallback(Window *viewWindow) {
if (_scheduledDepthChange) {
_scheduledDepthChange = false;
- Location location = _staticData.location;
- sceneView->jumpToScene(location);
+ sceneView->jumpToScene(loc);
}
return SC_TRUE;
@@ -1855,6 +1857,7 @@ DeathGodAltar::DeathGodAltar(BuriedEngine *vm, Window *viewWindow, const Locatio
int DeathGodAltar::postEnterRoom(Window *viewWindow, const Location &priorLocation) {
SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
GlobalFlags &globalFlags = sceneView->getGlobalFlags();
+ Location &loc = _staticData.location;
if (globalFlags.myDGOfferedHeart == 1) {
if (!sceneView->isNumberInGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), MAYAN_EVIDENCE_ENVIRON_CART)) {
@@ -1862,15 +1865,15 @@ int DeathGodAltar::postEnterRoom(Window *viewWindow, const Location &priorLocati
_staticData.navFrameIndex = 51;
viewWindow->invalidateWindow(false);
- if ((_staticData.location.timeZone != priorLocation.timeZone || _staticData.location.environment != priorLocation.environment ||
- _staticData.location.node != priorLocation.node || _staticData.location.facing != priorLocation.facing ||
- _staticData.location.orientation != priorLocation.orientation || _staticData.location.depth != priorLocation.depth) &&
+ if ((loc.timeZone != priorLocation.timeZone || loc.environment != priorLocation.environment ||
+ loc.node != priorLocation.node || loc.facing != priorLocation.facing ||
+ loc.orientation != priorLocation.orientation || loc.depth != priorLocation.depth) &&
!sceneView->isNumberInGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), MAYAN_EVIDENCE_ENVIRON_CART))
sceneView->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_PRESENT));
}
- } else if ((_staticData.location.timeZone != priorLocation.timeZone || _staticData.location.environment != priorLocation.environment ||
- _staticData.location.node != priorLocation.node || _staticData.location.facing != priorLocation.facing ||
- _staticData.location.orientation != priorLocation.orientation || _staticData.location.depth != priorLocation.depth) &&
+ } else if ((loc.timeZone != priorLocation.timeZone || loc.environment != priorLocation.environment ||
+ loc.node != priorLocation.node || loc.facing != priorLocation.facing ||
+ loc.orientation != priorLocation.orientation || loc.depth != priorLocation.depth) &&
!sceneView->isNumberInGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), MAYAN_EVIDENCE_PHONY_BLOOD)) {
sceneView->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_PRESENT));
}
@@ -2001,6 +2004,7 @@ private:
DeathGodPuzzleBox::DeathGodPuzzleBox(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation) :
SceneBase(vm, viewWindow, sceneStaticData, priorLocation) {
+ Location &loc = _staticData.location;
_translateText = false;
_puzzleIndexes[0] = _puzzleIndexes[1] = _puzzleIndexes[2] = _puzzleIndexes[3] = 0;
_clickableRegions[0] = Common::Rect(30, 0, 111, 189);
@@ -2010,10 +2014,10 @@ DeathGodPuzzleBox::DeathGodPuzzleBox(BuriedEngine *vm, Window *viewWindow, const
_puzzleRightHandle = Common::Rect(380, 0, 432, 189);
// Load the spinner movies
- _puzzleFrames[0].open(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, 4));
- _puzzleFrames[1].open(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, 5));
- _puzzleFrames[2].open(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, 6));
- _puzzleFrames[3].open(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, 7));
+ _puzzleFrames[0].open(_vm->getFilePath(loc.timeZone, loc.environment, 4));
+ _puzzleFrames[1].open(_vm->getFilePath(loc.timeZone, loc.environment, 5));
+ _puzzleFrames[2].open(_vm->getFilePath(loc.timeZone, loc.environment, 6));
+ _puzzleFrames[3].open(_vm->getFilePath(loc.timeZone, loc.environment, 7));
}
DeathGodPuzzleBox::~DeathGodPuzzleBox() {
@@ -2350,6 +2354,7 @@ WalkDualAmbientVolumeChange::WalkDualAmbientVolumeChange(BuriedEngine *vm, Windo
SceneBase(vm, viewWindow, sceneStaticData, priorLocation) {
SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
GlobalFlags &globalFlags = sceneView->getGlobalFlags();
+ Location &loc = _staticData.location;
_newVolume = newVolume;
_volumeChangeTime = volumeChangeTime;
@@ -2357,9 +2362,9 @@ WalkDualAmbientVolumeChange::WalkDualAmbientVolumeChange(BuriedEngine *vm, Windo
_secondVolume = secondVolume;
// If we have stepped on the far ledge, set the flag
- if (_staticData.location.timeZone == 2 && _staticData.location.environment == 4 &&
- _staticData.location.node == 5 && _staticData.location.facing == 0 &&
- _staticData.location.orientation == 1 && _staticData.location.depth == 0)
+ if (loc.timeZone == 2 && loc.environment == 4 &&
+ loc.node == 5 && loc.facing == 0 &&
+ loc.orientation == 1 && loc.depth == 0)
globalFlags.myWTSteppedOnFarLedge = 1;
}
Commit: ebf110d98f0daa5add6c22a91f808294304326b4
https://github.com/scummvm/scummvm/commit/ebf110d98f0daa5add6c22a91f808294304326b4
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-02T12:20:48+02:00
Commit Message:
BURIED: Rewrite the handling of head flags for the arrow god scenes
This simplifies the code and reduces the usage of getGlobalFlagByte()
and setGlobalFlagByte()
Changed paths:
engines/buried/environ/mayan.cpp
diff --git a/engines/buried/environ/mayan.cpp b/engines/buried/environ/mayan.cpp
index 6b971eb55d7..62e201c1d64 100644
--- a/engines/buried/environ/mayan.cpp
+++ b/engines/buried/environ/mayan.cpp
@@ -1186,8 +1186,19 @@ private:
int _headAnimations[4];
GlobalFlags &_globalFlags;
- uint32 getHeadOpenedTime(byte headId) const;
+ uint32 *headOpenedTime(byte headId);
+ uint32 getHeadOpenedTime(byte headId);
void setHeadOpenedTime(byte headId, uint32 value);
+ byte *headTouched(byte headId);
+ void setHeadTouched(byte value);
+ byte *headStatus(byte headId);
+ byte getHeadStatus();
+ byte getHeadStatus(byte headId);
+ void setHeadStatus(byte headId, byte value);
+ void setHeadStatus(byte value);
+ byte *headStatusSkullId(byte headId);
+ byte getHeadStatusSkullId();
+ void setHeadStatusSkullId(byte value);
};
ArrowGodHead::ArrowGodHead(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
@@ -1196,8 +1207,6 @@ ArrowGodHead::ArrowGodHead(BuriedEngine *vm, Window *viewWindow, const LocationS
int emptyClosedAnim, int emptyOpenAnim, int fullClosedAnim, int fullOpenAnim) :
SceneBase(vm, viewWindow, sceneStaticData, priorLocation),
_globalFlags(((SceneViewWindow *)viewWindow)->getGlobalFlags()) {
- SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
-
_soundID = -1;
_headID = headID;
_skullRegion = Common::Rect(clickLeft, clickTop, clickRight, clickBottom);
@@ -1209,15 +1218,119 @@ ArrowGodHead::ArrowGodHead(BuriedEngine *vm, Window *viewWindow, const LocationS
_headAnimations[1] = emptyOpenAnim;
_headAnimations[2] = fullClosedAnim;
_headAnimations[3] = fullOpenAnim;
- _staticData.navFrameIndex = _stillFrames[sceneView->getGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatus) + _headID)];
+ _staticData.navFrameIndex = _stillFrames[getHeadStatus()];
}
-int ArrowGodHead::postEnterRoom(Window *viewWindow, const Location &priorLocation) {
- SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
- GlobalFlags &globalFlags = sceneView->getGlobalFlags();
+uint32 *ArrowGodHead::headOpenedTime(byte headId) {
+ switch (headId) {
+ case 0:
+ return &_globalFlags.myAGHeadAOpenedTime;
+ case 1:
+ return &_globalFlags.myAGHeadBOpenedTime;
+ case 2:
+ return &_globalFlags.myAGHeadCOpenedTime;
+ case 3:
+ return &_globalFlags.myAGHeadDOpenedTime;
+ default:
+ return nullptr;
+ }
+}
+
+uint32 ArrowGodHead::getHeadOpenedTime(byte headId) {
+ uint32 *openedTime = headOpenedTime(headId);
+ return openedTime ? *openedTime : 0;
+}
+
+void ArrowGodHead::setHeadOpenedTime(byte headId, uint32 value) {
+ uint32 *openedTime = headOpenedTime(headId);
+ if (openedTime)
+ *openedTime = value;
+}
+
+byte *ArrowGodHead::headTouched(byte headId) {
+ switch (headId) {
+ case 0:
+ return &_globalFlags.myAGHeadATouched;
+ case 1:
+ return &_globalFlags.myAGHeadBTouched;
+ case 2:
+ return &_globalFlags.myAGHeadCTouched;
+ case 3:
+ return &_globalFlags.myAGHeadDTouched;
+ default:
+ return nullptr;
+ }
+}
+
+void ArrowGodHead::setHeadTouched(byte value) {
+ byte *touched = headTouched(_headID);
+ if (touched)
+ *touched = value;
+}
- byte headAStatus = globalFlags.myAGHeadAStatus;
- byte headDStatus = globalFlags.myAGHeadDStatus;
+byte *ArrowGodHead::headStatus(byte headId) {
+ switch (headId) {
+ case 0:
+ return &_globalFlags.myAGHeadAStatus;
+ case 1:
+ return &_globalFlags.myAGHeadBStatus;
+ case 2:
+ return &_globalFlags.myAGHeadCStatus;
+ case 3:
+ return &_globalFlags.myAGHeadDStatus;
+ default:
+ return nullptr;
+ }
+}
+
+byte ArrowGodHead::getHeadStatus() {
+ return getHeadStatus(_headID);
+}
+
+byte ArrowGodHead::getHeadStatus(byte headId) {
+ byte *status = headStatus(headId);
+ return status ? *status : 0;
+}
+
+void ArrowGodHead::setHeadStatus(byte value) {
+ setHeadStatus(_headID, value);
+}
+
+void ArrowGodHead::setHeadStatus(byte headId, byte value) {
+ byte *status = headStatus(headId);
+ if (status)
+ *status = value;
+}
+
+byte *ArrowGodHead::headStatusSkullId(byte headId) {
+ switch (headId) {
+ case 0:
+ return &_globalFlags.myAGHeadAStatusSkullID;
+ case 1:
+ return &_globalFlags.myAGHeadBStatusSkullID;
+ case 2:
+ return &_globalFlags.myAGHeadCStatusSkullID;
+ case 3:
+ return &_globalFlags.myAGHeadDStatusSkullID;
+ default:
+ return nullptr;
+ }
+}
+
+byte ArrowGodHead::getHeadStatusSkullId() {
+ byte *status = headStatusSkullId(_headID);
+ return status ? *status : 0;
+}
+
+void ArrowGodHead::setHeadStatusSkullId(byte value) {
+ byte *status = headStatusSkullId(_headID);
+ if (status)
+ *status = value;
+}
+
+int ArrowGodHead::postEnterRoom(Window *viewWindow, const Location &priorLocation) {
+ byte headAStatus = _globalFlags.myAGHeadAStatus;
+ byte headDStatus = _globalFlags.myAGHeadDStatus;
if (_staticData.location.node == 0) {
if (headAStatus == 0)
@@ -1237,21 +1350,19 @@ int ArrowGodHead::postEnterRoom(Window *viewWindow, const Location &priorLocatio
}
int ArrowGodHead::mouseDown(Window *viewWindow, const Common::Point &pointLocation) {
- SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
- GlobalFlags &globalFlags = sceneView->getGlobalFlags();
BioChipRightWindow *bioChipRightWindow = ((GameUIWindow *)viewWindow->getParent())->_bioChipRightWindow;
InventoryWindow *inventoryWindow = ((GameUIWindow *)viewWindow->getParent())->_inventoryWindow;
// For walkthrough mode, don't allow input
- if (globalFlags.generalWalkthroughMode == 1 && (_headID == 0 || _headID == 3))
+ if (_globalFlags.generalWalkthroughMode == 1 && (_headID == 0 || _headID == 3))
return SC_FALSE;
- if (_skullRegion.contains(pointLocation) && sceneView->getGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatus) + _headID) == 3) {
- byte skullIndex = sceneView->getGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatusSkullID) + _headID);
- sceneView->setGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatusSkullID) + _headID, 0);
- sceneView->setGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatus) + _headID, 1);
+ if (_skullRegion.contains(pointLocation) && getHeadStatus() == 3) {
+ byte skullIndex = getHeadStatusSkullId();
+ setHeadStatusSkullId(0);
+ setHeadStatus(1);
_staticData.navFrameIndex = _stillFrames[1];
- sceneView->setGlobalFlagByte(offsetof(GlobalFlags, myAGHeadATouched) + _headID, 1);
+ setHeadTouched(1);
// Begin dragging
Common::Point ptInventoryWindow = viewWindow->convertPointToWindow(pointLocation, inventoryWindow);
@@ -1263,61 +1374,26 @@ int ArrowGodHead::mouseDown(Window *viewWindow, const Common::Point &pointLocati
return SC_FALSE;
}
-uint32 ArrowGodHead::getHeadOpenedTime(byte headId) const {
- switch (headId) {
- case 0:
- return _globalFlags.myAGHeadAOpenedTime;
- case 1:
- return _globalFlags.myAGHeadBOpenedTime;
- case 2:
- return _globalFlags.myAGHeadCOpenedTime;
- case 3:
- return _globalFlags.myAGHeadDOpenedTime;
- default:
- return 0;
- }
-}
-
-void ArrowGodHead::setHeadOpenedTime(byte headId, uint32 value) {
- switch (headId) {
- case 0:
- _globalFlags.myAGHeadAOpenedTime = value;
- break;
- case 1:
- _globalFlags.myAGHeadBOpenedTime = value;
- break;
- case 2:
- _globalFlags.myAGHeadCOpenedTime = value;
- break;
- case 3:
- _globalFlags.myAGHeadDOpenedTime = value;
- break;
- default:
- break;
- }
-}
-
int ArrowGodHead::mouseUp(Window *viewWindow, const Common::Point &pointLocation) {
SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
- GlobalFlags &globalFlags = sceneView->getGlobalFlags();
BioChipRightWindow *bioChipRightWindow = ((GameUIWindow *)viewWindow->getParent())->_bioChipRightWindow;
Location &loc = _staticData.location;
// For walkthrough mode, don't allow input
- if (globalFlags.generalWalkthroughMode == 1 && (_headID == 0 || _headID == 3))
+ if (_globalFlags.generalWalkthroughMode == 1 && (_headID == 0 || _headID == 3))
return SC_FALSE;
// Did we click on the head?
if (_skullRegion.contains(pointLocation)) {
- byte headStatus = sceneView->getGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatus) + _headID);
- sceneView->setGlobalFlagByte(offsetof(GlobalFlags, myAGHeadATouched) + _headID, 1);
+ byte headStatus = getHeadStatus();
+ setHeadTouched(1);
if (headStatus & 1)
headStatus--;
else
headStatus++;
- sceneView->setGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatus) + _headID, headStatus);
+ setHeadStatus(headStatus);
// Play the proper movie
int currentSoundID = -1;
@@ -1338,10 +1414,10 @@ int ArrowGodHead::mouseUp(Window *viewWindow, const Common::Point &pointLocation
_staticData.navFrameIndex = _stillFrames[headStatus];
viewWindow->invalidateWindow(false);
- byte headAStatus = globalFlags.myAGHeadAStatus;
- byte headBStatus = globalFlags.myAGHeadBStatus;
- byte headCStatus = globalFlags.myAGHeadCStatus;
- byte headDStatus = globalFlags.myAGHeadDStatus;
+ byte headAStatus = _globalFlags.myAGHeadAStatus;
+ byte headBStatus = _globalFlags.myAGHeadBStatus;
+ byte headCStatus = _globalFlags.myAGHeadCStatus;
+ byte headDStatus = _globalFlags.myAGHeadDStatus;
if (loc.node == 0) {
if (headAStatus == 0)
@@ -1375,13 +1451,10 @@ int ArrowGodHead::mouseUp(Window *viewWindow, const Common::Point &pointLocation
}
int ArrowGodHead::draggingItem(Window *viewWindow, int itemID, const Common::Point &pointLocation, int itemFlags) {
- SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
- GlobalFlags &globalFlags = sceneView->getGlobalFlags();
-
- if (globalFlags.generalWalkthroughMode == 1 && (_headID == 0 || _headID == 3))
+ if (_globalFlags.generalWalkthroughMode == 1 && (_headID == 0 || _headID == 3))
return 0;
- if ((itemID == kItemCavernSkull || itemID == kItemEntrySkull || itemID == kItemSpearSkull) && sceneView->getGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatus) + _headID) < 2 && _skullRegion.contains(pointLocation))
+ if ((itemID == kItemCavernSkull || itemID == kItemEntrySkull || itemID == kItemSpearSkull) && getHeadStatus() < 2 && _skullRegion.contains(pointLocation))
return 1;
return 0;
@@ -1389,19 +1462,18 @@ int ArrowGodHead::draggingItem(Window *viewWindow, int itemID, const Common::Poi
int ArrowGodHead::droppedItem(Window *viewWindow, int itemID, const Common::Point &pointLocation, int itemFlags) {
SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
- GlobalFlags &globalFlags = sceneView->getGlobalFlags();
BioChipRightWindow *bioChipRightWindow = ((GameUIWindow *)viewWindow->getParent())->_bioChipRightWindow;
- if (globalFlags.generalWalkthroughMode == 1 && (_headID == 0 || _headID == 3))
+ if (_globalFlags.generalWalkthroughMode == 1 && (_headID == 0 || _headID == 3))
return SIC_REJECT;
if (pointLocation.x == -1 && pointLocation.y == -1)
return SIC_REJECT;
- if ((itemID == kItemCavernSkull || itemID == kItemEntrySkull || itemID == kItemSpearSkull) && sceneView->getGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatus) + _headID) == 1 && _skullRegion.contains(pointLocation)) {
- sceneView->setGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatus) + _headID, 2);
- sceneView->setGlobalFlagByte(offsetof(GlobalFlags, myAGHeadATouched) + _headID, 1);
- sceneView->setGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatusSkullID) + _headID, itemID);
+ if ((itemID == kItemCavernSkull || itemID == kItemEntrySkull || itemID == kItemSpearSkull) && getHeadStatus() == 1 && _skullRegion.contains(pointLocation)) {
+ setHeadStatus(2);
+ setHeadTouched(1);
+ setHeadStatusSkullId(itemID);
int currentSoundID = _vm->_sound->playSoundEffect(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, 14), 128, false, true);
@@ -1410,8 +1482,8 @@ int ArrowGodHead::droppedItem(Window *viewWindow, int itemID, const Common::Poin
_staticData.navFrameIndex = _stillFrames[2];
viewWindow->invalidateWindow(false);
- byte headAStatus = globalFlags.myAGHeadAStatus;
- byte headDStatus = globalFlags.myAGHeadDStatus;
+ byte headAStatus = _globalFlags.myAGHeadAStatus;
+ byte headDStatus = _globalFlags.myAGHeadDStatus;
if (_staticData.location.node == 0) {
if (headAStatus == 0)
@@ -1437,14 +1509,11 @@ int ArrowGodHead::droppedItem(Window *viewWindow, int itemID, const Common::Poin
}
int ArrowGodHead::specifyCursor(Window *viewWindow, const Common::Point &pointLocation) {
- SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
- GlobalFlags &globalFlags = sceneView->getGlobalFlags();
-
- if (globalFlags.generalWalkthroughMode == 1 && (_headID == 0 || _headID == 3))
+ if (_globalFlags.generalWalkthroughMode == 1 && (_headID == 0 || _headID == 3))
return 0;
if (_skullRegion.contains(pointLocation)) {
- if (sceneView->getGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatus) + _headID) == 3)
+ if (getHeadStatus() == 3)
return kCursorOpenHand;
return kCursorFinger;
@@ -1455,7 +1524,6 @@ int ArrowGodHead::specifyCursor(Window *viewWindow, const Common::Point &pointLo
int ArrowGodHead::timerCallback(Window *viewWindow) {
SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
- GlobalFlags &globalFlags = sceneView->getGlobalFlags();
BioChipRightWindow *bioChipRightWindow = ((GameUIWindow *)viewWindow->getParent())->_bioChipRightWindow;
Location &loc = _staticData.location;
@@ -1468,11 +1536,11 @@ int ArrowGodHead::timerCallback(Window *viewWindow) {
TempCursorChange cursorChange(kCursorWait);
if (i == _headID) {
- byte status = sceneView->getGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatus) + i);
+ byte status = getHeadStatus();
if (status & 1) {
status--;
- sceneView->setGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatus) + i, status);
+ setHeadStatus(status);
int currentSoundID = -1;
if (status == 2)
@@ -1487,10 +1555,10 @@ int ArrowGodHead::timerCallback(Window *viewWindow) {
_vm->_sound->stopSoundEffect(currentSoundID);
- byte headAStatus = globalFlags.myAGHeadAStatus;
- byte headBStatus = globalFlags.myAGHeadBStatus;
- byte headCStatus = globalFlags.myAGHeadCStatus;
- byte headDStatus = globalFlags.myAGHeadDStatus;
+ byte headAStatus = _globalFlags.myAGHeadAStatus;
+ byte headBStatus = _globalFlags.myAGHeadBStatus;
+ byte headCStatus = _globalFlags.myAGHeadCStatus;
+ byte headDStatus = _globalFlags.myAGHeadDStatus;
if (loc.node == 0) {
if (headAStatus == 0)
@@ -1517,19 +1585,19 @@ int ArrowGodHead::timerCallback(Window *viewWindow) {
bioChipRightWindow->sceneChanged();
} else {
- byte status = sceneView->getGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatus) + i);
+ byte status = getHeadStatus(i);
if (status & 1) {
status--;
- sceneView->setGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatus) + i, status);
+ setHeadStatus(i, status);
if (status == 2)
_vm->_sound->playSynchronousSoundEffect(_vm->getFilePath(loc.timeZone, loc.environment, 14), 128);
else
_vm->_sound->playSynchronousSoundEffect(_vm->getFilePath(loc.timeZone, loc.environment, 13), 128);
- byte headAStatus = globalFlags.myAGHeadAStatus;
- byte headDStatus = globalFlags.myAGHeadDStatus;
+ byte headAStatus = _globalFlags.myAGHeadAStatus;
+ byte headDStatus = _globalFlags.myAGHeadDStatus;
if (loc.node == 0) {
if (headAStatus == 0)
@@ -1574,23 +1642,26 @@ private:
GlobalFlags &_globalFlags;
bool adjustSpearVolume(Window *viewWindow);
- uint32 getHeadOpenedTime(byte headId) const;
+ uint32 *headOpenedTime(byte headId);
+ uint32 getHeadOpenedTime(byte headId);
void setHeadOpenedTime(byte headId, uint32 value);
+ byte *headStatus(byte headId);
+ byte getHeadStatus(byte headId);
+ void setHeadStatus(byte headId, byte value);
};
ArrowGodDepthChange::ArrowGodDepthChange(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation) :
SceneBase(vm, viewWindow, sceneStaticData, priorLocation),
_globalFlags(((SceneViewWindow *)viewWindow)->getGlobalFlags()) {
SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
- GlobalFlags &globalFlags = sceneView->getGlobalFlags();
_scheduledDepthChange = false;
_soundID = -1;
- byte headAStatus = globalFlags.myAGHeadAStatus;
- byte headBStatus = globalFlags.myAGHeadBStatus;
- byte headCStatus = globalFlags.myAGHeadCStatus;
- byte headDStatus = globalFlags.myAGHeadDStatus;
+ byte headAStatus = _globalFlags.myAGHeadAStatus;
+ byte headBStatus = _globalFlags.myAGHeadBStatus;
+ byte headCStatus = _globalFlags.myAGHeadCStatus;
+ byte headDStatus = _globalFlags.myAGHeadDStatus;
int targetDepth = 0;
@@ -1650,11 +1721,10 @@ int ArrowGodDepthChange::postEnterRoom(Window *viewWindow, const Location &prior
if (((priorLocation.depth >= 8 && priorLocation.depth <= 11) && _staticData.location.depth < 8) ||
((priorLocation.depth >= 4 && priorLocation.depth <= 7) && _staticData.location.depth < 4)) {
SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
- GlobalFlags &globalFlags = sceneView->getGlobalFlags();
- byte headBStatus = globalFlags.myAGHeadBStatus;
- byte headCStatus = globalFlags.myAGHeadCStatus;
- byte &headDStatus = globalFlags.myAGHeadDStatus;
+ byte headBStatus = _globalFlags.myAGHeadBStatus;
+ byte headCStatus = _globalFlags.myAGHeadCStatus;
+ byte &headDStatus = _globalFlags.myAGHeadDStatus;
byte doorLevelVolume = 0;
switch (_staticData.location.node) {
@@ -1709,43 +1779,60 @@ int ArrowGodDepthChange::postExitRoom(Window *viewWindow, const Location &newLoc
return SC_TRUE;
}
-uint32 ArrowGodDepthChange::getHeadOpenedTime(byte headId) const {
+uint32 *ArrowGodDepthChange::headOpenedTime(byte headId) {
switch (headId) {
case 0:
- return _globalFlags.myAGHeadAOpenedTime;
+ return &_globalFlags.myAGHeadAOpenedTime;
case 1:
- return _globalFlags.myAGHeadBOpenedTime;
+ return &_globalFlags.myAGHeadBOpenedTime;
case 2:
- return _globalFlags.myAGHeadCOpenedTime;
+ return &_globalFlags.myAGHeadCOpenedTime;
case 3:
- return _globalFlags.myAGHeadDOpenedTime;
+ return &_globalFlags.myAGHeadDOpenedTime;
default:
- return 0;
+ return nullptr;
}
}
+uint32 ArrowGodDepthChange::getHeadOpenedTime(byte headId) {
+ uint32 *openedTime = headOpenedTime(headId);
+ return openedTime ? *openedTime : 0;
+}
+
void ArrowGodDepthChange::setHeadOpenedTime(byte headId, uint32 value) {
+ uint32 *openedTime = headOpenedTime(headId);
+ if (openedTime)
+ *openedTime = value;
+}
+
+byte *ArrowGodDepthChange::headStatus(byte headId) {
switch (headId) {
case 0:
- _globalFlags.myAGHeadAOpenedTime = value;
- break;
+ return &_globalFlags.myAGHeadAStatus;
case 1:
- _globalFlags.myAGHeadBOpenedTime = value;
- break;
+ return &_globalFlags.myAGHeadBStatus;
case 2:
- _globalFlags.myAGHeadCOpenedTime = value;
- break;
+ return &_globalFlags.myAGHeadCStatus;
case 3:
- _globalFlags.myAGHeadDOpenedTime = value;
- break;
+ return &_globalFlags.myAGHeadDStatus;
default:
- break;
+ return nullptr;
}
}
+byte ArrowGodDepthChange::getHeadStatus(byte headId) {
+ byte *status = headStatus(headId);
+ return status ? *status : 0;
+}
+
+void ArrowGodDepthChange::setHeadStatus(byte headId, byte value) {
+ byte *status = headStatus(headId);
+ if (status)
+ *status = value;
+}
+
int ArrowGodDepthChange::timerCallback(Window *viewWindow) {
SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
- GlobalFlags &globalFlags = sceneView->getGlobalFlags();
BioChipRightWindow *bioChipRightWindow = ((GameUIWindow *)viewWindow->getParent())->_bioChipRightWindow;
Location &loc = _staticData.location;
@@ -1780,15 +1867,15 @@ int ArrowGodDepthChange::timerCallback(Window *viewWindow) {
// Check if there is a timer going for this head
if (lastStartedTimer > 0 && (g_system->getMillis() > (lastStartedTimer + WAR_GOD_HEAD_TIMER_VALUE) ||
- i == 0 || (globalFlags.generalWalkthroughMode == 1 && i == 1) ||
- (sceneView->getGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatus) + i) == 2 && i == 3))) {
+ i == 0 || (_globalFlags.generalWalkthroughMode == 1 && i == 1) ||
+ (getHeadStatus(i) == 2 && i == 3))) {
setHeadOpenedTime(i, 0);
TempCursorChange cursorChange(kCursorWait);
- byte status = sceneView->getGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatus) + i);
+ byte status = getHeadStatus(i);
if (status & 1) {
status--;
- sceneView->setGlobalFlagByte(offsetof(GlobalFlags, myAGHeadAStatus) + i, status);
+ setHeadStatus(i, status);
_vm->_sound->playSynchronousSoundEffect(_vm->getFilePath(loc.timeZone, loc.environment, (status == 2) ? 14 : 13), 128);
_scheduledDepthChange = true;
adjustSpearVolume(viewWindow);
@@ -1807,14 +1894,11 @@ int ArrowGodDepthChange::timerCallback(Window *viewWindow) {
}
bool ArrowGodDepthChange::adjustSpearVolume(Window *viewWindow) {
- SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
- GlobalFlags &globalFlags = sceneView->getGlobalFlags();
-
// TODO: Looks like there's a bug in the original. node == 3 should also be in here, I think
// Need to investigate
if (_staticData.location.node >= 0 && _staticData.location.node <= 2) {
- byte headAStatus = globalFlags.myAGHeadAStatus;
- byte headDStatus = globalFlags.myAGHeadDStatus;
+ byte headAStatus = _globalFlags.myAGHeadAStatus;
+ byte headDStatus = _globalFlags.myAGHeadDStatus;
if (headAStatus == 0) {
_vm->_sound->adjustSecondaryAmbientSoundVolume(128, false, 0, 0);
Commit: fdf43e51ac906b797b8ae58764f73f929874611b
https://github.com/scummvm/scummvm/commit/fdf43e51ac906b797b8ae58764f73f929874611b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-02T12:20:48+02:00
Commit Message:
BURIED: Pass global flag by ref to the ViewSingleTranslation() callback
This reduces the usage of setGlobalFlagByte()
Changed paths:
engines/buried/environ/mayan.cpp
diff --git a/engines/buried/environ/mayan.cpp b/engines/buried/environ/mayan.cpp
index 62e201c1d64..0a7e51bc76f 100644
--- a/engines/buried/environ/mayan.cpp
+++ b/engines/buried/environ/mayan.cpp
@@ -413,8 +413,8 @@ int DateCombinationRead::mouseMove(Window *viewWindow, const Common::Point &poin
class ViewSingleTranslation : public SceneBase {
public:
ViewSingleTranslation(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int translatedTextID = -1, int left = -1, int top = -1, int right = -1, int bottom = -1,
- int flagAOffset = -1, int flagBOffset = -1, int visitedFlagOffset = -1);
+ int translatedTextID, int left, int top, int right, int bottom,
+ byte &flagA, byte &flagB, byte &visitedFlag);
int gdiPaint(Window *viewWindow) override;
int mouseUp(Window *viewWindow, const Common::Point &pointLocation) override;
int mouseMove(Window *viewWindow, const Common::Point &pointLocation) override;
@@ -424,26 +424,19 @@ private:
bool _textTranslated;
int _textID;
Common::Rect _clickableRegion;
- int _flagAOffset;
- int _flagBOffset;
- int _visitedFlagOffset;
+ byte &_flagA;
+ byte &_flagB;
};
ViewSingleTranslation::ViewSingleTranslation(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
int translatedTextID, int left, int top, int right, int bottom,
- int flagAOffset, int flagBOffset, int visitedFlagOffset) :
- SceneBase(vm, viewWindow, sceneStaticData, priorLocation) {
- SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
-
+ byte &flagA, byte &flagB, byte &visitedFlag) :
+ SceneBase(vm, viewWindow, sceneStaticData, priorLocation),
+ _flagA(flagA), _flagB(flagB) {
_textTranslated = false;
_textID = translatedTextID;
_clickableRegion = Common::Rect(left, top, right, bottom);
- _flagAOffset = flagAOffset;
- _flagBOffset = flagBOffset;
- _visitedFlagOffset = visitedFlagOffset;
-
- if (_visitedFlagOffset >= 0)
- sceneView->setGlobalFlagByte(_visitedFlagOffset, 1);
+ visitedFlag = 1;
}
int ViewSingleTranslation::gdiPaint(Window *viewWindow) {
@@ -481,10 +474,8 @@ int ViewSingleTranslation::mouseMove(Window *viewWindow, const Common::Point &po
if (_clickableRegion.contains(pointLocation)) {
// Make sure we didn't already render the text
if (!_textTranslated) {
- if (_flagAOffset >= 0)
- sceneView->setGlobalFlagByte(_flagAOffset, 1);
- if (_flagBOffset >= 0)
- sceneView->setGlobalFlagByte(_flagBOffset, 1);
+ _flagA = 1;
+ _flagB = 1;
// Load and display the text
sceneView->displayTranslationText(_vm->getString(_textID));
@@ -2464,18 +2455,14 @@ int WalkDualAmbientVolumeChange::preExitRoom(Window *viewWindow, const Location
class SetVolumeAndFlag : public SceneBase {
public:
SetVolumeAndFlag(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- byte newVolume = 64, int flagOffset = -1, byte flagValue = 255);
+ byte newVolume, byte &flag, byte flagValue = 255);
};
SetVolumeAndFlag::SetVolumeAndFlag(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- byte newVolume, int flagOffset, byte flagValue) :
+ byte newVolume, byte &flag, byte flagValue) :
SceneBase(vm, viewWindow, sceneStaticData, priorLocation) {
- SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
-
_vm->_sound->adjustAmbientSoundVolume(newVolume, false, 0, 0);
-
- if (flagOffset >= 0)
- sceneView->setGlobalFlagByte(flagOffset, flagValue);
+ flag = flagValue;
}
bool SceneViewWindow::initializeMayanTimeZoneAndEnvironment(Window *viewWindow, int environment) {
@@ -2675,6 +2662,7 @@ bool SceneViewWindow::checkCustomMayanAICommentDependencies(const Location &comm
SceneBase *SceneViewWindow::constructMayanSceneObject(Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation) {
SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
GlobalFlags &globalFlags = sceneView->getGlobalFlags();
+ byte dummyFlag = 0; // a dummy flag, used as a placeholder for writing (but not reading)
// Special scene for the trial version
if (_vm->isTrial())
@@ -2697,49 +2685,49 @@ SceneBase *SceneViewWindow::constructMayanSceneObject(Window *viewWindow, const
case 6:
return new DateCombinationRead(_vm, viewWindow, sceneStaticData, priorLocation);
case 7:
- return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYTP_INNER_DOOR_TRANS_TEXT, 16, 6, 402, 110, offsetof(GlobalFlags, myTPTextTranslated), offsetof(GlobalFlags, myTPTransBreathOfItzamna));
+ return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYTP_INNER_DOOR_TRANS_TEXT, 16, 6, 402, 110, globalFlags.myTPTextTranslated, globalFlags.myTPTransBreathOfItzamna, dummyFlag);
case 8:
- return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYTP_INNER_LEFT_TRANS_TEXT, 1, 6, 431, 98, offsetof(GlobalFlags, myTPTextTranslated));
+ return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYTP_INNER_LEFT_TRANS_TEXT, 1, 6, 431, 98, globalFlags.myTPTextTranslated, dummyFlag, dummyFlag);
case 9:
- return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYTP_INNER_MIDDLE_TRANS_TEXT, 16, 8, 430, 114, offsetof(GlobalFlags, myTPTextTranslated), offsetof(GlobalFlags, myTPCalendarTopTranslated));
+ return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYTP_INNER_MIDDLE_TRANS_TEXT, 16, 8, 430, 114, globalFlags.myTPTextTranslated, globalFlags.myTPCalendarTopTranslated, dummyFlag);
case 10:
- return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYTP_OUTER_SOUTHLEFT_TRANS_TEXT, 4, 55, 426, 95, offsetof(GlobalFlags, myTPTextTranslated));
+ return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYTP_OUTER_SOUTHLEFT_TRANS_TEXT, 4, 55, 426, 95, globalFlags.myTPTextTranslated, dummyFlag, dummyFlag);
case 11:
- return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYTP_OUTER_WEST_TRANS_TEXT, 4, 72, 420, 108, offsetof(GlobalFlags, myTPTextTranslated));
+ return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYTP_OUTER_WEST_TRANS_TEXT, 4, 72, 420, 108, globalFlags.myTPTextTranslated, dummyFlag, dummyFlag);
case 12:
- return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYTP_OUTER_NORTH_TRANS_TEXT, 6, 38, 428, 76, offsetof(GlobalFlags, myTPTextTranslated));
+ return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYTP_OUTER_NORTH_TRANS_TEXT, 6, 38, 428, 76, globalFlags.myTPTextTranslated, dummyFlag, dummyFlag);
case 13:
return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 140, 124, 174, 158, kItemCavernSkull, 3, globalFlags.myMCPickedUpSkull);
case 14:
return new GenericCavernDoorMainView(_vm, viewWindow, sceneStaticData, priorLocation, 1, 126, 1, 306, 30, 2, 287, 30, 379, 82, 3, 275, 84, 401, 174);
case 15:
- return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYMC_WG_DOOR_TOP_TRANS_TEXT, 12, 128, 426, 156, offsetof(GlobalFlags, myMCTransDoor), offsetof(GlobalFlags, myWGTransDoorTop));
+ return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYMC_WG_DOOR_TOP_TRANS_TEXT, 12, 128, 426, 156, globalFlags.myMCTransDoor, globalFlags.myWGTransDoorTop, dummyFlag);
case 16:
- return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYMC_WG_DOOR_RIGHT_TRANS_TEXT, 46, 1, 315, 188, offsetof(GlobalFlags, myMCTransDoor), offsetof(GlobalFlags, myMCTransWGOffering));
+ return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYMC_WG_DOOR_RIGHT_TRANS_TEXT, 46, 1, 315, 188, globalFlags.myMCTransDoor, globalFlags.myMCTransWGOffering, dummyFlag);
case 17:
return new GenericCavernDoorOfferingHead(_vm, viewWindow, sceneStaticData, priorLocation, kItemGoldCoins, 4, TRANSITION_WALK, -1, 1082, 13);
case 18:
return new GenericCavernDoorMainView(_vm, viewWindow, sceneStaticData, priorLocation, 1, 126, 1, 306, 30, 2, 287, 30, 379, 82, 3, 275, 84, 401, 174);
case 19:
- return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYMC_WATERGOD_DOOR_TOP_TRANS_TEXT, 12, 128, 426, 156, offsetof(GlobalFlags, myMCTransDoor));
+ return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYMC_WATERGOD_DOOR_TOP_TRANS_TEXT, 12, 128, 426, 156, globalFlags.myMCTransDoor, dummyFlag, dummyFlag);
case 20:
- return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYMC_WATERGOD_DOOR_RIGHT_TRANS_TEXT, 46, 1, 315, 188, offsetof(GlobalFlags, myMCTransDoor), offsetof(GlobalFlags, myMCTransWTOffering));
+ return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYMC_WATERGOD_DOOR_RIGHT_TRANS_TEXT, 46, 1, 315, 188, globalFlags.myMCTransDoor, globalFlags.myMCTransWTOffering, dummyFlag);
case 21:
return new GenericCavernDoorOfferingHead(_vm, viewWindow, sceneStaticData, priorLocation, kItemWaterCanFull, 4, TRANSITION_WALK, -1, 1125, 13);
case 22:
return new GenericCavernDoorMainView(_vm, viewWindow, sceneStaticData, priorLocation, 1, 126, 1, 306, 30, 2, 287, 30, 379, 82, 3, 275, 84, 401, 174);
case 23:
- return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYMC_AG_DOOR_TOP_TRANS_TEXT, 12, 128, 426, 156, offsetof(GlobalFlags, myMCTransDoor));
+ return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYMC_AG_DOOR_TOP_TRANS_TEXT, 12, 128, 426, 156, globalFlags.myMCTransDoor, dummyFlag, dummyFlag);
case 24:
- return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYMC_AG_DOOR_RIGHT_TRANS_TEXT, 46, 1, 315, 188, offsetof(GlobalFlags, myMCTransDoor), offsetof(GlobalFlags, myMCTransAGOffering));
+ return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYMC_AG_DOOR_RIGHT_TRANS_TEXT, 46, 1, 315, 188, globalFlags.myMCTransDoor, globalFlags.myMCTransAGOffering, dummyFlag);
case 25:
return new GenericCavernDoorOfferingHead(_vm, viewWindow, sceneStaticData, priorLocation, kItemBloodyArrow, 4, TRANSITION_WALK, -1, 1010, 12);
case 26:
return new GenericCavernDoorMainView(_vm, viewWindow, sceneStaticData, priorLocation, 1, 126, 1, 306, 30, 2, 287, 30, 379, 82, 3, 275, 84, 401, 174);
case 27:
- return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYMC_DEATHGOD_DOOR_TOP_TRANS_TEXT, 12, 128, 426, 156, offsetof(GlobalFlags, myMCTransDoor));
+ return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYMC_DEATHGOD_DOOR_TOP_TRANS_TEXT, 12, 128, 426, 156, globalFlags.myMCTransDoor, dummyFlag, dummyFlag);
case 28:
- return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYMC_DEATHGOD_DOOR_RIGHT_TRANS_TEXT, 46, 1, 315, 188, offsetof(GlobalFlags, myMCTransDoor), offsetof(GlobalFlags, myMCTransDGOffering));
+ return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDMYMC_DEATHGOD_DOOR_RIGHT_TRANS_TEXT, 46, 1, 315, 188, globalFlags.myMCTransDoor, globalFlags.myMCTransDGOffering, dummyFlag);
case 29:
return new DeathGodCavernDoorOfferingHead(_vm, viewWindow, sceneStaticData, priorLocation, 4, TRANSITION_WALK, -1, 1045, 13);
case 30:
@@ -2839,11 +2827,11 @@ SceneBase *SceneViewWindow::constructMayanSceneObject(Window *viewWindow, const
case 85:
return new WalkVolumeChange(_vm, viewWindow, sceneStaticData, priorLocation, 255, 0, -1, 10); // First param has to be wrong
case 86:
- return new SetVolumeAndFlag(_vm, viewWindow, sceneStaticData, priorLocation, 64, offsetof(GlobalFlags, myWGSeenLowerPassage));
+ return new SetVolumeAndFlag(_vm, viewWindow, sceneStaticData, priorLocation, 64, globalFlags.myWGSeenLowerPassage);
case 87:
- return new SetVolumeAndFlag(_vm, viewWindow, sceneStaticData, priorLocation, 64, offsetof(GlobalFlags, myWGCrossedRopeBridge));
+ return new SetVolumeAndFlag(_vm, viewWindow, sceneStaticData, priorLocation, 64, globalFlags.myWGCrossedRopeBridge);
case 88:
- return new SetVolumeAndFlag(_vm, viewWindow, sceneStaticData, priorLocation, 64);
+ return new SetVolumeAndFlag(_vm, viewWindow, sceneStaticData, priorLocation, 64, dummyFlag);
case 90:
return new WalkVolumeChange(_vm, viewWindow, sceneStaticData, priorLocation, 40, 3160, 12, 14);
case 91:
@@ -2867,11 +2855,11 @@ SceneBase *SceneViewWindow::constructMayanSceneObject(Window *viewWindow, const
case 125:
return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 226, 90, 256, 104, kItemCopperMedallion, 15, globalFlags.myAGRetrievedCopperMedal);
case 126:
- return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDS_MY_AG_ALTAR_TEXT, 120, 44, 330, 72, -1, -1, offsetof(GlobalFlags, myAGVisitedAltar));
+ return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDS_MY_AG_ALTAR_TEXT, 120, 44, 330, 72, dummyFlag, dummyFlag, globalFlags.myAGVisitedAltar);
case 127:
- return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDS_MY_WG_ALTAR_TEXT, 118, 14, 338, 44);
+ return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDS_MY_WG_ALTAR_TEXT, 118, 14, 338, 44, dummyFlag, dummyFlag, dummyFlag);
case 128:
- return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDS_MY_WT_ALTAR_TEXT, 106, 128, 344, 162);
+ return new ViewSingleTranslation(_vm, viewWindow, sceneStaticData, priorLocation, IDS_MY_WT_ALTAR_TEXT, 106, 128, 344, 162, dummyFlag, dummyFlag, dummyFlag);
default:
warning("Unknown Mayan scene object %d", sceneStaticData.classID);
break;
Commit: 259572f50bf7c31c404ff920dd3ae9c0bb65fab0
https://github.com/scummvm/scummvm/commit/259572f50bf7c31c404ff920dd3ae9c0bb65fab0
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-02T12:20:49+02:00
Commit Message:
BURIED: Adapt hardcoded flag in the OpenFirstItemAcquire() callback
Changed paths:
engines/buried/environ/castle.cpp
engines/buried/environ/scene_common.cpp
engines/buried/environ/scene_common.h
diff --git a/engines/buried/environ/castle.cpp b/engines/buried/environ/castle.cpp
index b339d48ec1d..1e5d2b2442b 100644
--- a/engines/buried/environ/castle.cpp
+++ b/engines/buried/environ/castle.cpp
@@ -1246,7 +1246,7 @@ SceneBase *SceneViewWindow::constructCastleSceneObject(Window *viewWindow, const
case 39:
return new StorageRoomDoor(_vm, viewWindow, sceneStaticData, priorLocation, 38, 0, 386, 189, 1, 9, 5, 2, 1, 1, 11, 130, 12, 0);
case 41:
- return new OpenFirstItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 138, 32, 288, 107, 175, 65, 226, 90, 2, 1, kItemGoldCoins, 34, 35, offsetof(GlobalFlags, cgGoldCoinsPresent));
+ return new OpenFirstItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 138, 32, 288, 107, 175, 65, 226, 90, 2, 1, kItemGoldCoins, 34, 35);
case 42:
return new SmithyBench(_vm, viewWindow, sceneStaticData, priorLocation);
case 43:
diff --git a/engines/buried/environ/scene_common.cpp b/engines/buried/environ/scene_common.cpp
index c7d16798db5..b04bac981c3 100644
--- a/engines/buried/environ/scene_common.cpp
+++ b/engines/buried/environ/scene_common.cpp
@@ -972,17 +972,15 @@ int ClickChangeDepth::specifyCursor(Window *viewWindow, const Common::Point &poi
OpenFirstItemAcquire::OpenFirstItemAcquire(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
int openLeft, int openTop, int openRight, int openBottom, int getLeft, int getTop, int getRight,
- int getBottom, int animOpenWith, int animOpenWithout, int itemID, int fullStillFrame, int clearStillFrame,
- int itemFlagOffset):
+ int getBottom, int animOpenWith, int animOpenWithout, int itemID, int fullStillFrame, int clearStillFrame):
SceneBase(vm, viewWindow, sceneStaticData, priorLocation) {
_open = false;
- _itemPresent = ((SceneViewWindow *)viewWindow)->getGlobalFlagByte(itemFlagOffset) == 0;
+ _itemPresent = ((SceneViewWindow *)viewWindow)->getGlobalFlags().cgGoldCoinsPresent == 0;
_openClickRegion = Common::Rect(openLeft, openTop, openRight, openBottom);
_acquireRegion = Common::Rect(getLeft, getTop, getRight, getBottom);
_fullFrameIndex = fullStillFrame;
_clearFrameIndex = clearStillFrame;
_itemID = itemID;
- _itemFlagOffset = itemFlagOffset;
_animOpenWith = animOpenWith;
_animOpenWithout = animOpenWithout;
}
@@ -991,9 +989,7 @@ int OpenFirstItemAcquire::mouseDown(Window *viewWindow, const Common::Point &poi
if (_acquireRegion.contains(pointLocation) && _itemPresent && _open) {
_itemPresent = false;
_staticData.navFrameIndex = _clearFrameIndex;
-
- if (_itemFlagOffset >= 0)
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(_itemFlagOffset, 1);
+ ((SceneViewWindow *)viewWindow)->getGlobalFlags().cgGoldCoinsPresent = 1;
// Call inventory drag start function
Common::Point ptInventoryWindow = viewWindow->convertPointToGlobal(pointLocation);
@@ -1028,9 +1024,7 @@ int OpenFirstItemAcquire::droppedItem(Window *viewWindow, int itemID, const Comm
if (_itemID == itemID && !_itemPresent && _open && pointLocation.x != -1 && pointLocation.y != -1) {
_itemPresent = true;
_staticData.navFrameIndex = _fullFrameIndex;
-
- if (_itemFlagOffset >= 0)
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(_itemFlagOffset, 0);
+ ((SceneViewWindow *)viewWindow)->getGlobalFlags().cgGoldCoinsPresent = 0;
viewWindow->invalidateWindow(false);
return SIC_ACCEPT;
diff --git a/engines/buried/environ/scene_common.h b/engines/buried/environ/scene_common.h
index 80cb7c7a5b0..de2f3f762ea 100644
--- a/engines/buried/environ/scene_common.h
+++ b/engines/buried/environ/scene_common.h
@@ -349,8 +349,7 @@ class OpenFirstItemAcquire : public SceneBase {
public:
OpenFirstItemAcquire(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
int openLeft = 0, int openTop = 0, int openRight = 0, int openBottom = 0, int getLeft = 0, int getTop = 0, int getRight = 0,
- int getBottom = 0, int animOpenWith = 0, int animOpenWithout = 0, int itemID = 0, int fullStillFrame = 0, int clearStillFrame = 0,
- int itemFlagOffset = 0);
+ int getBottom = 0, int animOpenWith = 0, int animOpenWithout = 0, int itemID = 0, int fullStillFrame = 0, int clearStillFrame = 0);
int mouseDown(Window *viewWindow, const Common::Point &pointLocation);
int mouseUp(Window *viewWindow, const Common::Point &pointLocation);
int droppedItem(Window *viewWindow, int itemID, const Common::Point &pointLocation, int itemFlags);
@@ -364,7 +363,6 @@ private:
int _fullFrameIndex;
int _clearFrameIndex;
int _itemID;
- int _itemFlagOffset;
int _animOpenWith;
int _animOpenWithout;
};
Commit: a900070a0759bb569a481497c4c927687bf7e886
https://github.com/scummvm/scummvm/commit/a900070a0759bb569a481497c4c927687bf7e886
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-02T12:20:49+02:00
Commit Message:
BURIED: Rewrite the post box slot flag logic in KitchenUnitPostBox
This reduces the usage of getGlobalFlagByte() and setGlobalFlagByte()
Changed paths:
engines/buried/environ/future_apartment.cpp
diff --git a/engines/buried/environ/future_apartment.cpp b/engines/buried/environ/future_apartment.cpp
index b861e25e36e..4cbe8abca48 100644
--- a/engines/buried/environ/future_apartment.cpp
+++ b/engines/buried/environ/future_apartment.cpp
@@ -636,12 +636,17 @@ private:
Common::Rect _replicateButton;
Graphics::Font *_textFont;
int _lineHeight;
+ GlobalFlags &_globalFlags;
void changeBackgroundBitmap();
+ byte *postBoxSlot(byte slot);
+ byte getPostBoxSlot(byte slot);
+ void setPostBoxSlot(byte slot, byte value);
};
KitchenUnitPostBox::KitchenUnitPostBox(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation) :
- SceneBase(vm, viewWindow, sceneStaticData, priorLocation) {
+ SceneBase(vm, viewWindow, sceneStaticData, priorLocation),
+ _globalFlags(((SceneViewWindow *)viewWindow)->getGlobalFlags()) {
_packageCount = 0;
_selectedPackage = -1;
_menuButton = Common::Rect(49, 96, 121, 118);
@@ -673,6 +678,30 @@ void KitchenUnitPostBox::preDestructor() {
_textFont = nullptr;
}
+byte *KitchenUnitPostBox::postBoxSlot(byte slot) {
+ switch (slot) {
+ case 0:
+ return &_globalFlags.faKIPostBoxSlotA;
+ case 1:
+ return &_globalFlags.faKIPostBoxSlotB;
+ case 2:
+ return &_globalFlags.faKIPostBoxSlotC;
+ default:
+ return nullptr;
+ }
+}
+
+byte KitchenUnitPostBox::getPostBoxSlot(byte slot) {
+ byte *s = postBoxSlot(slot);
+ return s ? *s : 0;
+}
+
+void KitchenUnitPostBox::setPostBoxSlot(byte slot, byte value) {
+ byte *s = postBoxSlot(slot);
+ if (s)
+ *s = value;
+}
+
int KitchenUnitPostBox::mouseUp(Window *viewWindow, const Common::Point &pointLocation) {
if (_menuButton.contains(pointLocation)) {
_vm->_sound->playSoundEffect(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, 8));
@@ -698,7 +727,7 @@ int KitchenUnitPostBox::mouseUp(Window *viewWindow, const Common::Point &pointLo
newScene.transitionStartFrame = -1;
newScene.transitionLength = -1;
- switch (((SceneViewWindow *)viewWindow)->getGlobalFlagByte(offsetof(GlobalFlags, faKIPostBoxSlotA) + _selectedPackage)) {
+ switch (getPostBoxSlot(_selectedPackage)) {
case 2:
newScene.destinationScene.depth = 6;
newScene.transitionData = 9;
@@ -715,12 +744,12 @@ int KitchenUnitPostBox::mouseUp(Window *viewWindow, const Common::Point &pointLo
// Remove the item from the post box
for (int i = _selectedPackage; i < _packageCount - 1; i++) {
- byte nextPackage = ((SceneViewWindow *)viewWindow)->getGlobalFlagByte(offsetof(GlobalFlags, faKIPostBoxSlotA) + i + 1);
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(offsetof(GlobalFlags, faKIPostBoxSlotA) + i, nextPackage);
+ byte nextPackage = getPostBoxSlot(i + 1);
+ setPostBoxSlot(i, nextPackage);
}
// Reset the last entry to 0
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(offsetof(GlobalFlags, faKIPostBoxSlotA) + _packageCount - 1, 0);
+ setPostBoxSlot(_packageCount - 1, 0);
// Move to the destination scene
((SceneViewWindow *)viewWindow)->moveToDestination(newScene);
@@ -747,7 +776,7 @@ int KitchenUnitPostBox::gdiPaint(Window *viewWindow) {
for (int i = 0; i < _packageCount; i++) {
Common::String text;
- switch (((SceneViewWindow *)viewWindow)->getGlobalFlagByte(offsetof(GlobalFlags, faKIPostBoxSlotA) + i)) {
+ switch (getPostBoxSlot(i)) {
case 2:
text = _vm->getString(IDFAKI_SN_TRANSLATE_CHIP_CODE_TITLE);
break;
Commit: d2b3bbd968f791d1261838c79da840635dfb524b
https://github.com/scummvm/scummvm/commit/d2b3bbd968f791d1261838c79da840635dfb524b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-02T12:20:49+02:00
Commit Message:
BURIED: Adapt the global flag parameters in the rest of the callbacks
This removes the majority of getGlobalFlagByte() and setGlobalFlagByte(),
and they are used only in playAICommentFromData() for AI comments now
Changed paths:
engines/buried/environ/alien.cpp
engines/buried/environ/castle.cpp
engines/buried/environ/da_vinci.cpp
engines/buried/environ/future_apartment.cpp
engines/buried/environ/mayan.cpp
engines/buried/environ/scene_common.cpp
engines/buried/environ/scene_common.h
diff --git a/engines/buried/environ/alien.cpp b/engines/buried/environ/alien.cpp
index 75c02050c05..219742d8b58 100644
--- a/engines/buried/environ/alien.cpp
+++ b/engines/buried/environ/alien.cpp
@@ -1173,6 +1173,9 @@ bool SceneViewWindow::startAlienAmbient(int oldTimeZone, int oldEnvironment, int
}
SceneBase *SceneViewWindow::constructAlienSceneObject(Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation) {
+ SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
+ GlobalFlags &globalFlags = sceneView->getGlobalFlags();
+
switch (sceneStaticData.classID) {
case 0:
// Default scene
@@ -1234,7 +1237,7 @@ SceneBase *SceneViewWindow::constructAlienSceneObject(Window *viewWindow, const
case 42:
return new NerveNavigation(_vm, viewWindow, sceneStaticData, priorLocation, 180, 160, 270, 189);
case 50:
- return new PlayStingers(_vm, viewWindow, sceneStaticData, priorLocation, 127, offsetof(GlobalFlags, asRBLastStingerID), offsetof(GlobalFlags, asRBStingerID), 10, 14);
+ return new PlayStingers(_vm, viewWindow, sceneStaticData, priorLocation, 127, globalFlags.asRBLastStingerID, globalFlags.asRBStingerID, 10, 14);
default:
warning("Unknown Alien scene object %d", sceneStaticData.classID);
break;
diff --git a/engines/buried/environ/castle.cpp b/engines/buried/environ/castle.cpp
index 1e5d2b2442b..e134b0ca863 100644
--- a/engines/buried/environ/castle.cpp
+++ b/engines/buried/environ/castle.cpp
@@ -1155,6 +1155,7 @@ bool SceneViewWindow::checkCustomCastleAICommentDependencies(const Location &com
SceneBase *SceneViewWindow::constructCastleSceneObject(Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation) {
SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
GlobalFlags &globalFlags = sceneView->getGlobalFlags();
+ byte dummyFlag = 0; // a dummy flag, used as a placeholder for writing (but not reading)
// Special scene for the trial version
if (_vm->isTrial())
@@ -1175,9 +1176,9 @@ SceneBase *SceneViewWindow::constructCastleSceneObject(Window *viewWindow, const
case 6:
return new WallSlideDeath(_vm, viewWindow, sceneStaticData, priorLocation);
case 7:
- return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, cgWallExploded), 0, 0, 1, 0, 0);
+ return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, globalFlags.cgWallExploded, 0, 0, 1, 0, 0);
case 8:
- return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, cgWallExploded), 0, 1, 0, 0, 0);
+ return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, globalFlags.cgWallExploded, 0, 1, 0, 0, 0);
case 9:
return new BasicDoor(_vm, viewWindow, sceneStaticData, priorLocation, 81, 25, 360, 189, 1, 4, 2, 1, 1, 1, 2, 11, 413, 25);
case 10:
@@ -1199,46 +1200,46 @@ SceneBase *SceneViewWindow::constructCastleSceneObject(Window *viewWindow, const
case 19:
return new KingsStudyGuard(_vm, viewWindow, sceneStaticData, priorLocation);
case 20:
- return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, cgHookPresent), 0, 0, 1, 0, 0);
+ return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, globalFlags.cgHookPresent, 0, 0, 1, 0, 0);
case 21:
- return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, cgHookPresent), 0, 1, 0, 0, 0);
+ return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, globalFlags.cgHookPresent, 0, 1, 0, 0, 0);
case 22:
return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 163, 83, 236, 162, kItemGrapplingHook, 75, globalFlags.cgHookPresent);
case 23:
- return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, cgArrowPresent), 0, 0, 1, 0, 0);
+ return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, globalFlags.cgArrowPresent, 0, 0, 1, 0, 0);
case 24:
- return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, cgArrowPresent), 0, 1, 0, 0, 0);
+ return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, globalFlags.cgArrowPresent, 0, 1, 0, 0, 0);
case 25:
return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 241, 7, 284, 92, kItemBloodyArrow, 57, globalFlags.cgArrowPresent);
case 26:
if (_vm->isDemo())
- return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, cgHammerPresent), 0, 0, 1, 0, 0);
+ return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, globalFlags.cgHammerPresent, 0, 0, 1, 0, 0);
break;
case 27:
if (_vm->isDemo())
- return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, cgHammerPresent), 0, 1, 0, 0, 0);
+ return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, globalFlags.cgHammerPresent, 0, 1, 0, 0, 0);
else
return new PlaySoundExitingFromScene(_vm, viewWindow, sceneStaticData, priorLocation, 14);
case 28:
return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 184, 111, 237, 189, kItemHammer, 3, globalFlags.cgHammerPresent);
case 29:
if (_vm->isDemo())
- return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, cgHammerPresent), 0, 0, 0, 1, 0);
+ return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, globalFlags.cgHammerPresent, 0, 0, 0, 1, 0);
break;
case 30:
- return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, cgHookPresent), 0, 0, 0, 1, 0);
+ return new TurnDepthPreChange(_vm, viewWindow, sceneStaticData, priorLocation, globalFlags.cgHookPresent, 0, 0, 0, 1, 0);
case 31:
return new ClickPlayVideo(_vm, viewWindow, sceneStaticData, priorLocation, 1, kCursorFinger, 51, 25, 149, 149);
case 32:
- return new OneShotEntryVideoWarning(_vm, viewWindow, sceneStaticData, priorLocation, 0, offsetof(GlobalFlags, cgSmithyGuard), IDS_HUMAN_PRESENCE_10METERS);
+ return new OneShotEntryVideoWarning(_vm, viewWindow, sceneStaticData, priorLocation, 0, globalFlags.cgSmithyGuard, IDS_HUMAN_PRESENCE_10METERS);
case 33:
- return new OneShotEntryVideoWarning(_vm, viewWindow, sceneStaticData, priorLocation, _vm->isDemo() ? 2 : 6, offsetof(GlobalFlags, cgBaileyOneWayGuard), IDS_HUMAN_PRESENCE_10METERS);
+ return new OneShotEntryVideoWarning(_vm, viewWindow, sceneStaticData, priorLocation, _vm->isDemo() ? 2 : 6, globalFlags.cgBaileyOneWayGuard, IDS_HUMAN_PRESENCE_10METERS);
case 34:
return new CycleEntryVideoWarning(_vm, viewWindow, sceneStaticData, priorLocation, _vm->isDemo() ? 5 : 7, _vm->isDemo() ? 6 : 8, IDS_HUMAN_PRESENCE_10METERS);
case 35:
- return new ClickPlayVideoSwitch(_vm, viewWindow, sceneStaticData, priorLocation, 3, kCursorFinger, offsetof(GlobalFlags, cgTapestryFlag), 0, 0, 330, 189);
+ return new ClickPlayVideoSwitch(_vm, viewWindow, sceneStaticData, priorLocation, 3, kCursorFinger, globalFlags.cgTapestryFlag, 0, 0, 330, 189);
case 36:
- return new ClickPlayVideoSwitch(_vm, viewWindow, sceneStaticData, priorLocation, 4, kCursorFinger, offsetof(GlobalFlags, cgTapestryFlag), 0, 0, 330, 189);
+ return new ClickPlayVideoSwitch(_vm, viewWindow, sceneStaticData, priorLocation, 4, kCursorFinger, globalFlags.cgTapestryFlag, 0, 0, 330, 189);
case 37:
return new GenericItemAcquire(_vm, viewWindow, sceneStaticData, priorLocation, 175, 64, 237, 126, kItemBurnedLetter, 84, globalFlags.cgBurnedLetterPresent);
case 38:
@@ -1294,15 +1295,15 @@ SceneBase *SceneViewWindow::constructCastleSceneObject(Window *viewWindow, const
// Original incremented the flag each time, but it's expected that the code will never go above 1
return new SetFlagOnEntry(_vm, viewWindow, sceneStaticData, priorLocation, globalFlags.cgViewedKeepPlans, 1);
case 67:
- return new ClickChangeSceneSetFlag(_vm, viewWindow, sceneStaticData, priorLocation, 10, 0, 376, 189, kCursorPutDown, 1, 6, 5, 1, 0, 0, TRANSITION_VIDEO, 5, -1, -1, offsetof(GlobalFlags, cgFoundChestPanel));
+ return new ClickChangeSceneSetFlag(_vm, viewWindow, sceneStaticData, priorLocation, 10, 0, 376, 189, kCursorPutDown, 1, 6, 5, 1, 0, 0, TRANSITION_VIDEO, 5, -1, -1, globalFlags.cgFoundChestPanel);
case 70:
return new PlaySoundExitingFromScene(_vm, viewWindow, sceneStaticData, priorLocation, 12);
case 71:
return new PlaySoundExitingFromScene(_vm, viewWindow, sceneStaticData, priorLocation, 14);
case 72:
- return new ClickPlaySound(_vm, viewWindow, sceneStaticData, priorLocation, -1, 12, kCursorFinger, 28, 34, 336, 189);
+ return new ClickPlaySound(_vm, viewWindow, sceneStaticData, priorLocation, dummyFlag, 12, kCursorFinger, 28, 34, 336, 189);
case 73:
- return new ClickPlaySound(_vm, viewWindow, sceneStaticData, priorLocation, -1, 13, kCursorFinger, 0, 0, 270, 189);
+ return new ClickPlaySound(_vm, viewWindow, sceneStaticData, priorLocation, dummyFlag, 13, kCursorFinger, 0, 0, 270, 189);
case 74:
return new PlaySoundExitingFromSceneDeux(_vm, viewWindow, sceneStaticData, priorLocation, 14);
case 75:
@@ -1310,7 +1311,7 @@ SceneBase *SceneViewWindow::constructCastleSceneObject(Window *viewWindow, const
case 76:
return new SetFlagOnEntry(_vm, viewWindow, sceneStaticData, priorLocation, globalFlags.cgSROpenedChest, 1);
case 77:
- return new ClickPlaySound(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, cgTSTriedDoorB), 14, kCursorFinger, 72, 0, 372, 189);
+ return new ClickPlaySound(_vm, viewWindow, sceneStaticData, priorLocation, globalFlags.cgTSTriedDoorB, 14, kCursorFinger, 72, 0, 372, 189);
default:
warning("Unknown Castle scene object %d", sceneStaticData.classID);
break;
diff --git a/engines/buried/environ/da_vinci.cpp b/engines/buried/environ/da_vinci.cpp
index 0eb321b4b9a..8b2486d53ad 100644
--- a/engines/buried/environ/da_vinci.cpp
+++ b/engines/buried/environ/da_vinci.cpp
@@ -2594,6 +2594,7 @@ bool SceneViewWindow::checkCustomDaVinciAICommentDependencies(const Location &co
SceneBase *SceneViewWindow::constructDaVinciSceneObject(Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation) {
SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
GlobalFlags &globalFlags = sceneView->getGlobalFlags();
+ byte dummyFlag = 0; // a dummy flag, used as a placeholder for writing (but not reading)
// Special scene for the trial version
if (_vm->isTrial())
@@ -2632,11 +2633,11 @@ SceneBase *SceneViewWindow::constructDaVinciSceneObject(Window *viewWindow, cons
case 14:
return new BasicDoor(_vm, viewWindow, sceneStaticData, priorLocation, 208, 0, 306, 189, 5, 3, 0, 2, 1, 1, TRANSITION_WALK, 11, 740, 23);
case 15:
- return new ClickPlaySound(_vm, viewWindow, sceneStaticData, priorLocation, -1, 13, kCursorFinger, 0, 0, 384, 189);
+ return new ClickPlaySound(_vm, viewWindow, sceneStaticData, priorLocation, dummyFlag, 13, kCursorFinger, 0, 0, 384, 189);
case 16:
return new PlaySoundExitingFromScene(_vm, viewWindow, sceneStaticData, priorLocation, 14);
case 17:
- return new ClickPlaySound(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, dsGDClickedOnCodexDoor), 13, kCursorFinger, 222, 0, 318, 189);
+ return new ClickPlaySound(_vm, viewWindow, sceneStaticData, priorLocation, globalFlags.dsGDClickedOnCodexDoor, 13, kCursorFinger, 222, 0, 318, 189);
case 18:
return new BasicDoor(_vm, viewWindow, sceneStaticData, priorLocation, 216, 0, 324, 189, 5, 3, 2, 0, 1, 1, TRANSITION_WALK, 11, 833, 26);
case 19:
@@ -2656,11 +2657,11 @@ SceneBase *SceneViewWindow::constructDaVinciSceneObject(Window *viewWindow, cons
case 26:
return new ClickChangeScene(_vm, viewWindow, sceneStaticData, priorLocation, 0, 44, 232, 189, kCursorMagnifyingGlass, 5, 4, 4, 3, 0, 1, TRANSITION_VIDEO, 7, -1, -1);
case 27:
- return new ClickChangeSceneSetFlag(_vm, viewWindow, sceneStaticData, priorLocation, 0, 0, 432, 189, kCursorPutDown, 5, 4, 4, 3, 0, 0, TRANSITION_VIDEO, 8, -1, -1, offsetof(GlobalFlags, dsWSSeenBallistaSketch));
+ return new ClickChangeSceneSetFlag(_vm, viewWindow, sceneStaticData, priorLocation, 0, 0, 432, 189, kCursorPutDown, 5, 4, 4, 3, 0, 0, TRANSITION_VIDEO, 8, -1, -1, globalFlags.dsWSSeenBallistaSketch);
case 28:
return new ClickChangeScene(_vm, viewWindow, sceneStaticData, priorLocation, 112, 52, 380, 189, kCursorMagnifyingGlass, 5, 4, 4, 2, 0, 1, TRANSITION_VIDEO, 9, -1, -1);
case 29:
- return new ClickChangeSceneSetFlag(_vm, viewWindow, sceneStaticData, priorLocation, 0, 0, 432, 189, kCursorPutDown, 5, 4, 4, 2, 0, 0, TRANSITION_VIDEO, 10, -1, -1, offsetof(GlobalFlags, dsWSSeenBallistaSketch));
+ return new ClickChangeSceneSetFlag(_vm, viewWindow, sceneStaticData, priorLocation, 0, 0, 432, 189, kCursorPutDown, 5, 4, 4, 2, 0, 0, TRANSITION_VIDEO, 10, -1, -1, globalFlags.dsWSSeenBallistaSketch);
case 30:
return new ClickChangeScene(_vm, viewWindow, sceneStaticData, priorLocation, 96, 130, 222, 164, kCursorMagnifyingGlass, 5, 4, 7, 3, 1, 1, TRANSITION_VIDEO, 11, -1, -1 );
case 31:
@@ -2718,7 +2719,7 @@ SceneBase *SceneViewWindow::constructDaVinciSceneObject(Window *viewWindow, cons
case 57:
return new CourtyardCannon(_vm, viewWindow, sceneStaticData, priorLocation);
case 58:
- return new ClickPlayVideoSwitch(_vm, viewWindow, sceneStaticData, priorLocation, 1, kCursorFinger, offsetof(GlobalFlags, dsCYWeebleClicked), 200, 88, 270, 189);
+ return new ClickPlayVideoSwitch(_vm, viewWindow, sceneStaticData, priorLocation, 1, kCursorFinger, globalFlags.dsCYWeebleClicked, 200, 88, 270, 189);
case 59:
return new ClickPlayVideo(_vm, viewWindow, sceneStaticData, priorLocation, 2, kCursorFinger, 70, 136, 190, 189);
case 60:
@@ -2750,9 +2751,9 @@ SceneBase *SceneViewWindow::constructDaVinciSceneObject(Window *viewWindow, cons
case 73:
return new LensFilterNotify(_vm, viewWindow, sceneStaticData, priorLocation);
case 74:
- return new ClickPlaySound(_vm, viewWindow, sceneStaticData, priorLocation, -1, 13, kCursorFinger, 140, 0, 432, 189);
+ return new ClickPlaySound(_vm, viewWindow, sceneStaticData, priorLocation, dummyFlag, 13, kCursorFinger, 140, 0, 432, 189);
case 75:
- return new ClickPlaySound(_vm, viewWindow, sceneStaticData, priorLocation, offsetof(GlobalFlags, dsCYTriedElevator), 13, kCursorFinger, 140, 130, 432, 189);
+ return new ClickPlaySound(_vm, viewWindow, sceneStaticData, priorLocation, globalFlags.dsCYTriedElevator, 13, kCursorFinger, 140, 130, 432, 189);
case 76:
return new PlaySoundEnteringScene(_vm, viewWindow, sceneStaticData, priorLocation, 12, globalFlags.dsCTPlayedBallistaFalling);
case 77:
diff --git a/engines/buried/environ/future_apartment.cpp b/engines/buried/environ/future_apartment.cpp
index 4cbe8abca48..08d88cf16fa 100644
--- a/engines/buried/environ/future_apartment.cpp
+++ b/engines/buried/environ/future_apartment.cpp
@@ -1989,15 +1989,16 @@ bool SceneViewWindow::startFutureApartmentAmbient(int oldTimeZone, int oldEnviro
SceneBase *SceneViewWindow::constructFutureApartmentSceneObject(Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation) {
SceneViewWindow *sceneView = ((SceneViewWindow *)viewWindow);
GlobalFlags &globalFlags = sceneView->getGlobalFlags();
+ byte dummyFlag = 0; // a dummy flag, used as a placeholder for writing (but not reading)
switch (sceneStaticData.classID) {
case 0:
// Default scene
break;
case 1:
- return new ClickPlayVideoSwitchAI(_vm, viewWindow, sceneStaticData, priorLocation, 0, kCursorFinger, offsetof(GlobalFlags, faKICoffeeSpilled), 212, 114, 246, 160);
+ return new ClickPlayVideoSwitchAI(_vm, viewWindow, sceneStaticData, priorLocation, 0, kCursorFinger, globalFlags.faKICoffeeSpilled, 212, 114, 246, 160);
case 2:
- return new ClickPlayVideoSwitchAI(_vm, viewWindow, sceneStaticData, priorLocation, 1, kCursorFinger, offsetof(GlobalFlags, faKIBirdsBobbed), 150, 40, 260, 164);
+ return new ClickPlayVideoSwitchAI(_vm, viewWindow, sceneStaticData, priorLocation, 1, kCursorFinger, globalFlags.faKIBirdsBobbed, 150, 40, 260, 164);
case 3:
return new OvenDoor(_vm, viewWindow, sceneStaticData, priorLocation, 2, 3, 37, 25, 0, 0, 270, 80);
case 4:
@@ -2045,7 +2046,7 @@ SceneBase *SceneViewWindow::constructFutureApartmentSceneObject(Window *viewWind
case 26:
return new FlagChangeBackground(_vm, viewWindow, sceneStaticData, priorLocation, 1, 9);
case 30:
- return new PlayStingers(_vm, viewWindow, sceneStaticData, priorLocation, 128, offsetof(GlobalFlags, faStingerID), offsetof(GlobalFlags, faStingerChannelID), 10, 14);
+ return new PlayStingers(_vm, viewWindow, sceneStaticData, priorLocation, 128, globalFlags.faStingerID, globalFlags.faStingerChannelID, 10, 14);
case 31:
return new ClickZoomInTopOfBookshelf(_vm, viewWindow, sceneStaticData, priorLocation);
case 32:
@@ -2073,9 +2074,9 @@ SceneBase *SceneViewWindow::constructFutureApartmentSceneObject(Window *viewWind
case 43:
return new ClickChangeScene(_vm, viewWindow, sceneStaticData, priorLocation, 0, 0, 432, 189, kCursorPutDown, 4, 3, 5, 0, 0, 0, TRANSITION_VIDEO, 29, -1, -1);
case 44:
- return new ClickPlayLoopingVideoClip(_vm, viewWindow, sceneStaticData, priorLocation, kCursorFinger, 25, 120, 0, 299, 132, offsetof(GlobalFlags, faMNPongClicked), 1);
+ return new ClickPlayLoopingVideoClip(_vm, viewWindow, sceneStaticData, priorLocation, kCursorFinger, 25, 120, 0, 299, 132, globalFlags.faMNPongClicked, 1);
case 45:
- return new ClickPlayLoopingVideoClip(_vm, viewWindow, sceneStaticData, priorLocation, kCursorFinger, 27, 0, 0, 432, 189);
+ return new ClickPlayLoopingVideoClip(_vm, viewWindow, sceneStaticData, priorLocation, kCursorFinger, 27, 0, 0, 432, 189, dummyFlag, 0);
case 46:
return new ClickChangeScene(_vm, viewWindow, sceneStaticData, priorLocation, 44, 26, 254, 144, kCursorMagnifyingGlass, 4, 3, 0, 2, 0, 1, TRANSITION_VIDEO, 30, -1, -1);
case 47:
diff --git a/engines/buried/environ/mayan.cpp b/engines/buried/environ/mayan.cpp
index 0a7e51bc76f..88b1cfc723e 100644
--- a/engines/buried/environ/mayan.cpp
+++ b/engines/buried/environ/mayan.cpp
@@ -2799,7 +2799,7 @@ SceneBase *SceneViewWindow::constructMayanSceneObject(Window *viewWindow, const
case 69:
return new PlaySoundExitingFromScene(_vm, viewWindow, sceneStaticData, priorLocation, 10);
case 70:
- return new PlayStingers(_vm, viewWindow, sceneStaticData, priorLocation, 128, offsetof(GlobalFlags, myMCStingerID), offsetof(GlobalFlags, myMCStingerChannelID), 11, 14);
+ return new PlayStingers(_vm, viewWindow, sceneStaticData, priorLocation, 128, globalFlags.myMCStingerID, globalFlags.myMCStingerChannelID, 11, 14);
case 71:
return new DisplayMessageWithEvidenceWhenEnteringNode(_vm, viewWindow, sceneStaticData, priorLocation, MAYAN_EVIDENCE_BROKEN_GLASS_PYRAMID, IDS_MBT_EVIDENCE_PRESENT);
case 72:
diff --git a/engines/buried/environ/scene_common.cpp b/engines/buried/environ/scene_common.cpp
index b04bac981c3..a8e5dad8579 100644
--- a/engines/buried/environ/scene_common.cpp
+++ b/engines/buried/environ/scene_common.cpp
@@ -93,9 +93,9 @@ int BasicDoor::specifyCursor(Window *viewWindow, const Common::Point &pointLocat
}
TurnDepthPreChange::TurnDepthPreChange(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int flagOffset, int upDepth, int leftDepth, int rightDepth, int downDepth, int forwardDepth) :
+ byte &flag, int upDepth, int leftDepth, int rightDepth, int downDepth, int forwardDepth) :
SceneBase(vm, viewWindow, sceneStaticData, priorLocation) {
- if (((SceneViewWindow *)viewWindow)->getGlobalFlagByte(flagOffset)) {
+ if (flag) {
if (upDepth >= 0)
_staticData.destUp.destinationScene.depth = upDepth;
@@ -255,19 +255,18 @@ int ClickChangeScene::specifyCursor(Window *viewWindow, const Common::Point &poi
ClickPlayVideoSwitchAI::ClickPlayVideoSwitchAI(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int animID, int cursorID, int flagOffset, int left, int top, int right, int bottom) :
- SceneBase(vm, viewWindow, sceneStaticData, priorLocation) {
+ int animID, int cursorID, byte &flag, int left, int top, int right, int bottom) :
+ SceneBase(vm, viewWindow, sceneStaticData, priorLocation), _flag(flag) {
_cursorID = cursorID;
_animID = animID;
_clickRegion = Common::Rect(left, top, right, bottom);
- _flagOffset = flagOffset;
}
int ClickPlayVideoSwitchAI::mouseUp(Window *viewWindow, const Common::Point &pointLocation) {
if (_clickRegion.contains(pointLocation)) {
// Play the animation clip
((SceneViewWindow *)viewWindow)->playSynchronousAnimation(_animID);
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(_flagOffset, 1);
+ _flag = 1;
// Play any spontaneous AI comments
if (((GameUIWindow *)viewWindow->getParent())->_inventoryWindow->isItemInInventory(kItemBioChipAI)) {
@@ -291,61 +290,52 @@ int ClickPlayVideoSwitchAI::specifyCursor(Window *viewWindow, const Common::Poin
ClickChangeSceneSetFlag::ClickChangeSceneSetFlag(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
int left, int top, int right, int bottom, int cursorID,
int timeZone, int environment, int node, int facing, int orientation, int depth,
- int transitionType, int transitionData, int transitionStartFrame, int transitionLength, int flagIndex) :
+ int transitionType, int transitionData, int transitionStartFrame, int transitionLength, byte &flag) :
ClickChangeScene(vm, viewWindow, sceneStaticData, priorLocation, left, top, right, bottom, cursorID, timeZone, environment, node, facing, orientation, depth,
transitionType, transitionData, transitionStartFrame, transitionLength) {
- if (flagIndex >= 0)
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(flagIndex, 1);
+ flag = 1;
}
PlayStingers::PlayStingers(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int stingerVolume, int lastStingerFlagOffset, int effectIDFlagOffset, int firstStingerFileID, int lastStingerFileID) :
- SceneBase(vm, viewWindow, sceneStaticData, priorLocation) {
+ int stingerVolume, byte &lastStingerFlag, byte &effectIDFlag, int firstStingerFileID, int lastStingerFileID) :
+ SceneBase(vm, viewWindow, sceneStaticData, priorLocation),
+ _lastStingerFlag(lastStingerFlag), _effectIDFlag(effectIDFlag) {
_stingerVolume = stingerVolume;
- _lastStingerFlagOffset = lastStingerFlagOffset;
- _effectIDFlagOffset = effectIDFlagOffset;
_firstStingerFileID = firstStingerFileID;
_lastStingerFileID = lastStingerFileID;
}
int PlayStingers::postEnterRoom(Window *viewWindow, const Location &priorLocation) {
- if (_effectIDFlagOffset >= 0) {
- // More evil.
- byte effectID = ((SceneViewWindow *)viewWindow)->getGlobalFlagByte(_effectIDFlagOffset);
-
- if (!_vm->_sound->isSoundEffectPlaying(effectID - 1)) {
- byte lastStinger = ((SceneViewWindow *)viewWindow)->getGlobalFlagByte(_lastStingerFlagOffset);
- lastStinger++;
+ if (!_vm->_sound->isSoundEffectPlaying(_effectIDFlag - 1)) {
+ byte lastStinger = _lastStingerFlag;
+ lastStinger++;
- uint32 fileNameIndex = _vm->computeFileNameResourceID(_staticData.location.timeZone, _staticData.location.environment, _firstStingerFileID + lastStinger - 1);
- byte newStingerID = _vm->_sound->playSoundEffect(_vm->getFilePath(fileNameIndex), _stingerVolume, false, true) + 1;
+ uint32 fileNameIndex = _vm->computeFileNameResourceID(_staticData.location.timeZone, _staticData.location.environment, _firstStingerFileID + lastStinger - 1);
+ byte newStingerID = _vm->_sound->playSoundEffect(_vm->getFilePath(fileNameIndex), _stingerVolume, false, true) + 1;
- if (lastStinger > _lastStingerFileID - _firstStingerFileID)
- lastStinger = 0;
+ if (lastStinger > _lastStingerFileID - _firstStingerFileID)
+ lastStinger = 0;
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(_effectIDFlagOffset, newStingerID);
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(_lastStingerFlagOffset, lastStinger);
- }
+ _effectIDFlag = newStingerID;
+ _lastStingerFlag = lastStinger;
}
return SC_TRUE;
}
ClickPlaySound::ClickPlaySound(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int flagOffset, int soundID, int cursorID, int left, int top, int right, int bottom) :
- SceneBase(vm, viewWindow, sceneStaticData, priorLocation) {
+ byte &flag, int soundID, int cursorID, int left, int top, int right, int bottom) :
+ SceneBase(vm, viewWindow, sceneStaticData, priorLocation), _flag(flag) {
_cursorID = cursorID;
_soundID = soundID;
_clickRegion = Common::Rect(left, top, right, bottom);
- _flagOffset = flagOffset;
}
int ClickPlaySound::mouseUp(Window *viewWindow, const Common::Point &pointLocation) {
if (_clickRegion.contains(pointLocation)) {
_vm->_sound->playSoundEffect(_vm->getFilePath(_staticData.location.timeZone, _staticData.location.environment, _soundID), 127, false, true);
- if (_flagOffset >= 0)
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(_flagOffset, 1);
+ _flag = 1;
if (((GameUIWindow *)viewWindow->getParent())->_inventoryWindow->isItemInInventory(kItemBioChipAI))
((SceneViewWindow *)viewWindow)->playAIComment(_staticData.location, AI_COMMENT_TYPE_SPONTANEOUS);
@@ -742,12 +732,11 @@ int DisplayMessageWithEvidenceWhenEnteringNode::postEnterRoom(Window *viewWindow
}
ClickPlayLoopingVideoClip::ClickPlayLoopingVideoClip(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int cursorID, int animID, int left, int top, int right, int bottom, int flagOffset, int newFlagValue) :
- SceneBase(vm, viewWindow, sceneStaticData, priorLocation) {
+ int cursorID, int animID, int left, int top, int right, int bottom, byte &flag, int newFlagValue) :
+ SceneBase(vm, viewWindow, sceneStaticData, priorLocation), _flag(flag) {
_cursorID = cursorID;
_animID = animID;
_clickRegion = Common::Rect(left, top, right, bottom);
- _flagOffset = flagOffset;
_flagValue = newFlagValue;
_playing = false;
}
@@ -757,9 +746,7 @@ int ClickPlayLoopingVideoClip::preExitRoom(Window *viewWindow, const Location &n
((SceneViewWindow *)viewWindow)->stopAsynchronousAnimation();
_vm->_sound->restart();
_playing = false;
-
- if (_flagOffset >= 0 && _flagValue >= 0)
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(_flagOffset, _flagValue);
+ _flag = _flagValue;
}
return SC_TRUE;
@@ -774,8 +761,7 @@ int ClickPlayLoopingVideoClip::mouseUp(Window *viewWindow, const Common::Point &
_vm->_sound->restart();
// Change the flag
- if (_flagOffset >= 0 && _flagValue >= 0)
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(_flagOffset, _flagValue);
+ _flag = _flagValue;
// Check for spontaneous AI comments
if (((GameUIWindow *)viewWindow->getParent())->_inventoryWindow->isItemInInventory(kItemBioChipAI))
@@ -802,19 +788,19 @@ int ClickPlayLoopingVideoClip::specifyCursor(Window *viewWindow, const Common::P
}
OneShotEntryVideoWarning::OneShotEntryVideoWarning(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int animID, int flagOffset, int warningMessageID) : SceneBase(vm, viewWindow, sceneStaticData, priorLocation) {
+ int animID, byte &flag, int warningMessageID) :
+ SceneBase(vm, viewWindow, sceneStaticData, priorLocation), _flag(flag) {
_animID = animID;
- _flagOffset = flagOffset;
_warningMessageID = warningMessageID;
}
int OneShotEntryVideoWarning::postEnterRoom(Window *viewWindow, const Location &priorLocation) {
- if (((SceneViewWindow *)viewWindow)->getGlobalFlagByte(_flagOffset) == 0) {
+ if (_flag == 0) {
if (_warningMessageID >= 0)
((SceneViewWindow *)viewWindow)->displayLiveText(_vm->getString(_warningMessageID));
((SceneViewWindow *)viewWindow)->playSynchronousAnimation(_animID);
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(_flagOffset, 1);
+ _flag = 1;
}
return SC_TRUE;
@@ -855,26 +841,23 @@ int CycleEntryVideoWarning::postEnterRoom(Window *viewWindow, const Location &pr
}
ClickPlayVideoSwitch::ClickPlayVideoSwitch(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int animID, int cursorID, int flagOffset, int left, int top, int right, int bottom) :
- SceneBase(vm, viewWindow, sceneStaticData, priorLocation) {
+ int animID, int cursorID, byte &flag, int left, int top, int right, int bottom) :
+ SceneBase(vm, viewWindow, sceneStaticData, priorLocation), _flag(flag) {
_cursorID = cursorID;
_animID = animID;
_clickRegion = Common::Rect(left, top, right, bottom);
- _flagOffset = flagOffset;
}
int ClickPlayVideoSwitch::mouseUp(Window *viewWindow, const Common::Point &pointLocation) {
if (_clickRegion.contains(pointLocation)) {
((SceneViewWindow *)viewWindow)->playSynchronousAnimation(_animID);
- if (_flagOffset >= 0) {
- ((SceneViewWindow *)viewWindow)->setGlobalFlagByte(_flagOffset, 1);
+ _flag = 1;
- if (((GameUIWindow *)viewWindow->getParent())->_inventoryWindow->isItemInInventory(kItemBioChipAI))
- ((SceneViewWindow *)viewWindow)->playAIComment(_staticData.location, AI_COMMENT_TYPE_SPONTANEOUS);
+ if (((GameUIWindow *)viewWindow->getParent())->_inventoryWindow->isItemInInventory(kItemBioChipAI))
+ ((SceneViewWindow *)viewWindow)->playAIComment(_staticData.location, AI_COMMENT_TYPE_SPONTANEOUS);
- ((GameUIWindow *)viewWindow->getParent())->_bioChipRightWindow->sceneChanged();
- }
+ ((GameUIWindow *)viewWindow->getParent())->_bioChipRightWindow->sceneChanged();
return SC_TRUE;
}
diff --git a/engines/buried/environ/scene_common.h b/engines/buried/environ/scene_common.h
index de2f3f762ea..1a93b836ffa 100644
--- a/engines/buried/environ/scene_common.h
+++ b/engines/buried/environ/scene_common.h
@@ -52,7 +52,7 @@ public:
class TurnDepthPreChange : public SceneBase {
public:
TurnDepthPreChange(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int flagOffset = -1, int upDepth = -1, int leftDepth = -1, int rightDepth = -1, int downDepth = -1, int forwardDepth = -1);
+ byte &flag, int upDepth = -1, int leftDepth = -1, int rightDepth = -1, int downDepth = -1, int forwardDepth = -1);
};
class GenericItemAcquire : public SceneBase {
@@ -121,7 +121,7 @@ private:
class ClickPlayVideoSwitchAI : public SceneBase {
public:
ClickPlayVideoSwitchAI(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int animID = 0, int cursorID = 0, int flagOffset = 0, int left = 0, int top = 0, int right = 0, int bottom = 0);
+ int animID, int cursorID, byte &flag, int left = 0, int top = 0, int right = 0, int bottom = 0);
int mouseUp(Window *viewWindow, const Common::Point &pointLocation);
int specifyCursor(Window *viewWindow, const Common::Point &pointLocation);
@@ -129,27 +129,27 @@ private:
int _cursorID;
int _animID;
Common::Rect _clickRegion;
- int _flagOffset;
+ byte &_flag;
};
class ClickChangeSceneSetFlag : public ClickChangeScene {
public:
ClickChangeSceneSetFlag(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int left = -1, int top = -1, int right = -1, int bottom = -1, int cursorID = 0,
- int timeZone = -1, int environment = -1, int node = -1, int facing = -1, int orientation = -1, int depth = -1,
- int transitionType = -1, int transitionData = -1, int transitionStartFrame = -1, int transitionLength = -1, int flagIndex = -1);
+ int left, int top, int right, int bottom, int cursorID,
+ int timeZone, int environment, int node, int facing, int orientation, int depth,
+ int transitionType, int transitionData, int transitionStartFrame, int transitionLength, byte &flag);
};
class PlayStingers : public SceneBase {
public:
PlayStingers(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int stingerVolume = 127, int lastStingerFlagOffset = -1, int effectIDFlagOffset = -1, int firstStingerFileID = -1, int lastStingerFileID = -1);
+ int stingerVolume, byte &lastStingerFlag, byte &effectIDFlag, int firstStingerFileID, int lastStingerFileID);
int postEnterRoom(Window *viewWindow, const Location &priorLocation);
private:
int _stingerVolume;
- int _lastStingerFlagOffset;
- int _effectIDFlagOffset;
+ byte &_lastStingerFlag;
+ byte &_effectIDFlag;
int _firstStingerFileID;
int _lastStingerFileID;
};
@@ -157,7 +157,7 @@ private:
class ClickPlaySound : public SceneBase {
public:
ClickPlaySound(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int flagOffset = -1, int soundID = 0, int cursorID = 0, int left = 0, int top = 0, int right = 0, int bottom = 0);
+ byte &flag, int soundID, int cursorID, int left, int top, int right, int bottom);
int mouseUp(Window *viewWindow, const Common::Point &pointLocation);
int specifyCursor(Window *viewWindow, const Common::Point &pointLocation);
@@ -165,7 +165,7 @@ private:
int _cursorID;
int _soundID;
Common::Rect _clickRegion;
- int _flagOffset;
+ byte &_flag;
};
class ClickZoom : public SceneBase {
@@ -248,7 +248,7 @@ private:
class ClickPlayLoopingVideoClip : public SceneBase {
public:
ClickPlayLoopingVideoClip(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int cursorID = 0, int animID = -1, int left = 0, int top = 0, int right = 0, int bottom = 0, int flagOffset = -1, int newFlagValue = -1);
+ int cursorID, int animID, int left, int top, int right, int bottom, byte &flag, int newFlagValue);
int preExitRoom(Window *viewWindow, const Location &newLocation);
int mouseUp(Window *viewWindow, const Common::Point &pointLocation);
int specifyCursor(Window *viewWindow, const Common::Point &pointLocation);
@@ -257,7 +257,7 @@ private:
int _cursorID;
int _animID;
Common::Rect _clickRegion;
- int _flagOffset;
+ byte &_flag;
int _flagValue;
bool _playing;
};
@@ -265,12 +265,12 @@ private:
class OneShotEntryVideoWarning : public SceneBase {
public:
OneShotEntryVideoWarning(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int animID = 0, int flagOffset = 0, int warningMessageID = -1);
+ int animID, byte &flag, int warningMessageID);
int postEnterRoom(Window *viewWindow, const Location &priorLocation);
private:
int _animID;
- int _flagOffset;
+ byte &_flag;
int _warningMessageID;
};
@@ -295,7 +295,7 @@ private:
class ClickPlayVideoSwitch : public SceneBase {
public:
ClickPlayVideoSwitch(BuriedEngine *vm, Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation,
- int animID = 0, int cursorID = -1, int flagOffset = 0, int left = 0, int top = 0, int right = 0, int bottom = 0);
+ int animID, int cursorID, byte &flag, int left = 0, int top = 0, int right = 0, int bottom = 0);
int mouseUp(Window *viewWindow, const Common::Point &pointLocation);
int specifyCursor(Window *viewWindow, const Common::Point &pointLocation);
@@ -304,7 +304,7 @@ private:
int _cursorID;
int _animID;
Common::Rect _clickRegion;
- int _flagOffset;
+ byte &_flag;
};
class ClickPlayVideo : public SceneBase {
Commit: 660ce11b109ff25d1aadec3943f8d30fab015144
https://github.com/scummvm/scummvm/commit/660ce11b109ff25d1aadec3943f8d30fab015144
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-02T12:20:50+02:00
Commit Message:
BURIED: Rewrite the AI comment info data into an array
This cleans up the code and allows us to reuse this data
Changed paths:
engines/buried/scene_view.cpp
engines/buried/scene_view.h
diff --git a/engines/buried/scene_view.cpp b/engines/buried/scene_view.cpp
index f613b8b90b9..ef386c04dc4 100644
--- a/engines/buried/scene_view.cpp
+++ b/engines/buried/scene_view.cpp
@@ -2037,152 +2037,15 @@ bool SceneViewWindow::playAICommentFromData(const AIComment &commentData) {
Common::String commentFileName = "BITDATA/";
- switch (commentData.location.timeZone) {
- case 1: // Castle
- commentFileName += "CASTLE/";
-
- switch (commentData.location.environment) {
- case 1:
- commentFileName += "CGTT";
- break;
- case 2:
- commentFileName += "CGTS";
- break;
- case 3:
- commentFileName += "CGMW";
- break;
- case 4:
- commentFileName += "CGMB";
- break;
- case 5:
- commentFileName += "CGBS";
- break;
- case 6:
- commentFileName += "CGKC";
- break;
- case 7:
- commentFileName += "CGST";
- break;
- case 8:
- commentFileName += "CGKS";
- break;
- case 9:
- commentFileName += "CGSR";
- break;
- case 10:
- commentFileName += "CGTR";
- break;
- default:
- return false;
- }
- break;
- case 2: // Mayan
- commentFileName += "MAYAN/";
-
- switch (commentData.location.environment) {
- case 1:
- commentFileName += "MYTP";
- break;
- case 2:
- commentFileName += "MYMC";
- break;
- case 3:
- commentFileName += "MYWG";
- break;
- case 4:
- commentFileName += "MYWT";
- break;
- case 5:
- commentFileName += "MYAG";
- break;
- case 6:
- commentFileName += "MYDG";
- break;
- default:
- return false;
- }
- break;
- case 4: // Future Apartment
- commentFileName += "FUTAPT/";
-
- switch (commentData.location.environment) {
- case 1:
- commentFileName += "FAKI";
- break;
- case 2:
- commentFileName += "FAER";
- break;
- case 3:
- commentFileName += "FAMN";
+ for (const AICommentInfo *info = s_aiCommentInfo; info->timeZone; ++info) {
+ if (info->timeZone == commentData.location.timeZone && info->environment == commentData.location.environment) {
+ commentFileName += info->filePath;
break;
- default:
- return false;
- }
- break;
- case 5: // Da Vinci
- commentFileName += "DAVINCI/";
-
- switch (commentData.location.environment) {
- case 1:
- commentFileName += "DSPT";
- break;
- case 2:
- commentFileName += "DSCT";
- break;
- case 3:
- commentFileName += "DSGD";
- break;
- case 4:
- commentFileName += "DSWS";
- break;
- case 5:
- commentFileName += "DSCY";
- break;
- default:
- return false;
}
- break;
- case 6: // Space Station
- commentFileName += "AILAB/";
+ }
- switch (commentData.location.environment) {
- case 1:
- commentFileName += "AIHW";
- break;
- case 2:
- commentFileName += "AICR";
- break;
- case 3:
- commentFileName += "AIDB";
- break;
- case 4:
- commentFileName += "AISC";
- break;
- case 5:
- commentFileName += "AINX";
- break;
- case 6:
- commentFileName += "AIIC";
- break;
- case 7:
- commentFileName += "AISW";
- break;
- case 8:
- commentFileName += "AIMR";
- break;
- case 9:
- // There is no 9.
- return false;
- case 10:
- commentFileName += "AIHW";
- break;
- default:
- return false;
- }
- break;
- default:
+ if (commentFileName == "BITDATA/")
return false;
- }
commentFileName += "_";
diff --git a/engines/buried/scene_view.h b/engines/buried/scene_view.h
index 73b2d83eadd..685175466ce 100644
--- a/engines/buried/scene_view.h
+++ b/engines/buried/scene_view.h
@@ -162,6 +162,8 @@ public:
const SceneBase *getCurrentScene() const { return _currentScene; }
+ Common::Array<AIComment> getAICommentDatabase(int timeZone, int environment);
+
private:
Graphics::Surface *_preBuffer;
SceneBase *_currentScene;
@@ -205,7 +207,6 @@ private:
SceneBase *constructSceneObject(Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation);
Common::Array<AnimEvent> getAnimationDatabase(int timeZone, int environment);
- Common::Array<AIComment> getAICommentDatabase(int timeZone, int environment);
bool moveToDestination(const DestinationScene &destinationData, int navFrame);
@@ -248,6 +249,34 @@ private:
SceneBase *constructAlienSceneObject(Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation);
};
+struct AICommentInfo {
+ byte timeZone;
+ byte environment;
+ const char *filePath;
+};
+
+// timeZone, environment, filePath
+static const AICommentInfo s_aiCommentInfo[] {
+ // Castle
+ { 1, 1, "CASTLE/CGTT" }, { 1, 2, "CASTLE/CGTS" }, { 1, 3, "CASTLE/CGMW" },
+ { 1, 4, "CASTLE/CGMB" }, { 1, 5, "CASTLE/CGBS" }, { 1, 6, "CASTLE/CGKC" },
+ { 1, 7, "CASTLE/CGST" }, { 1, 8, "CASTLE/CGKS" }, { 1, 9, "CASTLE/CGSR" },
+ { 1, 10, "CASTLE/CGTR" },
+ // Mayan
+ { 2, 1, "MAYAN/MYTP" }, { 2, 2, "MAYAN/MYMC" }, { 2, 3, "MAYAN/MYWG" },
+ { 2, 4, "MAYAN/MYWT" }, { 2, 5, "MAYAN/MYAG" }, { 2, 6, "MAYAN/MYDG" },
+ // Future Apartment
+ { 4, 1, "FUTAPT/FAKI" }, { 4, 2, "FUTAPT/FAER" }, { 4, 3, "FUTAPT/FAMN" },
+ // Da Vinci
+ { 5, 1, "DAVINCI/DSPT" }, { 5, 2, "DAVINCI/DSCT" }, { 5, 3, "DAVINCI/DSGD" },
+ { 5, 4, "DAVINCI/DSWS" }, { 5, 5, "DAVINCI/DSCY" },
+ // Space Station
+ { 6, 1, "AILAB/AIHW" }, { 6, 2, "AILAB/AICR" }, { 6, 3, "AILAB/AIDB" },
+ { 6, 4, "AILAB/AISC" }, { 6, 5, "AILAB/AINX" }, { 6, 6, "AILAB/AIIC" },
+ { 6, 7, "AILAB/AISW" }, { 6, 8, "AILAB/AIMR" }, { 6, 10, "AILAB/AIHW" }, // there is no 9
+ { 0, 0, "" }
+};
+
} // End of namespace Buried
#endif
Commit: 9c81f95440c3d3d1e317bd4ac85e465168aa24f4
https://github.com/scummvm/scummvm/commit/9c81f95440c3d3d1e317bd4ac85e465168aa24f4
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-02T12:20:50+02:00
Commit Message:
BURIED: Add console command aicommentinfo
This will allow us to debug AI comment info data
Changed paths:
engines/buried/console.cpp
engines/buried/console.h
diff --git a/engines/buried/console.cpp b/engines/buried/console.cpp
index cae4bdcc320..bba8c4b766a 100644
--- a/engines/buried/console.cpp
+++ b/engines/buried/console.cpp
@@ -40,6 +40,7 @@ BuriedConsole::BuriedConsole(BuriedEngine *vm) : _vm(vm) {
registerCmd("jumpentry", WRAP_METHOD(BuriedConsole, cmdJumpEntry));
registerCmd("curloc", WRAP_METHOD(BuriedConsole, cmdCurLocation));
+ registerCmd("aicommentinfo", WRAP_METHOD(BuriedConsole, cmdAiCommentInfo));
}
BuriedConsole::~BuriedConsole() {
@@ -155,6 +156,83 @@ bool BuriedConsole::cmdCurLocation(int argc, const char **argv) {
return true;
}
+bool BuriedConsole::cmdAiCommentInfo(int argc, const char **argv) {
+ loadJumpEntryList();
+
+ if (argc < 2) {
+ debugPrintf("Usage: %s <index>\n\nEntries:\n", argv[0]);
+ debugPrintf("# |Time Zone |Environment \n");
+ debugPrintf("--|----------------|-----------------------\n");
+
+ for (uint32 i = 0; i < _jumpEntryList.size(); i++) {
+ const JumpEntry &entry = _jumpEntryList[i];
+ debugPrintf("%2d|%-16s|%-23s\n", i + 1, entry.timeZoneName.c_str(), entry.locationName.c_str());
+ }
+
+ return true;
+ }
+
+ // Bail if not playing
+ if (!isPlaying())
+ return true;
+
+ int entry = atoi(argv[1]) - 1;
+ if (entry < 0 || entry >= (int)_jumpEntryList.size()) {
+ debugPrintf("Invalid entry!\n");
+ return true;
+ }
+
+ FrameWindow *frameWindow = getFrameWindow();
+ if (!frameWindow)
+ return true;
+
+ SceneViewWindow *sceneView = ((GameUIWindow *)frameWindow->getMainChildWindow())->_sceneViewWindow;
+ if (!sceneView) {
+ debugPrintf("No scene view!\n");
+ return true;
+ }
+
+ // Check if the location has AI comment data
+ Location &loc = _jumpEntryList[entry].location;
+ bool found = false;
+
+ for (const AICommentInfo *info = s_aiCommentInfo; info->timeZone; ++info) {
+ if (info->timeZone == loc.timeZone && info->environment == loc.environment) {
+ found = true;
+ break;
+ }
+ }
+
+ if (found) {
+ Common::Array<AIComment> commentDatabase = sceneView->getAICommentDatabase(loc.timeZone, loc.environment);
+
+ if (!commentDatabase.empty()) {
+ debugPrintf("ID |Flags |DFlagA |non-base |DValA |DFlagB |non-base |DValB |SFlag |non-base\n");
+ debugPrintf("----|------|-------|---------|------|-------|---------|------|------|--------\n");
+ for (uint32 i = 0; i < commentDatabase.size(); i++) {
+ const AIComment &comment = commentDatabase[i];
+ debugPrintf("%4d|%-6d|%-7d|%-9d|%-6d|%-7d|%-9d|%-6d|%-6d|%-8d\n",
+ comment.commentID, comment.commentFlags,
+ comment.dependencyFlagOffsetA,
+ comment.commentFlags & AI_DEPENDENCY_FLAG_NON_BASE_DERIVED_A,
+ comment.dependencyValueA,
+ comment.dependencyFlagOffsetB,
+ comment.commentFlags & AI_DEPENDENCY_FLAG_NON_BASE_DERIVED_B,
+ comment.dependencyValueB,
+ comment.statusFlagOffset,
+ comment.commentFlags & AI_STATUS_FLAG_NON_BASE_DERIVED);
+ }
+
+ } else {
+ debugPrintf("Location has no AI comment data");
+ }
+ } else {
+ debugPrintf("Location has no AI comment data");
+ }
+
+ return true;
+}
+
void BuriedConsole::postEnter() {
GUI::Debugger::postEnter();
diff --git a/engines/buried/console.h b/engines/buried/console.h
index cc0f9642278..ad7e34638ae 100644
--- a/engines/buried/console.h
+++ b/engines/buried/console.h
@@ -40,6 +40,7 @@ public:
bool cmdRemoveItem(int argc, const char **argv);
bool cmdJumpEntry(int argc, const char **argv);
bool cmdCurLocation(int argc, const char **argv);
+ bool cmdAiCommentInfo(int argc, const char **argv);
protected:
void postEnter();
Commit: 8a62864d28534df78ac62507e23ad7a2d288ce70
https://github.com/scummvm/scummvm/commit/8a62864d28534df78ac62507e23ad7a2d288ce70
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-02T12:20:50+02:00
Commit Message:
BURIED: Remove offset access to globals in checkAICommentDependencies
This has been verified with the AI comment data. Only four global
variables are actually accessed by offset, so these have been cleanly
defined. This allows us to remove the last use cases of getGlobalFlagByte()
and setGlobalFlagByte()
Changed paths:
engines/buried/scene_view.cpp
engines/buried/scene_view.h
diff --git a/engines/buried/scene_view.cpp b/engines/buried/scene_view.cpp
index ef386c04dc4..846c66be796 100644
--- a/engines/buried/scene_view.cpp
+++ b/engines/buried/scene_view.cpp
@@ -1416,24 +1416,6 @@ bool SceneViewWindow::closeCycleFrameMovie() {
return true;
}
-byte SceneViewWindow::getGlobalFlagByte(int offset) {
- // TODO: Verify the offset
-
- if (offset < 0)
- return 0;
-
- const byte *data = (const byte *)&_globalFlags;
- return data[offset];
-}
-
-bool SceneViewWindow::setGlobalFlagByte(int offset, byte value) {
- // TODO: Verify the offset
-
- byte *data = (byte *)&_globalFlags;
- data[offset] = value;
- return true;
-}
-
bool SceneViewWindow::addNumberToGlobalFlagTable(int tableOffset, int curItemCountOffset, int maxItems, byte numberToAdd) {
// TODO: Rewrite this
byte *data = (byte *)&_globalFlags;
@@ -1993,6 +1975,40 @@ bool SceneViewWindow::retrieveAICommentEntry(const Location &commentLocation, in
return entryFound;
}
+byte* SceneViewWindow::aiFlag(uint16 offset) {
+ switch (offset) {
+ case 93:
+ return &_globalFlags.faMNTazClicked;
+ case 94:
+ return &_globalFlags.faMNPongClicked;
+ case 95:
+ return &_globalFlags.faKIBirdsBobbed;
+ case 96:
+ return &_globalFlags.faKICoffeeSpilled;
+ default:
+ return nullptr;
+ }
+}
+
+byte SceneViewWindow::getAIFlag(uint16 offset) {
+ byte *flag = aiFlag(offset);
+ if (flag) {
+ return *flag;
+ } else {
+ warning("Unable to get AI flag with offset %d", offset);
+ return 0;
+ }
+}
+
+void SceneViewWindow::setAIFlag(uint16 offset, byte value) {
+ byte *flag = aiFlag(offset);
+ if (flag) {
+ *flag = value;
+ } else {
+ warning("Unable to set AI flag with offset %d", offset);
+ }
+}
+
bool SceneViewWindow::checkAICommentDependencies(const Location &commentLocation, const AIComment &commentData) {
// Ignore comments designed for solely adventure mode in walkthrough mode
if (_globalFlags.generalWalkthroughMode == 1 && commentData.commentFlags & AI_COMMENT_DISABLE_IN_WALKTHROUGH)
@@ -2000,7 +2016,7 @@ bool SceneViewWindow::checkAICommentDependencies(const Location &commentLocation
byte flagValueA = 0;
if (commentData.commentFlags & AI_DEPENDENCY_FLAG_NON_BASE_DERIVED_A)
- flagValueA = getGlobalFlagByte(commentData.dependencyFlagOffsetA);
+ flagValueA = getAIFlag(commentData.dependencyFlagOffsetA);
else
flagValueA = _globalFlags.aiData[commentData.dependencyFlagOffsetA];
@@ -2018,7 +2034,7 @@ bool SceneViewWindow::checkAICommentDependencies(const Location &commentLocation
byte flagValueB = 0;
if (commentData.commentFlags & AI_DEPENDENCY_FLAG_NON_BASE_DERIVED_B)
- flagValueB = getGlobalFlagByte(commentData.dependencyFlagOffsetB);
+ flagValueB = getAIFlag(commentData.dependencyFlagOffsetB);
else
flagValueB = _globalFlags.aiData[commentData.dependencyFlagOffsetB];
@@ -2072,14 +2088,14 @@ bool SceneViewWindow::playAICommentFromData(const AIComment &commentData) {
byte flagValue = 0;
if (commentData.commentFlags & AI_STATUS_FLAG_NON_BASE_DERIVED)
- flagValue = getGlobalFlagByte(commentData.statusFlagOffset);
+ flagValue = getAIFlag(commentData.statusFlagOffset);
else
flagValue = _globalFlags.aiData[commentData.statusFlagOffset];
flagValue++;
if (commentData.commentFlags & AI_STATUS_FLAG_NON_BASE_DERIVED)
- setGlobalFlagByte(commentData.statusFlagOffset, flagValue);
+ setAIFlag(commentData.statusFlagOffset, flagValue);
else
_globalFlags.aiData[commentData.statusFlagOffset] = flagValue;
diff --git a/engines/buried/scene_view.h b/engines/buried/scene_view.h
index 685175466ce..cdb723b3756 100644
--- a/engines/buried/scene_view.h
+++ b/engines/buried/scene_view.h
@@ -98,8 +98,6 @@ public:
bool isCyclingEnabled() const { return _cycleEnabled || _forceCycleEnabled; }
bool closeCycleFrameMovie();
- byte getGlobalFlagByte(int offset);
- bool setGlobalFlagByte(int offset, byte value);
bool addNumberToGlobalFlagTable(int offset, int curItemCountOffset, int maxItems, byte numberToAdd);
byte getNumberFromGlobalFlagTable(int offset, int tableIndex);
bool isNumberInGlobalFlagTable(int offset, int curItemCountOffset, byte numberToCheck);
@@ -247,6 +245,10 @@ private:
bool initializeAlienTimeZoneAndEnvironment(Window *viewWindow, int environment);
bool startAlienAmbient(int oldTimeZone, int oldEnvironment, int environment, bool fade);
SceneBase *constructAlienSceneObject(Window *viewWindow, const LocationStaticData &sceneStaticData, const Location &priorLocation);
+
+ byte *aiFlag(uint16 offset);
+ byte getAIFlag(uint16 offset);
+ void setAIFlag(uint16 offset, byte value);
};
struct AICommentInfo {
Commit: 654cf8301839bb48bfc55eae11e142e471c63206
https://github.com/scummvm/scummvm/commit/654cf8301839bb48bfc55eae11e142e471c63206
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-02T12:20:50+02:00
Commit Message:
BURIED: Rewrite the logic for biochip evidence access to global vars
This allows us to remove the last traces of offsetof(), together with
struct packing for the GlobalFlags struct, since its members are now
accessed directly, without using offsets
Changed paths:
engines/buried/biochip_view.cpp
engines/buried/environ/ai_lab.cpp
engines/buried/environ/castle.cpp
engines/buried/environ/da_vinci.cpp
engines/buried/environ/mayan.cpp
engines/buried/environ/scene_common.cpp
engines/buried/global_flags.h
engines/buried/scene_view.cpp
engines/buried/scene_view.h
diff --git a/engines/buried/biochip_view.cpp b/engines/buried/biochip_view.cpp
index 7ce0eb154e4..4af9a6ab42a 100644
--- a/engines/buried/biochip_view.cpp
+++ b/engines/buried/biochip_view.cpp
@@ -429,7 +429,7 @@ void EvidenceBioChipViewWindow::onLButtonUp(const Common::Point &point, uint fla
// Loop through the evidence piece regions, determining if we have another page to go to
for (int i = 0; i < 6; i++) {
if (_evidence[i].contains(point) && (_pageIndex * 6 + i) < itemCount) {
- _status = ((SceneViewWindow *)getParent()->getParent())->getNumberFromGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), _pageIndex * 6 + i);
+ _status = ((SceneViewWindow *)getParent()->getParent())->getNumberFromGlobalFlagTable(_pageIndex * 6 + i);
invalidateWindow(false);
((GameUIWindow *)getParent()->getParent()->getParent())->_liveTextWindow->updateLiveText(_vm->getString(IDS_EC_DESC_TEXT_A + _status - 1), false);
@@ -470,7 +470,7 @@ bool EvidenceBioChipViewWindow::rebuildMainPrebuffer() {
for (int i = 0; i < 6; i++) {
if ((_pageIndex * 6 + i) < itemCount) {
- frameIndex = ((SceneViewWindow *)getParent()->getParent())->getNumberFromGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), _pageIndex * 6 + i) - 1;
+ frameIndex = ((SceneViewWindow *)getParent()->getParent())->getNumberFromGlobalFlagTable(_pageIndex * 6 + i) - 1;
frame = _evidenceFrames.getFrame(frameIndex);
if (frame) {
diff --git a/engines/buried/environ/ai_lab.cpp b/engines/buried/environ/ai_lab.cpp
index 3d28470598b..275f1d0611a 100644
--- a/engines/buried/environ/ai_lab.cpp
+++ b/engines/buried/environ/ai_lab.cpp
@@ -3149,7 +3149,7 @@ int MachineRoomTamperedSculpture::mouseUp(Window *viewWindow, const Common::Poin
((SceneViewWindow *)viewWindow)->playSynchronousAnimation(1);
// Attempt to add it to the biochip
- if (((SceneViewWindow *)viewWindow)->addNumberToGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), 12, AI_EVIDENCE_SCULPTURE))
+ if (((SceneViewWindow *)viewWindow)->addNumberToGlobalFlagTable(AI_EVIDENCE_SCULPTURE))
((SceneViewWindow *)viewWindow)->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_RIPPLE_DOCUMENTED));
else
((SceneViewWindow *)viewWindow)->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_ALREADY_ACQUIRED));
@@ -3178,7 +3178,7 @@ int MachineRoomTamperedSculpture::mouseUp(Window *viewWindow, const Common::Poin
int MachineRoomTamperedSculpture::postEnterRoom(Window *viewWindow, const Location &priorLocation) {
// If we have not yet captured it, set the anachronism message
- if (!((SceneViewWindow *)viewWindow)->isNumberInGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), AI_EVIDENCE_SCULPTURE))
+ if (!((SceneViewWindow *)viewWindow)->isNumberInGlobalFlagTable(AI_EVIDENCE_SCULPTURE))
((SceneViewWindow *)viewWindow)->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_PRESENT));
return SC_TRUE;
@@ -3186,7 +3186,7 @@ int MachineRoomTamperedSculpture::postEnterRoom(Window *viewWindow, const Locati
int MachineRoomTamperedSculpture::locateAttempted(Window *viewWindow, const Common::Point &pointLocation) {
if (((SceneViewWindow *)viewWindow)->getGlobalFlags().bcLocateEnabled == 1 && _clickable.contains(pointLocation) &&
- !((SceneViewWindow *)viewWindow)->isNumberInGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), AI_EVIDENCE_SCULPTURE)) {
+ !((SceneViewWindow *)viewWindow)->isNumberInGlobalFlagTable(AI_EVIDENCE_SCULPTURE)) {
((SceneViewWindow *)viewWindow)->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_MUST_BE_REVEALED)); // All will be reveaaaaaled
return SC_TRUE;
}
diff --git a/engines/buried/environ/castle.cpp b/engines/buried/environ/castle.cpp
index e134b0ca863..6c1a2680863 100644
--- a/engines/buried/environ/castle.cpp
+++ b/engines/buried/environ/castle.cpp
@@ -702,7 +702,7 @@ int MiddleBaileyFootprintCapture::locateAttempted(Window *viewWindow, const Comm
((SceneViewWindow *)viewWindow)->playSynchronousAnimation(9);
// Add it to the list
- if (((SceneViewWindow *)viewWindow)->addNumberToGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), 12, CASTLE_EVIDENCE_FOOTPRINT))
+ if (((SceneViewWindow *)viewWindow)->addNumberToGlobalFlagTable(CASTLE_EVIDENCE_FOOTPRINT))
((SceneViewWindow *)viewWindow)->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_ACQUIRED));
else
((SceneViewWindow *)viewWindow)->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_ALREADY_ACQUIRED));
@@ -757,7 +757,7 @@ int TreasureRoomSwordCapture::locateAttempted(Window *viewWindow, const Common::
((SceneViewWindow *)viewWindow)->getGlobalFlags().cgTRFoundSword = 1;
// Attempt to add it to the biochip
- if (((SceneViewWindow *)viewWindow)->addNumberToGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), 12, CASTLE_EVIDENCE_SWORD))
+ if (((SceneViewWindow *)viewWindow)->addNumberToGlobalFlagTable(CASTLE_EVIDENCE_SWORD))
((SceneViewWindow *)viewWindow)->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_RIPPLE_DOCUMENTED));
else
((SceneViewWindow *)viewWindow)->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_ALREADY_ACQUIRED));
@@ -857,7 +857,7 @@ int StorageRoomDoor::mouseUp(Window *viewWindow, const Common::Point &pointLocat
}
if (globalFlags.cgStorageRoomVisit == 0) {
- if (((SceneViewWindow *)viewWindow)->addNumberToGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), 12, CASTLE_EVIDENCE_AGENT3))
+ if (((SceneViewWindow *)viewWindow)->addNumberToGlobalFlagTable(CASTLE_EVIDENCE_AGENT3))
((SceneViewWindow *)viewWindow)->displayLiveText(vm->getString(IDS_MBT_EVIDENCE_ACQUIRED));
else
((SceneViewWindow *)viewWindow)->displayLiveText(vm->getString(IDS_MBT_EVIDENCE_ALREADY_ACQUIRED));
diff --git a/engines/buried/environ/da_vinci.cpp b/engines/buried/environ/da_vinci.cpp
index 8b2486d53ad..04f103b4817 100644
--- a/engines/buried/environ/da_vinci.cpp
+++ b/engines/buried/environ/da_vinci.cpp
@@ -88,7 +88,7 @@ int CapturePaintingTowerFootprint::locateAttempted(Window *viewWindow, const Com
((SceneViewWindow *)viewWindow)->playSynchronousAnimation(0);
// Attempt to add it to the biochip
- if (((SceneViewWindow *)viewWindow)->addNumberToGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), 12, DAVINCI_EVIDENCE_FOOTPRINT))
+ if (((SceneViewWindow *)viewWindow)->addNumberToGlobalFlagTable(DAVINCI_EVIDENCE_FOOTPRINT))
((SceneViewWindow *)viewWindow)->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_ACQUIRED));
else
((SceneViewWindow *)viewWindow)->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_ALREADY_ACQUIRED));
@@ -955,7 +955,7 @@ int CodexTowerLensEvidenceCapture::locateAttempted(Window *viewWindow, const Com
((SceneViewWindow *)viewWindow)->moveToDestination(destData);
// Add it to the list
- if (((SceneViewWindow *)viewWindow)->addNumberToGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), 12, DAVINCI_EVIDENCE_LENS_FILTER))
+ if (((SceneViewWindow *)viewWindow)->addNumberToGlobalFlagTable(DAVINCI_EVIDENCE_LENS_FILTER))
((SceneViewWindow *)viewWindow)->displayLiveText(vm->getString(IDS_MBT_EVIDENCE_ACQUIRED));
else
((SceneViewWindow *)viewWindow)->displayLiveText(vm->getString(IDS_MBT_EVIDENCE_ALREADY_ACQUIRED));
@@ -1192,7 +1192,7 @@ ZoomInOnCodexes::ZoomInOnCodexes(BuriedEngine *vm, Window *viewWindow, const Loc
int ZoomInOnCodexes::postEnterRoom(Window *viewWindow, const Location &priorLocation) {
// If we have not yet captured the codex evidence, display a message
- if (!((SceneViewWindow *)viewWindow)->isNumberInGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), DAVINCI_EVIDENCE_CODEX))
+ if (!((SceneViewWindow *)viewWindow)->isNumberInGlobalFlagTable(DAVINCI_EVIDENCE_CODEX))
((SceneViewWindow *)viewWindow)->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_PRESENT));
((SceneViewWindow *)viewWindow)->getGlobalFlags().dsCYFoundCodexes = 1;
@@ -1236,7 +1236,7 @@ int ZoomInOnCodexes::mouseUp(Window *viewWindow, const Common::Point &pointLocat
}
int ZoomInOnCodexes::locateAttempted(Window *viewWindow, const Common::Point &pointLocation) {
- if (((SceneViewWindow *)viewWindow)->getGlobalFlags().bcLocateEnabled == 1 && _middleCodex.contains(pointLocation) && !((SceneViewWindow *)viewWindow)->isNumberInGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), DAVINCI_EVIDENCE_CODEX)) {
+ if (((SceneViewWindow *)viewWindow)->getGlobalFlags().bcLocateEnabled == 1 && _middleCodex.contains(pointLocation) && !((SceneViewWindow *)viewWindow)->isNumberInGlobalFlagTable(DAVINCI_EVIDENCE_CODEX)) {
((SceneViewWindow *)viewWindow)->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_MUST_BE_REVEALED));
((GameUIWindow *)viewWindow->getParent())->_bioChipRightWindow->disableEvidenceCapture();
return SC_TRUE;
@@ -1432,7 +1432,7 @@ int BrowseCodex::timerCallback(Window *viewWindow) {
((SceneViewWindow *)viewWindow)->playSynchronousAnimation(24);
// Attempt to add it to your evidence biochip
- if (((SceneViewWindow *)viewWindow)->addNumberToGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), 12, DAVINCI_EVIDENCE_CODEX))
+ if (((SceneViewWindow *)viewWindow)->addNumberToGlobalFlagTable(DAVINCI_EVIDENCE_CODEX))
((SceneViewWindow *)viewWindow)->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_RIPPLE_DOCUMENTED));
else
((SceneViewWindow *)viewWindow)->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_ALREADY_ACQUIRED));
@@ -1453,7 +1453,7 @@ int BrowseCodex::timerCallback(Window *viewWindow) {
}
int BrowseCodex::locateAttempted(Window *viewWindow, const Common::Point &pointLocation) {
- if (_lensStartFrame >= 0 && !((SceneViewWindow *)viewWindow)->isNumberInGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), DAVINCI_EVIDENCE_CODEX)) {
+ if (_lensStartFrame >= 0 && !((SceneViewWindow *)viewWindow)->isNumberInGlobalFlagTable(DAVINCI_EVIDENCE_CODEX)) {
((SceneViewWindow *)viewWindow)->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_MUST_BE_REVEALED));
((GameUIWindow *)viewWindow->getParent())->_bioChipRightWindow->disableEvidenceCapture();
return SC_TRUE;
@@ -1463,7 +1463,7 @@ int BrowseCodex::locateAttempted(Window *viewWindow, const Common::Point &pointL
}
int BrowseCodex::specifyCursor(Window *viewWindow, const Common::Point &pointLocation) {
- if (_lensStartFrame >= 0 && ((SceneViewWindow *)viewWindow)->getGlobalFlags().bcLocateEnabled == 1 && !((SceneViewWindow *)viewWindow)->isNumberInGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), DAVINCI_EVIDENCE_CODEX))
+ if (_lensStartFrame >= 0 && ((SceneViewWindow *)viewWindow)->getGlobalFlags().bcLocateEnabled == 1 && !((SceneViewWindow *)viewWindow)->isNumberInGlobalFlagTable(DAVINCI_EVIDENCE_CODEX))
return -2;
if (_top.contains(pointLocation) && (_curPage % 2) != 0)
@@ -1916,12 +1916,12 @@ PaintingTowerCapAgent::PaintingTowerCapAgent(BuriedEngine *vm, Window *viewWindo
int PaintingTowerCapAgent::postEnterRoom(Window *viewWindow, const Location &priorLocation) {
((SceneViewWindow *)viewWindow)->getGlobalFlags().dsPTBeenOnBalcony = 1;
- if (!((SceneViewWindow *)viewWindow)->isNumberInGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), DAVINCI_EVIDENCE_AGENT3)) {
+ if (!((SceneViewWindow *)viewWindow)->isNumberInGlobalFlagTable(DAVINCI_EVIDENCE_AGENT3)) {
// Play animation of capturing the evidence
((SceneViewWindow *)viewWindow)->playSynchronousAnimation(11);
// Attempt to add the evidence to the biochip
- ((SceneViewWindow *)viewWindow)->addNumberToGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), 12, DAVINCI_EVIDENCE_AGENT3);
+ ((SceneViewWindow *)viewWindow)->addNumberToGlobalFlagTable(DAVINCI_EVIDENCE_AGENT3);
((SceneViewWindow *)viewWindow)->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_ACQUIRED));
// Turn off evidence capture
@@ -2354,7 +2354,7 @@ LensFilterNotify::LensFilterNotify(BuriedEngine *vm, Window *viewWindow, const L
}
int LensFilterNotify::postEnterRoom(Window *viewWindow, const Location &newLocation) {
- if (newLocation.node != _staticData.location.node && !((SceneViewWindow *)viewWindow)->isNumberInGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), DAVINCI_EVIDENCE_LENS_FILTER))
+ if (newLocation.node != _staticData.location.node && !((SceneViewWindow *)viewWindow)->isNumberInGlobalFlagTable(DAVINCI_EVIDENCE_LENS_FILTER))
((SceneViewWindow *)viewWindow)->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_PRESENT));
return SC_TRUE;
@@ -2371,7 +2371,7 @@ CodexFormulaeNotify::CodexFormulaeNotify(BuriedEngine *vm, Window *viewWindow, c
}
int CodexFormulaeNotify::postEnterRoom(Window *viewWindow, const Location &newLocation) {
- if (newLocation.node != _staticData.location.node && !((SceneViewWindow *)viewWindow)->isNumberInGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), DAVINCI_EVIDENCE_CODEX))
+ if (newLocation.node != _staticData.location.node && !((SceneViewWindow *)viewWindow)->isNumberInGlobalFlagTable(DAVINCI_EVIDENCE_CODEX))
((SceneViewWindow *)viewWindow)->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_PRESENT));
return SC_TRUE;
diff --git a/engines/buried/environ/mayan.cpp b/engines/buried/environ/mayan.cpp
index 88b1cfc723e..9d328df241b 100644
--- a/engines/buried/environ/mayan.cpp
+++ b/engines/buried/environ/mayan.cpp
@@ -547,7 +547,7 @@ int GenericCavernDoorMainView::postEnterRoom(Window *viewWindow, const Location
if (loc.node == 7 && (loc.timeZone != priorLocation.timeZone ||
loc.environment != priorLocation.environment || loc.node != priorLocation.node ||
loc.facing != priorLocation.facing || loc.orientation != priorLocation.orientation ||
- loc.depth != priorLocation.depth) && !sceneView->isNumberInGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), MAYAN_EVIDENCE_BROKEN_GLASS_PYRAMID))
+ loc.depth != priorLocation.depth) && !sceneView->isNumberInGlobalFlagTable(MAYAN_EVIDENCE_BROKEN_GLASS_PYRAMID))
sceneView->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_PRESENT));
return SC_TRUE;
}
@@ -1935,7 +1935,7 @@ int DeathGodAltar::postEnterRoom(Window *viewWindow, const Location &priorLocati
Location &loc = _staticData.location;
if (globalFlags.myDGOfferedHeart == 1) {
- if (!sceneView->isNumberInGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), MAYAN_EVIDENCE_ENVIRON_CART)) {
+ if (!sceneView->isNumberInGlobalFlagTable(MAYAN_EVIDENCE_ENVIRON_CART)) {
sceneView->playSynchronousAnimation(3);
_staticData.navFrameIndex = 51;
viewWindow->invalidateWindow(false);
@@ -1943,13 +1943,13 @@ int DeathGodAltar::postEnterRoom(Window *viewWindow, const Location &priorLocati
if ((loc.timeZone != priorLocation.timeZone || loc.environment != priorLocation.environment ||
loc.node != priorLocation.node || loc.facing != priorLocation.facing ||
loc.orientation != priorLocation.orientation || loc.depth != priorLocation.depth) &&
- !sceneView->isNumberInGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), MAYAN_EVIDENCE_ENVIRON_CART))
+ !sceneView->isNumberInGlobalFlagTable(MAYAN_EVIDENCE_ENVIRON_CART))
sceneView->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_PRESENT));
}
} else if ((loc.timeZone != priorLocation.timeZone || loc.environment != priorLocation.environment ||
loc.node != priorLocation.node || loc.facing != priorLocation.facing ||
loc.orientation != priorLocation.orientation || loc.depth != priorLocation.depth) &&
- !sceneView->isNumberInGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), MAYAN_EVIDENCE_PHONY_BLOOD)) {
+ !sceneView->isNumberInGlobalFlagTable(MAYAN_EVIDENCE_PHONY_BLOOD)) {
sceneView->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_PRESENT));
}
@@ -1992,7 +1992,7 @@ int DeathGodAltar::droppedItem(Window *viewWindow, int itemID, const Common::Poi
sceneView->playSynchronousAnimation(3);
_staticData.navFrameIndex = 51;
- if (!sceneView->isNumberInGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), MAYAN_EVIDENCE_ENVIRON_CART))
+ if (!sceneView->isNumberInGlobalFlagTable(MAYAN_EVIDENCE_ENVIRON_CART))
sceneView->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_PRESENT));
return SIC_ACCEPT;
@@ -2031,7 +2031,7 @@ int DeathGodAltar::locateAttempted(Window *viewWindow, const Common::Point &poin
if (globalFlags.bcLocateEnabled == 1 &&
globalFlags.takenEnvironCart == 0 &&
_puzzleBox.contains(pointLocation) && _staticData.navFrameIndex == 51 &&
- !sceneView->isNumberInGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), MAYAN_EVIDENCE_ENVIRON_CART)) {
+ !sceneView->isNumberInGlobalFlagTable(MAYAN_EVIDENCE_ENVIRON_CART)) {
sceneView->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_MUST_BE_REVEALED)); // All will be reveaaaaaaaaled (Yes, I used this joke twice now)
return SC_TRUE;
}
@@ -2041,7 +2041,7 @@ int DeathGodAltar::locateAttempted(Window *viewWindow, const Common::Point &poin
sceneView->playSynchronousAnimation(6);
// Attempt to add it to the biochip
- if (sceneView->addNumberToGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), 12, MAYAN_EVIDENCE_PHONY_BLOOD))
+ if (sceneView->addNumberToGlobalFlagTable(MAYAN_EVIDENCE_PHONY_BLOOD))
sceneView->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_ACQUIRED));
else
sceneView->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_ALREADY_ACQUIRED));
@@ -2197,7 +2197,7 @@ int DeathGodPuzzleBox::mouseUp(Window *viewWindow, const Common::Point &pointLoc
sceneView->playSynchronousAnimation(7);
// Attempt to add it to the biochip
- if (sceneView->addNumberToGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), 12, MAYAN_EVIDENCE_ENVIRON_CART))
+ if (sceneView->addNumberToGlobalFlagTable(MAYAN_EVIDENCE_ENVIRON_CART))
sceneView->displayLiveText(vm->getString(IDS_MBT_EVIDENCE_RIPPLE_DOCUMENTED));
else
sceneView->displayLiveText(vm->getString(IDS_MBT_EVIDENCE_ALREADY_ACQUIRED));
@@ -2321,7 +2321,7 @@ int MainCavernGlassCapture::locateAttempted(Window *viewWindow, const Common::Po
sceneView->playSynchronousAnimation(22);
// Attempt to add it to the biochip
- if (sceneView->addNumberToGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), 12, MAYAN_EVIDENCE_BROKEN_GLASS_PYRAMID))
+ if (sceneView->addNumberToGlobalFlagTable(MAYAN_EVIDENCE_BROKEN_GLASS_PYRAMID))
sceneView->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_ACQUIRED));
else
sceneView->displayLiveText(_vm->getString(IDS_MBT_EVIDENCE_ALREADY_ACQUIRED));
diff --git a/engines/buried/environ/scene_common.cpp b/engines/buried/environ/scene_common.cpp
index a8e5dad8579..e4d477ef059 100644
--- a/engines/buried/environ/scene_common.cpp
+++ b/engines/buried/environ/scene_common.cpp
@@ -724,7 +724,7 @@ int DisplayMessageWithEvidenceWhenEnteringNode::postEnterRoom(Window *viewWindow
_staticData.location.facing != priorLocation.facing ||
_staticData.location.orientation != priorLocation.orientation ||
_staticData.location.depth != priorLocation.depth) &&
- !((SceneViewWindow *)viewWindow)->isNumberInGlobalFlagTable(offsetof(GlobalFlags, evcapBaseID), offsetof(GlobalFlags, evcapNumCaptured), _evidenceID)) {
+ !((SceneViewWindow *)viewWindow)->isNumberInGlobalFlagTable(_evidenceID)) {
((SceneViewWindow *)viewWindow)->displayLiveText(_vm->getString(_messageBoxTextID));
}
diff --git a/engines/buried/global_flags.h b/engines/buried/global_flags.h
index 5126e7b4a84..19aea5b9ca1 100644
--- a/engines/buried/global_flags.h
+++ b/engines/buried/global_flags.h
@@ -31,12 +31,6 @@ namespace Buried {
// This is the struct that holds all the global variables for the game
// Originally, it was just a 1024 byte block of data with offsets into it
-// (There clearly aren't enough variables)
-// For double-fun, they still need to be accessed by index for AI support
-// -> It therefore needs to be packed (Yes, this is totally evil)
-// This is all horrible, really. Avert your eyes.
-
-#include "common/pack-start.h"
struct GlobalFlags {
byte cgWallExploded; // 0
@@ -317,9 +311,7 @@ struct GlobalFlags {
byte generalWalkthroughMode; // 500
byte unused5[11]; // 501-511
byte aiData[512]; // 512-1023
-} PACKED_STRUCT;
-
-#include "common/pack-end.h"
+};
enum {
kAIHWStartingValue = 100,
diff --git a/engines/buried/scene_view.cpp b/engines/buried/scene_view.cpp
index 846c66be796..b0d55af0076 100644
--- a/engines/buried/scene_view.cpp
+++ b/engines/buried/scene_view.cpp
@@ -1416,38 +1416,26 @@ bool SceneViewWindow::closeCycleFrameMovie() {
return true;
}
-bool SceneViewWindow::addNumberToGlobalFlagTable(int tableOffset, int curItemCountOffset, int maxItems, byte numberToAdd) {
- // TODO: Rewrite this
- byte *data = (byte *)&_globalFlags;
- byte *itemCountPtr = data + curItemCountOffset;
- int itemCount = *itemCountPtr;
-
- if (itemCount >= maxItems)
+bool SceneViewWindow::addNumberToGlobalFlagTable(byte numberToAdd) {
+ if (_globalFlags.evcapNumCaptured >= 12)
return false;
- byte *tableEntries = data + tableOffset;
- for (int i = 0; i < itemCount; i++)
- if (tableEntries[i] == numberToAdd)
+ for (int i = 0; i < _globalFlags.evcapNumCaptured; i++)
+ if (_globalFlags.evcapBaseID[i] == numberToAdd)
return false;
- tableEntries[itemCount] = numberToAdd;
- *itemCountPtr = itemCount + 1;
+ _globalFlags.evcapBaseID[_globalFlags.evcapNumCaptured] = numberToAdd;
+ _globalFlags.evcapNumCaptured++;
return true;
}
-byte SceneViewWindow::getNumberFromGlobalFlagTable(int tableOffset, int tableIndex) {
- const byte *data = (const byte *)&_globalFlags;
- return data[tableOffset + tableIndex];
+byte SceneViewWindow::getNumberFromGlobalFlagTable(int tableIndex) {
+ return _globalFlags.evcapBaseID[tableIndex];
}
-bool SceneViewWindow::isNumberInGlobalFlagTable(int tableOffset, int curItemCountOffset, byte numberToCheck) {
- const byte *data = (const byte *)&_globalFlags;
- int itemCount = *(data + curItemCountOffset);
-
- const byte *tableEntries = data + tableOffset;
-
- for (int i = 0; i < itemCount; i++)
- if (tableEntries[i] == numberToCheck)
+bool SceneViewWindow::isNumberInGlobalFlagTable(byte numberToCheck) {
+ for (int i = 0; i < _globalFlags.evcapNumCaptured; i++)
+ if (_globalFlags.evcapBaseID[i] == numberToCheck)
return true;
return false;
@@ -2083,9 +2071,6 @@ bool SceneViewWindow::playAICommentFromData(const AIComment &commentData) {
if (playedSuccessfully) {
_lastAICommentFileName = commentFileName;
- // This is pure evil. Ugh.
- // The [g|s]etGlobalFlagByte nonsense, anyway.
-
byte flagValue = 0;
if (commentData.commentFlags & AI_STATUS_FLAG_NON_BASE_DERIVED)
flagValue = getAIFlag(commentData.statusFlagOffset);
diff --git a/engines/buried/scene_view.h b/engines/buried/scene_view.h
index cdb723b3756..353dc42d076 100644
--- a/engines/buried/scene_view.h
+++ b/engines/buried/scene_view.h
@@ -98,9 +98,9 @@ public:
bool isCyclingEnabled() const { return _cycleEnabled || _forceCycleEnabled; }
bool closeCycleFrameMovie();
- bool addNumberToGlobalFlagTable(int offset, int curItemCountOffset, int maxItems, byte numberToAdd);
- byte getNumberFromGlobalFlagTable(int offset, int tableIndex);
- bool isNumberInGlobalFlagTable(int offset, int curItemCountOffset, byte numberToCheck);
+ bool addNumberToGlobalFlagTable(byte numberToAdd);
+ byte getNumberFromGlobalFlagTable(int tableIndex);
+ bool isNumberInGlobalFlagTable(byte numberToCheck);
bool playSynchronousAnimation(int animationID);
bool playSynchronousAnimationExtern(int animationID);
Commit: 3e595eedda30d6eb381b09fd5d8ef651802a28fa
https://github.com/scummvm/scummvm/commit/3e595eedda30d6eb381b09fd5d8ef651802a28fa
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-02T12:20:51+02:00
Commit Message:
BURIED: Adjust comments
Changed paths:
engines/buried/biochip_right.h
engines/buried/complete.cpp
engines/buried/death.cpp
diff --git a/engines/buried/biochip_right.h b/engines/buried/biochip_right.h
index 2d7bdb99a23..06a5c9d276e 100644
--- a/engines/buried/biochip_right.h
+++ b/engines/buried/biochip_right.h
@@ -63,7 +63,9 @@ public:
void onEnable(bool enable);
void onLButtonUp(const Common::Point &point, uint flags);
- // clone2727 says: These are labeled as HACKS, so I assume they are.
+ // These are used to enable the help and comment buttons
+ // when the player finds Arthur, while he explains how
+ // these two buttons are used.
bool _forceHelp;
bool _forceComment;
diff --git a/engines/buried/complete.cpp b/engines/buried/complete.cpp
index ea7def12bfe..88d68eaf574 100644
--- a/engines/buried/complete.cpp
+++ b/engines/buried/complete.cpp
@@ -138,9 +138,10 @@ CompletionWindow::CompletionWindow(BuriedEngine *vm, Window *parent, GlobalFlags
int totalScore = finalCriticalEvidenceScore + finalSupportingEvidenceScore + finalPuzzleScore + finalResearchScore + completionScore;
// Build the string buffers
+ // Newer versions include these strings as resources in the main executable.
+ // For earlier versions, we hardcode them here.
if (_walkthroughMode) {
if (_vm->getVersion() >= MAKEVERSION(1, 0, 4, 0)) {
- // HACK HACK HACK: Oh god. This is horrid.
Common::String stringResource = _vm->getString(IDS_COMPL_WALK_SCORE_DESC_TEMPL);
_scoringTextDescriptions = Common::String::format(stringResource.c_str(), criticalEvidence, supportingEvidence, puzzlesSolved, researchBonusRaw);
stringResource = _vm->getString(IDS_COMPL_WALK_SCORE_AMT_TEMPL);
@@ -154,7 +155,6 @@ CompletionWindow::CompletionWindow(BuriedEngine *vm, Window *parent, GlobalFlags
totalScore -= hintsScore;
if (_vm->getVersion() >= MAKEVERSION(1, 0, 4, 0)) {
- // HACK HACK HACK: Again, horrid.
Common::String stringResource = _vm->getString(IDS_COMPL_SCORE_DESC_TEMPL);
_scoringTextDescriptions = Common::String::format(stringResource.c_str(), criticalEvidence, supportingEvidence, puzzlesSolved, researchBonusRaw, hints);
stringResource = _vm->getString(IDS_COMPL_SCORE_AMT_TEMPL);
@@ -166,8 +166,6 @@ CompletionWindow::CompletionWindow(BuriedEngine *vm, Window *parent, GlobalFlags
}
}
- // This would be a hack, but since it's just printing one number, I'm not
- // loading that damned string too.
_scoringTextFinalScore = Common::String::format("%d", totalScore);
_vm->_sound->setAmbientSound();
diff --git a/engines/buried/death.cpp b/engines/buried/death.cpp
index 34af37cf36f..e0c48fbc59d 100644
--- a/engines/buried/death.cpp
+++ b/engines/buried/death.cpp
@@ -124,9 +124,10 @@ AgentEvaluation::AgentEvaluation(BuriedEngine *vm, GlobalFlags &globalFlags, int
int totalScore = finalCriticalEvidenceScore + finalSupportingEvidenceScore + finalPuzzleScore + finalResearchScore + completionScore;
// Build the string buffers
+ // Newer versions include these strings as resources in the main executable.
+ // For earlier versions, we hardcode them here.
if (_globalFlags.generalWalkthroughMode != 0) {
if (vm->getVersion() >= MAKEVERSION(1, 0, 4, 0)) {
- // HACK HACK HACK: More horridness.
Common::String stringResource = vm->getString(IDS_DEATH_WALK_SCORE_DESC_TEMPL);
_scoringTextDescriptions = Common::String::format(stringResource.c_str(), criticalEvidence, supportingEvidence, puzzlesSolved, researchBonusRaw);
stringResource = vm->getString(IDS_DEATH_WALK_SCORE_AMT_TEMPL);
@@ -153,7 +154,6 @@ AgentEvaluation::AgentEvaluation(BuriedEngine *vm, GlobalFlags &globalFlags, int
totalScore -= hintsScore;
if (vm->getVersion() >= MAKEVERSION(1, 0, 4, 0)) {
- // HACK HACK HACK: Did I mention this was terrible?
Common::String stringResource = vm->getString(IDS_DEATH_SCORE_DESC_TEMPL);
_scoringTextDescriptions = Common::String::format(stringResource.c_str(), criticalEvidence, supportingEvidence, puzzlesSolved, researchBonusRaw, hints);
stringResource = vm->getString(IDS_DEATH_SCORE_AMT_TEMPL);
Commit: c4d40efd72ac85501b9864751d7d3eea7d7a1f8b
https://github.com/scummvm/scummvm/commit/c4d40efd72ac85501b9864751d7d3eea7d7a1f8b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-02T12:20:51+02:00
Commit Message:
BURIED: Add constant for the intro video filename
Changed paths:
engines/buried/gameui.cpp
engines/buried/resources.h
diff --git a/engines/buried/gameui.cpp b/engines/buried/gameui.cpp
index 359493d5c86..2feb3a8e429 100644
--- a/engines/buried/gameui.cpp
+++ b/engines/buried/gameui.cpp
@@ -85,7 +85,7 @@ bool GameUIWindow::startNewGameIntro(bool walkthrough) {
VideoWindow *video = new VideoWindow(_vm, this);
- if (!video->openVideo(_vm->getFilePath(19972))) // FIXME: Why is this not a constant?
+ if (!video->openVideo(_vm->getFilePath(IDS_INTRO_FILENAME)))
error("Failed to load intro video");
video->setWindowPos(nullptr, 104, 145, 0, 0, kWindowPosNoSize | kWindowPosNoZOrder);
diff --git a/engines/buried/resources.h b/engines/buried/resources.h
index f82db21483f..7ee6232bd81 100644
--- a/engines/buried/resources.h
+++ b/engines/buried/resources.h
@@ -307,6 +307,7 @@ namespace Buried {
#define IDS_TITLE_PRESTO_LOGO_FILENAME 6166
#define IDS_TITLE_SW_LOGO_FILENAME 6167
+#define IDS_INTRO_FILENAME 19972
#define IDS_FUTAPT_BOOK_AUDIO_FILENAME 6170
Commit: 74f2df71c30f4f1e0bb9419bedb8b6b222708212
https://github.com/scummvm/scummvm/commit/74f2df71c30f4f1e0bb9419bedb8b6b222708212
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-02T12:25:49+02:00
Commit Message:
BURIED: Fix Arthur being visible after AI biochip is lost - bug #313193
This is an original game bug. The fix expands upon the original one so
that the active biochip is only changed if Arthur's biochip was active
before he sacrifices himself
Changed paths:
engines/buried/biochip_right.cpp
engines/buried/biochip_right.h
engines/buried/environ/agent3_lair.cpp
diff --git a/engines/buried/biochip_right.cpp b/engines/buried/biochip_right.cpp
index b32d4db7ac7..5d6b8f66a05 100644
--- a/engines/buried/biochip_right.cpp
+++ b/engines/buried/biochip_right.cpp
@@ -115,6 +115,13 @@ bool BioChipRightWindow::destroyBioChipViewWindow() {
return true;
}
+void BioChipRightWindow::swapAIBioChipIfActive() {
+ if (_curBioChip == kItemBioChipAI) {
+ _curBioChip = kItemBioChipBlank;
+ invalidateWindow(false);
+ }
+}
+
void BioChipRightWindow::sceneChanged() {
if (_curBioChip == kItemBioChipAI)
invalidateWindow(false);
diff --git a/engines/buried/biochip_right.h b/engines/buried/biochip_right.h
index 06a5c9d276e..29df79ee630 100644
--- a/engines/buried/biochip_right.h
+++ b/engines/buried/biochip_right.h
@@ -52,6 +52,7 @@ public:
bool changeCurrentBioChip(int bioChipID);
bool showBioChipMainView();
bool destroyBioChipViewWindow();
+ void swapAIBioChipIfActive();
void sceneChanged();
void disableEvidenceCapture();
void jumpInitiated(bool redraw);
diff --git a/engines/buried/environ/agent3_lair.cpp b/engines/buried/environ/agent3_lair.cpp
index f9d26fe6d7d..0201c0bffd6 100644
--- a/engines/buried/environ/agent3_lair.cpp
+++ b/engines/buried/environ/agent3_lair.cpp
@@ -346,7 +346,7 @@ int LairEntry::onCharacter(Window *viewWindow, const Common::KeyState &character
_vm->_sound->stopSoundEffect(_currentSoundID);
((GameUIWindow *)viewWindow->getParent())->_inventoryWindow->removeItem(kItemBioChipAI);
((GameUIWindow *)viewWindow->getParent())->_inventoryWindow->addItem(kItemBioChipBlank);
- ((GameUIWindow *)viewWindow->getParent())->_bioChipRightWindow->changeCurrentBioChip(kItemBioChipBlank);
+ ((GameUIWindow *)viewWindow->getParent())->_bioChipRightWindow->swapAIBioChipIfActive();
_vm->_sound->setAmbientSound(_vm->getFilePath(3, 2, SF_AMBIENT), false, 64);
_passwordIndex = 5;
More information about the Scummvm-git-logs
mailing list