From 61e449d02b1b805b27882a2cba7379cf5e440124 Mon Sep 17 00:00:00 2001 From: "wagic.the.homebrew@gmail.com" Date: Sun, 21 Jun 2009 10:46:33 +0000 Subject: [PATCH] Erwan - Changecontroller now sends a changezone event - Manacost bug fix (memory leak) --- projects/mtg/bin/Res/test/_tests.txt | 2 +- projects/mtg/include/AllAbilities.h | 4 +++- projects/mtg/include/MTGCardInstance.h | 2 +- projects/mtg/src/MTGAbility.cpp | 1 - projects/mtg/src/MTGCardInstance.cpp | 7 +++---- projects/mtg/src/ManaCost.cpp | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index daec65759..5027a4a83 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -134,4 +134,4 @@ zombify.txt #Momir Basic Tests ######################## momir/keldon_warlord.txt -momir/overcost.txt +momir/overcost.txt \ No newline at end of file diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index e1bc3d981..799e637c0 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -1546,7 +1546,9 @@ class AControlStealAura: public MTGAbility{ Player * originalController; AControlStealAura(int _id , MTGCardInstance * _source, MTGCardInstance * _target):MTGAbility(_id, _source, _target){ originalController = _target->controller(); - _target->changeController(game->currentlyActing()); + MTGCardInstance * copy = _target->changeController(game->currentlyActing()); + target = copy; + source->target = copy; } int destroy(){ diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index cb6f37fd5..5bb3aca6c 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -48,7 +48,7 @@ class MTGCardInstance: public MTGCard, public Damageable, public Targetable { int summoningSickness; // The recommended method to test for summoning Sickness ! int hasSummoningSickness(); - int changeController(Player * newcontroller); + MTGCardInstance * changeController(Player * newcontroller); MTGCardInstance * defenser; float changedZoneRecently; Player * owner; diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 86fdb77b0..e8a8d7fe6 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -1669,7 +1669,6 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ case 1326: //Wheel of fortune { for (int i = 0; i < 2; i++){ - // MTGLibrary * library = game->players[i]->game->library; MTGHand * hand = game->players[i]->game->hand; for (int j = hand->nb_cards-1; j>=0; j--){ game->players[i]->game->putInGraveyard(hand->cards[j]); diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 83dc28cc1..cffd711cd 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -241,13 +241,12 @@ int MTGCardInstance::hasSummoningSickness(){ return 1; } -int MTGCardInstance::changeController(Player * newController){ +MTGCardInstance * MTGCardInstance::changeController(Player * newController){ Player * originalOwner = controller(); if (originalOwner == newController) return 0; - MTGCardInstance * copy = originalOwner->game->inPlay->removeCard(this,0); - newController->game->inPlay->addCard(copy); + MTGCardInstance * copy = originalOwner->game->putInZone(this, originalOwner->game->inPlay, newController->game->inPlay); //summoningSickness = 1; - return 1; + return copy; } //Reset the card parameters diff --git a/projects/mtg/src/ManaCost.cpp b/projects/mtg/src/ManaCost.cpp index 283ed1161..e598e51fa 100644 --- a/projects/mtg/src/ManaCost.cpp +++ b/projects/mtg/src/ManaCost.cpp @@ -144,7 +144,7 @@ void ManaCost::init(){ } nbhybrids = 0; extraCosts = NULL; - extraCostsIsCopy = 1; + extraCostsIsCopy = 0; }