[Scummvm-cvs-logs] SF.net SVN: scummvm:[55736] scummvm/trunk/engines/sword25
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Wed Feb 2 20:32:04 CET 2011
Revision: 55736
http://scummvm.svn.sourceforge.net/scummvm/?rev=55736&view=rev
Author: thebluegr
Date: 2011-02-02 19:32:04 +0000 (Wed, 02 Feb 2011)
Log Message:
-----------
SWORD25: Cache related changes
- Increase the resource cache limits
- Added a check before forcing resources to be freed
- Only force free image and animation resources, with a warning. It seems like there is
a bug in the resource reference code and several bitmap resources are not freed - added
a FIXME
- Clarify that initializeAnimationResource() is used with XML resources
Modified Paths:
--------------
scummvm/trunk/engines/sword25/gfx/animation.h
scummvm/trunk/engines/sword25/kernel/resmanager.cpp
Modified: scummvm/trunk/engines/sword25/gfx/animation.h
===================================================================
--- scummvm/trunk/engines/sword25/gfx/animation.h 2011-02-02 17:28:28 UTC (rev 55735)
+++ scummvm/trunk/engines/sword25/gfx/animation.h 2011-02-02 19:32:04 UTC (rev 55736)
@@ -211,6 +211,10 @@
void initMembers();
AnimationDescription *getAnimationDescription() const;
+
+ /**
+ * Initializes a new animation resource from an XML file.
+ */
void initializeAnimationResource(const Common::String &fileName);
};
Modified: scummvm/trunk/engines/sword25/kernel/resmanager.cpp
===================================================================
--- scummvm/trunk/engines/sword25/kernel/resmanager.cpp 2011-02-02 17:28:28 UTC (rev 55735)
+++ scummvm/trunk/engines/sword25/kernel/resmanager.cpp 2011-02-02 19:32:04 UTC (rev 55736)
@@ -43,11 +43,12 @@
// Sets the amount of resources that are simultaneously loaded.
// This needs to be a relatively high number, as all the animation
// frames in each scene are loaded as separate resources.
-#define SWORD25_RESOURCECACHE_MIN 200
+// Also, George's walk states are all loaded here (150 files)
+#define SWORD25_RESOURCECACHE_MIN 400
// The maximum number of loaded resources. If more than these resources
// are loaded, the resource manager will start purging resources till it
// hits the minimum limit above
-#define SWORD25_RESOURCECACHE_MAX 300
+#define SWORD25_RESOURCECACHE_MAX 500
ResourceManager::~ResourceManager() {
// Clear all unlocked resources
@@ -105,16 +106,29 @@
} while (iter != _resources.begin() && _resources.size() >= SWORD25_RESOURCECACHE_MIN);
// Are we still above the minimum? If yes, then start releasing locked resources
+ // FIXME: This code shouldn't be needed at all, but it seems like there is a bug
+ // in the resource lock code, and resources are not unlocked when changing rooms.
+ // Only image/animation resources are unlocked forcibly, thus this shouldn't have
+ // any impact on the game itself.
+ if (_resources.size() <= SWORD25_RESOURCECACHE_MIN)
+ return;
+
iter = _resources.end();
do {
--iter;
- // Forcibly unlock the resource
- while ((*iter)->getLockCount() > 0) {
- (*iter)->release();
- };
+ // Only unlock image/animation resources
+ if ((*iter)->getFileName().hasSuffix(".swf") ||
+ (*iter)->getFileName().hasSuffix(".png")) {
- iter = deleteResource(*iter);
+ warning("Forcibly unlocking %s", (*iter)->getFileName().c_str());
+
+ // Forcibly unlock the resource
+ while ((*iter)->getLockCount() > 0)
+ (*iter)->release();
+
+ iter = deleteResource(*iter);
+ }
} while (iter != _resources.begin() && _resources.size() >= SWORD25_RESOURCECACHE_MIN);
}
@@ -145,21 +159,12 @@
// Determine whether the resource is already loaded
// If the resource is found, it will be placed at the head of the resource list and returned
- {
- Resource *pResource = getResource(uniqueFileName);
- if (!pResource)
- pResource = loadResource(uniqueFileName);
-
- if (pResource) {
- moveToFront(pResource);
- (pResource)->addReference();
- return pResource;
- }
- }
-
- Resource *pResource = loadResource(uniqueFileName);
+ Resource *pResource = getResource(uniqueFileName);
+ if (!pResource)
+ pResource = loadResource(uniqueFileName);
if (pResource) {
- pResource->addReference();
+ moveToFront(pResource);
+ (pResource)->addReference();
return pResource;
}
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