Jeck - Please review: this makes minor changes to a lot of files, and major changes to the WCache flatten() function.

* Removed all calls to Release(JQuad*).
* Updated flatten(). Prior flatten was buggy beyond belief.
* Done some extensive testing, but if this causes more trouble than it fixes, we'll have to revert. It's too close to release time.
This commit is contained in:
wagic.jeck
2009-10-27 02:46:39 +00:00
parent 538248d979
commit fb7f48f26b
17 changed files with 114 additions and 121 deletions

View File

@@ -20,6 +20,7 @@ class GameStateMenu: public GameState, public JGuiListener
JTexture * bgTexture;
JQuad * mBg;
JQuad * mSplash;
JTexture * splashTex;
float mCreditsYPos;
int currentState;
//JMusic * bgMusic;

View File

@@ -23,6 +23,8 @@ class GameStateShop: public GameState, public JGuiListener
JLBFont * itemFont;
JTexture * altThumb[8];
JQuad * mBack;
JQuad * mBg;
JTexture * mBgTex;
SimpleMenu * menu;
int mStage;
char starterBuffer[128], boosterBuffer[128];

View File

@@ -12,7 +12,6 @@ class GuiPhaseBar : public GuiLayer
static const unsigned Phases = 12;
protected:
JQuad* quad;
Phase* phase;
float angle;

View File

@@ -59,6 +59,7 @@ class ShopItems:public JGuiController,public JGuiListener{
PriceList * pricelist;
int mX, mY, mHeight;
JLBFont* mFont;
JTexture * mBgAATex;
JQuad * mBgAA;
MTGAllCards * collection;
SimpleMenu * dialog;

View File

@@ -11,6 +11,7 @@
class WResource{
public:
friend class WResourceManager;
friend struct WCacheSort;
template<class cacheItem,class cacheActual> friend class WCache;
WResource();
@@ -64,8 +65,7 @@ public:
void Refresh();
unsigned long size();
bool isGood();
bool isLocked();
bool isGood();
bool Attempt(string filename, int submode, int & error);
bool compare(JTexture * t) {return (t == texture);};
JTexture * Actual(); //Return this texture as is. Does not make a new one.

View File

@@ -13,6 +13,12 @@
#define TEXTURES_CACHE_MINSIZE 2000000 // Minimum size of the cache on the PSP. The program should complain if the cache ever gets smaller than this
#define OPERATIONAL_SIZE 5000000 // Size required by Wagic for operational stuff. 3MB is not enough. The cache will usually try to take (Total Ram - Operational size)
#define MIN_LINEAR_RAM 1000000
#ifdef DEBUG_CACHE
#define MAX_CACHE_TIME 2000 //The threshold above which we try to prevent nowTime() from looping.
#else
#define MAX_CACHE_TIME 2000000000
#endif
#define THUMBNAILS_OFFSET 100000000
#define OTHERS_OFFSET 2000000000
@@ -67,6 +73,10 @@ enum ENUM_CACHE_ERROR{
CACHE_ERROR_NOT_MANAGED,
};
struct WCacheSort{
bool operator()(const WResource * l, const WResource * r); //Predicate for use in sorting. See flatten().
};
template <class cacheItem, class cacheActual>
class WCache{
public:
@@ -84,7 +94,6 @@ public:
void Refresh(); //Refreshes all cache items.
unsigned int Flatten(); //Ensures that the times don't loop. Returns new lastTime.
void Resize(unsigned long size, int items); //Sets new limits, then enforces them. Lock safe, so not a "hard limit".
protected:
bool RemoveItem(cacheItem * item, bool force = true); //Removes an item, deleting it. if(force), ignores locks / permanent
bool UnlinkCache(cacheItem * item); //Removes an item from our cache, does not delete it. Use with care.
@@ -121,6 +130,7 @@ public:
WResourceManager();
~WResourceManager();
void Unmiss(string filename);
JQuad * RetrieveCard(MTGCard * card, int style = RETRIEVE_NORMAL,int submode = CACHE_NORMAL);
JSample * RetrieveSample(string filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL);
JTexture * RetrieveTexture(string filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL);
@@ -130,7 +140,6 @@ public:
int RetrieveError();
void Release(JTexture * tex);
void Release(JQuad * quad);
void Release(JSample * sample);
bool RemoveOldest();