[Scummvm-cvs-logs] SF.net SVN: scummvm:[48765] scummvm/trunk/engines/tinsel/handle.cpp
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Wed Apr 21 23:23:08 CEST 2010
Revision: 48765
http://scummvm.svn.sourceforge.net/scummvm/?rev=48765&view=rev
Author: fingolfin
Date: 2010-04-21 21:23:08 +0000 (Wed, 21 Apr 2010)
Log Message:
-----------
TINSEL: Change cdGraphStream to a Common::File pointer,
to not rely on global constructors
Modified Paths:
--------------
scummvm/trunk/engines/tinsel/handle.cpp
Modified: scummvm/trunk/engines/tinsel/handle.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/handle.cpp 2010-04-21 21:22:43 UTC (rev 48764)
+++ scummvm/trunk/engines/tinsel/handle.cpp 2010-04-21 21:23:08 UTC (rev 48765)
@@ -80,7 +80,7 @@
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 @@
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 @@
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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list