[Scummvm-cvs-logs] SF.net SVN: scummvm:[38596] scummvm/trunk/engines/sci

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Fri Feb 20 16:56:00 CET 2009


Revision: 38596
          http://scummvm.svn.sourceforge.net/scummvm/?rev=38596&view=rev
Author:   fingolfin
Date:     2009-02-20 15:55:59 +0000 (Fri, 20 Feb 2009)

Log Message:
-----------
SCI: Renamed some ResourceManager members, cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/sci/include/sciresource.h
    scummvm/trunk/engines/sci/scicore/resource.cpp
    scummvm/trunk/engines/sci/scicore/resource_map.cpp

Modified: scummvm/trunk/engines/sci/include/sciresource.h
===================================================================
--- scummvm/trunk/engines/sci/include/sciresource.h	2009-02-20 15:47:37 UTC (rev 38595)
+++ scummvm/trunk/engines/sci/include/sciresource.h	2009-02-20 15:55:59 UTC (rev 38596)
@@ -125,7 +125,7 @@
 
 typedef struct resource_index_struct resource_index_t;
 
-typedef struct resource_source_struct {
+struct ResourceSource {
 	int source_type;
 	int scanned;
 	union {
@@ -140,15 +140,15 @@
 			struct _resource_struct *resource;
 		} internal_map;
 	} location;
-	struct resource_source_struct *associated_map;
-	struct resource_source_struct *next;
-} ResourceSource;
+	ResourceSource *associated_map;
+	ResourceSource *next;
+};
 
-typedef struct _resource_altsource_struct {
+struct resource_altsource_t {
 	ResourceSource *source;
 	unsigned int file_offset;
-	struct _resource_altsource_struct *next;
-} resource_altsource_t;
+	resource_altsource_t *next;
+};
 
 
 typedef struct _resource_struct {
@@ -173,13 +173,13 @@
 } resource_t; /* for storing resources in memory */
 
 
-typedef struct {
-	int max_memory; /* Config option: Maximum total byte number allocated */
+struct ResourceManager {
+	int _maxMemory; /* Config option: Maximum total byte number allocated */
 	int sci_version; /* SCI resource version to use */
 
-	int resources_nr;
-	ResourceSource *sources;
-	resource_t *resources;
+	int _resourcesNr;
+	ResourceSource *_sources;
+	resource_t *_resources;
 
 	int memory_locked; /* Amount of resource bytes in locked memory */
 	int memory_lru; /* Amount of resource bytes under LRU control */
@@ -188,22 +188,22 @@
 
 	resource_t *lru_first, *lru_last; /* Pointers to the first and last LRU queue entries */
 	/* LRU queue: lru_first points to the most recent entry */
-} ResourceManager;
+};
 
 /**** FUNCTION DECLARATIONS ****/
 
 /**--- New Resource manager ---**/
 
 ResourceManager *
-scir_new_resource_manager(char *dir, int version, int max_memory);
+scir_new_resource_manager(char *dir, int version, int maxMemory);
 /* Creates a new FreeSCI resource manager
 ** Parameters: (char *) dir: Path to the resource and patch files (not modified or freed
 **                           by the resource manager)
 **             (int) version: The SCI version to look for; use SCI_VERSION_AUTODETECT
 **                            in the default case.
-**             (int) max_memory: Maximum number of bytes to allow allocated for resources
+**             (int) maxMemory: Maximum number of bytes to allow allocated for resources
 ** Returns   : (ResourceManager *) A newly allocated resource manager
-** max_memory will not be interpreted as a hard limit, only as a restriction for resources
+** maxMemory will not be interpreted as a hard limit, only as a restriction for resources
 ** which are not explicitly locked. However, a warning will be issued whenever this limit
 ** is exceeded.
 */
@@ -437,10 +437,10 @@
 /*--- Internal helper functions ---*/
 
 void
-_scir_free_resources(resource_t *resources, int resources_nr);
+_scir_free_resources(resource_t *resources, int resourcesNr);
 /* Frees a block of resources and associated data
 ** Parameters: (resource_t *) resources: The resources to free
-**             (int) resources_nr: Number of resources in the block
+**             (int) resourcesNr: Number of resources in the block
 ** Returns   : (void)
 */
 

Modified: scummvm/trunk/engines/sci/scicore/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/resource.cpp	2009-02-20 15:47:37 UTC (rev 38595)
+++ scummvm/trunk/engines/sci/scicore/resource.cpp	2009-02-20 15:55:59 UTC (rev 38596)
@@ -165,8 +165,8 @@
 	                            malloc(sizeof(ResourceSource));
 
 	/* Add the new source to the SLL of sources */
-	newsrc->next = mgr->sources;
-	mgr->sources = newsrc;
+	newsrc->next = mgr->_sources;
+	mgr->_sources = newsrc;
 
 	newsrc->source_type = RESSOURCE_TYPE_EXTERNAL_MAP;
 	newsrc->location.file.name = strdup(file_name);
