STARK: The 4 CD version stores some sounds in the archives

This commit is contained in:
Bastien Bouclet 2016-01-01 14:48:17 +01:00
parent 1597db5003
commit 66e8e7da7f
3 changed files with 20 additions and 5 deletions

View File

@ -40,9 +40,10 @@ Sound::~Sound() {
Sound::Sound(Object *parent, byte subType, uint16 index, const Common::String &name) :
Object(parent, subType, index, name),
_enabled(0),
_looping(0),
_looping(false),
_field_64(0),
_loopIndefinitely(0),
_loopIndefinitely(false),
_loadFromFile(true),
_maxDuration(0),
_stockSoundType(0),
_field_6C(0),
@ -53,10 +54,16 @@ Sound::Sound(Object *parent, byte subType, uint16 index, const Common::String &n
}
Audio::RewindableAudioStream *Sound::makeAudioStream() {
Common::SeekableReadStream *stream = nullptr;
Audio::RewindableAudioStream *audioStream = nullptr;
// First try the .iss / isn files
Common::SeekableReadStream *stream = StarkArchiveLoader->getExternalFile(_filename, _archiveName);
if (_loadFromFile) {
stream = StarkArchiveLoader->getExternalFile(_filename, _archiveName);
} else {
stream = StarkArchiveLoader->getFile(_filename, _archiveName);
}
if (stream) {
audioStream = Formats::makeISSStream(stream, DisposeAfterUse::YES);
}
@ -137,7 +144,7 @@ void Sound::readData(Formats::XRCReadStream *stream) {
_field_64 = stream->readUint32LE();
_loopIndefinitely = stream->readBool();
_maxDuration = stream->readUint32LE();
stream->readUint32LE(); // Skipped ?
_loadFromFile = stream->readBool(); // Used only in the 4CD version
_stockSoundType = stream->readUint32LE();
_soundName = stream->readString();
_field_6C = stream->readUint32LE();
@ -154,6 +161,7 @@ void Sound::printData() {
debug("field_64: %d", _field_64);
debug("loopIndefinitely: %d", _loopIndefinitely);
debug("maxDuration: %d", _maxDuration);
debug("loadFromFile: %d", _loadFromFile);
debug("stockSoundType: %d", _stockSoundType);
debug("soundName: %s", _soundName.c_str());
debug("field_6C: %d", _field_6C);

View File

@ -84,6 +84,7 @@ protected:
uint32 _field_64;
bool _loopIndefinitely;
uint32 _maxDuration;
bool _loadFromFile;
uint32 _stockSoundType;
Common::String _soundName;
uint32 _field_6C;

View File

@ -82,7 +82,13 @@ void ArchiveLoader::unloadUnused() {
ArchiveReadStream *ArchiveLoader::getFile(const Common::String &fileName, const Common::String &archiveName) {
LoadedArchive *archive = findArchive(archiveName);
Formats::XARCArchive &xarc = archive->getXArc();
return new ArchiveReadStream(xarc.createReadStreamForMember(fileName));
Common::SeekableReadStream *stream = xarc.createReadStreamForMember(fileName);
if (!stream) {
return nullptr;
}
return new ArchiveReadStream(stream);
}
bool ArchiveLoader::returnRoot(const Common::String &archiveName) {