- fixed a problem with DOS card files under psp/linux
- Added a bunch of SAFE_DELETE, not sure they're really necessary
- fixed a small interface problem in Shop
This commit is contained in:
wagic.the.homebrew
2008-11-30 11:47:47 +00:00
parent f4cb587426
commit 9ec06eb4e7
13 changed files with 31 additions and 35 deletions

View File

@@ -626,9 +626,9 @@ class AManaProducer: public MTGAbility{
~AManaProducer(){ ~AManaProducer(){
LOG("==Destroying ManaProducer Object"); LOG("==Destroying ManaProducer Object");
if (cost) delete cost; SAFE_DELETE(cost);
SAFE_DELETE(output); SAFE_DELETE(output);
if (mParticleSys) delete mParticleSys; SAFE_DELETE(mParticleSys);
LOG("==Destroying ManaProducer Object Successful!"); LOG("==Destroying ManaProducer Object Successful!");
} }
@@ -2377,7 +2377,7 @@ class AAtog:public TargetAbility{
TargetAbility::Update(dt); TargetAbility::Update(dt);
Player * newController = source->controller(); Player * newController = source->controller();
if (newController != currentController){ if (newController != currentController){
delete tc; SAFE_DELETE(tc);
MTGGameZone * zones[] = {newController->game->inPlay}; //In case Atog's controller changes MTGGameZone * zones[] = {newController->game->inPlay}; //In case Atog's controller changes
tc = NEW TypeTargetChooser("artifact", zones, 1, source); tc = NEW TypeTargetChooser("artifact", zones, 1, source);
currentController = newController; currentController = newController;

View File

@@ -77,7 +77,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
GameStateDeckViewer(GameApp* parent): GameState(parent) { GameStateDeckViewer(GameApp* parent): GameState(parent) {
bgMusic = NULL; bgMusic = NULL;
scrollSpeed = HIGH_SPEED; scrollSpeed = MED_SPEED;
} }
virtual ~GameStateDeckViewer() { virtual ~GameStateDeckViewer() {
SAFE_DELETE(bgMusic); SAFE_DELETE(bgMusic);
@@ -241,7 +241,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
SAFE_DELETE(menu); SAFE_DELETE(menu);
SAFE_DELETE(pspIconsTexture); SAFE_DELETE(pspIconsTexture);
for (int i=0; i < 8; i++){ for (int i=0; i < 8; i++){
delete pspIcons[i]; SAFE_DELETE(pspIcons[i]);
} }
SAFE_DELETE(myCollection); SAFE_DELETE(myCollection);
SAFE_DELETE(myDeck); SAFE_DELETE(myDeck);

View File

@@ -63,7 +63,7 @@ public:
int lastTime; int lastTime;
JSample * sample; JSample * sample;
SampleCached(int _lastTime, JSample * _sample):lastTime(_lastTime),sample(_sample){}; SampleCached(int _lastTime, JSample * _sample):lastTime(_lastTime),sample(_sample){};
~SampleCached(){delete sample;}; ~SampleCached(){SAFE_DELETE(sample);};
}; };
class SampleCache{ class SampleCache{

View File

@@ -14,10 +14,10 @@ AIPlayer::AIPlayer(MTGPlayerCards * _deck, string file): Player(_deck, file){
} }
AIPlayer::~AIPlayer(){ AIPlayer::~AIPlayer(){
if (potentialMana) delete potentialMana; SAFE_DELETE(potentialMana);
if (stats){ if (stats){
stats->save(); stats->save();
delete stats; SAFE_DELETE(stats);
} }
} }
MTGCardInstance * AIPlayer::chooseCard(TargetChooser * tc, MTGCardInstance * source, int random){ MTGCardInstance * AIPlayer::chooseCard(TargetChooser * tc, MTGCardInstance * source, int random){

View File

@@ -160,9 +160,9 @@ int ActionLayer::reactToClick(MTGCardInstance * card){
void ActionLayer::setMenuObject(Targetable * object){ void ActionLayer::setMenuObject(Targetable * object){
menuObject = object; menuObject = object;
if (abilitiesMenu){
delete abilitiesMenu; SAFE_DELETE(abilitiesMenu);
}
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(MAIN_FONT); JLBFont * mFont = GameApp::CommonRes->GetJLBFont(MAIN_FONT);
abilitiesMenu = NEW SimpleMenu(10, this, mFont, 100, 100, 200); abilitiesMenu = NEW SimpleMenu(10, this, mFont, 100, 100, 200);

View File

@@ -590,7 +590,7 @@ int ActionStack::CombatDamages(int strike){
if (damageitems){ if (damageitems){
addAction(damages); addAction(damages);
}else{ }else{
delete damages; SAFE_DELETE(damages);
} }
return damageitems; return damageitems;
} }
@@ -602,7 +602,7 @@ int ActionStack::garbageCollect(){
if (current->state != NOT_RESOLVED){ if (current->state != NOT_RESOLVED){
mObjects[i] = mObjects[mCount-1]; mObjects[i] = mObjects[mCount-1];
mCount--; mCount--;
delete current; SAFE_DELETE(current);
} }
} }
return 1; return 1;

View File

@@ -14,7 +14,7 @@ Blocker::Blocker(int id, MTGCardInstance * card, MTGCardInstance *_target, ManaC
} }
Blocker::~Blocker(){ Blocker::~Blocker(){
delete manaCost; SAFE_DELETE(manaCost);
} }
void Blocker::init(ManaCost * _cost){ void Blocker::init(ManaCost * _cost){

View File

@@ -50,7 +50,7 @@ Counters::Counters(MTGCardInstance * _target):target(_target){
} }
Counters::~Counters(){ Counters::~Counters(){
for (int i = 0; i < mCount; i++){ for (int i = 0; i < mCount; i++){
delete counters[i]; SAFE_DELETE(counters[i]);
} }
} }

View File

@@ -12,8 +12,8 @@ DamagerDamaged::DamagerDamaged(CardGui * cardg, Player * _damageSelecter, bool _
DamagerDamaged::~DamagerDamaged(){ DamagerDamaged::~DamagerDamaged(){
for (int i = 0; i < mCount; i++){ for (int i = 0; i < mCount; i++){
delete damages[i]; SAFE_DELETE(damages[i]);
damages[i] = NULL;
} }
} }
@@ -62,8 +62,7 @@ int DamagerDamaged::removeDamagesFrom(DamagerDamaged * source){
for (int i = 0; i < mCount; i++){ for (int i = 0; i < mCount; i++){
if (damages[i]->source == source->card){ if (damages[i]->source == source->card){
int damage = damages[i]->damage; int damage = damages[i]->damage;
delete(damages[i]); SAFE_DELETE(damages[i]);
damages[i] = NULL;
damages[i] = damages[mCount-1]; damages[i] = damages[mCount-1];
mCount--; mCount--;
return damage; return damage;

View File

@@ -17,7 +17,7 @@ DeckStats * DeckStats::GetInstance(){
void DeckStats::cleanStats(){ void DeckStats::cleanStats(){
map<string,DeckStat *>::iterator it; map<string,DeckStat *>::iterator it;
for (it = stats.begin(); it != stats.end(); it++){ for (it = stats.begin(); it != stats.end(); it++){
delete(it->second); SAFE_DELETE(it->second);
} }
stats.clear(); stats.clear();
} }

View File

@@ -159,26 +159,26 @@ void GameApp::Destroy()
{ {
if (mGameStates[i]){ if (mGameStates[i]){
mGameStates[i]->Destroy(); mGameStates[i]->Destroy();
delete mGameStates[i]; SAFE_DELETE(mGameStates[i]);
} }
} }
for (int i= 0; i < 6; i++){ for (int i= 0; i < 6; i++){
delete Particles[i]; SAFE_DELETE(Particles[i]);
} }
if (collection){ if (collection){
collection->destroyAllCards(); collection->destroyAllCards();
delete collection; SAFE_DELETE(collection);
} }
if (cache) delete cache; SAFE_DELETE(cache);
if (CommonRes) delete CommonRes; SAFE_DELETE(CommonRes);
GameOptions::Destroy(); GameOptions::Destroy(); //No delete ???
if (Subtypes::subtypesList) delete Subtypes::subtypesList; SAFE_DELETE(Subtypes::subtypesList);
if (MtgSets::SetsList) delete MtgSets::SetsList; SAFE_DELETE(MtgSets::SetsList);
SAFE_DELETE(music); SAFE_DELETE(music);

View File

@@ -151,12 +151,7 @@ MTGAllCards::~MTGAllCards(){
void MTGAllCards::destroyAllCards(){ void MTGAllCards::destroyAllCards(){
for (int i= 0; i < total_cards; i++){ for (int i= 0; i < total_cards; i++){
#ifdef WIN32 SAFE_DELETE(collection[i]);
char buf[4096];
sprintf(buf,"deleting %s\n", collection[i]->getName());
OutputDebugString(buf);
#endif
delete collection[i];
}; };
} }
@@ -235,6 +230,8 @@ int MTGAllCards::readConfLine(std::ifstream &file, int set_id){
string s; string s;
int result = 0; int result = 0;
if(std::getline(file,s)) result = 1; if(std::getline(file,s)) result = 1;
if (!s.size()) return 0;
if (s[s.size()-1] == '\r') s.erase(s.size()-1); //Handle DOS files
switch(conf_read_mode) { switch(conf_read_mode) {
case 0: case 0:
if (s.find("[card]") != string::npos){ if (s.find("[card]") != string::npos){

View File

@@ -153,7 +153,7 @@ void ShopItems::Add(char * text, JQuad * quad,JQuad * thumb, int price){
void ShopItems::Update(float dt){ void ShopItems::Update(float dt){
if (display){ if (display){
// display->CheckUserInput(dt); while (u32 key = JGE::GetInstance()->ReadButton()) display->CheckUserInput(key);
if (display) display->Update(dt); if (display) display->Update(dt);
}else{ }else{
if (showPriceDialog!=-1){ if (showPriceDialog!=-1){