@@ -183,8 +183,8 @@
 	                            malloc(sizeof(ResourceSource));
 
 	/* Add the new source to the SLL of sources */
-	newsrc->next = mgr->sources;
-	mgr->sources = newsrc;
+	newsrc->next = mgr->_sources;
+	mgr->_sources = newsrc;
 
 	newsrc->source_type = RESSOURCE_TYPE_VOLUME;
 	newsrc->scanned = 0;
@@ -200,8 +200,8 @@
 	                            malloc(sizeof(ResourceSource));
 
 	/* Add the new source to the SLL of sources */
-	newsrc->next = mgr->sources;
-	mgr->sources = newsrc;
+	newsrc->next = mgr->_sources;
+	mgr->_sources = newsrc;
 
 	newsrc->source_type = RESSOURCE_TYPE_DIRECTORY;
 	newsrc->scanned = 0;
@@ -211,7 +211,7 @@
 
 ResourceSource *
 scir_get_volume(ResourceManager *mgr, ResourceSource *map, int volume_nr) {
-	ResourceSource *seeker = mgr->sources;
+	ResourceSource *seeker = mgr->_sources;
 
 	while (seeker) {
 		if (seeker->source_type == RESSOURCE_TYPE_VOLUME &&
@@ -230,8 +230,8 @@
 
 static void
 _scir_init_trivial(ResourceManager *mgr) {
-	mgr->resources_nr = 0;
-	mgr->resources = (resource_t*)sci_malloc(1);
+	mgr->_resourcesNr = 0;
+	mgr->_resources = (resource_t*)sci_malloc(1);
 }
 
 
@@ -339,7 +339,7 @@
 	binseeker.type = type;
 	binseeker.number = number;
 	return (resource_t *)
-	       bsearch(&binseeker, mgr->resources, mgr->resources_nr,
+	       bsearch(&binseeker, mgr->_resources, mgr->_resourcesNr,
 	               sizeof(resource_t), resourcecmp);
 }
 
@@ -472,7 +472,7 @@
 	int preset_version = mgr->sci_version;
 	int resource_error = 0;
 	int dummy = mgr->sci_version;
-//	resource_t **concat_ptr = &(mgr->resources[mgr->resources_nr-1].next);
+//	resource_t **concat_ptr = &(mgr->_resources[mgr->_resourcesNr-1].next);
 
 	if (detected_version == NULL)
 		detected_version = &dummy;
@@ -487,12 +487,12 @@
 		case RESSOURCE_TYPE_DIRECTORY:
 			if (mgr->sci_version <= SCI_VERSION_01)
 				sci0_read_resource_patches(source,
-				                           &mgr->resources,
-				                           &mgr->resources_nr);
+				                           &mgr->_resources,
+				                           &mgr->_resourcesNr);
 			else
 				sci1_read_resource_patches(source,
-				                           &mgr->resources,
-				                           &mgr->resources_nr);
+				                           &mgr->_resources,
+				                           &mgr->_resourcesNr);
 			break;
 		case RESSOURCE_TYPE_EXTERNAL_MAP:
 			if (preset_version <= SCI_VERSION_01_VGA_ODD
@@ -500,8 +500,8 @@
 				resource_error =
 				    sci0_read_resource_map(mgr,
 				                           source,
-				                           &mgr->resources,
-				                           &mgr->resources_nr,
+				                           &mgr->_resources,
+				                           &mgr->_resourcesNr,
 				                           detected_version);
 
 #if 0
@@ -536,8 +536,8 @@
 				    sci1_read_resource_map(mgr,
 				                           source,
 				                           scir_get_volume(mgr, source, 0),
-				                           &mgr->resources,
-				                           &mgr->resources_nr,
+				                           &mgr->_resources,
+				                           &mgr->_resourcesNr,
 				                           detected_version);
 
 				if (resource_error == SCI_ERROR_RESMAP_NOT_FOUND) {
@@ -555,7 +555,7 @@
 			mgr->sci_version = *detected_version;
 			break;
 		}
-		qsort(mgr->resources, mgr->resources_nr, sizeof(resource_t),
+		qsort(mgr->_resources, mgr->_resourcesNr, sizeof(resource_t),
 		      resourcecmp); /* Sort resources */
 	}
 	return resource_error;
@@ -563,7 +563,7 @@
 
 int
 scir_scan_new_sources(ResourceManager *mgr, int *detected_version) {
-	_scir_scan_new_sources(mgr, detected_version, mgr->sources);
+	_scir_scan_new_sources(mgr, detected_version, mgr->_sources);
 	return 0;
 }
 
@@ -576,7 +576,7 @@
 }
 
 ResourceManager *
-scir_new_resource_manager(char *dir, int version, int max_memory) {
+scir_new_resource_manager(char *dir, int version, int maxMemory) {
 	int resource_error = 0;
 	ResourceManager *mgr = (ResourceManager*)sci_malloc(sizeof(ResourceManager));
 	char *caller_cwd = sci_getcwd();
@@ -588,28 +588,28 @@
 		return NULL;
 	}
 
-	mgr->max_memory = max_memory;
+	mgr->_maxMemory = maxMemory;
 
 	mgr->memory_locked = 0;
 	mgr->memory_lru = 0;
 
 	mgr->resource_path = dir;
 
-	mgr->resources = NULL;
-	mgr->resources_nr = 0;
-	mgr->sources = NULL;
+	mgr->_resources = NULL;
+	mgr->_resourcesNr = 0;
+	mgr->_sources = NULL;
 	mgr->sci_version = version;
 
 	scir_add_appropriate_sources(mgr, dir);
 	scir_scan_new_sources(mgr, &resmap_version);
 
-	if (!mgr->resources || !mgr->resources_nr) {
-		if (mgr->resources) {
-			free(mgr->resources);
-			mgr->resources = NULL;
+	if (!mgr->_resources || !mgr->_resourcesNr) {
+		if (mgr->_resources) {
+			free(mgr->_resources);
+			mgr->_resources = NULL;
 		}
 		sciprintf("Resmgr: Could not retrieve a resource list!\n");
-		_scir_free_resource_sources(mgr->sources);
+		_scir_free_resource_sources(mgr->_sources);
 		free(mgr);
 		chdir(caller_cwd);
 		free(caller_cwd);
@@ -619,7 +619,7 @@
 	mgr->lru_first = NULL;
 	mgr->lru_last = NULL;
 
-	qsort(mgr->resources, mgr->resources_nr, sizeof(resource_t),
+	qsort(mgr->_resources, mgr->_resourcesNr, sizeof(resource_t),
 	      resourcecmp); /* Sort resources */
 
 	if (version == SCI_VERSION_AUTODETECT)
@@ -685,15 +685,15 @@
 #if 0
 		if (version <= SCI_VERSION_01)
 			sci0_read_resource_patches(dir,
-			                           &mgr->resources,
-			                           &mgr->resources_nr);
+			                           &mgr->_resources,
+			                           &mgr->_resourcesNr);
 		else
 			sci1_read_resource_patches(dir,
-			                           &mgr->resources,
-			                           &mgr->resources_nr);
+			                           &mgr->_resources,
+			                           &mgr->_resourcesNr);
 #endif
 
-		qsort(mgr->resources, mgr->resources_nr, sizeof(resource_t),
+		qsort(mgr->_resources, mgr->_resourcesNr, sizeof(resource_t),
 		      resourcecmp); /* Sort resources */
 	}
 
@@ -714,10 +714,10 @@
 }
 
 void
-_scir_free_resources(resource_t *resources, int resources_nr) {
+_scir_free_resources(resource_t *resources, int _resourcesNr) {
 	int i;
 
-	for (i = 0; i < resources_nr; i++) {
+	for (i = 0; i < _resourcesNr; i++) {
 		resource_t *res = resources + i;
 
 		// FIXME: alt_sources->next may point to an invalid memory location
@@ -732,9 +732,9 @@
 
 void
 scir_free_resource_manager(ResourceManager *mgr) {
-	_scir_free_resources(mgr->resources, mgr->resources_nr);
-	_scir_free_resource_sources(mgr->sources);
-	mgr->resources = NULL;
+	_scir_free_resources(mgr->_resources, mgr->_resourcesNr);
+	_scir_free_resource_sources(mgr->_sources);
+	mgr->_resources = NULL;
 
 	free(mgr);
 }
@@ -818,7 +818,7 @@
 
 static void
 _scir_free_old_resources(ResourceManager *mgr, int last_invulnerable) {
-	while (mgr->max_memory < mgr->memory_lru
+	while (mgr->_maxMemory < mgr->memory_lru
 	        && (!last_invulnerable || mgr->lru_first != mgr->lru_last)) {
 		resource_t *goner = mgr->lru_last;
 		if (!goner) {

Modified: scummvm/trunk/engines/sci/scicore/resource_map.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/resource_map.cpp	2009-02-20 15:47:37 UTC (rev 38595)
+++ scummvm/trunk/engines/sci/scicore/resource_map.cpp	2009-02-20 15:55:59 UTC (rev 38596)
@@ -433,8 +433,8 @@
 	}
 
 	resources_nr = (fsize - types[0]) / entrysize;
-	resource_start = resources = (resource_t*)sci_realloc(mgr->resources, (mgr->resources_nr + resources_nr) * sizeof(resource_t));
-	resources += mgr->resources_nr;
+	resource_start = resources = (resource_t*)sci_realloc(mgr->_resources, (mgr->_resourcesNr + resources_nr) * sizeof(resource_t));
+	resources += mgr->_resourcesNr;
 
 	i = 0;
 	while (types[i] == 0) i++;


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