[Scummvm-cvs-logs] SF.net SVN: scummvm:[41180] scummvm/trunk/engines/sci
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Fri Jun 5 00:16:31 CEST 2009
Revision: 41180
http://scummvm.svn.sourceforge.net/scummvm/?rev=41180&view=rev
Author: fingolfin
Date: 2009-06-04 22:16:31 +0000 (Thu, 04 Jun 2009)
Log Message:
-----------
SCI: Made some members of class Resource protected; some cleanup
Modified Paths:
--------------
scummvm/trunk/engines/sci/resource.cpp
scummvm/trunk/engines/sci/resource.h
scummvm/trunk/engines/sci/vocabulary.cpp
Modified: scummvm/trunk/engines/sci/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource.cpp 2009-06-04 22:12:13 UTC (rev 41179)
+++ scummvm/trunk/engines/sci/resource.cpp 2009-06-04 22:16:31 UTC (rev 41180)
@@ -63,7 +63,7 @@
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 @@
};
// 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 @@
"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 @@
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 @@
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 i;
for (i = 0; i < 1000; i++) {
- res = mgr->testResource(kResourceTypeView, i);
+ res = testResource(kResourceTypeView, i);
if (!res)
continue;
@@ -322,7 +315,7 @@
// 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 @@
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 @@
}
}
-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 @@
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;
Modified: scummvm/trunk/engines/sci/resource.h
===================================================================
--- scummvm/trunk/engines/sci/resource.h 2009-06-04 22:12:13 UTC (rev 41179)
+++ scummvm/trunk/engines/sci/resource.h 2009-06-04 22:16:31 UTC (rev 41180)
@@ -88,7 +88,6 @@
#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 @@
};
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 @@
ResourceSource *next;
};
+class ResourceManager;
+
/** Class for storing resources in memory */
class Resource {
+ friend class ResourceManager;
public:
Resource();
~Resource();
@@ -155,10 +155,11 @@
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 @@
* @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 @@
void printLRU();
void addToLRU(Resource *res);
void removeFromLRU(Resource *res);
+
+ int guessSciVersion();
};
/**
Modified: scummvm/trunk/engines/sci/vocabulary.cpp
===================================================================
--- scummvm/trunk/engines/sci/vocabulary.cpp 2009-06-04 22:12:13 UTC (rev 41179)
+++ scummvm/trunk/engines/sci/vocabulary.cpp 2009-06-04 22:16:31 UTC (rev 41180)
@@ -241,7 +241,7 @@
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();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list