From 34ef5016f5e648b241bdf4542d02fd94bfc3493d Mon Sep 17 00:00:00 2001 From: "wagic.jeck" Date: Thu, 22 Oct 2009 05:54:45 +0000 Subject: [PATCH] Jeck - Possible fix for issue 109, issue 112. Please confirm. * mError status was being reset properly. What I'm thinking happened is that somewhere along the line, a file would miss and return CACHE_ERROR_404. Then, cache.find() would fail because the file was not in the cache, but because mError wasn't reset it would still report CACHE_ERROR_404. In some cases, this would be overwritten (causing the flickering single frame wrong image), and in others this would erroneously report a miss. * Tested through three demo games and three player games. Shop screen still shows, didn't notice any missing sounds. --- projects/mtg/src/WResourceManager.cpp | 44 ++++++++++++++------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/projects/mtg/src/WResourceManager.cpp b/projects/mtg/src/WResourceManager.cpp index fab18f057..a60eaaca5 100644 --- a/projects/mtg/src/WResourceManager.cpp +++ b/projects/mtg/src/WResourceManager.cpp @@ -191,26 +191,26 @@ WResourceManager::~WResourceManager(){ LOG("==Successfully Destroyed WResourceManager=="); } -JQuad * WResourceManager::RetrieveCard(MTGCard * card, int style, int submode){ - //Cards are never, ever resource managed, so just check cache. - if(!card || options[Options::DISABLECARDS].number) - return NULL; - - submode = submode | TEXTURE_SUB_CARD; - - string filename = card->getSetName(); - filename += "/"; - filename += card->getImageName(); - int id = card->getMTGId(); - JQuad * jq = RetrieveQuad(filename,0,0,0,0, "",style,submode|TEXTURE_SUB_5551,id); - lastError = textureWCache.mError; - if(jq){ - jq->SetHotSpot(jq->mTex->mWidth / 2, jq->mTex->mHeight / 2); - return jq; - } - - return NULL; -} +JQuad * WResourceManager::RetrieveCard(MTGCard * card, int style, int submode){ + //Cards are never, ever resource managed, so just check cache. + if(!card || options[Options::DISABLECARDS].number) + return NULL; + + submode = submode | TEXTURE_SUB_CARD; + + string filename = card->getSetName(); + filename += "/"; + filename += card->getImageName(); + int id = card->getMTGId(); + JQuad * jq = RetrieveQuad(filename,0,0,0,0, "",style,submode|TEXTURE_SUB_5551,id); + lastError = textureWCache.mError; + if(jq){ + jq->SetHotSpot(jq->mTex->mWidth / 2, jq->mTex->mHeight / 2); + return jq; + } + + return NULL; +} int WResourceManager::CreateQuad(const string &quadName, const string &textureName, float x, float y, float width, float height){ @@ -981,6 +981,7 @@ cacheItem* WCache::AttemptNew(string filename, int submo } //Probably not enough memory: cleanup and try again Cleanup(); + mError = CACHE_ERROR_NONE; if(!item->Attempt(filename,submode,mError) || !item->isGood()) { SAFE_DELETE(item); mError = CACHE_ERROR_BAD; @@ -1000,6 +1001,7 @@ template cacheItem * WCache::Retrieve(int id, string filename, int style, int submode){ //Check cache. cacheItem * tc = NULL; + mError = CACHE_ERROR_NONE; //Reset error status. if(style == RETRIEVE_EXISTING || style == RETRIEVE_RESOURCE) tc = Get(id,filename,style,submode|CACHE_EXISTING); @@ -1041,7 +1043,7 @@ cacheItem * WCache::Retrieve(int id, string filename, in } //Record managed failure. Cache failure is recorded in Get(). - if(style == RETRIEVE_MANAGE || style == RETRIEVE_RESOURCE) + if((style == RETRIEVE_MANAGE || style == RETRIEVE_RESOURCE) && mError == CACHE_ERROR_404) managed[makeID(id,filename,submode)] = NULL; return NULL;