From 2f91c2f69625ac902669f19828175079b7035561 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 24 Feb 2020 21:59:04 +0100 Subject: [PATCH] - fixed the Exhumed sequence reader. There was interference with the sound loader here - both accessed the same file handle so the sequence's sound data wasn't read correctly, resulting in memory corruption. --- source/exhumed/src/sequence.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/source/exhumed/src/sequence.cpp b/source/exhumed/src/sequence.cpp index f1a2c8d95..bb737d0e0 100644 --- a/source/exhumed/src/sequence.cpp +++ b/source/exhumed/src/sequence.cpp @@ -166,7 +166,7 @@ int seq_ReadSequence(const char *seqName) strcat(buffer, seqName); strcat(buffer, ".seq"); - auto hFile = fileSystem.OpenFileReader(buffer, 1); + auto hFile = fileSystem.ReopenFileReader(fileSystem.FindFile(buffer), true); if (!hFile.isOpen()) { initprintf("Unable to open '%s'!\n", buffer); @@ -288,6 +288,7 @@ int seq_ReadSequence(const char *seqName) int hSound = LoadSound(&buffer[(var_2C&0x1FF)*10]); + assert(vdi + var_28 < 18000); FrameSound[vdi + var_28] = hSound | (var_2C & 0xFE00); } } @@ -318,6 +319,23 @@ void seq_LoadSequences() } } + FILE* f = fopen("seq.dump", "wb"); + + fwrite(SeqBase, 1, sizeof(SeqBase), f); + fwrite(SeqSize, 1, sizeof(SeqSize), f); + fwrite(SeqFlag, 1, sizeof(SeqFlag), f); + fwrite("++++++++++++++++", 1, 16, f); + fwrite(FrameSound, 1, sizeof(FrameSound), f); + fwrite("++++++++++++++++", 1, 16, f); + fwrite(FrameSize, 1, sizeof(FrameSize), f); + fwrite(FrameBase, 1, sizeof(FrameBase), f); + fwrite(FrameFlag, 1, sizeof(FrameFlag), f); + fwrite(ChunkYpos, 1, sizeof(ChunkYpos), f); + fwrite(ChunkXpos, 1, sizeof(ChunkXpos), f); + fwrite(ChunkPict, 1, sizeof(ChunkPict), f); + fwrite(ChunkFlag, 1, sizeof(ChunkFlag), f); + fclose(f); + nShadowPic = seq_GetFirstSeqPicnum(kSeqShadow); nShadowWidth = tilesiz[nShadowPic].x;