diff --git a/JGE/src/iOS/EAGLView.m b/JGE/src/iOS/EAGLView.m index d6efbaf47..00e7657e9 100755 --- a/JGE/src/iOS/EAGLView.m +++ b/JGE/src/iOS/EAGLView.m @@ -270,11 +270,9 @@ void DestroyGame(void) NSLog(@"EAGL View - init With Frame: origin(%f %f) size(%f %f)", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); - if ((self = [super initWithFrame:frame])) { - - self = [self initialize]; - - } + self = [super initWithFrame:frame]; + if (self) + [self initialize]; return self; } @@ -283,9 +281,11 @@ void DestroyGame(void) //The EAGL view is stored in the nib file. When it's unarchived it's sent -initWithCoder: - (id)initWithCoder:(NSCoder*)coder { - if (( self = [super initWithCoder:coder] )) + self = [super initWithCoder:coder]; + + if (self) { - self = [self initialize]; + [self initialize]; } return self; diff --git a/projects/mtg/include/WGui.h b/projects/mtg/include/WGui.h index ea6b1f84a..2c46239c9 100644 --- a/projects/mtg/include/WGui.h +++ b/projects/mtg/include/WGui.h @@ -798,7 +798,7 @@ class WGuiMenu: public WGuiItem public: friend class WGuiFilters; virtual ~WGuiMenu(); - WGuiMenu(JButton next, JButton prev, bool mDPad = false, WSyncable * syncme = NULL); + WGuiMenu(JButton next = JGE_BTN_RIGHT, JButton prev = JGE_BTN_LEFT, bool mDPad = false, WSyncable * syncme = NULL); virtual bool yieldFocus(); virtual void Render(); diff --git a/projects/mtg/src/AIPlayer.cpp b/projects/mtg/src/AIPlayer.cpp index 5f5c3a65c..dcf38f1c0 100644 --- a/projects/mtg/src/AIPlayer.cpp +++ b/projects/mtg/src/AIPlayer.cpp @@ -87,7 +87,6 @@ int AIAction::clickMultiAct(vector& actionTargets) { GameObserver * g = owner->getObserver(); TargetChooser * tc = g->getCurrentTargetChooser(); - if(!tc) return 0; for(size_t f = 0;f < actionTargets.size();f++) { @@ -198,7 +197,6 @@ int AIPlayer::clickSingleTarget(TargetChooser * tc, vector& potenti { MTGCardInstance * card = ((MTGCardInstance *) potentialTargets[i]); clickstream.push(NEW AIAction(this, card)); - chosenCard = card; } break; } diff --git a/projects/mtg/src/AIPlayerBaka.cpp b/projects/mtg/src/AIPlayerBaka.cpp index 15b9272f6..232719661 100644 --- a/projects/mtg/src/AIPlayerBaka.cpp +++ b/projects/mtg/src/AIPlayerBaka.cpp @@ -51,10 +51,10 @@ int OrderedAIAction::getEfficiency(AADamager * aad) if(p == target->controller()) return 0; - if (aad->getDamage() >= dTarget->toughness) + if (dTarget && aad && (aad->getDamage() >= dTarget->toughness)) return 100; - if (dTarget->toughness) + if (dTarget && dTarget->toughness) return (50 * aad->getDamage()) / dTarget->toughness; return 0; diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 76587c0b8..363095558 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -3519,18 +3519,25 @@ void APhaseAction::Update(float dt) if(newPhase == phase && next ) { MTGCardInstance * _target = NULL; + bool isTargetable = false; + if(target) - _target = (MTGCardInstance *) target; - if(!sAbility.size() || (!target || _target != this->source)) + { + _target = static_cast(target); + isTargetable = (_target && !_target->currentZone && _target != this->source); + } + + if(!sAbility.size() || (!target || isTargetable)) { this->forceDestroy = 1; return; } else { - while(_target->next) + while(_target && _target->next) _target = _target->next; } + AbilityFactory af(game); MTGAbility * ability = af.parseMagicLine(sAbility, abilityId, NULL, _target); diff --git a/projects/mtg/src/DeckStats.cpp b/projects/mtg/src/DeckStats.cpp index d56abe8df..911499be6 100644 --- a/projects/mtg/src/DeckStats.cpp +++ b/projects/mtg/src/DeckStats.cpp @@ -392,7 +392,7 @@ void StatsWrapper::updateStats(DeckDataWrapper *myDeck) this->totalManaCost = 0; this->totalCreatureCost = 0; this->totalSpellCost = 0; - MTGCard * current = myDeck->getCard(); + MTGCard * current = NULL; // Clearing arrays for (int i = 0; i <= Constants::STATS_MAX_MANA_COST; i++) diff --git a/projects/mtg/src/ExtraCost.cpp b/projects/mtg/src/ExtraCost.cpp index 310de92e0..b9d25bbda 100644 --- a/projects/mtg/src/ExtraCost.cpp +++ b/projects/mtg/src/ExtraCost.cpp @@ -568,9 +568,14 @@ CounterCost * CounterCost::clone() const CounterCost * ec = NEW CounterCost(*this); if (tc) ec->tc = tc->clone(); + if (counter) ec->counter = NEW Counter(counter->target, counter->name.c_str(), counter->power, counter->toughness); - ec->counter->nb = counter->nb; + + //TODO: counter can be NULL at this point, what do we set ec->counter->nb to if it is? + if (ec->counter != NULL) + ec->counter->nb = counter->nb; + return ec; } diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index c4bc9e580..ffd6d65cd 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -932,6 +932,7 @@ int GameObserver::cardClick(MTGCardInstance * card, Targetable * object) if (ORDER == combatStep) { + //TODO it is possible at this point that card is NULL. if so, what do we return since card->defenser would result in a crash? card->defenser->raiseBlockerRankOrder(card); return 1; } diff --git a/projects/mtg/src/GameStateDuel.cpp b/projects/mtg/src/GameStateDuel.cpp index a904056ee..43a997c9d 100644 --- a/projects/mtg/src/GameStateDuel.cpp +++ b/projects/mtg/src/GameStateDuel.cpp @@ -24,7 +24,7 @@ #include "NetworkPlayer.h" #endif -#if defined (WIN32) || defined (LINUX) +#if defined (WIN32) || defined (LINUX) || defined(IOS) #include #endif diff --git a/projects/mtg/src/GameStateMenu.cpp b/projects/mtg/src/GameStateMenu.cpp index e9a149eb1..351ecac0b 100644 --- a/projects/mtg/src/GameStateMenu.cpp +++ b/projects/mtg/src/GameStateMenu.cpp @@ -747,7 +747,6 @@ void GameStateMenu::Render() } else { - PIXEL_TYPE colors[] = { ARGB(255,3,3,0), ARGB(255,8,8,0), ARGB(255,21,21,10), ARGB(255,50,50,30), }; diff --git a/projects/mtg/src/MTGGameZones.cpp b/projects/mtg/src/MTGGameZones.cpp index 3af05d45a..3187132b0 100644 --- a/projects/mtg/src/MTGGameZones.cpp +++ b/projects/mtg/src/MTGGameZones.cpp @@ -759,7 +759,7 @@ void MTGLibrary::shuffleTopToBottom(int nbcards) { _cards[i] = cards[i - nb_cards]; } - // Logic error here: the final value of cards[i] will always be garbage. possible optimization: use vectors to push and pop + //TODO Logic error here: the final value of cards[i] will always be garbage. possible optimization: use vectors to push and pop for (int i = 0; i < nb_cards; i++) { cards[i] = _cards[i]; @@ -845,6 +845,7 @@ MTGGameZone * MTGGameZone::intToZone(GameObserver *g, int zoneId, MTGCardInstanc p = source->controller(); if (!target) { + //TODO source may be NULL, need to handle the case when it is NULL. method declaration has NULL being default value of source and target. if(source->target) { //bug case, this is a patchwork fix for now diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index ed978320a..301d0e4fb 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -1123,9 +1123,9 @@ int MTGMorphCostRule::reactToClick(MTGCardInstance * card) } //------------------------------------------------------------------------ ManaCost * previousManaPool = NEW ManaCost(player->getManaPool()); - int payResult = player->getManaPool()->pay(card->getManaCost()->morph); + player->getManaPool()->pay(card->getManaCost()->morph); card->getManaCost()->morph->doPayExtra(); - payResult = ManaCost::MANA_PAID_WITH_MORPH; + int payResult = ManaCost::MANA_PAID_WITH_MORPH; //if morph has a extra payment thats set, this code pays it.the if statement is 100% needed as it would cause a crash on cards that dont have the morph cost. if (morph) { diff --git a/projects/mtg/src/Rules.cpp b/projects/mtg/src/Rules.cpp index 7f7a27178..e2430a7c8 100644 --- a/projects/mtg/src/Rules.cpp +++ b/projects/mtg/src/Rules.cpp @@ -15,7 +15,7 @@ vector Rules::RulesList = vector(); -//Sorting by dissplayName +//Sorting by displayName struct RulesMenuCmp{ bool operator()(const Rules * a,const Rules * b) const{ return a->displayName < b->displayName; @@ -305,6 +305,7 @@ Player * Rules::initPlayer(GameObserver *g, int playerId) return loadPlayerRandom(g, isAI, GAME_TYPE_RANDOM2); } } + //TODO p may still be NULL, what do we do to handle this? Above switch has no default case to handle the case where p is NULL p->phaseRing = initState.playerData[playerId].player->phaseRing; p->offerInterruptOnPhase = initState.playerData[playerId].player->offerInterruptOnPhase; return p; @@ -345,8 +346,10 @@ void Rules::initPlayers(GameObserver *g) if(p && g->getPlayersNumber() < 2) g->players.push_back(p); MTGDeck * deck = buildDeck(i); + if (deck) { + // TODO: p may be NULL, initPlayer(g, i) may return NULL, what do we do in this case? p->game->initDeck(deck); SAFE_DELETE(deck); p->game->setOwner(p); diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index c1406d00b..cb66c2aea 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -727,11 +727,17 @@ bool TargetChooser::canTarget(Targetable * target,bool withoutProtections) tempcard = tempcard->previous; } } + if(source && ((source->hasSubtype(Subtypes::TYPE_AURA) || source->hasSubtype(Subtypes::TYPE_EQUIPMENT)) && source->target && source->target == card && source->target->isPhased && targetter->target == card)) - return true; + { + return true; + } //this is kinda cheating but by default we let auras and equipments always continue to target a phased creature. - else if(card->isPhased) - return false; + else if (card && card->isPhased) + { + return false; + } + if (source && targetter && card->isInPlay(observer) && !withoutProtections) { if (card->has(Constants::SHROUD)) return false; diff --git a/projects/mtg/src/WGui.cpp b/projects/mtg/src/WGui.cpp index 8c7a18707..fef1e8b79 100644 --- a/projects/mtg/src/WGui.cpp +++ b/projects/mtg/src/WGui.cpp @@ -899,13 +899,12 @@ bool WGuiSplit::yieldFocus() } //WGuiMenu -WGuiMenu::WGuiMenu(JButton next = JGE_BTN_RIGHT, JButton prev = JGE_BTN_LEFT, bool m, WSyncable * syncme) : - WGuiItem("") +WGuiMenu::WGuiMenu(JButton next, JButton prev, bool dPad, WSyncable * syncme) : WGuiItem("") { buttonNext = next; buttonPrev = prev; currentItem = -1; - mDPad = m; + mDPad = dPad; sync = syncme; held = JGE_BTN_NONE; } @@ -1100,7 +1099,6 @@ bool WGuiMenu::nextItem() while (potential < nbitems - 1 && items[potential]->Selectable() == false) potential++; - if (potential != currentItem && (!now || now->Leaving(buttonNext))) { currentItem = potential; @@ -1130,9 +1128,9 @@ bool WGuiMenu::prevItem() while (potential > 0 && items[potential]->Selectable() == false) potential--; - if (potential < 0 || !items[potential]->Selectable()) - potential = -1; - else if (potential != currentItem && (!now || now->Leaving(buttonNext))) + + if ( (!(potential < 0 || !items[potential]->Selectable())) + && (potential != currentItem && (!now || now->Leaving(buttonNext)))) { currentItem = potential; items[currentItem]->Entering(buttonPrev); diff --git a/projects/mtg/wagic.xcodeproj/project.pbxproj b/projects/mtg/wagic.xcodeproj/project.pbxproj index da1255b9b..36822de2e 100755 --- a/projects/mtg/wagic.xcodeproj/project.pbxproj +++ b/projects/mtg/wagic.xcodeproj/project.pbxproj @@ -3,12 +3,13 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 45; objects = { /* Begin PBXBuildFile section */ - 122F4B501438D553003A9129 /* AIPlayerBaka.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 122F4B4E1438D553003A9129 /* AIPlayerBaka.cpp */; }; - 122F4B511438D553003A9129 /* AIPlayerBakaB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 122F4B4F1438D553003A9129 /* AIPlayerBakaB.cpp */; }; + 12769486144127380088F6D3 /* AIPlayerBaka.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12769483144127380088F6D3 /* AIPlayerBaka.cpp */; }; + 12769487144127380088F6D3 /* AIPlayerBakaB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12769484144127380088F6D3 /* AIPlayerBakaB.cpp */; }; + 12769488144127380088F6D3 /* TestSuiteAI.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12769485144127380088F6D3 /* TestSuiteAI.cpp */; }; 127D4C6F1376B33200109AB4 /* mtg.txt in Resources */ = {isa = PBXBuildFile; fileRef = 127D4C6E1376B33200109AB4 /* mtg.txt */; }; 12B812341404B9E20092E303 /* !Pak0.cpk in Resources */ = {isa = PBXBuildFile; fileRef = 12B8121F1404B9E10092E303 /* !Pak0.cpk */; }; 12B812351404B9E20092E303 /* !Pak1.cpk in Resources */ = {isa = PBXBuildFile; fileRef = 12B812201404B9E10092E303 /* !Pak1.cpk */; }; @@ -182,8 +183,11 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 122F4B4E1438D553003A9129 /* AIPlayerBaka.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AIPlayerBaka.cpp; sourceTree = ""; }; - 122F4B4F1438D553003A9129 /* AIPlayerBakaB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AIPlayerBakaB.cpp; sourceTree = ""; }; + 12769483144127380088F6D3 /* AIPlayerBaka.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AIPlayerBaka.cpp; sourceTree = ""; }; + 12769484144127380088F6D3 /* AIPlayerBakaB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AIPlayerBakaB.cpp; sourceTree = ""; }; + 12769485144127380088F6D3 /* TestSuiteAI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestSuiteAI.cpp; sourceTree = ""; }; + 127694891441274D0088F6D3 /* AIPlayerBaka.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AIPlayerBaka.h; sourceTree = ""; }; + 1276948A1441274D0088F6D3 /* AIPlayerBakaB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AIPlayerBakaB.h; sourceTree = ""; }; 127D4C6E1376B33200109AB4 /* mtg.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = mtg.txt; path = bin/Res/sets/primitives/mtg.txt; sourceTree = ""; }; 12B8121F1404B9E10092E303 /* !Pak0.cpk */ = {isa = PBXFileReference; lastKnownFileType = file; path = "!Pak0.cpk"; sourceTree = ""; }; 12B812201404B9E10092E303 /* !Pak1.cpk */ = {isa = PBXFileReference; lastKnownFileType = file; path = "!Pak1.cpk"; sourceTree = ""; }; @@ -671,6 +675,8 @@ CEA376851291C60500B9016A /* include */ = { isa = PBXGroup; children = ( + 127694891441274D0088F6D3 /* AIPlayerBaka.h */, + 1276948A1441274D0088F6D3 /* AIPlayerBakaB.h */, 12B812411404BCE30092E303 /* AIHints.h */, 12B812421404BCE30092E303 /* CacheEngine.h */, 12B812431404BCE30092E303 /* IconButton.h */, @@ -789,8 +795,9 @@ CEA376ED1291C60500B9016A /* src */ = { isa = PBXGroup; children = ( - 122F4B4E1438D553003A9129 /* AIPlayerBaka.cpp */, - 122F4B4F1438D553003A9129 /* AIPlayerBakaB.cpp */, + 12769483144127380088F6D3 /* AIPlayerBaka.cpp */, + 12769484144127380088F6D3 /* AIPlayerBakaB.cpp */, + 12769485144127380088F6D3 /* TestSuiteAI.cpp */, 12B8124A1404BD0D0092E303 /* IconButton.cpp */, 12B8124C1404BD0D0092E303 /* ObjectAnalytics.cpp */, CE9E71EA1375A62300759DDC /* ModRules.cpp */, @@ -1058,11 +1065,8 @@ /* Begin PBXProject section */ 29B97313FDCFA39411CA2CEA /* Project object */ = { isa = PBXProject; - attributes = { - LastUpgradeCheck = 0420; - }; buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "wagic" */; - compatibilityVersion = "Xcode 3.2"; + compatibilityVersion = "Xcode 3.1"; developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( @@ -1258,8 +1262,9 @@ 12B8123F1404B9E20092E303 /* zstream.cpp in Sources */, 12B8124D1404BD0D0092E303 /* IconButton.cpp in Sources */, 12B8124F1404BD0D0092E303 /* ObjectAnalytics.cpp in Sources */, - 122F4B501438D553003A9129 /* AIPlayerBaka.cpp in Sources */, - 122F4B511438D553003A9129 /* AIPlayerBakaB.cpp in Sources */, + 12769486144127380088F6D3 /* AIPlayerBaka.cpp in Sources */, + 12769487144127380088F6D3 /* AIPlayerBakaB.cpp in Sources */, + 12769488144127380088F6D3 /* TestSuiteAI.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1271,14 +1276,14 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - CODE_SIGN_IDENTITY = "iPhone Developer"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = wagic_Prefix.pch; GCC_PREPROCESSOR_DEFINITIONS = ( + TESTSUITE, + _DEBUG, IOS, DEBUG, DARWIN_NO_CARBON, @@ -1303,8 +1308,6 @@ ); "New Setting" = ""; PRODUCT_NAME = wagic; - PROVISIONING_PROFILE = ""; - "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = NO; SDKROOT = iphoneos; }; @@ -1315,8 +1318,6 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - CODE_SIGN_IDENTITY = "iPhone Distribution"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; COPY_PHASE_STRIP = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = testproject_Prefix.pch; @@ -1333,8 +1334,6 @@ "\"$(SDKROOT)/usr/lib/gcc/powerpc-apple-darwin9/4.0.1\"", ); PRODUCT_NAME = testproject; - PROVISIONING_PROFILE = ""; - "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; @@ -1344,18 +1343,16 @@ isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)"; - CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEPLOYMENT_LOCATION = NO; DEPLOYMENT_POSTPROCESSING = NO; GCC_C_LANGUAGE_STANDARD = c99; GCC_PREPROCESSOR_DEFINITIONS = DEBUG; - GCC_VERSION = ""; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ../../Boost/boost; - PROVISIONING_PROFILE = ""; - SDKROOT = iphoneos; + PREBINDING = NO; + SDKROOT = iphoneos3.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -1366,12 +1363,12 @@ ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; GCC_C_LANGUAGE_STANDARD = c99; - GCC_VERSION = ""; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ../../Boost/boost; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; - SDKROOT = iphoneos; + PREBINDING = NO; + SDKROOT = iphoneos4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release;