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==");
|
LOG("==Successfully Destroyed WResourceManager==");
|
||||||
}
|
}
|
||||||
|
|
||||||
JQuad * WResourceManager::RetrieveCard(MTGCard * card, int style, int submode){
|
JQuad * WResourceManager::RetrieveCard(MTGCard * card, int style, int submode){
|
||||||
//Cards are never, ever resource managed, so just check cache.
|
//Cards are never, ever resource managed, so just check cache.
|
||||||
if(!card || options[Options::DISABLECARDS].number)
|
if(!card || options[Options::DISABLECARDS].number)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
submode = submode | TEXTURE_SUB_CARD;
|
submode = submode | TEXTURE_SUB_CARD;
|
||||||
|
|
||||||
string filename = card->getSetName();
|
string filename = card->getSetName();
|
||||||
filename += "/";
|
filename += "/";
|
||||||
filename += card->getImageName();
|
filename += card->getImageName();
|
||||||
int id = card->getMTGId();
|
int id = card->getMTGId();
|
||||||
JQuad * jq = RetrieveQuad(filename,0,0,0,0, "",style,submode|TEXTURE_SUB_5551,id);
|
JQuad * jq = RetrieveQuad(filename,0,0,0,0, "",style,submode|TEXTURE_SUB_5551,id);
|
||||||
lastError = textureWCache.mError;
|
lastError = textureWCache.mError;
|
||||||
if(jq){
|
if(jq){
|
||||||
jq->SetHotSpot(jq->mTex->mWidth / 2, jq->mTex->mHeight / 2);
|
jq->SetHotSpot(jq->mTex->mWidth / 2, jq->mTex->mHeight / 2);
|
||||||
return jq;
|
return jq;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int WResourceManager::CreateQuad(const string &quadName, const string &textureName, float x, float y, float width, float height){
|
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
|
//Probably not enough memory: cleanup and try again
|
||||||
Cleanup();
|
Cleanup();
|
||||||
|
mError = CACHE_ERROR_NONE;
|
||||||
if(!item->Attempt(filename,submode,mError) || !item->isGood()) {
|
if(!item->Attempt(filename,submode,mError) || !item->isGood()) {
|
||||||
SAFE_DELETE(item);
|
SAFE_DELETE(item);
|
||||||
mError = CACHE_ERROR_BAD;
|
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){
|
cacheItem * WCache<cacheItem, cacheActual>::Retrieve(int id, string filename, int style, int submode){
|
||||||
//Check cache.
|
//Check cache.
|
||||||
cacheItem * tc = NULL;
|
cacheItem * tc = NULL;
|
||||||
|
mError = CACHE_ERROR_NONE; //Reset error status.
|
||||||
|
|
||||||
if(style == RETRIEVE_EXISTING || style == RETRIEVE_RESOURCE)
|
if(style == RETRIEVE_EXISTING || style == RETRIEVE_RESOURCE)
|
||||||
tc = Get(id,filename,style,submode|CACHE_EXISTING);
|
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().
|
//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;
|
managed[makeID(id,filename,submode)] = NULL;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user