diff --git a/projects/mtg/include/WResourceManager.h b/projects/mtg/include/WResourceManager.h index a204430f9..4b246a523 100644 --- a/projects/mtg/include/WResourceManager.h +++ b/projects/mtg/include/WResourceManager.h @@ -9,10 +9,10 @@ #include //Soft limits. -//For values higher than ~8000000, we run the danger of hitting our reserved space in deck editor. -#define HUGE_CACHE_LIMIT 8000000 -#define LARGE_CACHE_LIMIT 6000000 -#define SMALL_CACHE_LIMIT 3000000 +//For values higher than ~6000000, we run the danger of hitting our reserved space in deck editor. +#define HUGE_CACHE_LIMIT 6000000 +#define LARGE_CACHE_LIMIT 4000000 +#define SMALL_CACHE_LIMIT 2000000 #define HUGE_CACHE_ITEMS 200 #define LARGE_CACHE_ITEMS 150 diff --git a/projects/mtg/src/WResourceManager.cpp b/projects/mtg/src/WResourceManager.cpp index ddb507f67..0d85534cd 100644 --- a/projects/mtg/src/WResourceManager.cpp +++ b/projects/mtg/src/WResourceManager.cpp @@ -1020,36 +1020,6 @@ bool WCache::AttemptNew(cacheItem* item, int submode){ return false; } - //Keep a bit of memory in reserve. - if(CACHE_SPACE_RESERVED > 0){ - char * test = (char*)malloc(CACHE_SPACE_RESERVED);; - int tries = 0; - while(!test && tries++ < MAX_CACHE_ATTEMPTS){ - if(!RemoveOldest()) - break; - - test = (char*)malloc(CACHE_SPACE_RESERVED); - } - - if(test){ - free(test); - test = NULL; - } - else{ - resources.ClearUnlocked(); - test = (char*)malloc(CACHE_SPACE_RESERVED); - - if(test){ - free(test); - test = NULL; - } - else{ - mError = CACHE_ERROR_BAD_ALLOC; - return false; - } - } - } - string filename = makeFilename(item->id,submode); if(!item->Attempt(filename,submode,mError)){ @@ -1064,7 +1034,7 @@ bool WCache::AttemptNew(cacheItem* item, int submode){ if(!RemoveOldest()) break; - if(item->Attempt(filename,submode,mError)) + if(item->Attempt(filename,submode,mError) && item->isGood()) break; //Failed attempt. Trash this. @@ -1072,18 +1042,20 @@ bool WCache::AttemptNew(cacheItem* item, int submode){ } if(!item->isGood()){ + item->Trash(); Cleanup(); item->Attempt(filename,submode,mError); } //Still no result, so clear cache entirely, then try again. if(!item->isGood()){ + item->Trash(); ClearUnlocked(); item->Attempt(filename,submode,mError); } } //Final failure. Trash it. - if(!item->isGood()){ + if(item && !item->isGood()){ item->Trash(); mError = CACHE_ERROR_BAD; return false;