diff options
-rw-r--r-- | scumm/insane/insane.cpp | 6 | ||||
-rw-r--r-- | scumm/nut_renderer.cpp | 4 | ||||
-rw-r--r-- | scumm/resource.cpp | 32 | ||||
-rw-r--r-- | scumm/scumm.h | 3 | ||||
-rw-r--r-- | scumm/smush/chunk.cpp | 5 | ||||
-rw-r--r-- | scumm/smush/chunk.h | 6 | ||||
-rw-r--r-- | scumm/smush/smush_player.cpp | 4 | ||||
-rw-r--r-- | scumm/sound.cpp | 27 | ||||
-rw-r--r-- | scumm/sound.h | 5 | ||||
-rw-r--r-- | scumm/string.cpp | 6 |
10 files changed, 48 insertions, 50 deletions
diff --git a/scumm/insane/insane.cpp b/scumm/insane/insane.cpp index a93cdc5a62..6efa9229c6 100644 --- a/scumm/insane/insane.cpp +++ b/scumm/insane/insane.cpp @@ -586,11 +586,11 @@ int32 Insane::processKeyboard(void) { } void Insane::readFileToMem(const char *name, byte **buf) { - File *in; + ScummFile *in; uint32 len; - in = new File(); - in->open(name); + in = new ScummFile(); + _vm->openFile(*in, name); len = in->size(); *buf = (byte *)malloc(len); in->read(*buf, len); diff --git a/scumm/nut_renderer.cpp b/scumm/nut_renderer.cpp index 5bf36d1e12..56e597e0bf 100644 --- a/scumm/nut_renderer.cpp +++ b/scumm/nut_renderer.cpp @@ -119,8 +119,8 @@ bool NutRenderer::loadFont(const char *filename) { warning("NutRenderer::loadFont() Font already loaded, ok, loading..."); } - File file; - file.open(filename); + ScummFile file; + _vm->openFile(file, filename); if (file.isOpen() == false) { warning("NutRenderer::loadFont() Can't open font file: %s", filename); return false; diff --git a/scumm/resource.cpp b/scumm/resource.cpp index 315379dbc2..4b9b64324d 100644 --- a/scumm/resource.cpp +++ b/scumm/resource.cpp @@ -111,7 +111,7 @@ bool ScummFile::openSubFile(const char *filename) { file_name[0x20] = 0; assert(file_name[0]); - //debug(0, "extracting \'%s\'", file_name); + //debug(7, " extracting \'%s\'", file_name); // Consistency check. make sure the file data is in the file if (file_off + file_len > data_file_len) { @@ -120,7 +120,6 @@ bool ScummFile::openSubFile(const char *filename) { if (scumm_stricmp(file_name, filename) == 0) { // We got a match! - _subFileName = file_name; setSubfileRange(file_off, file_len); return true; } @@ -376,28 +375,35 @@ void ScummEngine::readRoomsOffsets() { } } -bool ScummEngine::openResourceFile(const char *filename, byte encByte) { - debugC(DEBUG_GENERAL, "openResourceFile(%s)", filename); +bool ScummEngine::openFile(ScummFile &file, const char *filename) { bool result = false; if (!_containerFile.isEmpty()) { - if (!_fileHandle.isOpen()) - _fileHandle.open(_containerFile.c_str()); - assert(_fileHandle.isOpen()); + file.close(); + file.open(_containerFile.c_str()); + assert(file.isOpen()); - result = _fileHandle.openSubFile(filename); + result = file.openSubFile(filename); } if (!result) { - _fileHandle.close(); - result = _fileHandle.open(filename); + file.close(); + result = file.open(filename); } - - _fileHandle.setEnc(encByte); - + return result; } +bool ScummEngine::openResourceFile(const char *filename, byte encByte) { + debugC(DEBUG_GENERAL, "openResourceFile(%s)", filename); + + if (openFile(_fileHandle, filename)) { + _fileHandle.setEnc(encByte); + return true; + } + return false; +} + void ScummEngine::askForDisk(const char *filename, int disknum) { char buf[128]; diff --git a/scumm/scumm.h b/scumm/scumm.h index 6736e974ff..8b0a022185 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -66,7 +66,6 @@ private: byte _encbyte; uint32 _subFileStart; uint32 _subFileLen; - Common::String _subFileName; public: ScummFile(); void setEnc(byte value); @@ -629,6 +628,8 @@ protected: public: /** The name of the (macintosh/rescumm style) container file, if any. */ Common::String _containerFile; + + bool openFile(ScummFile &file, const char *filename); protected: int _resourceHeaderSize; diff --git a/scumm/smush/chunk.cpp b/scumm/smush/chunk.cpp index 8df68c1b15..181d7707c4 100644 --- a/scumm/smush/chunk.cpp +++ b/scumm/smush/chunk.cpp @@ -21,6 +21,7 @@ #include "stdafx.h" #include "scumm/smush/chunk.h" +#include "scumm/scumm.h" #include "common/file.h" #include "common/str.h" @@ -89,8 +90,8 @@ FileChunk::FileChunk() : } FileChunk::FileChunk(const char *fname) { - _data = new File(); - if (!_data->open(fname)) + _data = new ScummFile(); + if (!g_scumm->openFile(*_data, fname)) error("FileChunk: Unable to open file %s", fname); _type = _data->readUint32BE(); diff --git a/scumm/smush/chunk.h b/scumm/smush/chunk.h index 3419d536a3..63453103b2 100644 --- a/scumm/smush/chunk.h +++ b/scumm/smush/chunk.h @@ -24,10 +24,10 @@ #include "common/scummsys.h" -class File; - namespace Scumm { +class ScummFile; + class Chunk { public: virtual ~Chunk() {}; @@ -67,7 +67,7 @@ public: class FileChunk : public BaseChunk { private: - File *_data; + ScummFile *_data; uint32 _offset; protected: diff --git a/scumm/smush/smush_player.cpp b/scumm/smush/smush_player.cpp index 2950c150c0..8583151774 100644 --- a/scumm/smush/smush_player.cpp +++ b/scumm/smush/smush_player.cpp @@ -1116,8 +1116,8 @@ void SmushPlayer::seekSan(const char *file, int32 pos, int32 contFrame) { void SmushPlayer::play(const char *filename, int32 offset, int32 startFrame) { // Verify the specified file exists - File f; - f.open(filename); + ScummFile f; + _vm->openFile(f, filename); if (!f.isOpen()) { warning("SmushPlayer::play() File not found %s", filename); return; diff --git a/scumm/sound.cpp b/scumm/sound.cpp index 1fc1c16d96..d3cb4341c8 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -588,10 +588,10 @@ void Sound::startTalkSound(uint32 offset, uint32 b, int mode, PlayingSoundHandle _sfxFile->close(); sprintf(filename, "audio/%s.%d/%d.voc", roomname, offset, b); - _sfxFile->open(filename); + _vm->openFile(*_sfxFile, filename); if (!_sfxFile->isOpen()) { sprintf(filename, "%d.%d.voc", offset, b); - _sfxFile->open(filename); + _vm->openFile(*_sfxFile, filename); } if (!_sfxFile->isOpen()) { warning("startTalkSound: dig demo: voc file not found"); @@ -968,41 +968,30 @@ void Sound::startSfxSound(File *file, int file_size, PlayingSoundHandle *handle, } } -File *Sound::openSfxFile() { +ScummFile *Sound::openSfxFile() { struct SoundFileExtensions { const char *ext; SoundMode mode; }; static const SoundFileExtensions extensions[] = { + { "sou", kVOCMode }, #ifdef USE_FLAC { "sof", kFlacMode }, #endif - #ifdef USE_MAD - { "so3", kMP3Mode }, - #endif #ifdef USE_VORBIS { "sog", kVorbisMode }, #endif - { "sou", kVOCMode }, + #ifdef USE_MAD + { "so3", kMP3Mode }, + #endif { 0, kVOCMode } }; - - char buf[256]; ScummFile *file = new ScummFile(); _offsetTable = NULL; - - if (!_vm->_containerFile.isEmpty() && file->open(_vm->_containerFile.c_str())) { - if (file->openSubFile("monster.sou")) { - _soundMode = kVOCMode; - } else { - file->close(); - } - } - /* Try opening the file <_gameName>.sou first, e.g. tentacle.sou. * That way, you can keep .sou files for multiple games in the * same directory */ @@ -1014,7 +1003,7 @@ File *Sound::openSfxFile() { for (int j = 0; basename[j] && !file->isOpen(); ++j) { for (int i = 0; extensions[i].ext; ++i) { sprintf(buf, "%s.%s", basename[j], extensions[i].ext); - if (file->open(buf)) { + if (_vm->openFile(*file, buf)) { _soundMode = extensions[i].mode; break; } diff --git a/scumm/sound.h b/scumm/sound.h index 77d04e46b2..e1b9274aad 100644 --- a/scumm/sound.h +++ b/scumm/sound.h @@ -29,6 +29,7 @@ class File; namespace Scumm { class ScummEngine; +class ScummFile; struct MP3OffsetTable; @@ -57,7 +58,7 @@ protected: int16 _soundQuePos, _soundQue[0x100]; int16 _soundQue2Pos, _soundQue2Sound[10], _soundQue2Offset[10]; - File *_sfxFile; + ScummFile *_sfxFile; SoundMode _soundMode; MP3OffsetTable *_offsetTable; // For compressed audio int _numSoundEffects; // For compressed audio @@ -110,7 +111,7 @@ public: int getCurrentCDSound() const { return _currentCDSound; } protected: - File *openSfxFile(); + ScummFile *openSfxFile(); void startSfxSound(File *file, int file_size, PlayingSoundHandle *handle, int id = -1); bool isSfxFinished() const; void processSfxQueues(); diff --git a/scumm/string.cpp b/scumm/string.cpp index 0135e67190..f11c4409f3 100644 --- a/scumm/string.cpp +++ b/scumm/string.cpp @@ -691,13 +691,13 @@ int indexCompare(const void *p1, const void *p2) { // Create an index of the language file. void ScummEngine::loadLanguageBundle() { - File file; + ScummFile file; int32 size; if (_gameId == GID_DIG) { - file.open("language.bnd"); + openFile(file, "language.bnd"); } else if (_gameId == GID_CMI) { - file.open("language.tab"); + openFile(file, "language.tab"); } else { return; } |