From 61881ad6565e441d79559aeb117ced404af18160 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Sat, 17 Oct 2015 19:44:21 +0800 Subject: [PATCH] Fix issue #473 and #784 It seems when a zonechange event from inplay to inplay (player or opponent), the card->view item values is recalculated... so it destroys the GUI like missing card image, or moving it far off the screen... To reproduce, cast Splinter Twin to Conquering Manticore and gain control the same creature about 2 or 3 times... --- projects/mtg/include/WEvent.h | 6 ++++++ projects/mtg/src/GuiPlay.cpp | 2 ++ projects/mtg/src/MTGGameZones.cpp | 8 ++++++++ projects/mtg/src/WEvent.cpp | 11 +++++++++++ 4 files changed, 27 insertions(+) diff --git a/projects/mtg/include/WEvent.h b/projects/mtg/include/WEvent.h index 890762796..94043218e 100644 --- a/projects/mtg/include/WEvent.h +++ b/projects/mtg/include/WEvent.h @@ -279,6 +279,12 @@ struct WEventCardUnattached : public WEventCardUpdate { virtual Targetable * getTarget(int target); }; +//event when card moves from player/opponent battlefield to player/opponent battlefield +struct WEventCardControllerChange : public WEventCardUpdate { + WEventCardControllerChange(MTGCardInstance * card); + virtual Targetable * getTarget(int target); +}; + std::ostream& operator<<(std::ostream&, const WEvent&); #endif diff --git a/projects/mtg/src/GuiPlay.cpp b/projects/mtg/src/GuiPlay.cpp index 59a5a138c..eee380023 100644 --- a/projects/mtg/src/GuiPlay.cpp +++ b/projects/mtg/src/GuiPlay.cpp @@ -412,6 +412,8 @@ int GuiPlay::receiveEventPlus(WEvent * e) Replace(); else if (dynamic_cast (e)) Replace(); + else if (dynamic_cast (e)) + Replace(); Replace(); return 0; } diff --git a/projects/mtg/src/MTGGameZones.cpp b/projects/mtg/src/MTGGameZones.cpp index bcae61f0c..2f0b7027c 100644 --- a/projects/mtg/src/MTGGameZones.cpp +++ b/projects/mtg/src/MTGGameZones.cpp @@ -322,6 +322,7 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone int doCopy = 1; bool shufflelibrary = card->basicAbilities[(int)Constants::SHUFFLELIBRARYDEATH]; + bool inplaytoinplay = false; bool ripToken = false; if (g->players[0]->game->battlefield->hasName("Rest in Peace")||g->players[1]->game->battlefield->hasName("Rest in Peace")) ripToken = true; @@ -362,6 +363,8 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone == g->players[1]->game->inPlay)) { doCopy = 0; + asCopy = true;//don't send zone change event so it will not destroy the GUI when multiple switching of control... + inplaytoinplay = true;//try sending different event... } if (!(copy = from->removeCard(card, doCopy))) @@ -433,6 +436,11 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone WEvent * e = NEW WEventZoneChange(copy, from, to); g->receiveEvent(e); } + if(inplaytoinplay) + { + WEvent * ep = NEW WEventCardControllerChange(copy); + g->receiveEvent(ep); + } return ret; } diff --git a/projects/mtg/src/WEvent.cpp b/projects/mtg/src/WEvent.cpp index bba4fa8ef..4b1db1029 100644 --- a/projects/mtg/src/WEvent.cpp +++ b/projects/mtg/src/WEvent.cpp @@ -165,6 +165,11 @@ WEventCardUnattached::WEventCardUnattached(MTGCardInstance * card) : { } +WEventCardControllerChange::WEventCardControllerChange(MTGCardInstance * card) : + WEventCardUpdate(card) +{ +} + WEventCombatStepChange::WEventCombatStepChange(CombatStep step) : WEvent(), step(step) { @@ -319,6 +324,12 @@ Targetable * WEventCardUnattached::getTarget(int target) return NULL; } +Targetable * WEventCardControllerChange::getTarget(int target) +{ + if (target) return card; + return NULL; +} + std::ostream& WEvent::toString(std::ostream& out) const { return out << "EVENT";