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...
This commit is contained in:
Anthony Calosa
2015-10-17 19:44:21 +08:00
parent d1e64a410b
commit 61881ad656
4 changed files with 27 additions and 0 deletions
+6
View File
@@ -279,6 +279,12 @@ struct WEventCardUnattached : public WEventCardUpdate {
virtual Targetable * getTarget(int target); 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&); std::ostream& operator<<(std::ostream&, const WEvent&);
#endif #endif
+2
View File
@@ -412,6 +412,8 @@ int GuiPlay::receiveEventPlus(WEvent * e)
Replace(); Replace();
else if (dynamic_cast<WEventCardUnattached*> (e)) else if (dynamic_cast<WEventCardUnattached*> (e))
Replace(); Replace();
else if (dynamic_cast<WEventCardControllerChange*> (e))
Replace();
Replace(); Replace();
return 0; return 0;
} }
+8
View File
@@ -322,6 +322,7 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
int doCopy = 1; int doCopy = 1;
bool shufflelibrary = card->basicAbilities[(int)Constants::SHUFFLELIBRARYDEATH]; bool shufflelibrary = card->basicAbilities[(int)Constants::SHUFFLELIBRARYDEATH];
bool inplaytoinplay = false;
bool ripToken = false; bool ripToken = false;
if (g->players[0]->game->battlefield->hasName("Rest in Peace")||g->players[1]->game->battlefield->hasName("Rest in Peace")) if (g->players[0]->game->battlefield->hasName("Rest in Peace")||g->players[1]->game->battlefield->hasName("Rest in Peace"))
ripToken = true; ripToken = true;
@@ -362,6 +363,8 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
== g->players[1]->game->inPlay)) == g->players[1]->game->inPlay))
{ {
doCopy = 0; 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))) if (!(copy = from->removeCard(card, doCopy)))
@@ -433,6 +436,11 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
WEvent * e = NEW WEventZoneChange(copy, from, to); WEvent * e = NEW WEventZoneChange(copy, from, to);
g->receiveEvent(e); g->receiveEvent(e);
} }
if(inplaytoinplay)
{
WEvent * ep = NEW WEventCardControllerChange(copy);
g->receiveEvent(ep);
}
return ret; return ret;
} }
+11
View File
@@ -165,6 +165,11 @@ WEventCardUnattached::WEventCardUnattached(MTGCardInstance * card) :
{ {
} }
WEventCardControllerChange::WEventCardControllerChange(MTGCardInstance * card) :
WEventCardUpdate(card)
{
}
WEventCombatStepChange::WEventCombatStepChange(CombatStep step) : WEventCombatStepChange::WEventCombatStepChange(CombatStep step) :
WEvent(), step(step) WEvent(), step(step)
{ {
@@ -319,6 +324,12 @@ Targetable * WEventCardUnattached::getTarget(int target)
return NULL; return NULL;
} }
Targetable * WEventCardControllerChange::getTarget(int target)
{
if (target) return card;
return NULL;
}
std::ostream& WEvent::toString(std::ostream& out) const std::ostream& WEvent::toString(std::ostream& out) const
{ {
return out << "EVENT"; return out << "EVENT";