ScummVM API documentation
Sci::ResourceManager Class Reference

Public Member Functions

 ResourceManager (const bool detectionMode=false)
 
void init ()
 
int addAppropriateSources ()
 
int addAppropriateSourcesForDetection (const Common::FSList &fslist)
 
ResourcefindResource (ResourceId id, bool lock)
 
void unlockResource (Resource *res)
 
ResourcetestResource (const ResourceId &id) const
 
Common::List< ResourceIdlistResources (ResourceType type, int mapNumber=-1)
 
bool hasResourceType (ResourceType type)
 
void setAudioLanguage (int language)
 
int getAudioLanguage () const
 
void changeAudioDirectory (const Common::Path &path)
 
void changeMacAudioDirectory (const Common::Path &path)
 
bool isGMTrackIncluded ()
 
bool isSci11Mac () const
 
ViewType getViewType () const
 
const char * getMapVersionDesc () const
 
const char * getVolVersionDesc () const
 
ResVersion getVolVersion () const
 
void addNewGMPatch (SciGameId gameId)
 
void addNewD110Patch (SciGameId gameId)
 
bool detectFontExtended ()
 
bool detectPaletteMergingSci11 ()
 
bool detectEarlySound ()
 
Common::String findSierraGameId ()
 
reg_t findGameObject (const bool addSci11ScriptOffset)
 
ResourceType convertResType (byte type)
 
Common::Path getMacExecutableName () const
 
bool isKoreanMessageMap (ResourceSource *source)
 

Protected Types

typedef Common::List< ResourceSource * > SourcesList
 

Protected Member Functions

ResourceSourceaddPatchDir (const Common::Path &path)
 
ResourceSourcefindVolume (ResourceSource *map, int volume_nr)
 
ResourceSourceaddSource (ResourceSource *source)
 
ResourceSourceaddExternalMap (const Common::Path &filename, int volume_nr=0)
 
ResourceSourceaddExternalMap (const Common::FSNode *mapFile, int volume_nr=0)
 
void scanNewSources ()
 
bool addAudioSources ()
 
void addScriptChunkSources ()
 
void freeResourceSources ()
 
const char * versionDescription (ResVersion version) const
 
Common::SeekableReadStreamgetVolumeFile (ResourceSource *source)
 
void disposeVolumeFileStream (Common::SeekableReadStream *fileStream, ResourceSource *source)
 
void loadResource (Resource *res)
 
void freeOldResources ()
 
bool validateResource (const ResourceId &resourceId, const Common::Path &sourceMapLocation, const Common::Path &sourceName, const uint32 offset, const uint32 size, const uint32 sourceSize) const
 
ResourceaddResource (ResourceId resId, ResourceSource *src, uint32 offset, uint32 size=0, const Common::Path &sourceMapLocation=Common::Path("(no map location)"))
 
ResourceupdateResource (ResourceId resId, ResourceSource *src, uint32 size, const Common::Path &sourceMapLocation=Common::Path("(no map location)"))
 
ResourceupdateResource (ResourceId resId, ResourceSource *src, uint32 offset, uint32 size, const Common::Path &sourceMapLocation=Common::Path("(no map location)"))
 
void removeAudioResource (ResourceId resId)
 
ResVersion detectMapVersion ()
 
ResVersion detectVolVersion ()
 
int readResourceMapSCI0 (ResourceSource *map)
 
int readResourceMapSCI1 (ResourceSource *map)
 
int readAudioMapSCI11 (IntMapResourceSource *map)
 
int readAudioMapSCI1 (ResourceSource *map, bool unload=false)
 
void readResourcePatches ()
 
void readResourcePatchesBase36 ()
 
bool isBlacklistedPatch (const ResourceId &resId) const
 
void processPatch (ResourceSource *source, ResourceType resourceType, uint16 resourceNr, uint32 tuple=0)
 
void readWaveAudioPatches ()
 
void processWavePatch (ResourceId resourceId, const Common::Path &name)
 
bool hasOldScriptHeader ()
 
void addToLRU (Resource *res)
 
void removeFromLRU (Resource *res)
 
ResourceCompression getViewCompression ()
 
