diff options
author | Max Horn | 2010-04-21 21:23:08 +0000 |
---|---|---|
committer | Max Horn | 2010-04-21 21:23:08 +0000 |
commit | f103f01284b61b04aa8bc5978d5771d12e22f404 (patch) | |
tree | 264113423916cac807cb5350a734b952c5f2c025 /engines | |
parent | 37b7be45194ba118f039a9268e42beed895ea9ba (diff) | |
download | scummvm-rg350-f103f01284b61b04aa8bc5978d5771d12e22f404.tar.gz scummvm-rg350-f103f01284b61b04aa8bc5978d5771d12e22f404.tar.bz2 scummvm-rg350-f103f01284b61b04aa8bc5978d5771d12e22f404.zip |
TINSEL: Change cdGraphStream to a Common::File pointer,
to not rely on global constructors
svn-id: r48765
Diffstat (limited to 'engines')
-rw-r--r-- | engines/tinsel/handle.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/engines/tinsel/handle.cpp b/engines/tinsel/handle.cpp index 9366d06be6..e26ff9218e 100644 --- a/engines/tinsel/handle.cpp +++ b/engines/tinsel/handle.cpp @@ -80,7 +80,7 @@ static uint32 cdPlayHandle = (uint32)-1; static int cdPlayFileNum, cdPlaySceneNum; static SCNHANDLE cdBaseHandle = 0, cdTopHandle = 0; -static Common::File cdGraphStream; +static Common::File *cdGraphStream = 0; static char szCdPlayFile[100]; @@ -179,20 +179,23 @@ void FreeHandleTable() { free(handleTable); handleTable = NULL; } - if (cdGraphStream.isOpen()) - cdGraphStream.close(); + if (cdGraphStream) { + delete cdGraphStream; + cdGraphStream = 0; + } } /** * Loads a memory block as a file. */ void OpenCDGraphFile() { - if (cdGraphStream.isOpen()) - cdGraphStream.close(); + if (cdGraphStream) + delete cdGraphStream; // As the theory goes, the right CD will be in there! - if (!cdGraphStream.open(szCdPlayFile)) + cdGraphStream = new Common::File; + if (!cdGraphStream->open(szCdPlayFile)) error(CANNOT_FIND_FILE, szCdPlayFile); } @@ -214,14 +217,15 @@ void LoadCDGraphData(MEMHANDLE *pH) { assert(addr); // Move to correct place in file and load the required data - cdGraphStream.seek(cdBaseHandle & OFFSETMASK, SEEK_SET); - bytes = cdGraphStream.read(addr, (cdTopHandle - cdBaseHandle) & OFFSETMASK); + assert(cdGraphStream); + cdGraphStream->seek(cdBaseHandle & OFFSETMASK, SEEK_SET); + bytes = cdGraphStream->read(addr, (cdTopHandle - cdBaseHandle) & OFFSETMASK); // New code to try and handle CD read failures 24/2/97 while (bytes != ((cdTopHandle - cdBaseHandle) & OFFSETMASK) && retries++ < MAX_READ_RETRIES) { // Try again - cdGraphStream.seek(cdBaseHandle & OFFSETMASK, SEEK_SET); - bytes = cdGraphStream.read(addr, (cdTopHandle - cdBaseHandle) & OFFSETMASK); + cdGraphStream->seek(cdBaseHandle & OFFSETMASK, SEEK_SET); + bytes = cdGraphStream->read(addr, (cdTopHandle - cdBaseHandle) & OFFSETMASK); } // discardable - unlock the memory |