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

View File

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

View File

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

View File

@@ -14,10 +14,10 @@ AIPlayer::AIPlayer(MTGPlayerCards * _deck, string file): Player(_deck, file){
}
AIPlayer::~AIPlayer(){
if (potentialMana) delete potentialMana;
SAFE_DELETE(potentialMana);
if (stats){
stats->save();
delete stats;
SAFE_DELETE(stats);
}
}
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){
menuObject = object;
if (abilitiesMenu){
delete abilitiesMenu;
}
SAFE_DELETE(abilitiesMenu);
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(MAIN_FONT);
abilitiesMenu = NEW SimpleMenu(10, this, mFont, 100, 100, 200);

View File

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

View File

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

View File

@@ -50,7 +50,7 @@ Counters::Counters(MTGCardInstance * _target):target(_target){
}
Counters::~Counters(){
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(){
for (int i = 0; i < mCount; i++){
delete damages[i];
damages[i] = NULL;
SAFE_DELETE(damages[i]);
}
}
@@ -62,8 +62,7 @@ int DamagerDamaged::removeDamagesFrom(DamagerDamaged * source){
for (int i = 0; i < mCount; i++){
if (damages[i]->source == source->card){
int damage = damages[i]->damage;
delete(damages[i]);
damages[i] = NULL;
SAFE_DELETE(damages[i]);
damages[i] = damages[mCount-1];
mCount--;
return damage;

View File

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

View File

@@ -159,26 +159,26 @@ void GameApp::Destroy()
{
if (mGameStates[i]){
mGameStates[i]->Destroy();
delete mGameStates[i];
SAFE_DELETE(mGameStates[i]);
}
}
for (int i= 0; i < 6; i++){
delete Particles[i];
SAFE_DELETE(Particles[i]);
}
if (collection){
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;
if (MtgSets::SetsList) delete MtgSets::SetsList;
SAFE_DELETE(Subtypes::subtypesList);
SAFE_DELETE(MtgSets::SetsList);
SAFE_DELETE(music);

View File

@@ -151,12 +151,7 @@ MTGAllCards::~MTGAllCards(){
void MTGAllCards::destroyAllCards(){
for (int i= 0; i < total_cards; i++){
#ifdef WIN32
char buf[4096];
sprintf(buf,"deleting %s\n", collection[i]->getName());
OutputDebugString(buf);
#endif
delete collection[i];
SAFE_DELETE(collection[i]);
};
}
@@ -235,6 +230,8 @@ int MTGAllCards::readConfLine(std::ifstream &file, int set_id){
string s;
int result = 0;
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) {
case 0:
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){
if (display){
// display->CheckUserInput(dt);
while (u32 key = JGE::GetInstance()->ReadButton()) display->CheckUserInput(key);
if (display) display->Update(dt);
}else{
if (showPriceDialog!=-1){