AGOS: Get rid of ArchiveMan in favor of global SearchMan.

This in fact slightly changes the priority order of added archives. Formerly,
all archives in SearchMan were preferred to the customly added ones in
ArchiveMan. All standard paths (i.e. path and extrapath) will be still be
searched before the custom ones (which are all priority 0 right now) but system
specific paths will be searched after (due to their priority being -1). Since
system specific paths shouldn't contain any game data files this should
hopefully be harmless.

This wasn't tested for games with CAB archives.
This commit is contained in:
Johannes Schickel 2014-01-22 00:30:28 +01:00
parent e560dca6b1
commit 1cee8439e7
7 changed files with 28 additions and 88 deletions

View file

@ -25,7 +25,6 @@
#include "engines/engine.h" #include "engines/engine.h"
#include "common/archive.h"
#include "common/array.h" #include "common/array.h"
#include "common/error.h" #include "common/error.h"
#include "common/keyboard.h" #include "common/keyboard.h"
@ -187,22 +186,6 @@ class Debugger;
# define _OPCODE(ver, x) { &ver::x, "" } # define _OPCODE(ver, x) { &ver::x, "" }
#endif #endif
class ArchiveMan : public Common::SearchSet {
public:
ArchiveMan();
#ifdef ENABLE_AGOS2
void registerArchive(const Common::String &filename, int priority);
#endif
virtual bool hasFile(const Common::String &name) const;
virtual int listMatchingMembers(Common::ArchiveMemberList &list, const Common::String &pattern) const;
virtual int listMembers(Common::ArchiveMemberList &list) const;
virtual const Common::ArchiveMemberPtr getMember(const Common::String &name) const;
virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &filename) const;
};
class AGOSEngine : public Engine { class AGOSEngine : public Engine {
protected: protected:
friend class Debugger; friend class Debugger;
@ -617,8 +600,6 @@ public:
AGOSEngine(OSystem *system, const AGOSGameDescription *gd); AGOSEngine(OSystem *system, const AGOSGameDescription *gd);
virtual ~AGOSEngine(); virtual ~AGOSEngine();
ArchiveMan _archives;
byte *_curSfxFile; byte *_curSfxFile;
uint32 _curSfxFileSize; uint32 _curSfxFileSize;
uint16 _sampleEnd, _sampleWait; uint16 _sampleEnd, _sampleWait;

View file

@ -251,7 +251,7 @@ bool MoviePlayerDXA::load() {
} }
Common::String videoName = Common::String::format("%s.dxa", baseName); Common::String videoName = Common::String::format("%s.dxa", baseName);
Common::SeekableReadStream *videoStream = _vm->_archives.createReadStreamForMember(videoName); Common::SeekableReadStream *videoStream = SearchMan.createReadStreamForMember(videoName);
if (!videoStream) if (!videoStream)
error("Failed to load video file %s", videoName.c_str()); error("Failed to load video file %s", videoName.c_str());
if (!loadStream(videoStream)) if (!loadStream(videoStream))
@ -421,7 +421,7 @@ MoviePlayerSMK::MoviePlayerSMK(AGOSEngine_Feeble *vm, const char *name)
bool MoviePlayerSMK::load() { bool MoviePlayerSMK::load() {
Common::String videoName = Common::String::format("%s.smk", baseName); Common::String videoName = Common::String::format("%s.smk", baseName);
Common::SeekableReadStream *videoStream = _vm->_archives.createReadStreamForMember(videoName); Common::SeekableReadStream *videoStream = SearchMan.createReadStreamForMember(videoName);
if (!videoStream) if (!videoStream)
error("Failed to load video file %s", videoName.c_str()); error("Failed to load video file %s", videoName.c_str());
if (!loadStream(videoStream)) if (!loadStream(videoStream))
@ -532,25 +532,25 @@ MoviePlayer *makeMoviePlayer(AGOSEngine_Feeble *vm, const char *name) {
memcpy(shortName, baseName, 6); memcpy(shortName, baseName, 6);
sprintf(filename, "%s~1.dxa", shortName); sprintf(filename, "%s~1.dxa", shortName);
if (vm->_archives.hasFile(filename)) { if (SearchMan.hasFile(filename)) {
memset(baseName, 0, sizeof(baseName)); memset(baseName, 0, sizeof(baseName));
memcpy(baseName, filename, 8); memcpy(baseName, filename, 8);
} }
sprintf(filename, "%s~1.smk", shortName); sprintf(filename, "%s~1.smk", shortName);
if (vm->_archives.hasFile(filename)) { if (SearchMan.hasFile(filename)) {
memset(baseName, 0, sizeof(baseName)); memset(baseName, 0, sizeof(baseName));
memcpy(baseName, filename, 8); memcpy(baseName, filename, 8);
} }
} }
sprintf(filename, "%s.dxa", baseName); sprintf(filename, "%s.dxa", baseName);
if (vm->_archives.hasFile(filename)) { if (SearchMan.hasFile(filename)) {
return new MoviePlayerDXA(vm, baseName); return new MoviePlayerDXA(vm, baseName);
} }
sprintf(filename, "%s.smk", baseName); sprintf(filename, "%s.smk", baseName);
if (vm->_archives.hasFile(filename)) { if (SearchMan.hasFile(filename)) {
return new MoviePlayerSMK(vm, baseName); return new MoviePlayerSMK(vm, baseName);
} }

View file

@ -28,6 +28,7 @@
#include "common/savefile.h" #include "common/savefile.h"
#include "common/system.h" #include "common/system.h"
#include "common/textconsole.h" #include "common/textconsole.h"
#include "common/installshield_cab.h"
#include "agos/intern.h" #include "agos/intern.h"
#include "agos/agos.h" #include "agos/agos.h"
@ -269,8 +270,12 @@ void AGOSEngine::loadArchives() {
if (getFeatures() & GF_PACKED) { if (getFeatures() & GF_PACKED) {
for (ag = _gameDescription->desc.filesDescriptions; ag->fileName; ag++) { for (ag = _gameDescription->desc.filesDescriptions; ag->fileName; ag++) {
if (!_archives.hasArchive(ag->fileName)) if (!SearchMan.hasArchive(ag->fileName)) {
_archives.registerArchive(ag->fileName, ag->fileType); Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(ag->fileName);
if (stream)
SearchMan.add(ag->fileName, Common::makeInstallShieldArchive(stream, DisposeAfterUse::YES), ag->fileType);
}
} }
} }
} }

View file

@ -24,7 +24,6 @@
#include "common/archive.h" #include "common/archive.h"
#include "common/installshield_cab.h"
#include "common/file.h" #include "common/file.h"
#include "common/memstream.h" #include "common/memstream.h"
#include "common/textconsole.h" #include "common/textconsole.h"
@ -38,51 +37,6 @@
namespace AGOS { namespace AGOS {
ArchiveMan::ArchiveMan() {
}
#ifdef ENABLE_AGOS2
void ArchiveMan::registerArchive(const Common::String &filename, int priority) {
Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(filename);
if (stream)
add(filename, makeInstallShieldArchive(stream, DisposeAfterUse::YES), priority);
}
#endif
bool ArchiveMan::hasFile(const Common::String &name) const {
if (SearchMan.hasFile(name))
return true;
return Common::SearchSet::hasFile(name);
}
int ArchiveMan::listMatchingMembers(Common::ArchiveMemberList &list, const Common::String &pattern) const {
const int matches = SearchMan.listMatchingMembers(list, pattern);
return matches + Common::SearchSet::listMatchingMembers(list, pattern);
}
int ArchiveMan::listMembers(Common::ArchiveMemberList &list) const {
const int matches = SearchMan.listMembers(list);
return matches + Common::SearchSet::listMembers(list);
}
const Common::ArchiveMemberPtr ArchiveMan::getMember(const Common::String &name) const {
Common::ArchiveMemberPtr ptr = SearchMan.getMember(name);
if (ptr)
return ptr;
return Common::SearchSet::getMember(name);
}
Common::SeekableReadStream *ArchiveMan::createReadStreamForMember(const Common::String &filename) const {
if (SearchMan.hasFile(filename)) {
return SearchMan.createReadStreamForMember(filename);
}
return Common::SearchSet::createReadStreamForMember(filename);
}
#ifdef ENABLE_AGOS2 #ifdef ENABLE_AGOS2
uint16 AGOSEngine_Feeble::to16Wrapper(uint value) { uint16 AGOSEngine_Feeble::to16Wrapper(uint value) {
return TO_LE_16(value); return TO_LE_16(value);
@ -201,7 +155,7 @@ void AGOSEngine_PN::loadGamePcFile() {
if (getFileName(GAME_BASEFILE) != NULL) { if (getFileName(GAME_BASEFILE) != NULL) {
// Read dataBase // Read dataBase
in = _archives.createReadStreamForMember(getFileName(GAME_BASEFILE)); in = SearchMan.createReadStreamForMember(getFileName(GAME_BASEFILE));
if (!in) { if (!in) {
error("loadGamePcFile: Can't load database file '%s'", getFileName(GAME_BASEFILE)); error("loadGamePcFile: Can't load database file '%s'", getFileName(GAME_BASEFILE));
} }
@ -219,7 +173,7 @@ void AGOSEngine_PN::loadGamePcFile() {
if (getFileName(GAME_TEXTFILE) != NULL) { if (getFileName(GAME_TEXTFILE) != NULL) {
// Read textBase // Read textBase
in = _archives.createReadStreamForMember(getFileName(GAME_TEXTFILE)); in = SearchMan.createReadStreamForMember(getFileName(GAME_TEXTFILE));
if (!in) { if (!in) {
error("loadGamePcFile: Can't load textbase file '%s'", getFileName(GAME_TEXTFILE)); error("loadGamePcFile: Can't load textbase file '%s'", getFileName(GAME_TEXTFILE));
} }
@ -242,7 +196,7 @@ void AGOSEngine::loadGamePcFile() {
if (getFileName(GAME_BASEFILE) != NULL) { if (getFileName(GAME_BASEFILE) != NULL) {
/* Read main gamexx file */ /* Read main gamexx file */
in = _archives.createReadStreamForMember(getFileName(GAME_BASEFILE)); in = SearchMan.createReadStreamForMember(getFileName(GAME_BASEFILE));
if (!in) { if (!in) {
error("loadGamePcFile: Can't load gamexx file '%s'", getFileName(GAME_BASEFILE)); error("loadGamePcFile: Can't load gamexx file '%s'", getFileName(GAME_BASEFILE));
} }
@ -268,7 +222,7 @@ void AGOSEngine::loadGamePcFile() {
if (getFileName(GAME_TBLFILE) != NULL) { if (getFileName(GAME_TBLFILE) != NULL) {
/* Read list of TABLE resources */ /* Read list of TABLE resources */
in = _archives.createReadStreamForMember(getFileName(GAME_TBLFILE)); in = SearchMan.createReadStreamForMember(getFileName(GAME_TBLFILE));
if (!in) { if (!in) {
error("loadGamePcFile: Can't load table resources file '%s'", getFileName(GAME_TBLFILE)); error("loadGamePcFile: Can't load table resources file '%s'", getFileName(GAME_TBLFILE));
} }
@ -289,7 +243,7 @@ void AGOSEngine::loadGamePcFile() {
if (getFileName(GAME_STRFILE) != NULL) { if (getFileName(GAME_STRFILE) != NULL) {
/* Read list of TEXT resources */ /* Read list of TEXT resources */
in = _archives.createReadStreamForMember(getFileName(GAME_STRFILE)); in = SearchMan.createReadStreamForMember(getFileName(GAME_STRFILE));
if (!in) if (!in)
error("loadGamePcFile: Can't load text resources file '%s'", getFileName(GAME_STRFILE)); error("loadGamePcFile: Can't load text resources file '%s'", getFileName(GAME_STRFILE));
@ -303,7 +257,7 @@ void AGOSEngine::loadGamePcFile() {
if (getFileName(GAME_STATFILE) != NULL) { if (getFileName(GAME_STATFILE) != NULL) {
/* Read list of ROOM STATE resources */ /* Read list of ROOM STATE resources */
in = _archives.createReadStreamForMember(getFileName(GAME_STATFILE)); in = SearchMan.createReadStreamForMember(getFileName(GAME_STATFILE));
if (!in) { if (!in) {
error("loadGamePcFile: Can't load state resources file '%s'", getFileName(GAME_STATFILE)); error("loadGamePcFile: Can't load state resources file '%s'", getFileName(GAME_STATFILE));
} }
@ -326,7 +280,7 @@ void AGOSEngine::loadGamePcFile() {
if (getFileName(GAME_RMSLFILE) != NULL) { if (getFileName(GAME_RMSLFILE) != NULL) {
/* Read list of ROOM ITEMS resources */ /* Read list of ROOM ITEMS resources */
in = _archives.createReadStreamForMember(getFileName(GAME_RMSLFILE)); in = SearchMan.createReadStreamForMember(getFileName(GAME_RMSLFILE));
if (!in) { if (!in) {
error("loadGamePcFile: Can't load room resources file '%s'", getFileName(GAME_RMSLFILE)); error("loadGamePcFile: Can't load room resources file '%s'", getFileName(GAME_RMSLFILE));
} }
@ -342,7 +296,7 @@ void AGOSEngine::loadGamePcFile() {
if (getFileName(GAME_XTBLFILE) != NULL) { if (getFileName(GAME_XTBLFILE) != NULL) {
/* Read list of XTABLE resources */ /* Read list of XTABLE resources */
in = _archives.createReadStreamForMember(getFileName(GAME_XTBLFILE)); in = SearchMan.createReadStreamForMember(getFileName(GAME_XTBLFILE));
if (!in) { if (!in) {
error("loadGamePcFile: Can't load xtable resources file '%s'", getFileName(GAME_XTBLFILE)); error("loadGamePcFile: Can't load xtable resources file '%s'", getFileName(GAME_XTBLFILE));
} }
@ -843,7 +797,7 @@ void AGOSEngine::loadVGABeardFile(uint16 id) {
sprintf(filename, "0%d.VGA", id); sprintf(filename, "0%d.VGA", id);
} }
in = _archives.createReadStreamForMember(filename); in = SearchMan.createReadStreamForMember(filename);
if (!in) if (!in)
error("loadSimonVGAFile: Can't load %s", filename); error("loadSimonVGAFile: Can't load %s", filename);
@ -921,7 +875,7 @@ void AGOSEngine::loadVGAVideoFile(uint16 id, uint8 type, bool useError) {
} }
} }
in = _archives.createReadStreamForMember(filename); in = SearchMan.createReadStreamForMember(filename);
if (!in) { if (!in) {
if (useError) if (useError)
error("loadVGAVideoFile: Can't load %s", filename); error("loadVGAVideoFile: Can't load %s", filename);

View file

@ -452,7 +452,7 @@ static const char *const dimpSoundList[32] = {
void AGOSEngine::loadSoundFile(const char* filename) { void AGOSEngine::loadSoundFile(const char* filename) {
Common::SeekableReadStream *in; Common::SeekableReadStream *in;
in = _archives.createReadStreamForMember(filename); in = SearchMan.createReadStreamForMember(filename);
if (!in) if (!in)
error("loadSound: Can't load %s", filename); error("loadSound: Can't load %s", filename);
@ -475,7 +475,7 @@ void AGOSEngine::loadSound(uint16 sound, int16 pan, int16 vol, uint16 type) {
assert(sound >= 1 && sound <= 32); assert(sound >= 1 && sound <= 32);
sprintf(filename, "%s.wav", dimpSoundList[sound - 1]); sprintf(filename, "%s.wav", dimpSoundList[sound - 1]);
in = _archives.createReadStreamForMember(filename); in = SearchMan.createReadStreamForMember(filename);
if (!in) if (!in)
error("loadSound: Can't load %s", filename); error("loadSound: Can't load %s", filename);

View file

@ -1031,7 +1031,7 @@ bool AGOSEngine::loadGame(const Common::String &filename, bool restartMode) {
if (restartMode) { if (restartMode) {
// Load restart state // Load restart state
f = _archives.createReadStreamForMember(filename); f = SearchMan.createReadStreamForMember(filename);
} else { } else {
f = _saveFileMan->openForLoading(filename); f = _saveFileMan->openForLoading(filename);
} }
@ -1205,7 +1205,7 @@ bool AGOSEngine_Elvira2::loadGame(const Common::String &filename, bool restartMo
if (restartMode) { if (restartMode) {
// Load restart state // Load restart state
f = _archives.createReadStreamForMember(filename); f = SearchMan.createReadStreamForMember(filename);
} else { } else {
f = _saveFileMan->openForLoading(filename); f = _saveFileMan->openForLoading(filename);
} }

View file

@ -266,7 +266,7 @@ Common::SeekableReadStream *AGOSEngine::openTablesFile(const char *filename) {
} }
Common::SeekableReadStream *AGOSEngine::openTablesFile_simon1(const char *filename) { Common::SeekableReadStream *AGOSEngine::openTablesFile_simon1(const char *filename) {
Common::SeekableReadStream *in = _archives.createReadStreamForMember(filename); Common::SeekableReadStream *in = SearchMan.createReadStreamForMember(filename);
if (!in) if (!in)
error("openTablesFile: Can't open '%s'", filename); error("openTablesFile: Can't open '%s'", filename);
return in; return in;