diff --git a/source/blood/src/qav.cpp b/source/blood/src/qav.cpp index ea0ac3f00..0ab613c49 100644 --- a/source/blood/src/qav.cpp +++ b/source/blood/src/qav.cpp @@ -33,17 +33,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS -#define kMaxClients 64 -static void (*clientCallback[kMaxClients])(int, void *); -static int nClients; +#define kMaxQavClients 64 +static void (*qavClientCallback[kMaxQavClients])(int, void *); +static int nQavClients; int qavRegisterClient(void(*pClient)(int, void *)) { - dassert(nClients < kMaxClients); - clientCallback[nClients] = pClient; + dassert(nQavClients < kMaxQavClients); + qavClientCallback[nQavClients] = pClient; - return nClients++; + return nQavClients++; } void DrawFrame(double x, double y, TILE_FRAME *pTile, int stat, int shade, int palnum, bool to3dview) @@ -152,7 +152,7 @@ void QAV::Play(int start, int end, int nCallback, void *pData) } if (pFrame->nCallbackId > 0 && nCallback != -1) { - clientCallback[nCallback](pFrame->nCallbackId, pData); + qavClientCallback[nCallback](pFrame->nCallbackId, pData); } } } @@ -218,10 +218,10 @@ void ByteSwapQAV(void* p) // Sequences were cached in the resource and directly returned from there in writable form, with byte swapping directly performed in the cache on Big Endian systems. // To avoid such unsafe operations this caches the read data separately. extern FMemArena seqcache; // Use the same storage as the SEQs. -static TMap sequences; +static TMap qavcache; QAV* getQAV(int res_id) { - auto p = sequences.CheckKey(res_id); + auto p = qavcache.CheckKey(res_id); if (p != nullptr) return *p; int index = fileSystem.FindResource(res_id, "QAV"); @@ -232,7 +232,7 @@ QAV* getQAV(int res_id) auto fr = fileSystem.OpenFileReader(index); auto qavdata = (QAV*)seqcache.Alloc(fr.GetLength()); fr.Read(qavdata, fr.GetLength()); - sequences.Insert(res_id, qavdata); + qavcache.Insert(res_id, qavdata); ByteSwapQAV(qavdata); return qavdata; } diff --git a/source/blood/src/seq.cpp b/source/blood/src/seq.cpp index e482b3c47..eb7906454 100644 --- a/source/blood/src/seq.cpp +++ b/source/blood/src/seq.cpp @@ -41,19 +41,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS -#define kMaxClients 256 +#define kMaxSeqClients 256 #define kMaxSequences 1024 static ACTIVE activeList[kMaxSequences]; -static int activeCount = 0; -static int nClients = 0; -static void(*clientCallback[kMaxClients])(int, int); +static int seqActiveCount = 0; +static int nSeqClients = 0; +static void(*seqClientCallback[kMaxSeqClients])(int, int); int seqRegisterClient(void(*pClient)(int, int)) { - dassert(nClients < kMaxClients); - clientCallback[nClients] = pClient; - return nClients++; + dassert(nSeqClients < kMaxSeqClients); + seqClientCallback[nSeqClients] = pClient; + return nSeqClients++; } void Seq::Preload(void) @@ -338,7 +338,7 @@ void SEQINST::Update(ACTIVE *pActive) break; } if (pSequence->frames[frameIndex].at5_5 && atc != -1) - clientCallback[atc](pActive->type, pActive->xindex); + seqClientCallback[atc](pActive->type, pActive->xindex); } SEQINST * GetInstance(int a1, int a2) @@ -381,18 +381,18 @@ void seqSpawn(int a1, int a2, int a3, int a4) if (!pSeq) ThrowError("Missing sequence #%d", a1); - int i = activeCount; + int i = seqActiveCount; if (pInst->at13) { if (pSeq == pInst->pSequence) return; UnlockInstance(pInst); - for (i = 0; i < activeCount; i++) + for (i = 0; i < seqActiveCount; i++) { if (activeList[i].type == a2 && activeList[i].xindex == a3) break; } - dassert(i < activeCount); + dassert(i < seqActiveCount); } if (memcmp(pSeq->signature, "SEQ\x1a", 4) != 0) ThrowError("Invalid sequence %d", a1); @@ -409,12 +409,12 @@ void seqSpawn(int a1, int a2, int a3, int a4) pInst->atc = a4; pInst->at10 = pSeq->at8; pInst->frameIndex = 0; - if (i == activeCount) + if (i == seqActiveCount) { - dassert(activeCount < kMaxSequences); - activeList[activeCount].type = a2; - activeList[activeCount].xindex = a3; - activeCount++; + dassert(seqActiveCount < kMaxSequences); + activeList[seqActiveCount].type = a2; + activeList[seqActiveCount].xindex = a3; + seqActiveCount++; } pInst->Update(&activeList[i]); } @@ -425,14 +425,14 @@ void seqKill(int a1, int a2) if (!pInst || !pInst->at13) return; int i; - for (i = 0; i < activeCount; i++) + for (i = 0; i < seqActiveCount; i++) { if (activeList[i].type == a1 && activeList[i].xindex == a2) break; } - dassert(i < activeCount); - activeCount--; - activeList[i] = activeList[activeCount]; + dassert(i < seqActiveCount); + seqActiveCount--; + activeList[i] = activeList[seqActiveCount]; pInst->at13 = 0; UnlockInstance(pInst); } @@ -458,7 +458,7 @@ void seqKillAll(void) if (siSprite[i].at13) UnlockInstance(&siSprite[i]); } - activeCount = 0; + seqActiveCount = 0; } int seqGetStatus(int a1, int a2) @@ -479,7 +479,7 @@ int seqGetID(int a1, int a2) void seqProcess(int a1) { - for (int i = 0; i < activeCount; i++) + for (int i = 0; i < seqActiveCount; i++) { SEQINST *pInst = GetInstance(activeList[i].type, activeList[i].xindex); Seq *pSeq = pInst->pSequence; @@ -524,7 +524,7 @@ void seqProcess(int a1) } } } - activeList[i--] = activeList[--activeCount]; + activeList[i--] = activeList[--seqActiveCount]; break; } } @@ -546,7 +546,7 @@ void SeqLoadSave::Load(void) Read(&siFloor, sizeof(siFloor)); Read(&siSprite, sizeof(siSprite)); Read(&activeList, sizeof(activeList)); - Read(&activeCount, sizeof(activeCount)); + Read(&seqActiveCount, sizeof(seqActiveCount)); for (int i = 0; i < kMaxXWalls; i++) { siWall[i].pSequence = NULL; @@ -561,7 +561,7 @@ void SeqLoadSave::Load(void) { siSprite[i].pSequence = NULL; } - for (int i = 0; i < activeCount; i++) + for (int i = 0; i < seqActiveCount; i++) { SEQINST *pInst = GetInstance(activeList[i].type, activeList[i].xindex); if (pInst->at13) @@ -589,14 +589,12 @@ void SeqLoadSave::Save(void) Write(&siFloor, sizeof(siFloor)); Write(&siSprite, sizeof(siSprite)); Write(&activeList, sizeof(activeList)); - Write(&activeCount, sizeof(activeCount)); + Write(&seqActiveCount, sizeof(seqActiveCount)); } -static SeqLoadSave *myLoadSave; - void SeqLoadSaveConstruct(void) { - myLoadSave = new SeqLoadSave(); + new SeqLoadSave(); }