From c0ab80a1bcf592f5648db048007eda41fe81dbff Mon Sep 17 00:00:00 2001 From: "omegablast2002@yahoo.com" Date: Sun, 18 Sep 2011 10:34:40 +0000 Subject: [PATCH] fixed a bug in targetchoosing where a player would get stuck in a targetchooser under certain situations as follows: opponent play an ability, player interupts and clicks a card with TargetChooser which has no valid targets; player then tries to cancel targetchooser, instead the stack is displayed again, player is then locked in a TargetChooser unable to click other cards. originally i was going to do it in the reactToClick however, after thinking about it, it made no sense to me that a targetchooser would be set and a cardwaitingfortargets would be set if you know ahead of time that no valid targets existed. now when clicking cards which have TargetChoosers and no valid targets, no tc is set, and no cardiswaitingfortargets; instead return 0. --- projects/mtg/src/GameObserver.cpp | 11 +++++++++-- projects/mtg/src/TargetChooser.cpp | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 7c404d0bf..cf3bdb3ae 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -1098,11 +1098,18 @@ int GameObserver::targetListIsSet(MTGCardInstance * card) { TargetChooserFactory tcf; targetChooser = tcf.createTargetChooser(card); - cardWaitingForTargets = card; if (targetChooser == NULL) { return 1; } } - return (targetChooser->targetListSet()); + if(targetChooser && targetChooser->validTargetsExist()) + { + cardWaitingForTargets = card; + return (targetChooser->targetListSet()); + } + else + targetChooser = NULL; + return 0; + } diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index f2a688b2d..18dd2a62d 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -789,8 +789,8 @@ bool TargetChooser::validTargetsExist(int maxTargets) int maxAmount = 0; Player *p = GameObserver::GetInstance()->players[i]; if (canTarget(p)) return true; - MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->exile }; - for (int k = 0; k < 5; k++) + MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->exile, p->game->stack }; + for (int k = 0; k < 6; k++) { MTGGameZone * z = zones[k]; if (targetsZone(z))