aboutsummaryrefslogtreecommitdiff
path: root/engines/tinsel/handle.cpp
diff options
context:
space:
mode:
authorMax Horn2009-10-26 20:36:44 +0000
committerMax Horn2009-10-26 20:36:44 +0000
commitd2e64a350ae9aa6955b2dd7a3715958cdb5477f5 (patch)
treeb76bffaf3c9be57f4ce5a4e0cc41448a87f20af5 /engines/tinsel/handle.cpp
parente1de772e721a7dc0d62223c17617f72af3d2308f (diff)
downloadscummvm-rg350-d2e64a350ae9aa6955b2dd7a3715958cdb5477f5.tar.gz
scummvm-rg350-d2e64a350ae9aa6955b2dd7a3715958cdb5477f5.tar.bz2
scummvm-rg350-d2e64a350ae9aa6955b2dd7a3715958cdb5477f5.zip
TINSEL: cleanup
svn-id: r45417
Diffstat (limited to 'engines/tinsel/handle.cpp')
-rw-r--r--engines/tinsel/handle.cpp64
1 files changed, 27 insertions, 37 deletions
diff --git a/engines/tinsel/handle.cpp b/engines/tinsel/handle.cpp
index cbfd782942..038fc831b4 100644
--- a/engines/tinsel/handle.cpp
+++ b/engines/tinsel/handle.cpp
@@ -87,7 +87,7 @@ static char szCdPlayFile[100];
//----------------- FORWARD REFERENCES --------------------
-static void LoadFile(MEMHANDLE *pH, bool bWarn); // load a memory block as a file
+static void LoadFile(MEMHANDLE *pH); // load a memory block as a file
/**
@@ -160,7 +160,7 @@ void SetupHandleTable(void) {
assert(pH->_ptr);
// load the data
- LoadFile(pH, true);
+ LoadFile(pH);
}
#ifdef BODGE
else if ((pH->filesize & FSIZE_MASK) == 8) {
@@ -280,9 +280,8 @@ void SetCdPlayHandle(int fileNum) {
/**
* Loads a memory block as a file.
* @param pH Memory block pointer
- * @param bWarn If set, treat warnings as errors
*/
-void LoadFile(MEMHANDLE *pH, bool bWarn) {
+void LoadFile(MEMHANDLE *pH) {
Common::File f;
char szFilename[sizeof(pH->szName) + 1];
@@ -327,14 +326,12 @@ void LoadFile(MEMHANDLE *pH, bool bWarn) {
return;
}
- if (bWarn)
- // file is corrupt
- error(FILE_IS_CORRUPT, szFilename);
+ // file is corrupt
+ error(FILE_IS_CORRUPT, szFilename);
}
- if (bWarn)
- // cannot find file
- error(CANNOT_FIND_FILE, szFilename);
+ // cannot find file
+ error(CANNOT_FIND_FILE, szFilename);
}
/**
@@ -364,47 +361,40 @@ byte *LockMem(SCNHANDLE offset) {
if (offset < cdBaseHandle || offset >= cdTopHandle)
error("Overlapping (in time) CD-plays");
- if (pH->_node->pBaseAddr && (pH->filesize & fLoaded))
- // already allocated and loaded
- return pH->_node->pBaseAddr + ((offset - cdBaseHandle) & OFFSETMASK);
-
- if (pH->_node->pBaseAddr == NULL)
+ if (pH->_node->pBaseAddr == NULL) {
// must have been discarded - reallocate the memory
MemoryReAlloc(pH->_node, cdTopHandle - cdBaseHandle);
+ assert(pH->_node->pBaseAddr);
+ }
- if (pH->_node->pBaseAddr == NULL)
- error("Out of memory");
+ if (!(pH->filesize & fLoaded)) {
- LoadCDGraphData(pH);
+ LoadCDGraphData(pH);
- // make sure address is valid
- assert(pH->_node->pBaseAddr);
-
- // update the LRU time (new in this file)
- pH->_node->lruTime = DwGetCurrentTime();
+ // update the LRU time (new in this file)
+ pH->_node->lruTime = DwGetCurrentTime();
+ }
return pH->_node->pBaseAddr + ((offset - cdBaseHandle) & OFFSETMASK);
} else {
- if (pH->_node->pBaseAddr && (pH->filesize & fLoaded))
- // already allocated and loaded
- return pH->_node->pBaseAddr + (offset & OFFSETMASK);
-
- if (pH->_node->pBaseAddr == NULL)
+ if (pH->_node->pBaseAddr == NULL) {
// must have been discarded - reallocate the memory
MemoryReAlloc(pH->_node, pH->filesize & FSIZE_MASK);
+ assert(pH->_node->pBaseAddr);
+ }
- if (pH->_node->pBaseAddr == NULL)
- error("Out of memory");
+ if (!(pH->filesize & fLoaded)) {
- if (TinselV2) {
- SetCD(pH->flags2 & fAllCds);
- CdCD(nullContext);
- }
- LoadFile(pH, true);
+ if (TinselV2) {
+ SetCD(pH->flags2 & fAllCds);
+ CdCD(nullContext);
+ }
+ LoadFile(pH);
- // make sure address is valid
- assert(pH->_node->pBaseAddr);
+ // make sure address is valid
+ assert(pH->filesize & fLoaded);
+ }
return pH->_node->pBaseAddr + (offset & OFFSETMASK);
}