aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorMax Horn2009-06-04 22:16:31 +0000
committerMax Horn2009-06-04 22:16:31 +0000
commitfa02e0df7b48a3d24984d78117dc2952d0b6c5b4 (patch)
tree602d44f287d601db94f7810cbf8860e53547211f /engines/sci
parent29cc1efe3cc6dd344383a8b8b6e9a59b4e78ece1 (diff)
downloadscummvm-rg350-fa02e0df7b48a3d24984d78117dc2952d0b6c5b4.tar.gz
scummvm-rg350-fa02e0df7b48a3d24984d78117dc2952d0b6c5b4.tar.bz2
scummvm-rg350-fa02e0df7b48a3d24984d78117dc2952d0b6c5b4.zip
SCI: Made some members of class Resource protected; some cleanup
svn-id: r41180
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/resource.cpp29
-rw-r--r--engines/sci/resource.h17
-rw-r--r--engines/sci/vocabulary.cpp2
3 files changed, 22 insertions, 26 deletions
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index 05dcf95bd0..4999299f75 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -63,7 +63,7 @@ enum SolFlags {
kSolFlagIsSigned = 1 << 3
};
-const char *sci_error_types[] = {
+static const char *sci_error_types[] = {
"No error",
"I/O error",
"Resource is empty (size 0)",
@@ -78,7 +78,7 @@ const char *sci_error_types[] = {
};
// These are the 20 resource types supported by SCI1.1
-const char *resourceTypeNames[] = {
+static const char *resourceTypeNames[] = {
"view", "pic", "script", "text", "sound",
"memory", "vocab", "font", "cursor",
"patch", "bitmap", "palette", "cdaudio",
@@ -86,7 +86,7 @@ const char *resourceTypeNames[] = {
"audio36", "sync36"
};
-const char *resourceTypeSuffixes[] = {
+static const char *resourceTypeSuffixes[] = {
"v56", "p56", "scr", "tex", "snd",
" ", "voc", "fon", "cur", "pat",
"bit", "pal", "cda", "aud", "syn",
@@ -97,13 +97,6 @@ const char *getResourceTypeName(ResourceType restype) {
return resourceTypeNames[restype];
}
-const char *getResourceTypeSuffix(ResourceType restype) {
- return resourceTypeSuffixes[restype];
-}
-
-typedef int decomp_funct(Resource *result, Common::ReadStream &stream, int sci_version);
-typedef void patch_sprintf_funct(char *string, Resource *res);
-
//-- Resource main functions --
Resource::Resource() {
data = NULL;
@@ -290,7 +283,7 @@ int sci0_get_compression_method(Common::ReadStream &stream) {
return compressionMethod;
}
-int sci_test_view_type(ResourceManager *mgr) {
+int ResourceManager::guessSciVersion() {
Common::File file;
char filename[MAXPATHLEN];
int compression;
@@ -298,7 +291,7 @@ int sci_test_view_type(ResourceManager *mgr) {
int i;
for (i = 0; i < 1000; i++) {
- res = mgr->testResource(kResourceTypeView, i);
+ res = testResource(kResourceTypeView, i);
if (!res)
continue;
@@ -322,7 +315,7 @@ int sci_test_view_type(ResourceManager *mgr) {
// Try the same thing with pics
for (i = 0; i < 1000; i++) {
- res = mgr->testResource(kResourceTypePic, i);
+ res = testResource(kResourceTypePic, i);
if (!res)
continue;
@@ -442,14 +435,14 @@ ResourceManager::ResourceManager(int version, int maxMemory) {
switch (_mapVersion) {
case SCI_VERSION_0:
if (testResource(kResourceTypeVocab, VOCAB_RESOURCE_SCI0_MAIN_VOCAB)) {
- version = sci_test_view_type(this) ? SCI_VERSION_01_VGA : SCI_VERSION_0;
+ version = guessSciVersion() ? SCI_VERSION_01_VGA : SCI_VERSION_0;
} else if (testResource(kResourceTypeVocab, VOCAB_RESOURCE_SCI1_MAIN_VOCAB)) {
- version = sci_test_view_type(this);
+ version = guessSciVersion();
if (version != SCI_VERSION_01_VGA) {
version = testResource(kResourceTypeVocab, 912) ? SCI_VERSION_0 : SCI_VERSION_01;
}
} else {
- version = sci_test_view_type(this) ? SCI_VERSION_01_VGA : SCI_VERSION_0;
+ version = guessSciVersion() ? SCI_VERSION_01_VGA : SCI_VERSION_0;
}
break;
case SCI_VERSION_01_VGA_ODD:
@@ -586,7 +579,7 @@ void ResourceManager::freeOldResources(int last_invulnerable) {
}
}
-Resource *ResourceManager::findResource(ResourceType type, int number, int lock) {
+Resource *ResourceManager::findResource(ResourceType type, int number, bool lock) {
Resource *retval;
if (number >= sci_max_resource_nr[_sciVersion]) {
@@ -863,7 +856,7 @@ void ResourceManager::readResourcePatches(ResourceSource *source) {
SearchMan.listMatchingMembers(files, mask);
// SCI1 and later naming - nnn.typ
mask = "*.";
- mask += getResourceTypeSuffix((ResourceType)i);
+ mask += resourceTypeSuffixes[i];
SearchMan.listMatchingMembers(files, mask);
for (Common::ArchiveMemberList::const_iterator x = files.begin(); x != files.end(); x++) {
bAdd = false;
diff --git a/engines/sci/resource.h b/engines/sci/resource.h
index b1ae3d23ba..eade4acbd0 100644
--- a/engines/sci/resource.h
+++ b/engines/sci/resource.h
@@ -88,7 +88,6 @@ enum ResSourceType {
#define SCI1_RESMAP_ENTRIES_SIZE 6
#define SCI11_RESMAP_ENTRIES_SIZE 5
-extern const char *sci_error_types[];
extern const char *sci_version_types[];
extern const int sci_max_resource_nr[]; /**< Highest possible resource numbers */
@@ -118,8 +117,6 @@ enum ResourceType {
};
const char *getResourceTypeName(ResourceType restype);
-// Suffixes for SCI1 patch files
-const char *getResourceTypeSuffix(ResourceType restype);
#define sci0_last_resource kResourceTypePatch
#define sci1_last_resource kResourceTypeHeap
@@ -141,8 +138,11 @@ struct ResourceSource {
ResourceSource *next;
};
+class ResourceManager;
+
/** Class for storing resources in memory */
class Resource {
+ friend class ResourceManager;
public:
Resource();
~Resource();
@@ -155,10 +155,11 @@ public:
uint16 number;
ResourceType type;
uint32 id; //!< contains number and type.
- unsigned int size;
- unsigned int file_offset; /**< Offset in file */
+ uint32 size;
+protected:
+ uint32 file_offset; /**< Offset in file */
ResourceStatus status;
- unsigned short lockers; /**< Number of places where this resource was locked */
+ uint16 lockers; /**< Number of places where this resource was locked */
ResourceSource *source;
};
@@ -191,7 +192,7 @@ public:
* @note Locked resources are guaranteed not to have their contents freed until
* they are unlocked explicitly (by unlockResource).
*/
- Resource *findResource(ResourceType type, int number, int lock);
+ Resource *findResource(ResourceType type, int number, bool lock);
/* Unlocks a previously locked resource
** (Resource *) res: The resource to free
@@ -291,6 +292,8 @@ protected:
void printLRU();
void addToLRU(Resource *res);
void removeFromLRU(Resource *res);
+
+ int guessSciVersion();
};
/**
diff --git a/engines/sci/vocabulary.cpp b/engines/sci/vocabulary.cpp
index accdcc9eb1..b12114d845 100644
--- a/engines/sci/vocabulary.cpp
+++ b/engines/sci/vocabulary.cpp
@@ -241,7 +241,7 @@ void Vocabulary::freeSuffixes() {
else
resource = _resmgr->findResource(kResourceTypeVocab, VOCAB_RESOURCE_SCI1_SUFFIX_VOCAB, 0);
- if (resource && resource->status == kResStatusLocked)
+ if (resource)
_resmgr->unlockResource(resource, resource->number, kResourceTypeVocab);
_parserSuffixes.clear();