ViewType detectViewType ()
 
bool hasSci0Voc999 ()
 
bool hasSci1Voc900 ()
 
bool checkResourceDataForSignature (Resource *resource, const byte *signature)
 
bool checkResourceForSignatures (ResourceType resourceType, uint16 resourceNr, const byte *signature1, const byte *signature2)
 
void detectSciVersion ()
 

Protected Attributes

bool _detectionMode
 
int _maxMemoryLRU
 
ViewType _viewType
 
SourcesList _sources
 
int _memoryLocked
 Amount of resource bytes in locked memory.
 
int _memoryLRU
 Amount of resource bytes under LRU control.
 
Common::List< Resource * > _LRU
 Last Resource Used list.
 
ResourceMap _resMap
 
Common::List< Common::File * > _volumeFiles
 list of opened volume files
 
ResourceSource_audioMapSCI1
 Currently loaded audio map for SCI1.
 
ResVersion _volVersion
 resource.0xx version
 
ResVersion _mapVersion
 resource.map version
 
bool _isSci2Mac
 

Constructor & Destructor Documentation

◆ ResourceManager()

Sci::ResourceManager::ResourceManager ( const bool  detectionMode = false)

Creates a new SCI resource manager.

Member Function Documentation

◆ init()

void Sci::ResourceManager::init ( )

Initializes the resource manager.

◆ addAppropriateSources()

int Sci::ResourceManager::addAppropriateSources ( )

Adds all of the resource files for a game

◆ addAppropriateSourcesForDetection()

int Sci::ResourceManager::addAppropriateSourcesForDetection ( const Common::FSList fslist)

Similar to the function above, only called from the fallback detector

◆ findResource()

Resource* Sci::ResourceManager::findResource ( ResourceId  id,
bool  lock 
)

Looks up a resource's data.

Parameters
idThe resource type to look for
locknon-zero iff the resource should be locked
Returns
The resource, or NULL if it doesn't exist
Note
Locked resources are guaranteed not to have their contents freed until they are unlocked explicitly (by unlockResource).

◆ unlockResource()

void Sci::ResourceManager::unlockResource ( Resource res)

Unlocks a previously locked resource.

Parameters
resThe resource to free

◆ testResource()

Resource* Sci::ResourceManager::testResource ( const ResourceId id) const

Tests whether a resource exists.

This function may often be much faster than finding the resource and should be preferred for simple tests. The resource object returned is, indeed, the resource in question, but it should be used with care, as it may be unallocated. Use scir_find_resource() if you want to use the data contained in the resource.

Parameters
idId of the resource to check
Returns
non-NULL if the resource exists, NULL otherwise

◆ listResources()

Common::List<ResourceId> Sci::ResourceManager::listResources ( ResourceType  type,
int  mapNumber = -1 
)

Returns a list of all resources of the specified type.

Parameters
typeThe resource type to look for
mapNumberFor audio36 and sync36, limit search to this map
Returns
The resource list

◆ hasResourceType()

bool Sci::ResourceManager::hasResourceType ( ResourceType  type)

Returns if there are any resources of the specified type.

◆ addNewGMPatch()

void Sci::ResourceManager::addNewGMPatch ( SciGameId  gameId)

Adds the appropriate GM patch from the Sierra MIDI utility as 4.pat, without requiring the user to rename the file to 4.pat. Thus, the original Sierra archive can be extracted in the extras directory, and the GM patches can be applied per game, if applicable.

◆ findSierraGameId()

Common::String Sci::ResourceManager::findSierraGameId ( )

Finds the internal Sierra ID of the current game from script 0.

◆ findGameObject()

reg_t Sci::ResourceManager::findGameObject ( const bool  addSci11ScriptOffset)

Finds the location of the game object from script 0.

Parameters
addSci11ScriptOffsetAdjust the return value for SCI1.1 and newer games. Needs to be false when the heap is accessed directly inside findSierraGameId().

◆ convertResType()

ResourceType Sci::ResourceManager::convertResType ( byte  type)

Converts a map resource type to our type

Parameters
sciTypeThe type from the map/patch
Returns
The ResourceType

◆ addPatchDir()

