mirror of
https://github.com/scummvm/scummvm.git
synced 2026-05-21 05:40:43 +00:00
ZVISION: Rework engine to use standard SearchMan functionality.
Remove local SearchManager implementation.
This commit is contained in:
+3
-1
@@ -358,8 +358,10 @@ void SearchSet::addDirectory(const String &name, const Path &directory, int prio
|
||||
}
|
||||
|
||||
void SearchSet::addDirectory(const String &name, const FSNode &dir, int priority, int depth, bool flat) {
|
||||
if (!dir.exists() || !dir.isDirectory())
|
||||
if (!dir.exists() || !dir.isDirectory()) {
|
||||
error("Failed to add directory %s", name.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
add(name, new FSDirectory(dir, depth, flat, _ignoreClashes), priority);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ bool Console::cmdLoadSound(int argc, const char **argv) {
|
||||
int isStereo = atoi(argv[3]);
|
||||
|
||||
Common::File *file = new Common::File();
|
||||
if (!_engine->getSearchManager()->openFile(*file, argv[1])) {
|
||||
if (!file->open(argv[1])) {
|
||||
warning("File not found: %s", argv[1]);
|
||||
return true;
|
||||
}
|
||||
@@ -103,7 +103,7 @@ bool Console::cmdRawToWav(int argc, const char **argv) {
|
||||
}
|
||||
|
||||
Common::File file;
|
||||
if (!_engine->getSearchManager()->openFile(file, argv[1])) {
|
||||
if (!file.open(argv[1])) {
|
||||
warning("File not found: %s", argv[1]);
|
||||
return true;
|
||||
}
|
||||
@@ -232,7 +232,7 @@ bool Console::cmdDumpFile(int argc, const char **argv) {
|
||||
}
|
||||
|
||||
Common::File f;
|
||||
if (!_engine->getSearchManager()->openFile(f, argv[1])) {
|
||||
if (!f.open(argv[1])) {
|
||||
warning("File not found: %s", argv[1]);
|
||||
return true;
|
||||
}
|
||||
@@ -251,16 +251,20 @@ bool Console::cmdDumpFiles(int argc, const char **argv) {
|
||||
return true;
|
||||
}
|
||||
|
||||
SearchManager::MatchList fileList;
|
||||
_engine->getSearchManager()->listMembersWithExtension(fileList, argv[1]);
|
||||
|
||||
for (SearchManager::MatchList::iterator iter = fileList.begin(); iter != fileList.end(); ++iter) {
|
||||
fileName = iter->_value.name;
|
||||
Common::ArchiveMemberList fileList;
|
||||
Common::Path pattern;
|
||||
pattern = Common::Path(Common::String::format("*.%s", argv[1]));
|
||||
SearchMan.listMatchingMembers(fileList, pattern);
|
||||
|
||||
for (auto iter = fileList.begin(); iter != fileList.end(); ++iter) {
|
||||
fileName = iter->get()->getFileName();
|
||||
debugPrintf("Dumping %s\n", fileName.toString().c_str());
|
||||
|
||||
in = iter->_value.arch->createReadStreamForMember(iter->_value.name);
|
||||
in = iter->get()->createReadStream();
|
||||
if (in)
|
||||
dumpFile(in, fileName);
|
||||
else
|
||||
debugPrintf("Failed to dump!");
|
||||
delete in;
|
||||
}
|
||||
|
||||
@@ -280,7 +284,7 @@ bool Console::cmdDumpImage(int argc, const char **argv) {
|
||||
}
|
||||
|
||||
Common::File f;
|
||||
if (!_engine->getSearchManager()->openFile(f, fileName)) {
|
||||
if (!f.open(fileName)) {
|
||||
warning("File not found: %s", argv[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "common/config-manager.h"
|
||||
#include "common/events.h"
|
||||
#include "common/scummsys.h"
|
||||
#include "common/stream.h"
|
||||
#include "common/system.h"
|
||||
#include "common/rational.h"
|
||||
#include "engines/util.h"
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
|
||||
#include "common/config-manager.h"
|
||||
#include "common/file.h"
|
||||
#include "common/scummsys.h"
|
||||
#include "common/system.h"
|
||||
#include "common/translation.h"
|
||||
@@ -245,18 +246,12 @@ Common::SeekableReadStream *SaveManager::getSlotFile(uint slot) {
|
||||
else if (_engine->getGameId() == GID_NEMESIS)
|
||||
filename = Common::Path(Common::String::format("nemsav%u.sav", slot));
|
||||
|
||||
saveFile = _engine->getSearchManager()->openFile(filename);
|
||||
if (saveFile == NULL) {
|
||||
Common::File *tmpFile = new Common::File;
|
||||
if (!tmpFile->open(filename)) {
|
||||
delete tmpFile;
|
||||
} else {
|
||||
saveFile = tmpFile;
|
||||
}
|
||||
}
|
||||
|
||||
Common::File *tmpFile = new Common::File;
|
||||
if (!tmpFile->open(filename))
|
||||
delete tmpFile;
|
||||
else
|
||||
saveFile = tmpFile;
|
||||
}
|
||||
|
||||
return saveFile;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,273 +0,0 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/fs.h"
|
||||
#include "common/stream.h"
|
||||
#include "zvision/file/search_manager.h"
|
||||
#include "zvision/file/zfs_archive.h"
|
||||
|
||||
namespace ZVision {
|
||||
|
||||
SearchManager::SearchManager(const Common::Path &rootPath, int depth) {
|
||||
Common::FSNode fsNode(rootPath);
|
||||
|
||||
// Retrieve the root path from the FSNode, since it may not be the
|
||||
// same as rootPath any more, e.g. if we're doing auto-detection on
|
||||
// the current directory.
|
||||
|
||||
_root = fsNode.getPath();
|
||||
|
||||
listDirRecursive(_dirList, fsNode, depth);
|
||||
|
||||
for (Common::List<Common::Path>::iterator it = _dirList.begin(); it != _dirList.end();) {
|
||||
*it = it->relativeTo(_root);
|
||||
if (it->empty()) {
|
||||
it = _dirList.erase(it);
|
||||
} else {
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SearchManager::~SearchManager() {
|
||||
Common::List<Common::Archive *>::iterator it = _archList.begin();
|
||||
while (it != _archList.end()) {
|
||||
delete *it;
|
||||
it++;
|
||||
}
|
||||
|
||||
_archList.clear();
|
||||
}
|
||||
|
||||
void SearchManager::addFile(const Common::Path &name, Common::Archive *arch) {
|
||||
bool addArch = true;
|
||||
Common::List<Common::Archive *>::iterator it = _archList.begin();
|
||||
while (it != _archList.end()) {
|
||||
if (*it == arch) {
|
||||
addArch = false;
|
||||
break;
|
||||
}
|
||||
it++;
|
||||
}
|
||||
if (addArch)
|
||||
_archList.push_back(arch);
|
||||
|
||||
Common::Path lowerCaseName = name;
|
||||
lowerCaseName.toLowercase();
|
||||
|
||||
SearchManager::Node nod;
|
||||
nod.name = lowerCaseName;
|
||||
nod.arch = arch;
|
||||
|
||||
SearchManager::MatchList::iterator fit = _files.find(lowerCaseName);
|
||||
|
||||
if (fit == _files.end()) {
|
||||
_files[lowerCaseName] = nod;
|
||||
} else {
|
||||
Common::SeekableReadStream *stream = fit->_value.arch->createReadStreamForMember(fit->_value.name);
|
||||
if (stream) {
|
||||
if (stream->size() < 10)
|
||||
fit->_value.arch = arch;
|
||||
delete stream;
|
||||
} else {
|
||||
_files[lowerCaseName] = nod;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Common::File *SearchManager::openFile(const Common::Path &name) {
|
||||
SearchManager::MatchList::iterator fit = _files.find(name);
|
||||
|
||||
if (fit != _files.end()) {
|
||||
Common::File *tmp = new Common::File();
|
||||
tmp->open(fit->_value.name, *fit->_value.arch);
|
||||
return tmp;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool SearchManager::openFile(Common::File &file, const Common::Path &name) {
|
||||
SearchManager::MatchList::iterator fit = _files.find(name);
|
||||
|
||||
if (fit != _files.end())
|
||||
return file.open(fit->_value.name, *fit->_value.arch);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SearchManager::hasFile(const Common::Path &name) {
|
||||
SearchManager::MatchList::iterator fit = _files.find(name);
|
||||
|
||||
if (fit != _files.end())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SearchManager::loadZix(const Common::Path &name) {
|
||||
Common::File file;
|
||||
if (!file.open(name))
|
||||
return false;
|
||||
|
||||
Common::String line;
|
||||
|
||||
while (!file.eos()) {
|
||||
line = file.readLine();
|
||||
if (line.matchString("----------*", true))
|
||||
break;
|
||||
}
|
||||
|
||||
if (file.eos())
|
||||
error("Corrupt ZIX file: %s", name.toString(Common::Path::kNativeSeparator).c_str());
|
||||
|
||||
Common::Array<Common::Archive *> archives;
|
||||
|
||||
while (!file.eos()) {
|
||||
line = file.readLine();
|
||||
line.trim();
|
||||
if (line.matchString("----------*", true))
|
||||
break;
|
||||
else if (line.matchString("DIR:*", true) || line.matchString("CD0:*", true) || line.matchString("CD1:*", true) || line.matchString("CD2:*", true)) {
|
||||
Common::Archive *arc;
|
||||
|
||||
Common::String path(line.c_str() + 5);
|
||||
for (uint i = 0; i < path.size(); i++)
|
||||
if (path[i] == '\\')
|
||||
path.setChar('/', i);
|
||||
|
||||
// Check if NEMESIS.ZIX/MEDIUM.ZIX refers to the znemesis folder, and
|
||||
// check the game root folder instead
|
||||
if (path.hasPrefix("znemesis/"))
|
||||
path = Common::String(path.c_str() + 9);
|
||||
|
||||
// Check if INQUIS.ZIX refers to the ZGI folder, and check the game
|
||||
// root folder instead
|
||||
if (path.hasPrefix("zgi/"))
|
||||
path = Common::String(path.c_str() + 4);
|
||||
if (path.hasPrefix("zgi_e/"))
|
||||
path = Common::String(path.c_str() + 6);
|
||||
|
||||
if (path.size() && path[0] == '.')
|
||||
path.deleteChar(0);
|
||||
if (path.size() && path[0] == '/')
|
||||
path.deleteChar(0);
|
||||
if (path.size() && path.hasSuffix("/"))
|
||||
path.deleteLastChar();
|
||||
|
||||
// Handle paths in case-sensitive file systems (bug #6775)
|
||||
Common::Path path_(path);
|
||||
if (!path_.empty()) {
|
||||
for (Common::List<Common::Path>::iterator it = _dirList.begin(); it != _dirList.end(); ++it) {
|
||||
if (path_.equalsIgnoreCase(*it)) {
|
||||
path_ = *it;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (path.matchString("*.zfs", true)) {
|
||||
arc = new ZfsArchive(path_);
|
||||
} else {
|
||||
path_ = _root.join(path_);
|
||||
arc = new Common::FSDirectory(path_);
|
||||
}
|
||||
archives.push_back(arc);
|
||||
}
|
||||
}
|
||||
|
||||
if (file.eos())
|
||||
error("Corrupt ZIX file: %s", name.toString(Common::Path::kNativeSeparator).c_str());
|
||||
|
||||
while (!file.eos()) {
|
||||
line = file.readLine();
|
||||
line.trim();
|
||||
uint dr = 0;
|
||||
char buf[32];
|
||||
if (sscanf(line.c_str(), "%u %s", &dr, buf) == 2) {
|
||||
if (dr <= archives.size() && dr > 0) {
|
||||
addFile(buf, archives[dr - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SearchManager::addDir(const Common::Path &name) {
|
||||
Common::Path path;
|
||||
for (Common::List<Common::Path>::iterator it = _dirList.begin(); it != _dirList.end(); ++it)
|
||||
if (name.equalsIgnoreCase(*it)) {
|
||||
path = *it;
|
||||
break;
|
||||
}
|
||||
|
||||
if (path.empty())
|
||||
return;
|
||||
|
||||
|
||||
path = _root.join(path);
|
||||
Common::FSDirectory *dir = new Common::FSDirectory(path);
|
||||
|
||||
Common::ArchiveMemberList list;
|
||||
dir->listMatchingMembers(list, "*.zfs");
|
||||
|
||||
for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
|
||||
Common::String flname = (*iter)->getName();
|
||||
|
||||
ZfsArchive *zfs = new ZfsArchive(name.join(flname));
|
||||
|
||||
Common::ArchiveMemberList zfslist;
|
||||
zfs->listMembers(zfslist);
|
||||
|
||||
for (Common::ArchiveMemberList::iterator ziter = zfslist.begin(); ziter != zfslist.end(); ++ziter) {
|
||||
Common::Path zfsFileName = (*ziter)->getPathInArchive();
|
||||
addFile(zfsFileName, zfs);
|
||||
}
|
||||
}
|
||||
|
||||
list.clear();
|
||||
dir->listMembers(list);
|
||||
|
||||
for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
|
||||
Common::Path flname = (*iter)->getPathInArchive();
|
||||
addFile(flname, dir);
|
||||
}
|
||||
}
|
||||
|
||||
void SearchManager::listDirRecursive(Common::List<Common::Path> &_list, const Common::FSNode &fsNode, int depth) {
|
||||
Common::FSList fsList;
|
||||
if (fsNode.getChildren(fsList)) {
|
||||
|
||||
_list.push_back(fsNode.getPath().normalize());
|
||||
|
||||
if (depth > 1)
|
||||
for (Common::FSList::const_iterator it = fsList.begin(); it != fsList.end(); ++it)
|
||||
listDirRecursive(_list, *it, depth - 1);
|
||||
}
|
||||
}
|
||||
|
||||
void SearchManager::listMembersWithExtension(MatchList &fileList, Common::String extension) {
|
||||
for (SearchManager::MatchList::iterator it = _files.begin(); it != _files.end(); ++it) {
|
||||
if (it->_key.baseName().hasSuffix(extension))
|
||||
fileList[it->_key] = it->_value;
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace ZVision
|
||||
@@ -1,69 +0,0 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ZVISION_SEARCH_MANAGER_H
|
||||
#define ZVISION_SEARCH_MANAGER_H
|
||||
|
||||
#include "common/archive.h"
|
||||
#include "common/file.h"
|
||||
#include "common/hashmap.h"
|
||||
#include "common/hash-str.h"
|
||||
#include "common/list.h"
|
||||
#include "common/str.h"
|
||||
|
||||
namespace ZVision {
|
||||
|
||||
class SearchManager {
|
||||
public:
|
||||
SearchManager(const Common::Path &rootPath, int depth);
|
||||
~SearchManager();
|
||||
|
||||
void addFile(const Common::Path &name, Common::Archive *arch);
|
||||
void addDir(const Common::Path &name);
|
||||
|
||||
Common::File *openFile(const Common::Path &name);
|
||||
bool openFile(Common::File &file, const Common::Path &name);
|
||||
bool hasFile(const Common::Path &name);
|
||||
|
||||
bool loadZix(const Common::Path &name);
|
||||
|
||||
struct Node {
|
||||
Common::Path name;
|
||||
Common::Archive *arch;
|
||||
};
|
||||
|
||||
typedef Common::HashMap<Common::Path, Node, Common::Path::IgnoreCase_Hash, Common::Path::IgnoreCase_EqualTo> MatchList;
|
||||
|
||||
void listMembersWithExtension(MatchList &fileList, Common::String extension);
|
||||
|
||||
private:
|
||||
|
||||
void listDirRecursive(Common::List<Common::Path> &dirList, const Common::FSNode &fsNode, int depth);
|
||||
|
||||
Common::List<Common::Path> _dirList;
|
||||
Common::List<Common::Archive *> _archList;
|
||||
Common::Path _root;
|
||||
MatchList _files;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // ZVISION_SEARCH_MANAGER_H
|
||||
@@ -39,7 +39,7 @@ ZorkCursor::ZorkCursor(ZVision *engine, const Common::Path &fileName)
|
||||
_hotspotX(0),
|
||||
_hotspotY(0) {
|
||||
Common::File file;
|
||||
if (!engine->getSearchManager()->openFile(file, fileName))
|
||||
if (!file.open(fileName))
|
||||
error("Cursor file %s does not exist", fileName.toString().c_str());
|
||||
|
||||
uint32 magic = file.readUint32BE();
|
||||
|
||||
@@ -38,7 +38,7 @@ FogFx::FogFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, Effe
|
||||
|
||||
_pos = 0;
|
||||
|
||||
if (_engine->getSearchManager()->hasFile(clouds))
|
||||
if (SearchMan.hasFile(clouds))
|
||||
_engine->getRenderManager()->readImageToSurface(clouds, _fog);
|
||||
else
|
||||
_engine->getRenderManager()->readImageToSurface("cloud.tga", _fog);
|
||||
|
||||
@@ -295,7 +295,7 @@ void RenderManager::readImageToSurface(const Common::Path &fileName, Graphics::S
|
||||
void RenderManager::readImageToSurface(const Common::Path &fileName, Graphics::Surface &destination, bool transposed) {
|
||||
Common::File file;
|
||||
|
||||
if (!_engine->getSearchManager()->openFile(file, fileName)) {
|
||||
if (!file.open(fileName)) {
|
||||
warning("Could not open file %s", fileName.toString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ MODULE_OBJS := \
|
||||
core/events.o \
|
||||
file/lzss_read_stream.o \
|
||||
file/save_manager.o \
|
||||
file/search_manager.o \
|
||||
file/zfs_archive.o \
|
||||
graphics/cursors/cursor.o \
|
||||
graphics/cursors/cursor_manager.o \
|
||||
|
||||
@@ -576,9 +576,6 @@ bool ActionMusic::execute() {
|
||||
if (_midi) {
|
||||
_scriptManager->addSideFX(new MusicMidiNode(_engine, _slotKey, _prog, _note, volume));
|
||||
} else {
|
||||
if (!_engine->getSearchManager()->hasFile(_fileName))
|
||||
return true;
|
||||
|
||||
_scriptManager->addSideFX(new MusicNode(_engine, _slotKey, _fileName, _loop, volume));
|
||||
}
|
||||
|
||||
@@ -1113,7 +1110,7 @@ bool ActionStreamVideo::execute() {
|
||||
subname.setChar('u', subname.size() - 2);
|
||||
subname.setChar('b', subname.size() - 1);
|
||||
Common::Path subpath(_fileName.getParent().appendComponent(subname));
|
||||
bool subtitleExists = _engine->getSearchManager()->hasFile(subpath);
|
||||
bool subtitleExists = SearchMan.hasFile(subpath);
|
||||
bool switchToHires = false;
|
||||
|
||||
// NOTE: We only show the hires MPEG2 videos when libmpeg2 and liba52 are compiled in,
|
||||
@@ -1127,13 +1124,13 @@ bool ActionStreamVideo::execute() {
|
||||
|
||||
Common::Path hiresPath(_fileName.getParent().appendComponent(hiresFileName));
|
||||
|
||||
if (_scriptManager->getStateValue(StateKey_MPEGMovies) == 1 &&_engine->getSearchManager()->hasFile(hiresPath)) {
|
||||
if (_scriptManager->getStateValue(StateKey_MPEGMovies) == 1 && SearchMan.hasFile(hiresPath)) {
|
||||
_fileName = hiresPath;
|
||||
switchToHires = true;
|
||||
} else if (!_engine->getSearchManager()->hasFile(_fileName))
|
||||
} else if (!SearchMan.hasFile(_fileName))
|
||||
return true;
|
||||
#else
|
||||
if (!_engine->getSearchManager()->hasFile(_fileName))
|
||||
if (!SearchMan.hasFile(_fileName))
|
||||
return true;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ bool FistControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P
|
||||
|
||||
void FistControl::readDescFile(const Common::Path &fileName) {
|
||||
Common::File file;
|
||||
if (!_engine->getSearchManager()->openFile(file, fileName)) {
|
||||
if (!file.open(fileName)) {
|
||||
warning("Desc file %s could could be opened", fileName.toString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ void HotMovControl::readHsFile(const Common::Path &fileName) {
|
||||
return;
|
||||
|
||||
Common::File file;
|
||||
if (!_engine->getSearchManager()->openFile(file, fileName)) {
|
||||
if (!file.open(fileName)) {
|
||||
warning("HS file %s could could be opened", fileName.toString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ LeverControl::~LeverControl() {
|
||||
|
||||
void LeverControl::parseLevFile(const Common::Path &fileName) {
|
||||
Common::File file;
|
||||
if (!_engine->getSearchManager()->openFile(file, fileName)) {
|
||||
if (!file.open(fileName)) {
|
||||
warning("LEV file %s could could be opened", fileName.toString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "common/stream.h"
|
||||
#include "zvision/zvision.h"
|
||||
#include "zvision/graphics/cursors/cursor_manager.h"
|
||||
#include "zvision/graphics/render_manager.h"
|
||||
|
||||
@@ -85,7 +85,7 @@ void TitlerControl::setString(int strLine) {
|
||||
|
||||
void TitlerControl::readStringsFile(const Common::Path &fileName) {
|
||||
Common::File file;
|
||||
if (!_engine->getSearchManager()->openFile(file, fileName)) {
|
||||
if (!file.open(fileName)) {
|
||||
warning("String_resource_file %s could could be opened", fileName.toString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -23,8 +23,10 @@
|
||||
#define ZVISION_TITLER_CONTROL_H
|
||||
|
||||
#include "common/array.h"
|
||||
#include "common/file.h"
|
||||
#include "common/path.h"
|
||||
#include "common/rect.h"
|
||||
#include "common/stream.h"
|
||||
#include "graphics/surface.h"
|
||||
#include "zvision/scripting/control.h"
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::Path &filename, bool l
|
||||
|
||||
if (filename.baseName().contains(".wav")) {
|
||||
Common::File *file = new Common::File();
|
||||
if (_engine->getSearchManager()->openFile(*file, filename)) {
|
||||
if (file->open(filename)) {
|
||||
audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
|
||||
}
|
||||
} else {
|
||||
@@ -108,7 +108,7 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::Path &filename, bool l
|
||||
subname.setChar('b', subname.size() - 1);
|
||||
|
||||
Common::Path subpath(filename.getParent().appendComponent(subname));
|
||||
if (_engine->getSearchManager()->hasFile(subpath))
|
||||
if (SearchMan.hasFile(subpath))
|
||||
_sub = _engine->getSubtitleManager()->create(subpath, _handle); // NB automatic subtitle!
|
||||
|
||||
_loaded = true;
|
||||
|
||||
@@ -41,7 +41,7 @@ SyncSoundNode::SyncSoundNode(ZVision *engine, uint32 key, Common::Path &filename
|
||||
|
||||
if (filename.baseName().contains(".wav")) {
|
||||
Common::File *file = new Common::File();
|
||||
if (_engine->getSearchManager()->openFile(*file, filename)) {
|
||||
if (file->open(filename)) {
|
||||
audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
|
||||
}
|
||||
} else {
|
||||
@@ -56,7 +56,7 @@ SyncSoundNode::SyncSoundNode(ZVision *engine, uint32 key, Common::Path &filename
|
||||
subname.setChar('b', subname.size() - 1);
|
||||
|
||||
Common::Path subpath(filename.getParent().appendComponent(subname));
|
||||
if (_engine->getSearchManager()->hasFile(subpath))
|
||||
if (SearchMan.hasFile(subpath))
|
||||
_sub = _engine->getSubtitleManager()->create(subpath, _handle); // NB automatic subtitle!
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,8 @@ ttyTextNode::ttyTextNode(ZVision *engine, uint32 key, const Common::Path &file,
|
||||
_lineStartPos = 0;
|
||||
_startX = 0;
|
||||
|
||||
Common::File *infile = _engine->getSearchManager()->openFile(file);
|
||||
Common::File *infile = new Common::File;
|
||||
infile->open(file);
|
||||
if (infile) {
|
||||
while (!infile->eos()) {
|
||||
Common::U32String asciiLine = readWideLine(*infile);
|
||||
|
||||
@@ -77,7 +77,7 @@ void ScriptManager::parseScrFile(const Common::Path &fileName, ScriptScope &scop
|
||||
Common::Path auxFilePath(auxFileName);
|
||||
debugC(1, kDebugFile, "Auxiliary path %s", auxFilePath.toString().c_str());
|
||||
|
||||
if (!_engine->getSearchManager()->openFile(mainFile, fileName))
|
||||
if (!mainFile.open(fileName))
|
||||
error("Script file not found: %s", fileName.toString().c_str());
|
||||
else {
|
||||
debugC(1, kDebugScript, "Parsing primary script file %s", fileName.toString().c_str());
|
||||
|
||||
@@ -242,7 +242,7 @@ Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stre
|
||||
|
||||
Audio::RewindableAudioStream *makeRawZorkStream(const Common::Path &filePath, ZVision *engine) {
|
||||
Common::File *file = new Common::File();
|
||||
bool found = engine->getSearchManager()->openFile(*file, filePath);
|
||||
bool found = file->open(filePath);
|
||||
Common::String baseName = filePath.baseName();
|
||||
bool isRaw = baseName.hasSuffix(".raw");
|
||||
|
||||
@@ -251,13 +251,17 @@ Audio::RewindableAudioStream *makeRawZorkStream(const Common::Path &filePath, ZV
|
||||
file->close();
|
||||
|
||||
// Check for an audio patch (.src)
|
||||
baseName.setChar('s', baseName.size() - 3);
|
||||
baseName.setChar('r', baseName.size() - 2);
|
||||
baseName.setChar('c', baseName.size() - 1);
|
||||
Common::String patchName = baseName;
|
||||
patchName.setChar('s', baseName.size() - 3);
|
||||
patchName.setChar('r', baseName.size() - 2);
|
||||
patchName.setChar('c', baseName.size() - 1);
|
||||
|
||||
if (!engine->getSearchManager()->openFile(*file, filePath.getParent().appendComponent(baseName)))
|
||||
if (!file->open(filePath.getParent().appendComponent(patchName))) {
|
||||
warning("Audio file %s AND audio patch %s not found", baseName.c_str(), patchName.c_str());
|
||||
return NULL;
|
||||
}
|
||||
} else if (!found && !isRaw) {
|
||||
warning("Audio file %s not found", baseName.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "common/tokenizer.h"
|
||||
#include "graphics/fontman.h"
|
||||
#include "zvision/zvision.h"
|
||||
#include "zvision/file/search_manager.h"
|
||||
#include "zvision/text/string_manager.h"
|
||||
#include "zvision/text/text.h"
|
||||
|
||||
@@ -48,7 +47,7 @@ void StringManager::initialize(ZVisionGameId gameId) {
|
||||
|
||||
void StringManager::loadStrFile(const Common::Path &fileName) {
|
||||
Common::File file;
|
||||
if (!_engine->getSearchManager()->openFile(file, fileName))
|
||||
if (!file.open(fileName))
|
||||
error("%s does not exist. String parsing failed", fileName.toString().c_str());
|
||||
|
||||
uint lineNumber = 0;
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
*/
|
||||
|
||||
#include "common/config-manager.h"
|
||||
#include "common/file.h"
|
||||
#include "common/system.h"
|
||||
#include "zvision/detection.h"
|
||||
#include "zvision/file/search_manager.h"
|
||||
#include "zvision/graphics/render_manager.h"
|
||||
#include "zvision/scripting/script_manager.h"
|
||||
#include "zvision/text/subtitle_manager.h"
|
||||
@@ -291,7 +291,7 @@ Subtitle::Subtitle(ZVision *engine, const Common::Path &subname, bool vob) :
|
||||
_redraw(false) {
|
||||
Common::File subFile;
|
||||
Common::Point _textOffset = _engine->getSubtitleManager()->getTextOffset();
|
||||
if (!_engine->getSearchManager()->openFile(subFile, subname)) {
|
||||
if (!subFile.open(subname)) {
|
||||
warning("Failed to open subtitle %s", subname.toString().c_str());
|
||||
_toDelete = true;
|
||||
return;
|
||||
@@ -318,7 +318,7 @@ Subtitle::Subtitle(ZVision *engine, const Common::Path &subname, bool vob) :
|
||||
char filename[64];
|
||||
if (sscanf(str.c_str(), "%*[^:]:%s", filename) == 1) {
|
||||
Common::File txtFile;
|
||||
if (_engine->getSearchManager()->openFile(txtFile, Common::Path(filename))) {
|
||||
if (txtFile.open(Common::Path(filename))) {
|
||||
while (!txtFile.eos()) {
|
||||
Common::String txtline = readWideLine(txtFile).encode();
|
||||
Line curLine;
|
||||
|
||||
@@ -110,8 +110,8 @@ bool StyledTTFont::loadFont(const Common::String &fontName, int32 point, uint st
|
||||
|
||||
Common::File *file = new Common::File();
|
||||
Graphics::Font *newFont;
|
||||
if (!file->open(Common::Path(newFontName)) && !_engine->getSearchManager()->openFile(*file, Common::Path(newFontName)) &&
|
||||
!file->open(Common::Path(liberationFontName)) && !_engine->getSearchManager()->openFile(*file, Common::Path(liberationFontName))) {
|
||||
if (!file->open(Common::Path(newFontName)) && !file->open(Common::Path(newFontName)) &&
|
||||
!file->open(Common::Path(liberationFontName)) && !file->open(Common::Path(liberationFontName))) {
|
||||
newFont = Graphics::loadTTFFontFromArchive(liberationFontName, point, Graphics::kTTFSizeModeCell, 0, 0, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal));
|
||||
delete file;
|
||||
} else {
|
||||
|
||||
@@ -58,7 +58,8 @@ Video::VideoDecoder *ZVision::loadAnimation(const Common::Path &fileName) {
|
||||
else
|
||||
error("Unknown suffix for animation %s", fileName.toString().c_str());
|
||||
|
||||
Common::File *_file = getSearchManager()->openFile(fileName);
|
||||
Common::File *_file = new Common::File(); //TODO - verify that this is safely deleted when done with
|
||||
_file->open(fileName);
|
||||
if (!_file)
|
||||
error("Error opening %s", fileName.toString().c_str());
|
||||
|
||||
|
||||
+162
-37
@@ -38,7 +38,7 @@
|
||||
#include "zvision/zvision.h"
|
||||
#include "zvision/core/console.h"
|
||||
#include "zvision/file/save_manager.h"
|
||||
#include "zvision/file/search_manager.h"
|
||||
#include "zvision/file/zfs_archive.h"
|
||||
#include "zvision/graphics/render_manager.h"
|
||||
#include "zvision/graphics/cursors/cursor_manager.h"
|
||||
#include "zvision/scripting/menu.h"
|
||||
@@ -97,7 +97,6 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
|
||||
_menu(nullptr),
|
||||
_subtitleManager(nullptr),
|
||||
_volumeManager(nullptr),
|
||||
_searchManager(nullptr),
|
||||
_textRenderer(nullptr),
|
||||
_doubleFPS(false),
|
||||
_widescreen(false),
|
||||
@@ -176,30 +175,6 @@ void ZVision::saveSettings() {
|
||||
}
|
||||
|
||||
void ZVision::initialize() {
|
||||
// File Paths
|
||||
const Common::FSNode gameDataDir(ConfMan.getPath("path"));
|
||||
|
||||
_searchManager = new SearchManager(ConfMan.getPath("path"), 6);
|
||||
|
||||
_searchManager->addDir("FONTS");
|
||||
_searchManager->addDir("addon");
|
||||
switch (getGameId()) {
|
||||
case GID_GRANDINQUISITOR:
|
||||
if (!_searchManager->loadZix("INQUIS.ZIX"))
|
||||
error("Unable to load file INQUIS.ZIX");
|
||||
break;
|
||||
case GID_NEMESIS:
|
||||
if (!_searchManager->loadZix("NEMESIS.ZIX"))
|
||||
// The game might not be installed, try MEDIUM.ZIX instead
|
||||
if (!_searchManager->loadZix("ZNEMSCR/MEDIUM.ZIX"))
|
||||
error("Unable to load the file ZNEMSCR/MEDIUM.ZIX");
|
||||
break;
|
||||
case GID_NONE:
|
||||
default:
|
||||
error("Unknown/unspecified GameId");
|
||||
break;
|
||||
}
|
||||
|
||||
// Graphics
|
||||
_widescreen = ConfMan.getBool("widescreen");
|
||||
_doubleFPS = ConfMan.getBool("doublefps");
|
||||
@@ -302,9 +277,9 @@ Common::Error ZVision::run() {
|
||||
liberationFontName += liberationFontSuffixes[j];
|
||||
liberationFontName += ".ttf";
|
||||
|
||||
if (!Common::File::exists(Common::Path(fontName)) && !_searchManager->hasFile(Common::Path(fontName)) &&
|
||||
!Common::File::exists(Common::Path(liberationFontName)) && !_searchManager->hasFile(Common::Path(liberationFontName)) &&
|
||||
!Common::File::exists("fonts.dat") && !_searchManager->hasFile("fonts.dat")) {
|
||||
if (!Common::File::exists(Common::Path(fontName)) && !SearchMan.hasFile(Common::Path(fontName)) &&
|
||||
!Common::File::exists(Common::Path(liberationFontName)) && !SearchMan.hasFile(Common::Path(liberationFontName)) &&
|
||||
!Common::File::exists("fonts.dat") && !SearchMan.hasFile("fonts.dat")) {
|
||||
foundAllFonts = false;
|
||||
break;
|
||||
}
|
||||
@@ -331,14 +306,14 @@ Common::Error ZVision::run() {
|
||||
}
|
||||
if (getGameId() == GID_NEMESIS && !_midiManager->isAvailable()) {
|
||||
GUI::MessageDialog MIDIdialog(_(
|
||||
"MIDI playback is not available, or else improperly configured. "
|
||||
"Zork Nemesis contains several music puzzles which require "
|
||||
"MIDI audio in order to be solved. These puzzles may alternatively "
|
||||
"be solved using subtitles, if supported. Continue launching game?"
|
||||
),
|
||||
_("Yes"),
|
||||
_("No")
|
||||
);
|
||||
"MIDI playback is not available, or else improperly configured. "
|
||||
"Zork Nemesis contains several music puzzles which require "
|
||||
"MIDI audio in order to be solved. These puzzles may alternatively "
|
||||
"be solved using subtitles, if supported. Continue launching game?"
|
||||
),
|
||||
_("Yes"),
|
||||
_("No")
|
||||
);
|
||||
if (MIDIdialog.runModal() != GUI::kMessageOK)
|
||||
quitGame();
|
||||
}
|
||||
@@ -411,4 +386,154 @@ void ZVision::fpsTimer() {
|
||||
_renderedFrameCount = 0;
|
||||
}
|
||||
|
||||
void ZVision::initializePath(const Common::FSNode &gamePath) {
|
||||
// File Paths
|
||||
const Common::FSNode gameDataDir(gamePath);
|
||||
SearchMan.setIgnoreClashes(true);
|
||||
SearchMan.addDirectory(gamePath, 0, 5, true);
|
||||
SearchMan.addSubDirectoryMatching(gameDataDir, "FONTS");
|
||||
SearchMan.addSubDirectoryMatching(gameDataDir, "addon");
|
||||
|
||||
if (ConfMan.hasKey("extrapath")) {
|
||||
Common::Path gameExtraPath = ConfMan.getPath("extrapath");
|
||||
const Common::FSNode gameExtraDir(gameExtraPath);
|
||||
SearchMan.addDirectory(gameExtraPath, 0, 1, true);
|
||||
SearchMan.addSubDirectoryMatching(gameExtraDir, "auxvid");
|
||||
SearchMan.addSubDirectoryMatching(gameExtraDir, "auxscr");
|
||||
}
|
||||
|
||||
switch (getGameId()) {
|
||||
case GID_GRANDINQUISITOR:
|
||||
if (!loadZix("INQUIS.ZIX"))
|
||||
error("Unable to load file INQUIS.ZIX");
|
||||
break;
|
||||
case GID_NEMESIS:
|
||||
if (!loadZix("NEMESIS.ZIX"))
|
||||
// The game might not be installed, try MEDIUM.ZIX instead
|
||||
if (!loadZix("ZNEMSCR/MEDIUM.ZIX"))
|
||||
error("Unable to load the file ZNEMSCR/MEDIUM.ZIX");
|
||||
break;
|
||||
case GID_NONE:
|
||||
default:
|
||||
error("Unknown/unspecified GameId");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool ZVision::loadZix(const Common::Path &name) {
|
||||
Common::File file;
|
||||
if (!file.open(name))
|
||||
return false;
|
||||
|
||||
Common::String line;
|
||||
|
||||
//Skip first block
|
||||
while (!file.eos()) {
|
||||
line = file.readLine();
|
||||
if (line.matchString("----------*", true))
|
||||
break;
|
||||
}
|
||||
|
||||
if (file.eos())
|
||||
error("Corrupt ZIX file: %s", name.toString(Common::Path::kNativeSeparator).c_str());
|
||||
|
||||
uint8 archives = 0;
|
||||
|
||||
//Parse subdirectories & archives
|
||||
debugC(1, kDebugFile, "Parsing list of subdirectories & archives in %s", name.toString(Common::Path::kNativeSeparator).c_str());
|
||||
while (!file.eos()) {
|
||||
line = file.readLine();
|
||||
line.trim();
|
||||
if (line.matchString("----------*", true))
|
||||
break;
|
||||
else if (line.matchString("DIR:*", true) || line.matchString("CD0:*", true) || line.matchString("CD1:*", true) || line.matchString("CD2:*", true)) {
|
||||
line = Common::String(line.c_str() + 5);
|
||||
for (uint i = 0; i < line.size(); i++)
|
||||
if (line[i] == '\\')
|
||||
line.setChar('/', i);
|
||||
|
||||
// Check if NEMESIS.ZIX/MEDIUM.ZIX refers to the znemesis folder, and
|
||||
// check the game root folder instead
|
||||
if (line.hasPrefix("znemesis/"))
|
||||
line = Common::String(line.c_str() + 9);
|
||||
|
||||
// Check if INQUIS.ZIX refers to the ZGI folder, and check the game
|
||||
// root folder instead
|
||||
if (line.hasPrefix("zgi/"))
|
||||
line = Common::String(line.c_str() + 4);
|
||||
if (line.hasPrefix("zgi_e/"))
|
||||
line = Common::String(line.c_str() + 6);
|
||||
|
||||
if (line.size() && line[0] == '.')
|
||||
line.deleteChar(0);
|
||||
if (line.size() && line[0] == '/')
|
||||
line.deleteChar(0);
|
||||
if (line.size() && line.hasSuffix("/"))
|
||||
line.deleteLastChar();
|
||||
|
||||
Common::Path path(line, '/');
|
||||
path = path.getLastComponent(); //We are using the search manager in "flat" mode, so only filenames are needed
|
||||
|
||||
if (line.matchString("*.zfs", true)) {
|
||||
debugC(1, kDebugFile, "Adding archive %s to search manager.", path.toString().c_str());
|
||||
Common::Archive *arc;
|
||||
arc = new ZfsArchive(path);
|
||||
SearchMan.add(line, arc);
|
||||
}
|
||||
archives++;
|
||||
}
|
||||
}
|
||||
|
||||
if (file.eos())
|
||||
error("Corrupt ZIX file: %s", name.toString(Common::Path::kNativeSeparator).c_str());
|
||||
|
||||
const char* genExcluded[] {"*.dll", "*.ini", "*.exe", "*.isu", "*.inf", "*path*.txt", "r.svr", "*.zix"};
|
||||
const char* zgiExcluded[] {
|
||||
"c000h01q.raw", "cm00h01q.raw", "dm00h01q.raw", "e000h01q.raw", "em00h11p.raw", "em00h50q.raw", "gjnph65p.raw",
|
||||
"gjnph72p.raw", "h000h01q.raw", "m000h01q.raw", "p000h01q.raw", "q000h01q.raw", "sw00h01q.raw", "t000h01q.raw",
|
||||
"u000h01q.raw"
|
||||
};
|
||||
|
||||
//Parse files
|
||||
debugC(1, kDebugFile, "Parsing list of individual resource files in %s", name.toString(Common::Path::kNativeSeparator).c_str());
|
||||
while (!file.eos()) {
|
||||
line = file.readLine();
|
||||
line.trim();
|
||||
uint dr = 0;
|
||||
char buf[32];
|
||||
if (sscanf(line.c_str(), "%u %s", &dr, buf) == 2) {
|
||||
if (dr <= archives && dr > 0) {
|
||||
Common::String path(buf);
|
||||
bool exclude = false;
|
||||
for(auto filename : genExcluded)
|
||||
if(path.matchString(filename, true)) {
|
||||
exclude = true;
|
||||
break;
|
||||
}
|
||||
for(auto filename : zgiExcluded)
|
||||
if(path.matchString(filename, true)) {
|
||||
//exclude = true;
|
||||
break;
|
||||
}
|
||||
if(!exclude) {
|
||||
//No need to add file, just verify that it exists
|
||||
Common::File resource;
|
||||
if(!resource.exists(buf))
|
||||
warning("Missing file %s", path.c_str());
|
||||
else
|
||||
debugC(5, kDebugFile, "File found: %s", path.c_str());
|
||||
if(path.matchString("*.zfs", true)) {
|
||||
Common::Path path_(path);
|
||||
debugC(kDebugFile, "Adding archive %s to search manager.", path.c_str());
|
||||
Common::Archive *arc;
|
||||
arc = new ZfsArchive(path_);
|
||||
SearchMan.add(path, arc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End of namespace ZVision
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "gui/debugger.h"
|
||||
#include "zvision/detection.h"
|
||||
#include "zvision/core/clock.h"
|
||||
#include "zvision/file/search_manager.h"
|
||||
|
||||
namespace Common {
|
||||
class Keymap;
|
||||
@@ -142,7 +141,6 @@ private:
|
||||
RenderManager *_renderManager;
|
||||
CursorManager *_cursorManager;
|
||||
StringManager *_stringManager;
|
||||
SearchManager *_searchManager;
|
||||
TextRenderer *_textRenderer;
|
||||
MidiManager *_midiManager;
|
||||
SaveManager *_saveManager;
|
||||
@@ -196,9 +194,6 @@ public:
|
||||
StringManager *getStringManager() const {
|
||||
return _stringManager;
|
||||
}
|
||||
SearchManager *getSearchManager() const {
|
||||
return _searchManager;
|
||||
}
|
||||
TextRenderer *getTextRenderer() const {
|
||||
return _textRenderer;
|
||||
}
|
||||
@@ -281,6 +276,8 @@ public:
|
||||
private:
|
||||
void initialize();
|
||||
void initFonts();
|
||||
|
||||
void initializePath(const Common::FSNode &gamePath) override;
|
||||
|
||||
void parseStrFile(const Common::String &fileName);
|
||||
|
||||
@@ -297,6 +294,7 @@ private:
|
||||
uint8 getBufferedKey(uint8 pos);
|
||||
|
||||
double getVobAmplification(Common::String fileName) const;
|
||||
bool loadZix(const Common::Path &name);
|
||||
};
|
||||
|
||||
} // End of namespace ZVision
|
||||
|
||||
Reference in New Issue
Block a user