[Scummvm-cvs-logs] SF.net SVN: scummvm: [27021] scummvm/trunk/engines/cine
cyx at users.sourceforge.net
cyx at users.sourceforge.net
Wed May 30 20:43:29 CEST 2007
Revision: 27021
http://scummvm.svn.sourceforge.net/scummvm/?rev=27021&view=rev
Author: cyx
Date: 2007-05-30 11:43:28 -0700 (Wed, 30 May 2007)
Log Message:
-----------
cleanup, don't rely on assert() to ensure a gamefile/savefile is opened. Also removed the use of Common::File global objects.
Modified Paths:
--------------
scummvm/trunk/engines/cine/cine.cpp
scummvm/trunk/engines/cine/cine.h
scummvm/trunk/engines/cine/msg.cpp
scummvm/trunk/engines/cine/pal.cpp
scummvm/trunk/engines/cine/part.cpp
scummvm/trunk/engines/cine/texte.cpp
scummvm/trunk/engines/cine/various.cpp
scummvm/trunk/engines/cine/various.h
Modified: scummvm/trunk/engines/cine/cine.cpp
===================================================================
--- scummvm/trunk/engines/cine/cine.cpp 2007-05-30 18:39:35 UTC (rev 27020)
+++ scummvm/trunk/engines/cine/cine.cpp 2007-05-30 18:43:28 UTC (rev 27021)
@@ -68,12 +68,6 @@
freePoldatDat();
freeErrmessDat();
}
-
- if (palFileHandleP);
- delete palFileHandleP;
-
- if (partFileHandleP);
- delete partFileHandleP;
}
int CineEngine::init() {
@@ -82,9 +76,6 @@
GUIErrorMessage("No valid games were found in the specified directory.");
return -1;
}
-
- palFileHandleP = new Common::File();
- partFileHandleP = new Common::File();
// Initialize backend
_system->beginGFXTransaction();
Modified: scummvm/trunk/engines/cine/cine.h
===================================================================
--- scummvm/trunk/engines/cine/cine.h 2007-05-30 18:39:35 UTC (rev 27020)
+++ scummvm/trunk/engines/cine/cine.h 2007-05-30 18:43:28 UTC (rev 27021)
@@ -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 @@
void makeSystemMenu(void);
const CINEGameDescription *_gameDescription;
+ Common::File _partFileHandle;
private:
void initialize(void);
Modified: scummvm/trunk/engines/cine/msg.cpp
===================================================================
--- scummvm/trunk/engines/cine/msg.cpp 2007-05-30 18:39:35 UTC (rev 27020)
+++ scummvm/trunk/engines/cine/msg.cpp 2007-05-30 18:43:28 UTC (rev 27021)
@@ -42,13 +42,10 @@
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));
Modified: scummvm/trunk/engines/cine/pal.cpp
===================================================================
--- scummvm/trunk/engines/cine/pal.cpp 2007-05-30 18:39:35 UTC (rev 27020)
+++ scummvm/trunk/engines/cine/pal.cpp 2007-05-30 18:43:28 UTC (rev 27021)
@@ -34,8 +34,6 @@
uint16 palEntriesCount;
-Common::File *palFileHandleP = NULL;
-
PalEntry *palPtr = NULL;
byte paletteBuffer1[16];
@@ -48,8 +46,6 @@
strcat(buffer, ".PAL");
- palFileHandle.close();
-
if (palPtr) {
free(palPtr);
palPtr = NULL;
@@ -57,10 +53,10 @@
palEntriesCount = 0;
- palFileHandle.open(buffer);
+ Common::File palFileHandle;
+ if (!palFileHandle.open(buffer))
+ error("loadPal(): Cannot open file %s", fileName);
- assert(palFileHandle.isOpen());
-
palEntriesCount = palFileHandle.readUint16LE();
palFileHandle.readUint16LE(); // entry size
@@ -71,6 +67,7 @@
palFileHandle.read(palPtr[i].pal1, 16);
palFileHandle.read(palPtr[i].pal2, 16);
}
+ palFileHandle.close();
}
int16 findPaletteFromName(const char *fileName) {
Modified: scummvm/trunk/engines/cine/part.cpp
===================================================================
--- scummvm/trunk/engines/cine/part.cpp 2007-05-30 18:39:35 UTC (rev 27020)
+++ scummvm/trunk/engines/cine/part.cpp 2007-05-30 18:43:28 UTC (rev 27021)
@@ -36,36 +36,29 @@
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);
+ if (!g_cine->_partFileHandle.open(partName))
+ error("loadPart(): Cannot open file %s", partName);
- assert(partFileHandle.isOpen());
-
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 @@
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 @@
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 @@
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);
Modified: scummvm/trunk/engines/cine/texte.cpp
===================================================================
--- scummvm/trunk/engines/cine/texte.cpp 2007-05-30 18:39:35 UTC (rev 27020)
+++ scummvm/trunk/engines/cine/texte.cpp 2007-05-30 18:43:28 UTC (rev 27021)
@@ -52,10 +52,9 @@
assert(pFileName);
assert(pDestinationBuffer);
- pFileHandle.open(pFileName);
+ if (!pFileHandle.open(pFileName))
+ error("loadTextData(): Cannot open file %s", pFileName);
- assert(pFileHandle.isOpen());
-
entrySize = pFileHandle.readUint16BE();
numEntry = pFileHandle.readUint16BE();
Modified: scummvm/trunk/engines/cine/various.cpp
===================================================================
--- scummvm/trunk/engines/cine/various.cpp 2007-05-30 18:39:35 UTC (rev 27020)
+++ scummvm/trunk/engines/cine/various.cpp 2007-05-30 18:43:28 UTC (rev 27021)
@@ -56,8 +56,6 @@
void drawString(const char *string, byte param) {
}
-Common::File *partFileHandleP = NULL;
-
void waitPlayerInput(void) {
}
@@ -999,15 +997,14 @@
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 @@
}
}
-const int16 choiceResultTable[] = {
+static const int16 choiceResultTable[] = {
1,
1,
1,
@@ -1041,7 +1038,7 @@
1
};
-const int16 subObjectUseTable[] = {
+static const int16 subObjectUseTable[] = {
3,
3,
3,
@@ -1051,7 +1048,7 @@
0
};
-const int16 canUseOnItemTable[] = {
+static const int16 canUseOnItemTable[] = {
1,
0,
0,
Modified: scummvm/trunk/engines/cine/various.h
===================================================================
--- scummvm/trunk/engines/cine/various.h 2007-05-30 18:39:35 UTC (rev 27020)
+++ scummvm/trunk/engines/cine/various.h 2007-05-30 18:43:28 UTC (rev 27021)
@@ -79,13 +79,6 @@
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);
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