ResourceSource* Sci::ResourceManager::addPatchDir ( const Common::Path path)
protected

Add a path to the resource manager's list of sources.

Returns
a pointer to the added source structure, or NULL if an error occurred.

◆ addSource()

ResourceSource* Sci::ResourceManager::addSource ( ResourceSource source)
protected

Adds a source to the resource manager's list of sources.

Parameters
sourceThe new source to add
Returns
A pointer to the added source structure, or NULL if an error occurred.

◆ addExternalMap()

ResourceSource* Sci::ResourceManager::addExternalMap ( const Common::Path filename,
int  volume_nr = 0 
)
protected

Add an external (i.e., separate file) map resource to the resource manager's list of sources.

Parameters
filenameThe name of the volume to add
volume_nrThe volume number the map starts at, 0 for <SCI2.1
Returns
A pointer to the added source structure, or NULL if an error occurred.

◆ scanNewSources()

void Sci::ResourceManager::scanNewSources ( )
protected

Scans newly registered resource sources for resources, earliest addition first.

Parameters
detected_versionPointer to the detected version number, used during startup. May be NULL.
Returns
One of SCI_ERROR_*.

◆ versionDescription()

const char* Sci::ResourceManager::versionDescription ( ResVersion  version) const
protected

Returns a string describing a ResVersion.

Parameters
versionThe resource version
Returns
The description of version

◆ getVolumeFile()

Common::SeekableReadStream* Sci::ResourceManager::getVolumeFile ( ResourceSource source)
protected

All calls to getVolumeFile must be followed with a corresponding call to disposeVolumeFileStream once the stream is finished being used. Do NOT call delete directly on returned streams, as they may be cached.

◆ detectMapVersion()

ResVersion Sci::ResourceManager::detectMapVersion ( )
protected

Resource map decoding functions —

◆ readResourceMapSCI0()

int Sci::ResourceManager::readResourceMapSCI0 ( ResourceSource map)
protected

Reads the SCI0 resource.map file from a local directory.

Parameters
mapThe map
Returns
0 on success, an SCI_ERROR_* code otherwise

◆ readResourceMapSCI1()

int Sci::ResourceManager::readResourceMapSCI1 ( ResourceSource map)
protected

Reads the SCI1 resource.map file from a local directory.

Parameters
mapThe map
Returns
0 on success, an SCI_ERROR_* code otherwise

◆ readAudioMapSCI11()

int Sci::ResourceManager::readAudioMapSCI11 ( IntMapResourceSource map)
protected

Reads SCI1.1 audio map resources.

Parameters
mapThe map
Returns
0 on success, an SCI_ERROR_* code otherwise

◆ readAudioMapSCI1()

int Sci::ResourceManager::readAudioMapSCI1 ( ResourceSource map,
bool  unload = false 
)
protected

Reads SCI1 audio map files.

Parameters
mapThe map
unloadUnload the map instead of loading it
Returns
0 on success, an SCI_ERROR_* code otherwise

◆ readResourcePatches()

void Sci::ResourceManager::readResourcePatches ( )
protected

— Patch management functions — Reads patch files from a local directory.

◆ isBlacklistedPatch()

bool Sci::ResourceManager::isBlacklistedPatch ( const ResourceId resId) const
protected

Determines whether or not a patch file matching the given resource ID should be ignored when processing patches.

◆ readWaveAudioPatches()

void Sci::ResourceManager::readWaveAudioPatches ( )
protected

Process wave files as patches for Audio resources.

◆ hasOldScriptHeader()

bool Sci::ResourceManager::hasOldScriptHeader ( )
protected

Process AIFF files as patches for Audio resources. Applies to all versions before 0.000.395 (i.e. KQ4 old, XMAS 1988 and LSL2). Old SCI versions used two word header for script blocks (first word equal to 0x82, meaning of the second one unknown). New SCI versions used one word header. Also, old SCI versions assign 120 degrees to left & right, and 60 to up and down. Later versions use an even 90 degree distribution.

◆ getMacExecutableName()

Common::Path Sci::ResourceManager::getMacExecutableName ( ) const

Returns the file name of the game's Mac executable.


The documentation for this class was generated from the following file: