aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/cine/cine.cpp9
-rw-r--r--engines/cine/cine.h2
-rw-r--r--engines/cine/msg.cpp5
-rw-r--r--engines/cine/pal.cpp11
-rw-r--r--engines/cine/part.cpp47
-rw-r--r--engines/cine/texte.cpp5
-rw-r--r--engines/cine/various.cpp21
-rw-r--r--engines/cine/various.h7
8 files changed, 39 insertions, 68 deletions
diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp
index 3c4de4b6e4..b72a809841 100644
--- a/engines/cine/cine.cpp
+++ b/engines/cine/cine.cpp
@@ -68,12 +68,6 @@ CineEngine::~CineEngine() {
freePoldatDat();
freeErrmessDat();
}
-
- if (palFileHandleP);
- delete palFileHandleP;
-
- if (partFileHandleP);
- delete partFileHandleP;
}
int CineEngine::init() {
@@ -82,9 +76,6 @@ int CineEngine::init() {
GUIErrorMessage("No valid games were found in the specified directory.");
return -1;
}
-
- palFileHandleP = new Common::File();
- partFileHandleP = new Common::File();
// Initialize backend
_system->beginGFXTransaction();
diff --git a/engines/cine/cine.h b/engines/cine/cine.h
index 061e9ab66b..081f2f3493 100644
--- a/engines/cine/cine.h
+++ b/engines/cine/cine.h
@@ -27,6 +27,7 @@
#include "common/stdafx.h"
#include "common/scummsys.h"
+#include "common/file.h"
#include "common/util.h"
#include "engines/engine.h"
@@ -81,6 +82,7 @@ public:
void makeSystemMenu(void);
const CINEGameDescription *_gameDescription;
+ Common::File _partFileHandle;
private:
void initialize(void);
diff --git a/engines/cine/msg.cpp b/engines/cine/msg.cpp
index 0947cbd45a..244f464116 100644
--- a/engines/cine/msg.cpp
+++ b/engines/cine/msg.cpp
@@ -42,13 +42,10 @@ void loadMsg(char *pMsgName) {
for (i = 0; i < NUM_MAX_MESSAGE; i++) {
messageTable[i].len = 0;
-
if (messageTable[i].ptr) {
- assert(messageTable[i].ptr);
free(messageTable[i].ptr);
+ messageTable[i].ptr = NULL;
}
-
- messageTable[i].ptr = NULL;
}
ptr = dataPtr = readBundleFile(findFileInBundle(pMsgName));
diff --git a/engines/cine/pal.cpp b/engines/cine/pal.cpp
index a5b94d1034..0bb07f25a5 100644
--- a/engines/cine/pal.cpp
+++ b/engines/cine/pal.cpp
@@ -34,8 +34,6 @@ byte palette256[256 * 3];
uint16 palEntriesCount;
-Common::File *palFileHandleP = NULL;
-
PalEntry *palPtr = NULL;
byte paletteBuffer1[16];
@@ -48,8 +46,6 @@ void loadPal(const char *fileName) {
strcat(buffer, ".PAL");
- palFileHandle.close();
-
if (palPtr) {
free(palPtr);
palPtr = NULL;
@@ -57,9 +53,9 @@ void loadPal(const char *fileName) {
palEntriesCount = 0;
- palFileHandle.open(buffer);
-
- assert(palFileHandle.isOpen());
+ Common::File palFileHandle;
+ if (!palFileHandle.open(buffer))
+ error("loadPal(): Cannot open file %s", fileName);
palEntriesCount = palFileHandle.readUint16LE();
palFileHandle.readUint16LE(); // entry size
@@ -71,6 +67,7 @@ void loadPal(const char *fileName) {
palFileHandle.read(palPtr[i].pal1, 16);
palFileHandle.read(palPtr[i].pal2, 16);
}
+ palFileHandle.close();
}
int16 findPaletteFromName(const char *fileName) {
diff --git a/engines/cine/part.cpp b/engines/cine/part.cpp
index 5b7016b91b..1182624cd7 100644
--- a/engines/cine/part.cpp
+++ b/engines/cine/part.cpp
@@ -36,36 +36,29 @@ PartBuffer *partBuffer;
void loadPart(const char *partName) {
uint16 i;
- for (i = 0; i < NUM_MAX_PARTDATA; i++) {
- partBuffer[i].partName[0] = 0;
- partBuffer[i].offset = 0;
- partBuffer[i].packedSize = 0;
- partBuffer[i].unpackedSize = 0;
- }
-
+ memset(partBuffer, 0, sizeof(PartBuffer) * NUM_MAX_PARTDATA);
numElementInPart = 0;
- partFileHandle.close();
+ g_cine->_partFileHandle.close();
checkDataDisk(-1);
- partFileHandle.open(partName);
-
- assert(partFileHandle.isOpen());
+ if (!g_cine->_partFileHandle.open(partName))
+ error("loadPart(): Cannot open file %s", partName);
setMouseCursor(MOUSE_CURSOR_DISK);
- numElementInPart = partFileHandle.readUint16BE();
- partFileHandle.readUint16BE(); // entry size
+ numElementInPart = g_cine->_partFileHandle.readUint16BE();
+ g_cine->_partFileHandle.readUint16BE(); // entry size
strcpy(currentPartName, partName);
for (i = 0; i < numElementInPart; i++) {
- partFileHandle.read(partBuffer[i].partName, 14);
- partBuffer[i].offset = partFileHandle.readUint32BE();
- partBuffer[i].packedSize = partFileHandle.readUint32BE();
- partBuffer[i].unpackedSize = partFileHandle.readUint32BE();
- partFileHandle.readUint32BE(); // unused
+ g_cine->_partFileHandle.read(partBuffer[i].partName, 14);
+ partBuffer[i].offset = g_cine->_partFileHandle.readUint32BE();
+ partBuffer[i].packedSize = g_cine->_partFileHandle.readUint32BE();
+ partBuffer[i].unpackedSize = g_cine->_partFileHandle.readUint32BE();
+ g_cine->_partFileHandle.readUint32BE(); // unused
}
if (g_cine->getGameType() == Cine::GType_FW && g_cine->getPlatform() == Common::kPlatformPC && strcmp(partName, "BASESON.SND") != 0)
@@ -376,8 +369,8 @@ int16 findFileInBundle(const char *fileName) {
void readFromPart(int16 idx, byte *dataPtr) {
setMouseCursor(MOUSE_CURSOR_DISK);
- partFileHandle.seek(partBuffer[idx].offset, SEEK_SET);
- partFileHandle.read(dataPtr, partBuffer[idx].packedSize);
+ g_cine->_partFileHandle.seek(partBuffer[idx].offset, SEEK_SET);
+ g_cine->_partFileHandle.read(dataPtr, partBuffer[idx].packedSize);
}
byte *readBundleFile(int16 foundFileIdx) {
@@ -429,10 +422,9 @@ byte *readFile(const char *filename) {
if (!in.isOpen())
error("readFile(): Cannot open file %s", filename);
- byte *dataPtr;
uint32 size = in.size();
- dataPtr = (byte *)malloc(size);
+ byte *dataPtr = (byte *)malloc(size);
in.read(dataPtr, size);
return dataPtr;
@@ -450,12 +442,15 @@ void dumpBundle(const char *fileName) {
for (int i = 0; i < numElementInPart; i++) {
byte *data = readBundleFile(i);
+ debug(0, "%s", partBuffer[i].partName);
+
Common::File out;
+ if (out.open(Common::String("dumps/") + partBuffer[i].partName, Common::File::kFileWriteMode)) {
+ out.write(data, partBuffer[i].unpackedSize);
+ out.close();
+ }
- debug(0, "%s", partBuffer[i].partName);
- out.open(Common::String("dumps/") + partBuffer[i].partName, Common::File::kFileWriteMode);
- out.write(data, partBuffer[i].unpackedSize);
- out.close();
+ free(data);
}
loadPart(tmpPart);
diff --git a/engines/cine/texte.cpp b/engines/cine/texte.cpp
index 226dda2eb6..ee15874648 100644
--- a/engines/cine/texte.cpp
+++ b/engines/cine/texte.cpp
@@ -52,9 +52,8 @@ void loadTextData(const char *pFileName, byte *pDestinationBuffer) {
assert(pFileName);
assert(pDestinationBuffer);
- pFileHandle.open(pFileName);
-
- assert(pFileHandle.isOpen());
+ if (!pFileHandle.open(pFileName))
+ error("loadTextData(): Cannot open file %s", pFileName);
entrySize = pFileHandle.readUint16BE();
numEntry = pFileHandle.readUint16BE();
diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp
index fcf67a23b7..12643bf274 100644
--- a/engines/cine/various.cpp
+++ b/engines/cine/various.cpp
@@ -56,8 +56,6 @@ int16 buildObjectListCommand(void);
void drawString(const char *string, byte param) {
}
-Common::File *partFileHandleP = NULL;
-
void waitPlayerInput(void) {
}
@@ -999,15 +997,14 @@ void CineEngine::makeSystemMenu(void) {
if (!makeMenuChoice(confirmMenu, 2, mouseX, mouseY + 8, 100)) {
char saveString[256], tmp[80];
- Common::OutSaveFile *fHandle;
-
snprintf(tmp, 80, "%s.dir", _targetName.c_str());
- fHandle = g_saveFileMan->openForSaving(tmp);
- // FIXME: Properly handle openForSaving failures instead of
- // just crashing silently!
- assert(fHandle);
-
+ Common::OutSaveFile *fHandle = g_saveFileMan->openForSaving(tmp);
+ if (!fHandle) {
+ warning("Unable to open file %s for saving", tmp);
+ break;
+ }
+
fHandle->write(currentSaveName, 200);
delete fHandle;
@@ -1031,7 +1028,7 @@ void CineEngine::makeSystemMenu(void) {
}
}
-const int16 choiceResultTable[] = {
+static const int16 choiceResultTable[] = {
1,
1,
1,
@@ -1041,7 +1038,7 @@ const int16 choiceResultTable[] = {
1
};
-const int16 subObjectUseTable[] = {
+static const int16 subObjectUseTable[] = {
3,
3,
3,
@@ -1051,7 +1048,7 @@ const int16 subObjectUseTable[] = {
0
};
-const int16 canUseOnItemTable[] = {
+static const int16 canUseOnItemTable[] = {
1,
0,
0,
diff --git a/engines/cine/various.h b/engines/cine/various.h
index 578aed0ef5..234d27ce95 100644
--- a/engines/cine/various.h
+++ b/engines/cine/various.h
@@ -79,13 +79,6 @@ extern uint16 var3;
extern uint16 var4;
extern uint16 var5;
-extern Common::File *palFileHandleP;
-extern Common::File *partFileHandleP;
-
-#define palFileHandle (*palFileHandleP)
-#define partFileHandle (*partFileHandleP)
-
-
void mainLoopSub1(void);
void setTextWindow(uint16 param1, uint16 param2, uint16 param3, uint16 param4);