Another change that looks bigger than it is: changed out the global extern WResourceManager to a real singleton. This means that it's no longer being init'ed at static initialization time, and we can debug construction/destruction properly; it's also safer in a multithreaded context.

This commit is contained in:
wrenczes@gmail.com
2010-12-01 08:22:17 +00:00
parent aa6aa20ba5
commit 65e38b0694
53 changed files with 369 additions and 346 deletions

View File

@@ -130,8 +130,23 @@ struct WManagedQuad
class WResourceManager: public JResourceManager
{
public:
WResourceManager();
~WResourceManager();
static WResourceManager* Instance()
{
if (sInstance == NULL)
{
sInstance = NEW WResourceManager;
}
return sInstance;
}
static void Terminate()
{
if (sInstance)
SAFE_DELETE(sInstance);
}
virtual ~WResourceManager();
void Unmiss(string filename);
JQuad * RetrieveCard(MTGCard * card, int style = RETRIEVE_NORMAL,int submode = CACHE_NORMAL);
@@ -200,7 +215,12 @@ public:
string debugMessage;
#endif
private:
private:
/*
** Singleton object only accessibly via Instance(), constructor is private
*/
WResourceManager();
bool bThemedCards; //Does the theme have a "sets" directory for overwriting cards?
void FlattenTimes(); //To prevent bad cache timing on int overflow
@@ -222,7 +242,8 @@ private:
typedef std::map<int, WFont*> FontMap;
FontMap mWFontMap;
std::string mFontFileExtension;
static WResourceManager* sInstance;
};
extern WResourceManager resources;
#endif