From 86c559ff1c13ef6e1845f176617b2cb40526b0c3 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 6 Apr 2023 19:27:42 +1000 Subject: [PATCH] - Exhumed: Wrap all access to `ChunkFlag[]` array and make static. --- source/games/exhumed/src/sequence.cpp | 21 ++++++++++++++++----- source/games/exhumed/src/sequence.h | 4 +--- source/games/exhumed/src/status.cpp | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/source/games/exhumed/src/sequence.cpp b/source/games/exhumed/src/sequence.cpp index 5c3e4f558..3061ec0d2 100644 --- a/source/games/exhumed/src/sequence.cpp +++ b/source/games/exhumed/src/sequence.cpp @@ -63,7 +63,7 @@ static int16_t FrameFlag[kMaxSEQFrames]; static int16_t ChunkYpos[kMaxSEQChunks]; static int16_t ChunkXpos[kMaxSEQChunks]; static int16_t ChunkPict[kMaxSEQChunks]; -int16_t ChunkFlag[kMaxSEQChunks]; +static int16_t ChunkFlag[kMaxSEQChunks]; const char *SeqNames[kMaxSEQFiles] = @@ -256,6 +256,17 @@ int getSeqFrameChunkPicnum(const int nChunk) // //--------------------------------------------------------------------------- +int getSeqFrameChunkFlags(const int nChunk) +{ + return ChunkFlag[nChunk]; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + int seq_ReadSequence(const char *seqName) { const int16_t StartFrameCount = frames; @@ -524,10 +535,10 @@ int seq_DrawGunSequence(int nSeqOffset, int16_t dx, double xOffs, double yOffs, int y = getSeqFrameChunkPosY(nFrameBase) + 100; int stat = 0; - if (ChunkFlag[nFrameBase] & 1) + if (getSeqFrameChunkFlags(nFrameBase) & 1) stat |= RS_XFLIPHUD; - if (ChunkFlag[nFrameBase] & 2) + if (getSeqFrameChunkFlags(nFrameBase) & 2) stat |= RS_YFLIPHUD; if (align) stat |= RS_ALIGN_R; @@ -637,7 +648,7 @@ int seq_PlotArrowSequence(int nSprite, int16_t nSeq, int nVal) pTSprite->shade = nShade; pTSprite->statnum = nFrameSize; - if (ChunkFlag[nFrameBase] & 1) + if (getSeqFrameChunkFlags(nFrameBase) & 1) { pTSprite->xoffset = (int8_t)getSeqFrameChunkPosX(nFrameBase); pTSprite->cstat |= CSTAT_SPRITE_XFLIP; @@ -727,7 +738,7 @@ int seq_PlotSequence(int nSprite, int16_t edx, int16_t nFrame, int16_t ecx) tsp->clipdist = pTSprite->clipdist; tsp->statnum = esi; - if (ChunkFlag[nBase] & 1) + if (getSeqFrameChunkFlags(nBase) & 1) { tsp->xoffset = (int8_t)getSeqFrameChunkPosX(nBase); tsp->cstat |= CSTAT_SPRITE_XFLIP; // x-flipped diff --git a/source/games/exhumed/src/sequence.h b/source/games/exhumed/src/sequence.h index 20a6777af..0830df55b 100644 --- a/source/games/exhumed/src/sequence.h +++ b/source/games/exhumed/src/sequence.h @@ -116,9 +116,6 @@ extern int16_t nFlameHeight; extern int16_t nPilotLightFrame; extern int16_t nPilotLightCount; -extern int16_t ChunkFlag[]; - - void seq_LoadSequences(); int seq_GetFrameSound(int val, int edx); void seq_MoveSequence(DExhumedActor* actor, int16_t nSeq, int16_t nFrame); @@ -141,6 +138,7 @@ int getSeqFrameChunkCount(const int nFrame); int getSeqFrameChunkPosX(const int nChunk); int getSeqFrameChunkPosY(const int nChunk); int getSeqFrameChunkPicnum(const int nChunk); +int getSeqFrameChunkFlags(const int nChunk); END_PS_NS diff --git a/source/games/exhumed/src/status.cpp b/source/games/exhumed/src/status.cpp index 8a5f876c0..cabd80337 100644 --- a/source/games/exhumed/src/status.cpp +++ b/source/games/exhumed/src/status.cpp @@ -73,7 +73,7 @@ struct ChunkFrame auto ttex = tileGetTexture(getSeqFrameChunkPicnum(nFrameBase)); if (ttex) tex = ttex->GetID(); else tex.SetInvalid(); - flags = ChunkFlag[nFrameBase]; + flags = getSeqFrameChunkFlags(nFrameBase); } };