Erwan
- fixed a few memory leaks
This commit is contained in:
@@ -24,6 +24,7 @@ class ActionLayer: public GuiLayer, public JGuiListener{
|
|||||||
int unstopableRenderInProgress();
|
int unstopableRenderInProgress();
|
||||||
bool CheckUserInput(u32 key);
|
bool CheckUserInput(u32 key);
|
||||||
ActionLayer(int id, GameObserver* _game):GuiLayer(id, _game){ menuObject = NULL; abilitiesMenu = NULL;};
|
ActionLayer(int id, GameObserver* _game):GuiLayer(id, _game){ menuObject = NULL; abilitiesMenu = NULL;};
|
||||||
|
~ActionLayer();
|
||||||
int isWaitingForAnswer();
|
int isWaitingForAnswer();
|
||||||
int isReactingToTargetClick(Targetable * card);
|
int isReactingToTargetClick(Targetable * card);
|
||||||
int receiveEvent(WEvent * event);
|
int receiveEvent(WEvent * event);
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class SimpleMenu:public JGuiController{
|
|||||||
static unsigned int refCount;
|
static unsigned int refCount;
|
||||||
|
|
||||||
static JQuad *spadeR, *spadeL, *jewel, *side;
|
static JQuad *spadeR, *spadeL, *jewel, *side;
|
||||||
|
static JTexture *spadeRTex, *spadeLTex, *jewelTex, *sideTex;
|
||||||
static JLBFont* titleFont;
|
static JLBFont* titleFont;
|
||||||
static hgeParticleSystem* stars;
|
static hgeParticleSystem* stars;
|
||||||
// This works only because of no multithreading
|
// This works only because of no multithreading
|
||||||
@@ -51,6 +52,7 @@ class SimpleMenu:public JGuiController{
|
|||||||
|
|
||||||
float selectionTargetY;
|
float selectionTargetY;
|
||||||
bool closed;
|
bool closed;
|
||||||
|
static void destroy();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ protected:
|
|||||||
~SampleCache();
|
~SampleCache();
|
||||||
public:
|
public:
|
||||||
static SampleCache * GetInstance();
|
static SampleCache * GetInstance();
|
||||||
|
static void DestroyInstance();
|
||||||
SampleCache(){lastTime = 0;};
|
SampleCache(){lastTime = 0;};
|
||||||
JSample * getSample(string filename);
|
JSample * getSample(string filename);
|
||||||
|
|
||||||
|
|||||||
@@ -515,7 +515,7 @@ AIStats * AIPlayer::getStats(){
|
|||||||
if (!stats){
|
if (!stats){
|
||||||
char statFile[512];
|
char statFile[512];
|
||||||
sprintf(statFile, RESPATH"/ai/baka/stats/%s.stats", opponent()->deckFile.c_str());
|
sprintf(statFile, RESPATH"/ai/baka/stats/%s.stats", opponent()->deckFile.c_str());
|
||||||
stats = new AIStats(this, statFile);
|
stats = NEW AIStats(this, statFile);
|
||||||
}
|
}
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,3 +216,7 @@ void ActionLayer::ButtonPressed(int controllerid, int controlid){
|
|||||||
menuObject = 0;
|
menuObject = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ActionLayer::~ActionLayer(){
|
||||||
|
SAFE_DELETE(abilitiesMenu);
|
||||||
|
}
|
||||||
@@ -170,6 +170,8 @@ void GameApp::Destroy()
|
|||||||
SAFE_DELETE(collection);
|
SAFE_DELETE(collection);
|
||||||
}
|
}
|
||||||
SAFE_DELETE(cache);
|
SAFE_DELETE(cache);
|
||||||
|
SampleCache::DestroyInstance();
|
||||||
|
|
||||||
|
|
||||||
SAFE_DELETE(CommonRes);
|
SAFE_DELETE(CommonRes);
|
||||||
|
|
||||||
@@ -181,6 +183,10 @@ void GameApp::Destroy()
|
|||||||
SAFE_DELETE(music);
|
SAFE_DELETE(music);
|
||||||
|
|
||||||
delete(DeckStats::GetInstance());
|
delete(DeckStats::GetInstance());
|
||||||
|
|
||||||
|
SimpleMenu::destroy();
|
||||||
|
|
||||||
|
|
||||||
LOG("==Destroying GameApp Successful==");
|
LOG("==Destroying GameApp Successful==");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ void GameStateOptions::End()
|
|||||||
{
|
{
|
||||||
JRenderer::GetInstance()->EnableVSync(false);
|
JRenderer::GetInstance()->EnableVSync(false);
|
||||||
SAFE_DELETE(optionsList);
|
SAFE_DELETE(optionsList);
|
||||||
|
SAFE_DELETE(optionsMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -77,12 +77,9 @@ void GameStateShop::End()
|
|||||||
SAFE_DELETE(shop);
|
SAFE_DELETE(shop);
|
||||||
SAFE_DELETE(mBack);
|
SAFE_DELETE(mBack);
|
||||||
SAFE_DELETE(backTexture);
|
SAFE_DELETE(backTexture);
|
||||||
if(bgTexture)
|
SAFE_DELETE(bgTexture);
|
||||||
SAFE_DELETE(bgTexture);
|
SAFE_DELETE(mBg);
|
||||||
if(mBg)
|
SAFE_DELETE(menu);
|
||||||
SAFE_DELETE(mBg);
|
|
||||||
if(menu)
|
|
||||||
SAFE_DELETE(menu);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,11 +30,12 @@ MTGPlayerCards::MTGPlayerCards(MTGAllCards * _collection, int * idList, int idLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
MTGPlayerCards::~MTGPlayerCards(){
|
MTGPlayerCards::~MTGPlayerCards(){
|
||||||
if(library) delete library;
|
SAFE_DELETE(library);
|
||||||
if(graveyard) delete graveyard;
|
SAFE_DELETE(graveyard);
|
||||||
if(hand) delete hand;
|
SAFE_DELETE(hand);
|
||||||
if(inPlay) delete inPlay;
|
SAFE_DELETE(inPlay);
|
||||||
if(stack) delete stack;
|
SAFE_DELETE(stack);
|
||||||
|
SAFE_DELETE(removedFromGame);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MTGPlayerCards::setOwner(Player * player){
|
void MTGPlayerCards::setOwner(Player * player){
|
||||||
@@ -62,7 +63,6 @@ void MTGPlayerCards::init(){
|
|||||||
hand = NEW MTGHand();
|
hand = NEW MTGHand();
|
||||||
inPlay = NEW MTGInPlay();
|
inPlay = NEW MTGInPlay();
|
||||||
stack = NEW MTGStack();
|
stack = NEW MTGStack();
|
||||||
stack = NEW MTGStack();
|
|
||||||
removedFromGame = NEW MTGRemovedFromGame();
|
removedFromGame = NEW MTGRemovedFromGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ void ShopItem::Render(){
|
|||||||
renderer->RenderQuad(quad,mX + SCREEN_WIDTH/2 + 20,5,0, 0.9f,0.9f);
|
renderer->RenderQuad(quad,mX + SCREEN_WIDTH/2 + 20,5,0, 0.9f,0.9f);
|
||||||
}else{
|
}else{
|
||||||
if (card) CardGui::alternateRender(card,NULL,mX + SCREEN_WIDTH/2 + 100 + 20,133,0, 0.9f);
|
if (card) CardGui::alternateRender(card,NULL,mX + SCREEN_WIDTH/2 + 100 + 20,133,0, 0.9f);
|
||||||
//TODO
|
|
||||||
}
|
}
|
||||||
mFont->SetColor(ARGB(255,255,255,0));
|
mFont->SetColor(ARGB(255,255,255,0));
|
||||||
}else{
|
}else{
|
||||||
@@ -80,18 +79,15 @@ void ShopItem::Render(){
|
|||||||
|
|
||||||
void ShopItem::Update(float dt)
|
void ShopItem::Update(float dt)
|
||||||
{
|
{
|
||||||
if (mScale < mTargetScale)
|
if (mScale < mTargetScale){
|
||||||
{
|
|
||||||
mScale += 8.0f*dt;
|
mScale += 8.0f*dt;
|
||||||
if (mScale > mTargetScale)
|
if (mScale > mTargetScale)
|
||||||
mScale = mTargetScale;
|
mScale = mTargetScale;
|
||||||
}
|
}else if (mScale > mTargetScale){
|
||||||
else if (mScale > mTargetScale)
|
|
||||||
{
|
|
||||||
mScale -= 8.0f*dt;
|
mScale -= 8.0f*dt;
|
||||||
if (mScale < mTargetScale)
|
if (mScale < mTargetScale)
|
||||||
mScale = mTargetScale;
|
mScale = mTargetScale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -157,9 +153,9 @@ void ShopItems::Update(float dt){
|
|||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
sprintf(buffer,"%s : %i credits",item->getText(),price);
|
sprintf(buffer,"%s : %i credits",item->getText(),price);
|
||||||
if(!dialog){
|
if(!dialog){
|
||||||
dialog = NEW SimpleMenu(1,this,GameApp::CommonRes->GetJLBFont(Constants::MENU_FONT),SCREEN_WIDTH-300,SCREEN_HEIGHT/2,buffer);
|
dialog = NEW SimpleMenu(1,this,GameApp::CommonRes->GetJLBFont(Constants::MENU_FONT),SCREEN_WIDTH-300,SCREEN_HEIGHT/2,buffer);
|
||||||
dialog->Add(1,"Yes");
|
dialog->Add(1,"Yes");
|
||||||
dialog->Add(2,"No");
|
dialog->Add(2,"No");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
dialog->Update(dt);
|
dialog->Update(dt);
|
||||||
@@ -220,7 +216,7 @@ void ShopItems::ButtonPressed(int controllerId, int controlId){
|
|||||||
item->quantity--;
|
item->quantity--;
|
||||||
}else{
|
}else{
|
||||||
safeDeleteDisplay();
|
safeDeleteDisplay();
|
||||||
display = new CardDisplay(12,NULL, SCREEN_WIDTH - 200, SCREEN_HEIGHT/2,this,NULL,5);
|
display = NEW CardDisplay(12,NULL, SCREEN_WIDTH - 200, SCREEN_HEIGHT/2,this,NULL,5);
|
||||||
int curNbcards = playerdata->collection->totalCards();
|
int curNbcards = playerdata->collection->totalCards();
|
||||||
//if (showPriceDialog == 0){
|
//if (showPriceDialog == 0){
|
||||||
// //Starter Deck
|
// //Starter Deck
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ JQuad* SimpleMenu::spadeR = NULL;
|
|||||||
JQuad* SimpleMenu::spadeL = NULL;
|
JQuad* SimpleMenu::spadeL = NULL;
|
||||||
JQuad* SimpleMenu::jewel = NULL;
|
JQuad* SimpleMenu::jewel = NULL;
|
||||||
JQuad* SimpleMenu::side = NULL;
|
JQuad* SimpleMenu::side = NULL;
|
||||||
|
JTexture* SimpleMenu::spadeRTex = NULL;
|
||||||
|
JTexture* SimpleMenu::spadeLTex = NULL;
|
||||||
|
JTexture* SimpleMenu::jewelTex = NULL;
|
||||||
|
JTexture* SimpleMenu::sideTex = NULL;
|
||||||
JLBFont* SimpleMenu::titleFont = NULL;
|
JLBFont* SimpleMenu::titleFont = NULL;
|
||||||
hgeParticleSystem* SimpleMenu::stars = NULL;
|
hgeParticleSystem* SimpleMenu::stars = NULL;
|
||||||
unsigned int SimpleMenu::refCount = 0;
|
unsigned int SimpleMenu::refCount = 0;
|
||||||
@@ -36,21 +40,22 @@ SimpleMenu::SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int
|
|||||||
title = _title;
|
title = _title;
|
||||||
startId = 0;
|
startId = 0;
|
||||||
maxItems = _maxItems;
|
maxItems = _maxItems;
|
||||||
side = NULL;
|
|
||||||
selectionT = 0;
|
selectionT = 0;
|
||||||
timeOpen = 0;
|
timeOpen = 0;
|
||||||
closed = false;
|
closed = false;
|
||||||
++refCount;
|
++refCount;
|
||||||
|
|
||||||
JRenderer* renderer = JRenderer::GetInstance();
|
JRenderer* renderer = JRenderer::GetInstance();
|
||||||
static JTexture* spadeLTex = renderer->LoadTexture(spadeLPath, TEX_TYPE_USE_VRAM);
|
|
||||||
static JTexture* spadeRTex = renderer->LoadTexture(spadeRPath, TEX_TYPE_USE_VRAM);
|
if (!spadeLTex) spadeLTex= renderer->LoadTexture(spadeLPath, TEX_TYPE_USE_VRAM);
|
||||||
static JTexture* jewelTex = renderer->CreateTexture(5, 5, TEX_TYPE_USE_VRAM);
|
if (!spadeRTex) spadeRTex = renderer->LoadTexture(spadeRPath, TEX_TYPE_USE_VRAM);
|
||||||
static JTexture* sideTex = renderer->LoadTexture(sidePath, TEX_TYPE_USE_VRAM);
|
if (!jewelTex) jewelTex= renderer->CreateTexture(5, 5, TEX_TYPE_USE_VRAM);
|
||||||
if (NULL == spadeL) spadeL = NEW JQuad(spadeLTex, 2, 1, 16, 13);
|
if (!sideTex) sideTex = renderer->LoadTexture(sidePath, TEX_TYPE_USE_VRAM);
|
||||||
|
if (NULL == spadeL) spadeL = NEW JQuad(spadeLTex, 2, 1, 16, 13);
|
||||||
if (NULL == spadeR) spadeR = NEW JQuad(spadeRTex, 2, 1, 16, 13);
|
if (NULL == spadeR) spadeR = NEW JQuad(spadeRTex, 2, 1, 16, 13);
|
||||||
if (NULL == jewel) jewel = NEW JQuad(jewelTex, 1, 1, 3, 3);
|
if (NULL == jewel) jewel = NEW JQuad(jewelTex, 1, 1, 3, 3);
|
||||||
if (NULL == side) side = NEW JQuad(sideTex, 1, 1, 1, 7);
|
if (NULL == side) side = NEW JQuad(sideTex, 1, 1, 1, 7);
|
||||||
|
|
||||||
if (NULL == titleFont)
|
if (NULL == titleFont)
|
||||||
{
|
{
|
||||||
GameApp::CommonRes->LoadJLBFont(titleFontPath, 7);
|
GameApp::CommonRes->LoadJLBFont(titleFontPath, 7);
|
||||||
@@ -172,3 +177,15 @@ void SimpleMenu::Close()
|
|||||||
timeOpen = -1.0;
|
timeOpen = -1.0;
|
||||||
stars->Stop(true);
|
stars->Stop(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimpleMenu::destroy(){
|
||||||
|
SAFE_DELETE(SimpleMenu::spadeR);
|
||||||
|
SAFE_DELETE(SimpleMenu::spadeL);
|
||||||
|
SAFE_DELETE(SimpleMenu::jewel);
|
||||||
|
SAFE_DELETE(SimpleMenu::side);
|
||||||
|
SAFE_DELETE(SimpleMenu::spadeRTex);
|
||||||
|
SAFE_DELETE(SimpleMenu::spadeLTex);
|
||||||
|
SAFE_DELETE(SimpleMenu::jewelTex);
|
||||||
|
SAFE_DELETE(SimpleMenu::sideTex);
|
||||||
|
SAFE_DELETE(SimpleMenu::stars);
|
||||||
|
}
|
||||||
@@ -93,6 +93,7 @@ CardTexture::CardTexture(MTGCard * card, int _type): type(_type){
|
|||||||
LOG("==Creating CardTexture Object");
|
LOG("==Creating CardTexture Object");
|
||||||
char filename[100];
|
char filename[100];
|
||||||
quad = NULL;
|
quad = NULL;
|
||||||
|
tex = NULL;
|
||||||
nbpixels = 0;
|
nbpixels = 0;
|
||||||
lastTime = 0;
|
lastTime = 0;
|
||||||
if (type == CACHE_THUMB){
|
if (type == CACHE_THUMB){
|
||||||
@@ -103,7 +104,8 @@ CardTexture::CardTexture(MTGCard * card, int _type): type(_type){
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
OutputDebugString(filename);
|
OutputDebugString(filename);
|
||||||
#endif
|
#endif
|
||||||
tex = JRenderer::GetInstance()->LoadTexture(filename, false);
|
if (fileExists(filename))
|
||||||
|
tex = JRenderer::GetInstance()->LoadTexture(filename, false);
|
||||||
if (tex){
|
if (tex){
|
||||||
quad = NEW JQuad(tex, 0.0f, 0.0f, tex->mWidth, tex->mHeight);
|
quad = NEW JQuad(tex, 0.0f, 0.0f, tex->mWidth, tex->mHeight);
|
||||||
nbpixels = tex->mTexHeight * tex->mTexWidth;
|
nbpixels = tex->mTexHeight * tex->mTexWidth;
|
||||||
@@ -177,3 +179,7 @@ void SampleCache::cleanCache(){
|
|||||||
SampleCache::~SampleCache(){
|
SampleCache::~SampleCache(){
|
||||||
cleanCache();
|
cleanCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SampleCache::DestroyInstance(){
|
||||||
|
SAFE_DELETE(mInstance);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user