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
This commit is contained in:
Filippos Karapetis 2022-01-02 05:47:58 +02:00
parent 8a62864d28
commit 654cf83018
9 changed files with 44 additions and 67 deletions

View File

@ -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) {

View File

@ -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;
}

View File

@ -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));

View File

@ -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;

View File

@ -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));

View File

@ -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));
}

View File

@ -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,

View File

@ -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);

View File

@ -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);