SCI: Separate the rest of the detection-only functions
This should fix bug #6717 - "SCI fallback detection assert failure"
This commit is contained in:
parent
fe3ed8ded2
commit
4736c490e1
4 changed files with 48 additions and 14 deletions
|
@ -568,13 +568,13 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const FileMap &allFiles,
|
|||
|
||||
ResourceManager resMan;
|
||||
resMan.addAppropriateSourcesForDetection(fslist);
|
||||
resMan.init(true);
|
||||
resMan.initForDetection();
|
||||
// TODO: Add error handling.
|
||||
|
||||
#ifndef ENABLE_SCI32
|
||||
// Is SCI32 compiled in? If not, and this is a SCI32 game,
|
||||
// stop here
|
||||
if (getSciVersion() >= SCI_VERSION_2)
|
||||
if (getSciVersionForDetection() >= SCI_VERSION_2)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
@ -855,7 +860,7 @@ void ResourceManager::freeResourceSources() {
|
|||
ResourceManager::ResourceManager() {
|
||||
}
|
||||
|
||||
void ResourceManager::init(bool initFromFallbackDetector) {
|
||||
void ResourceManager::init() {
|
||||
_memoryLocked = 0;
|
||||
_memoryLRU = 0;
|
||||
_LRU.clear();
|
||||
|
@ -894,18 +899,17 @@ void ResourceManager::init(bool initFromFallbackDetector) {
|
|||
|
||||
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()));
|
||||
|
@ -940,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();
|
||||
|
@ -1642,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;
|
||||
|
|
|
@ -312,7 +312,12 @@ public:
|
|||
/**
|
||||
* Initializes the resource manager.
|
||||
*/
|
||||
void init(bool initFromFallbackDetector = false);
|
||||
void init();
|
||||
|
||||
/**
|
||||
* Similar to the function above, only called from the fallback detector
|
||||
*/
|
||||
void initForDetection();
|
||||
|
||||
/**
|
||||
* Adds all of the resource files for a game
|
||||
|
|
|
@ -428,6 +428,12 @@ extern SciEngine *g_sci;
|
|||
*/
|
||||
SciVersion getSciVersion();
|
||||
|
||||
/**
|
||||
* Same as above, but this version doesn't assert on unknown SCI versions.
|
||||
* Only used by the fallback detector
|
||||
*/
|
||||
SciVersion getSciVersionForDetection();
|
||||
|
||||
/**
|
||||
* Convenience function converting an SCI version into a human-readable string.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue