Skip to content

Commit 9955c95

Browse files
hari01584sev-
authored andcommitted
DIRECTOR: Add multiple resources in exe using ProjectorArchive
This patch uses ProjectorArchive to extract multiple resources embedded into executable files, additionally a new function getRawExe is defined which gets raw exe file name without --start-movie overriding it. Solves the problem for finding multiple resource files like `ModTB.DXR` in 'mcluhan', uses 'mcluhan.exe' to extract resources and add them to SearchMan.
1 parent 20ea821 commit 9955c95

File tree

4 files changed

+47
-31
lines changed

4 files changed

+47
-31
lines changed

engines/director/archive.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,36 @@ class RIFXArchive : public Archive {
149149
Common::HashMap<uint32, KeyMap> _keyData;
150150
};
151151

152+
/*******************************************
153+
*
154+
* Projector Archive
155+
*
156+
*******************************************/
157+
158+
class ProjectorArchive : public Common::Archive {
159+
public:
160+
ProjectorArchive(Common::String path);
161+
~ProjectorArchive() override;
162+
163+
bool hasFile(const Common::Path &path) const override;
164+
int listMembers(Common::ArchiveMemberList &list) const override;
165+
const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override;
166+
Common::SeekableReadStream *createReadStreamForMember(const Common::Path &path) const override;
167+
bool isLoaded() { return _isLoaded; }
168+
private:
169+
Common::SeekableReadStream *createBufferedReadStream();
170+
bool loadArchive(Common::SeekableReadStream *stream);
171+
172+
struct Entry {
173+
uint32 offset;
174+
uint32 size;
175+
};
176+
typedef Common::HashMap<Common::String, Entry, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> FileMap;
177+
FileMap _files;
178+
Common::String _path;
179+
180+
bool _isLoaded;
181+
};
152182
} // End of namespace Director
153183

154184
#endif

engines/director/director.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,17 @@ Common::CodePage DirectorEngine::getPlatformEncoding() {
290290
return getEncoding(getPlatform(), getLanguage());
291291
}
292292

293+
Common::String DirectorEngine::getRawEXEName() const {
294+
// Returns raw executable name (without getting overloaded from --start-movie option)
295+
return Common::punycode_decodefilename(Common::lastPathComponent(_gameDescription->desc.filesDescriptions[0].fileName, '/'));
296+
}
297+
293298
Common::String DirectorEngine::getEXEName() const {
294299
StartMovie startMovie = getStartMovie();
295300
if (startMovie.startMovie.size() > 0)
296301
return startMovie.startMovie;
297302

298-
return Common::punycode_decodefilename(Common::lastPathComponent(_gameDescription->desc.filesDescriptions[0].fileName, '/'));
303+
return getRawEXEName();
299304
}
300305

301306
void DirectorEngine::parseOptions() {

engines/director/director.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ class DirectorEngine : public ::Engine {
159159
Common::Language getLanguage() const;
160160
Common::String getTargetName() { return _targetName; }
161161
const char *getExtra();
162+
Common::String getRawEXEName() const;
162163
Common::String getEXEName() const;
163164
StartMovie getStartMovie() const;
164165
void parseOptions();

engines/director/resource.cpp

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ Common::Error Window::loadInitialMovie() {
6363
return Common::kNoGameDataFoundError;
6464
}
6565

66+
// Load multiple-resources based executable file (Projector)
67+
ProjectorArchive *multiArchive = new ProjectorArchive(_vm->getRawEXEName());
68+
if (multiArchive->isLoaded()) {
69+
// A valid projector archive, add to SearchMan
70+
SearchMan.add(_vm->getRawEXEName(), multiArchive);
71+
} else {
72+
delete multiArchive;
73+
}
74+
6675
_currentMovie = new Movie(this);
6776
_currentPath = getPath(movie, _currentPath);
6877
Common::String sharedCastPath = getSharedCastPath();
@@ -531,43 +540,14 @@ void Window::loadStartMovieXLibs() {
531540
g_lingo->openXLib("SerialPort", kXObj);
532541
}
533542

534-
/*******************************************
535-
*
536-
* Projector Archive
537-
*
538-
*******************************************/
539-
540-
class ProjectorArchive : public Common::Archive {
541-
public:
542-
ProjectorArchive(Common::String path);
543-
~ProjectorArchive() override;
544-
545-
bool hasFile(const Common::Path &path) const override;
546-
int listMembers(Common::ArchiveMemberList &list) const override;
547-
const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override;
548-
Common::SeekableReadStream *createReadStreamForMember(const Common::Path &path) const override;
549-
550-
private:
551-
Common::SeekableReadStream *createBufferedReadStream();
552-
bool loadArchive(Common::SeekableReadStream *stream);
553-
554-
struct Entry {
555-
uint32 offset;
556-
uint32 size;
557-
};
558-
typedef Common::HashMap<Common::String, Entry, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> FileMap;
559-
FileMap _files;
560-
Common::String _path;
561-
};
562-
563543
ProjectorArchive::ProjectorArchive(Common::String path)
564544
: _path(path), _files() {
565545

566546
// Buffer 100K into memory
567547
Common::SeekableReadStream *stream = createBufferedReadStream();
568548

569549
// Build our filemap using the buffered stream
570-
loadArchive(stream);
550+
_isLoaded = loadArchive(stream);
571551

572552
delete stream;
573553
}

0 commit comments

Comments
 (0)