aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/scicore/resource.h
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci/scicore/resource.h')
-rw-r--r--engines/sci/scicore/resource.h96
1 files changed, 47 insertions, 49 deletions
diff --git a/engines/sci/scicore/resource.h b/engines/sci/scicore/resource.h
index e662e186d0..08a5f97001 100644
--- a/engines/sci/scicore/resource.h
+++ b/engines/sci/scicore/resource.h
@@ -83,7 +83,7 @@ namespace Sci {
#define SCI_VERSION_1 SCI_VERSION_1_EARLY
-enum ResourceType {
+enum ResSourceType {
RESSOURCE_TYPE_DIRECTORY = 0,
RESSOURCE_TYPE_VOLUME = 2,
RESSOURCE_TYPE_EXTERNAL_MAP = 3,
@@ -123,7 +123,7 @@ struct resource_index_struct {
typedef struct resource_index_struct resource_index_t;
struct ResourceSource {
- ResourceType source_type;
+ ResSourceType source_type;
bool scanned;
Common::String location_name; // FIXME: Replace by FSNode ?
Common::String location_dir_name; // FIXME: Get rid of this again, only a temporary HACK!
@@ -140,24 +140,22 @@ struct resource_altsource_t {
/** Struct for storing resources in memory */
-struct resource_t {
- unsigned char *data;
+class Resource {
+public:
+// NOTE : Currently all member data has the same name and public visibility
+// to let the rest of the engine compile without changes
+ unsigned char *data;
unsigned short number;
unsigned short type;
uint16 id; /* contains number and type */
-
unsigned int size;
-
unsigned int file_offset; /* Offset in file */
- ResourceSource *source;
-
unsigned char status;
unsigned short lockers; /* Number of places where this resource was locked */
-
- resource_t *next; /* Position marker for the LRU queue */
- resource_t *prev;
-
+ Resource *next; /* Position marker for the LRU queue */
+ Resource *prev;
+ ResourceSource *source;
resource_altsource_t *alt_sources; /* SLL of alternative resource data sources */
};
@@ -207,74 +205,74 @@ public:
/** @param type: The resource type to look for
* @param number: The resource number to search
* @param lock: non-zero iff the resource should be locked
- * @return (resource_t *): The resource, or NULL if it doesn't exist
+ * @return (Resource *): 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).
*/
- resource_t *findResource(int type, int number, int lock);
+ Resource *findResource(int type, int number, int lock);
/* Unlocks a previously locked resource
- ** (resource_t *) res: The resource to free
+ ** (Resource *) res: The resource to free
** (int) type: Type of the resource to check (for error checking)
** (int) number: Number of the resource to check (ditto)
** Returns : (void)
*/
- void unlockResource(resource_t *res, int restype, int resnum);
+ void unlockResource(Resource *res, int restype, int resnum);
/* Tests whether a resource exists
** (int) type: Type of the resource to check
** (int) number: Number of the resource to check
- ** Returns : (resource_t *) non-NULL if the resource exists, NULL otherwise
+ ** Returns : (Resource *) non-NULL if the resource exists, NULL otherwise
** 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.
*/
- resource_t *testResource(int type, int number);
+ Resource *testResource(int type, int number);
protected:
int _maxMemory; /* Config option: Maximum total byte number allocated */
int _resourcesNr;
ResourceSource *_sources;
- resource_t *_resources;
+ Resource *_resources;
int _memoryLocked; // Amount of resource bytes in locked memory
int _memoryLRU; // Amount of resource bytes under LRU control
- resource_t *lru_first, *lru_last; // Pointers to the first and last LRU queue entries
+ Resource *lru_first, *lru_last; // Pointers to the first and last LRU queue entries
// LRU queue: lru_first points to the most recent entry
/* Frees a block of resources and associated data
- ** Parameters: (resource_t *) resources: The resources to free
+ ** Parameters: (Resource *) resources: The resources to free
** (int) _resourcesNr: Number of resources in the block
** Returns : (void)
*/
- void freeResources(resource_t *resources, int _resourcesNr);
- /* Finds a resource matching type.number in an unsorted resource_t block
+ void freeResources(Resource *resources, int _resourcesNr);
+ /* Finds a resource matching type.number in an unsorted Resource block
** To be used during initial resource loading, when the resource list
** may not have been sorted yet.
- ** Parameters: (resource_t *) res: Pointer to the block to search in
- ** (int) res_nr: Number of resource_t structs allocated and defined
+ ** Parameters: (Resource *) res: Pointer to the block to search in
+ ** (int) res_nr: Number of Resource structs allocated and defined
** in the block pointed to by res
** (int) type: Type of the resource to look for
** (int) number: Number of the resource to look for
- ** Returns : (resource_t) The matching resource entry, or NULL if not found
+ ** Returns : (Resource) The matching resource entry, or NULL if not found
*/
- resource_t *findResourceUnsorted(resource_t *res, int res_nr, int type, int number);
+ Resource *findResourceUnsorted(Resource *res, int res_nr, int type, int number);
/* Adds an alternative source to a resource
- ** Parameters: (resource_t *) res: The resource to add to
+ ** Parameters: (Resource *) res: The resource to add to
** (ResourceSource *) source: The source of the resource
** (unsigned int) file_offset: Offset in the file the resource
** is stored at
** Returns : (void)
*/
int addAppropriateSources();
- void addAltSource(resource_t *res, ResourceSource *source, unsigned int file_offset);
+ void addAltSource(Resource *res, ResourceSource *source, unsigned int file_offset);
void freeResourceSources(ResourceSource *rss);
void freeAltSources(resource_altsource_t *dynressrc);
- void loadResource(resource_t *res, bool protect);
- void loadFromPatchFile(Common::File &file, resource_t *res, char *filename);
+ void loadResource(Resource *res, bool protect);
+ void loadFromPatchFile(Common::File &file, Resource *res, char *filename);
void freeOldResources(int last_invulnerable);
- void unalloc(resource_t *res);
+ void unalloc(Resource *res);
/**--- Resource map decoding functions ---*/
@@ -292,7 +290,7 @@ protected:
int readResourceMapSCI1(ResourceSource *map, ResourceSource *vol, int *sci_version);
int isSCI10or11(int *types);
int detectOddSCI01(Common::File &file);
- int resReadEntry(ResourceSource *map, byte *buf, resource_t *res, int sci_version);
+ int resReadEntry(ResourceSource *map, byte *buf, Resource *res, int sci_version);
int resTypeSCI1(int ofs, int *types, int lastrt);
int parseHeaderSCI1(Common::ReadStream &stream, int *types, int *lastrt);
@@ -300,7 +298,7 @@ protected:
/* Reads SCI0 patch files from a local directory
** Parameters: (char *) path: (unused)
- ** (resource_t **) resources: Pointer to a pointer
+ ** (Resource **) resources: Pointer to a pointer
** that will be set to the
** location of the resources
** (in one large chunk)
@@ -312,7 +310,7 @@ protected:
/* Reads SCI1 patch files from a local directory
** Parameters: (char *) path: (unused)
- ** (resource_t **) resources: Pointer to a pointer
+ ** (Resource **) resources: Pointer to a pointer
** that will be set to the
** location of the resources
** (in one large chunk)
@@ -325,49 +323,49 @@ protected:
int resnumber);
void printLRU();
- void addToLRU(resource_t *res);
- void removeFromLRU(resource_t *res);
+ void addToLRU(Resource *res);
+ void removeFromLRU(Resource *res);
};
/* Prints the name of a matching patch to a string buffer
** Parameters: (char *) string: The buffer to print to
- ** (resource_t *) res: Resource containing the number and type of the
+ ** (Resource *) res: Resource containing the number and type of the
** resource whose name is to be print
** Returns : (void)
*/
- void sci0_sprintf_patch_file_name(char *string, resource_t *res);
+ void sci0_sprintf_patch_file_name(char *string, Resource *res);
/* Prints the name of a matching patch to a string buffer
** Parameters: (char *) string: The buffer to print to
- ** (resource_t *) res: Resource containing the number and type of the
+ ** (Resource *) res: Resource containing the number and type of the
** resource whose name is to be print
** Returns : (void)
*/
- void sci1_sprintf_patch_file_name(char *string, resource_t *res);
+ void sci1_sprintf_patch_file_name(char *string, Resource *res);
/**--- Decompression functions ---**/
- int decompress0(resource_t *result, Common::ReadStream &stream, int sci_version);
+ int decompress0(Resource *result, Common::ReadStream &stream, int sci_version);
/* Decrypts resource data and stores the result for SCI0-style compression.
- ** Parameters : result: The resource_t the decompressed data is stored in.
+ ** Parameters : result: The Resource the decompressed data is stored in.
** stream: Stream of the resource file
** sci_version : Actual SCI resource version
** Returns : (int) 0 on success, one of SCI_ERROR_* if a problem was
** encountered.
*/
- int decompress01(resource_t *result, Common::ReadStream &stream, int sci_version);
+ int decompress01(Resource *result, Common::ReadStream &stream, int sci_version);
/* Decrypts resource data and stores the result for SCI01-style compression.
- ** Parameters : result: The resource_t the decompressed data is stored in.
+ ** Parameters : result: The Resource the decompressed data is stored in.
** stream: Stream of the resource file
** sci_version : Actual SCI resource version
** Returns : (int) 0 on success, one of SCI_ERROR_* if a problem was
** encountered.
*/
- int decompress1(resource_t *result, Common::ReadStream &stream, int sci_version);
+ int decompress1(Resource *result, Common::ReadStream &stream, int sci_version);
/* Decrypts resource data and stores the result for SCI1.1-style compression.
- ** Parameters : result: The resource_t the decompressed data is stored in.
+ ** Parameters : result: The Resource the decompressed data is stored in.
** sci_version : Actual SCI resource version
** stream: Stream of the resource file
** Returns : (int) 0 on success, one of SCI_ERROR_* if a problem was
@@ -375,9 +373,9 @@ protected:
*/
- int decompress11(resource_t *result, Common::ReadStream &stream, int sci_version);
+ int decompress11(Resource *result, Common::ReadStream &stream, int sci_version);
/* Decrypts resource data and stores the result for SCI1.1-style compression.
- ** Parameters : result: The resource_t the decompressed data is stored in.
+ ** Parameters : result: The Resource the decompressed data is stored in.
** sci_version : Actual SCI resource version
** stream: Stream of the resource file
** Returns : (int) 0 on success, one of SCI_ERROR_* if a problem was