From cf3ea8eec29978450c8a7c29f12210dbdaa815da Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 12 May 2009 12:20:45 +0000 Subject: Cleanup. svn-id: r40479 --- engines/kyra/script.cpp | 26 +++++++++++++------------- engines/kyra/script.h | 13 ++++++------- engines/kyra/script_tim.cpp | 10 +++++----- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/engines/kyra/script.cpp b/engines/kyra/script.cpp index ebffa6ce20..09a9caf4ca 100644 --- a/engines/kyra/script.cpp +++ b/engines/kyra/script.cpp @@ -66,7 +66,7 @@ EMCInterpreter::EMCInterpreter(KyraEngine_v1 *vm) : _vm(vm) { } bool EMCInterpreter::load(const char *filename, EMCData *scriptData, const Common::Array *opcodes) { - ScriptFileParser file(filename, _vm->resource()); + IFFParser file(filename, _vm->resource()); if (!file) { error("Couldn't open script file '%s'", filename); return false; @@ -80,18 +80,18 @@ bool EMCInterpreter::load(const char *filename, EMCData *scriptData, const Commo return false; } - uint32 chunkSize = file.getIFFBlockSize(TEXT_CHUNK); + uint32 chunkSize = file.getBlockSize(TEXT_CHUNK); if (chunkSize != (uint32)-1) { scriptData->text = new byte[chunkSize]; - if (!file.loadIFFBlock(TEXT_CHUNK, scriptData->text, chunkSize)) { + if (!file.loadBlock(TEXT_CHUNK, scriptData->text, chunkSize)) { unload(scriptData); error("Couldn't load TEXT chunk from file: '%s'", filename); return false; } } - chunkSize = file.getIFFBlockSize(ORDR_CHUNK); + chunkSize = file.getBlockSize(ORDR_CHUNK); if (chunkSize == (uint32)-1) { unload(scriptData); error("No ORDR chunk found in file: '%s'", filename); @@ -101,7 +101,7 @@ bool EMCInterpreter::load(const char *filename, EMCData *scriptData, const Commo scriptData->ordr = new uint16[chunkSize]; - if (!file.loadIFFBlock(ORDR_CHUNK, scriptData->ordr, chunkSize << 1)) { + if (!file.loadBlock(ORDR_CHUNK, scriptData->ordr, chunkSize << 1)) { unload(scriptData); error("Couldn't load ORDR chunk from file: '%s'", filename); return false; @@ -110,7 +110,7 @@ bool EMCInterpreter::load(const char *filename, EMCData *scriptData, const Commo while (chunkSize--) scriptData->ordr[chunkSize] = READ_BE_UINT16(&scriptData->ordr[chunkSize]); - chunkSize = file.getIFFBlockSize(DATA_CHUNK); + chunkSize = file.getBlockSize(DATA_CHUNK); if (chunkSize == (uint32)-1) { unload(scriptData); error("No DATA chunk found in file: '%s'", filename); @@ -120,7 +120,7 @@ bool EMCInterpreter::load(const char *filename, EMCData *scriptData, const Commo scriptData->data = new uint16[chunkSize]; - if (!file.loadIFFBlock(DATA_CHUNK, scriptData->data, chunkSize << 1)) { + if (!file.loadBlock(DATA_CHUNK, scriptData->data, chunkSize << 1)) { unload(scriptData); error("Couldn't load DATA chunk from file: '%s'", filename); return false; @@ -217,10 +217,10 @@ bool EMCInterpreter::run(EMCState *script) { } #pragma mark - -#pragma mark - ScriptFileParser implementation +#pragma mark - IFFParser implementation #pragma mark - -void ScriptFileParser::setFile(const char *filename, Resource *res) { +void IFFParser::setFile(const char *filename, Resource *res) { destroy(); res->exists(filename, true); @@ -230,13 +230,13 @@ void ScriptFileParser::setFile(const char *filename, Resource *res) { _endOffset = _stream->size(); } -void ScriptFileParser::destroy() { +void IFFParser::destroy() { delete _stream; _stream = 0; _startOffset = _endOffset = 0; } -uint32 ScriptFileParser::getFORMBlockSize() { +uint32 IFFParser::getFORMBlockSize() { uint32 oldOffset = _stream->pos(); uint32 data = _stream->readUint32LE(); @@ -250,7 +250,7 @@ uint32 ScriptFileParser::getFORMBlockSize() { return data; } -uint32 ScriptFileParser::getIFFBlockSize(const uint32 chunkName) { +uint32 IFFParser::getBlockSize(const uint32 chunkName) { uint32 size = (uint32)-1; _stream->seek(_startOffset + 0x0C); @@ -271,7 +271,7 @@ uint32 ScriptFileParser::getIFFBlockSize(const uint32 chunkName) { return size; } -bool ScriptFileParser::loadIFFBlock(const uint32 chunkName, void *loadTo, uint32 ptrSize) { +bool IFFParser::loadBlock(const uint32 chunkName, void *loadTo, uint32 ptrSize) { _stream->seek(_startOffset + 0x0C); while ((uint)_stream->pos() < _endOffset) { diff --git a/engines/kyra/script.h b/engines/kyra/script.h index 7d6c9d5243..b65dee0398 100644 --- a/engines/kyra/script.h +++ b/engines/kyra/script.h @@ -73,20 +73,19 @@ struct EMCState { class Resource; class KyraEngine_v1; -class ScriptFileParser { +class IFFParser { public: - ScriptFileParser() : _stream(0), _startOffset(0), _endOffset(0) {} - ScriptFileParser(const char *filename, Resource *res) : _stream(0), _startOffset(0), _endOffset(0) { setFile(filename, res); } - ~ScriptFileParser() { destroy(); } + IFFParser() : _stream(0), _startOffset(0), _endOffset(0) {} + IFFParser(const char *filename, Resource *res) : _stream(0), _startOffset(0), _endOffset(0) { setFile(filename, res); } + ~IFFParser() { destroy(); } - // 'script' must be allocated with new! void setFile(const char *filename, Resource *res); operator bool() const { return (_startOffset != _endOffset) && _stream; } uint32 getFORMBlockSize(); - uint32 getIFFBlockSize(const uint32 chunk); - bool loadIFFBlock(const uint32 chunk, void *loadTo, uint32 ptrSize); + uint32 getBlockSize(const uint32 chunk); + bool loadBlock(const uint32 chunk, void *loadTo, uint32 ptrSize); private: void destroy(); diff --git a/engines/kyra/script_tim.cpp b/engines/kyra/script_tim.cpp index cae74ef82b..6b5e0761ce 100644 --- a/engines/kyra/script_tim.cpp +++ b/engines/kyra/script_tim.cpp @@ -119,7 +119,7 @@ TIM *TIMInterpreter::load(const char *filename, const Common::Arrayresource()->exists(filename)) return 0; - ScriptFileParser file(filename, vm()->resource()); + IFFParser file(filename, vm()->resource()); if (!file) error("Couldn't open TIM file '%s'", filename); @@ -137,16 +137,16 @@ TIM *TIMInterpreter::load(const char *filename, const Common::ArrayprocFunc = -1; tim->opcodes = opcodes; - uint32 avtlChunkSize = file.getIFFBlockSize(AVTL_CHUNK); - uint32 textChunkSize = file.getIFFBlockSize(TEXT_CHUNK); + uint32 avtlChunkSize = file.getBlockSize(AVTL_CHUNK); + uint32 textChunkSize = file.getBlockSize(TEXT_CHUNK); tim->avtl = new uint16[avtlChunkSize/2]; if (textChunkSize != 0xFFFFFFFF) tim->text = new byte[textChunkSize]; - if (!file.loadIFFBlock(AVTL_CHUNK, tim->avtl, avtlChunkSize)) + if (!file.loadBlock(AVTL_CHUNK, tim->avtl, avtlChunkSize)) error("Couldn't read AVTL chunk in TIM file '%s'", filename); - if (textChunkSize != 0xFFFFFFFF && !file.loadIFFBlock(TEXT_CHUNK, tim->text, textChunkSize)) + if (textChunkSize != 0xFFFFFFFF && !file.loadBlock(TEXT_CHUNK, tim->text, textChunkSize)) error("Couldn't read TEXT chunk in TIM file '%s'", filename); avtlChunkSize >>= 1; -- cgit v1.2.3