[Scummvm-cvs-logs] SF.net SVN: scummvm: [29176] scummvm/trunk/engines/kyra
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Tue Oct 9 07:40:21 CEST 2007
Revision: 29176
http://scummvm.svn.sourceforge.net/scummvm/?rev=29176&view=rev
Author: lordhoto
Date: 2007-10-08 22:40:20 -0700 (Mon, 08 Oct 2007)
Log Message:
-----------
HoF:
- now uses "FILEDATA.FDT" to detect what PAK files have to be loaded for ingame use
Modified Paths:
--------------
scummvm/trunk/engines/kyra/kyra.cpp
scummvm/trunk/engines/kyra/kyra_v2.cpp
scummvm/trunk/engines/kyra/resource.cpp
scummvm/trunk/engines/kyra/resource.h
Modified: scummvm/trunk/engines/kyra/kyra.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra.cpp 2007-10-09 04:47:41 UTC (rev 29175)
+++ scummvm/trunk/engines/kyra/kyra.cpp 2007-10-09 05:40:20 UTC (rev 29176)
@@ -130,6 +130,7 @@
_res = new Resource(this);
assert(_res);
+ _res->reset();
_text = new TextDisplayer(this, this->screen());
assert(_text);
_staticres = new StaticResource(this);
Modified: scummvm/trunk/engines/kyra/kyra_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.cpp 2007-10-09 04:47:41 UTC (rev 29175)
+++ scummvm/trunk/engines/kyra/kyra_v2.cpp 2007-10-09 05:40:20 UTC (rev 29176)
@@ -154,6 +154,11 @@
switch (gui_handleMainMenu()) {
case 0:
_screen->showMouse();
+
+ // load just the pak files needed for ingame
+ _res->unloadAllPakFiles();
+ _res->loadFileList("FILEDATA.FDT");
+
startup();
runLoop();
cleanup();
Modified: scummvm/trunk/engines/kyra/resource.cpp
===================================================================
--- scummvm/trunk/engines/kyra/resource.cpp 2007-10-09 04:47:41 UTC (rev 29175)
+++ scummvm/trunk/engines/kyra/resource.cpp 2007-10-09 05:40:20 UTC (rev 29176)
@@ -52,9 +52,21 @@
};
} // end of anonymous namespace
-Resource::Resource(KyraEngine *vm) {
- _vm = vm;
+Resource::Resource(KyraEngine *vm) : _vm(vm) {
+}
+Resource::~Resource() {
+ unloadAllPakFiles();
+}
+
+bool Resource::reset() {
+ unloadAllPakFiles();
+
+ FilesystemNode dir(ConfMan.get("path"));
+
+ if (!dir.exists() || !dir.isDirectory())
+ error("invalid game path '%s'", dir.getPath().c_str());
+
if (_vm->game() == GI_KYRA1) {
// we're loading KYRA.DAT here too (but just for Kyrandia 1)
if (!loadPakFile("KYRA.DAT") || !StaticResource::checkKyraDat()) {
@@ -65,7 +77,7 @@
// We only need kyra.dat for the demo.
if (_vm->gameFlags().isDemo)
- return;
+ return true;
// only VRM file we need in the *whole* game for kyra1
if (_vm->gameFlags().isTalkie)
@@ -80,10 +92,8 @@
}
FSList fslist;
- FilesystemNode dir(ConfMan.get("path"));
-
if (!dir.getChildren(fslist, FilesystemNode::kListFilesOnly))
- error("invalid game path '%s'", dir.getPath().c_str());
+ error("can't list files inside game path '%s'", dir.getPath().c_str());
if (_vm->game() == GI_KYRA1 && _vm->gameFlags().isTalkie) {
static const char *list[] = {
@@ -95,6 +105,10 @@
Common::for_each(list, list + ARRAYSIZE(list), Common::bind1st(Common::mem_fun(&Resource::loadPakFile), this));
Common::for_each(_pakfiles.begin(), _pakfiles.end(), Common::bind2nd(Common::mem_fun(&ResourceFile::protect), true));
} else {
+ // TODO: Kyra 2 InGame uses a special pak file list shipped with the game "FILEDATA.FDT", so we just have to load
+ // the files needed for Kyra 2 intro here. What has to be done is, checking what files are required in the intro
+ // and make a list similar to that for Kyra 1 and just load the files from the list and not all pak files we find.
+
for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
Common::String filename = file->getName();
filename.toUppercase();
@@ -119,13 +133,8 @@
}
}
}
-}
-Resource::~Resource() {
- for (ResIterator start = _pakfiles.begin() ;start != _pakfiles.end(); ++start) {
- delete *start;
- *start = 0;
- }
+ return true;
}
bool Resource::loadPakFile(const Common::String &filename) {
@@ -160,6 +169,35 @@
return true;
}
+bool Resource::loadFileList(const Common::String &filedata) {
+ Common::File f;
+
+ if (!f.open(filedata))
+ return false;
+
+ uint32 filenameOffset = 0;
+ while ((filenameOffset = f.readUint32LE()) != 0) {
+ uint32 offset = f.pos();
+ f.seek(filenameOffset, SEEK_SET);
+
+ uint8 buffer[64];
+ f.read(buffer, sizeof(buffer));
+ f.seek(offset + 16, SEEK_SET);
+
+ Common::String filename = (char*)buffer;
+ debug("%s", filename.c_str());
+
+ if (filename.hasSuffix(".PAK")) {
+ if (!loadPakFile(filename)) {
+ error("couldn't load file '%s'", filename.c_str());
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
void Resource::unloadPakFile(const Common::String &filename) {
ResIterator pak = Common::find_if(_pakfiles.begin(), _pakfiles.end(), ResFilenameEqual(Common::hashit_lower(filename)));
if (pak != _pakfiles.end())
@@ -170,6 +208,14 @@
return (Common::find_if(_pakfiles.begin(), _pakfiles.end(), ResFilenameEqual(Common::hashit_lower(filename))) != _pakfiles.end());
}
+void Resource::unloadAllPakFiles() {
+ for (ResIterator start = _pakfiles.begin(); start != _pakfiles.end(); ++start) {
+ delete *start;
+ *start = 0;
+ }
+ _pakfiles.clear();
+}
+
uint8 *Resource::fileData(const char *file, uint32 *size) const {
Common::File fileHandle;
Modified: scummvm/trunk/engines/kyra/resource.h
===================================================================
--- scummvm/trunk/engines/kyra/resource.h 2007-10-09 04:47:41 UTC (rev 29175)
+++ scummvm/trunk/engines/kyra/resource.h 2007-10-09 05:40:20 UTC (rev 29176)
@@ -116,10 +116,16 @@
Resource(KyraEngine *vm);
~Resource();
+ bool reset();
+
bool loadPakFile(const Common::String &filename);
void unloadPakFile(const Common::String &filename);
bool isInPakList(const Common::String &filename) const;
+ bool loadFileList(const Common::String &filedata);
+ // This unloads *all* pakfiles, even kyra.dat and protected ones
+ void unloadAllPakFiles();
+
uint32 getFileSize(const char *file) const;
uint8* fileData(const char *file, uint32 *size) const;
// gives back a file handle
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