diff options
Diffstat (limited to 'engines/sci/resource.cpp')
-rw-r--r-- | engines/sci/resource.cpp | 52 |
1 files changed, 36 insertions, 16 deletions
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp index 17195c14b8..d155792853 100644 --- a/engines/sci/resource.cpp +++ b/engines/sci/resource.cpp @@ -55,6 +55,11 @@ SciVersion getSciVersion() { return s_sciVersion; } +SciVersion getSciVersionForDetection() { + assert(!g_sci); + return s_sciVersion; +} + const char *getSciVersionDesc(SciVersion version) { switch (version) { case SCI_VERSION_NONE: @@ -88,9 +93,6 @@ const char *getSciVersionDesc(SciVersion version) { ////////////////////////////////////////////////////////////////////// - -#undef SCI_REQUIRE_RESOURCE_FILES - //#define SCI_VERBOSE_RESMAN 1 static const char *const s_errorDescriptions[] = { @@ -639,7 +641,7 @@ int ResourceManager::addAppropriateSources() { return 1; } -int ResourceManager::addAppropriateSources(const Common::FSList &fslist) { +int ResourceManager::addAppropriateSourcesForDetection(const Common::FSList &fslist) { ResourceSource *map = 0; Common::Array<ResourceSource *> sci21Maps; @@ -858,7 +860,7 @@ void ResourceManager::freeResourceSources() { ResourceManager::ResourceManager() { } -void ResourceManager::init(bool initFromFallbackDetector) { +void ResourceManager::init() { _memoryLocked = 0; _memoryLRU = 0; _LRU.clear(); @@ -890,25 +892,24 @@ void ResourceManager::init(bool initFromFallbackDetector) { debugC(1, kDebugLevelResMan, "resMan: Detected volume version %d: %s", _volVersion, versionDescription(_volVersion)); if ((_mapVersion == kResVersionUnknown) && (_volVersion == kResVersionUnknown)) { - warning("Volume and map version not detected, assuming that this is not a sci game"); + warning("Volume and map version not detected, assuming that this is not a SCI game"); _viewType = kViewUnknown; return; } scanNewSources(); - if (!initFromFallbackDetector) { - if (!addAudioSources()) { - // FIXME: This error message is not always correct. - // OTOH, it is nice to be able to detect missing files/sources - // So we should definitely fix addAudioSources so this error - // only pops up when necessary. Disabling for now. - //error("Somehow I can't seem to find the sound files I need (RESOURCE.AUD/RESOURCE.SFX), aborting"); - } - addScriptChunkSources(); - scanNewSources(); + if (!addAudioSources()) { + // FIXME: This error message is not always correct. + // OTOH, it is nice to be able to detect missing files/sources + // So we should definitely fix addAudioSources so this error + // only pops up when necessary. Disabling for now. + //error("Somehow I can't seem to find the sound files I need (RESOURCE.AUD/RESOURCE.SFX), aborting"); } + addScriptChunkSources(); + scanNewSources(); + detectSciVersion(); debugC(1, kDebugLevelResMan, "resMan: Detected %s", getSciVersionDesc(getSciVersion())); @@ -943,6 +944,22 @@ void ResourceManager::init(bool initFromFallbackDetector) { } } +void ResourceManager::initForDetection() { + assert(!g_sci); + + _memoryLocked = 0; + _memoryLRU = 0; + _LRU.clear(); + _resMap.clear(); + _audioMapSCI1 = NULL; + + _mapVersion = detectMapVersion(); + _volVersion = detectVolVersion(); + + scanNewSources(); + detectSciVersion(); +} + ResourceManager::~ResourceManager() { // freeing resources ResourceMap::iterator itr = _resMap.begin(); @@ -1645,6 +1662,9 @@ int ResourceManager::readResourceMapSCI1(ResourceSource *map) { do { type = fileStream->readByte() & 0x1F; resMap[type].wOffset = fileStream->readUint16LE(); + if (fileStream->eos()) + return SCI_ERROR_RESMAP_NOT_FOUND; + resMap[prevtype].wSize = (resMap[type].wOffset - resMap[prevtype].wOffset) / nEntrySize; prevtype = type; |