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.
This commit is contained in:
@@ -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<cacheItem, cacheActual>::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 <class cacheItem, class cacheActual>
|
||||
cacheItem * WCache<cacheItem, cacheActual>::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<cacheItem, cacheActual>::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;
|
||||
|
||||
Reference in New Issue
Block a user