diff options
-rw-r--r-- | kyra/resource.cpp | 9 | ||||
-rw-r--r-- | kyra/resource.h | 7 | ||||
-rw-r--r-- | kyra/script.cpp | 3 |
3 files changed, 12 insertions, 7 deletions
diff --git a/kyra/resource.cpp b/kyra/resource.cpp index 6e56ff3a08..d5d1809162 100644 --- a/kyra/resource.cpp +++ b/kyra/resource.cpp @@ -29,6 +29,7 @@ namespace Kyra { Resourcemanager::Resourcemanager(KyraEngine* engine, const char* gamedir) { _gameDir = gamedir; + _engine = engine; // prefetches all PAK Files @@ -41,12 +42,11 @@ namespace Kyra { }; for (uint32 tmp = 0; kyraFilelist[tmp]; ++tmp) { - // prefetch file PAKFile* file = new PAKFile(getPath() + kyraFilelist[tmp]); assert(file); - if (file->isValid()) + if (file->isOpen() && file->isValid()) _pakfiles.push_back(file); else warning("couldn't load file '%s' correctly", kyraFilelist[tmp]); @@ -179,9 +179,10 @@ namespace Kyra { /////////////////////////////////////////// // Pak file manager #define PAKFile_Iterate Common::List<PakChunk*>::iterator start=_files.begin();start != _files.end(); ++start - PAKFile::PAKFile(const Common::String& file) { File pakfile; + _buffer = 0; + _open = false; if (!pakfile.open(file.c_str())) { warning("PAKFile couldn't open: '%s'", file.c_str()); @@ -221,11 +222,13 @@ namespace Kyra { _files.push_back(chunk); } + _open = true; } PAKFile::~PAKFile() { delete [] _buffer; _buffer = 0; + _open = false; for (PAKFile_Iterate) { delete *start; diff --git a/kyra/resource.h b/kyra/resource.h index b0a73beaa5..e867bdcf21 100644 --- a/kyra/resource.h +++ b/kyra/resource.h @@ -34,7 +34,6 @@ namespace Kyra { // standard Package format for Kyrandia games class PAKFile { - struct PakChunk { const char* _name; const uint8* _data; @@ -49,10 +48,10 @@ namespace Kyra { const uint8* getFile(const char* file); uint32 getFileSize(const char* file); - bool isValid(void) { return (_buffer != 0); } - + bool isValid(void) {return (_buffer != 0);} + bool isOpen(void) {return _open;} private: - + bool _open; uint8* _buffer; // the whole file Common::List<PakChunk*> _files; // the entries diff --git a/kyra/script.cpp b/kyra/script.cpp index 8b5e18287a..c40ab826b4 100644 --- a/kyra/script.cpp +++ b/kyra/script.cpp @@ -345,6 +345,9 @@ namespace Kyra { { 0, 0 } }; + _commands = commandProcs; +// _opcodes = opcodeProcs; + _scriptFile = NULL; _scriptFileSize = 0; } |