fixed memory leak in double tap gesture

fixed some compiler warnings
removed dead and useless code
This commit is contained in:
techdragon.nguyen@gmail.com
2011-10-08 00:56:07 +00:00
parent 9f09bbeec3
commit fbe2e44814
14 changed files with 53 additions and 51 deletions

View File

@@ -109,7 +109,7 @@ bool JOBJModel::Load(const char *modelName, const char *textureName)
face.mVertCount = 0;
char *p = strchr(tmpLine, ' ');
char *pNext = p;
char *pNext = NULL;
int vertIdx, texIdx, norIdx;

View File

@@ -225,6 +225,7 @@ void DestroyGame(void)
[menuKeyRecognizer release];
[selectKeyRecognizer release];
[doubleTapRecognizer release];
[singleTapRecognizer release];
}
@@ -282,7 +283,7 @@ 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]))
if (( self = [super initWithCoder:coder] ))
{
self = [self initialize];
}

View File

@@ -87,7 +87,7 @@ int AIAction::clickMultiAct(vector<Targetable*>& actionTargets)
{
GameObserver * g = owner->getObserver();
TargetChooser * tc = g->getCurrentTargetChooser();
bool sourceIncluded = false;
if(!tc) return 0;
for(size_t f = 0;f < actionTargets.size();f++)
{
@@ -96,7 +96,6 @@ int AIAction::clickMultiAct(vector<Targetable*>& actionTargets)
{
g->cardClick(card);
actionTargets.erase(actionTargets.begin() + f);
sourceIncluded = true;
}
}
std::random_shuffle(actionTargets.begin(), actionTargets.end());
@@ -157,7 +156,6 @@ int AIPlayer::Act(float dt)
int AIPlayer::clickMultiTarget(TargetChooser * tc, vector<Targetable*>& potentialTargets)
{
bool sourceIncluded = false;
for(int f = 0;f < int(potentialTargets.size());f++)
{
MTGCardInstance * card = ((MTGCardInstance *) potentialTargets[f]);
@@ -167,7 +165,6 @@ int AIPlayer::clickMultiTarget(TargetChooser * tc, vector<Targetable*>& potentia
clickstream.push(NEW AIAction(this, card));
DebugTrace("Ai clicked source as a target: " << (card ? card->name : "None" ) << endl );
potentialTargets.erase(potentialTargets.begin() + f);
sourceIncluded = true;
}
if(pTarget && pTarget->typeAsTarget() == TARGET_PLAYER)
{

View File

@@ -634,7 +634,6 @@ MTGCardInstance * AIPlayerBaka::chooseCard(TargetChooser * tc, MTGCardInstance *
}
}
}
playerZones = source->controller()->opponent()->game;
}
return NULL;
}
@@ -1042,7 +1041,6 @@ vector<MTGAbility*> AIPlayerBaka::canPaySunBurst(ManaCost * cost)
//Make sure we can use the ability
if(fullColor == needColorConverted || fullColor == cost->getConvertedCost())
{
i = observer->mLayers->actionLayer()->manaObjects.size();
break;
}
MTGAbility * a = ((MTGAbility *) observer->mLayers->actionLayer()->manaObjects[i]);
@@ -1078,6 +1076,7 @@ vector<MTGAbility*> AIPlayerBaka::canPaySunBurst(ManaCost * cost)
}
}
}
for(int i = fullColor;i < cost->getConvertedCost();i++)
{
for (size_t i = 0; i < observer->mLayers->actionLayer()->manaObjects.size(); i++)
@@ -1833,13 +1832,8 @@ int AIPlayerBaka::computeActions()
case Constants::MTG_PHASE_SECONDMAIN:
{
ManaCost * currentMana = getPotentialMana();
bool potential = false;
currentMana->add(this->getManaPool());
if (currentMana->getConvertedCost())
{
//if theres mana i can use there then potential is true.
potential = true;
}
nextCardToPlay = FindCardToPlay(currentMana, "land");
//look for the most expensive creature we can afford. If not found, try enchantment, then artifact, etc...
const char* types[] = {"creature", "enchantment", "artifact", "sorcery", "instant"};

View File

@@ -35,9 +35,12 @@ int ActionLayer::removeFromGame(ActionElement * e)
if (i == -1)
return 0; //Should not happen, it means we deleted thesame object twice?
AbilityFactory af(observer);
if(dynamic_cast<MTGAbility*>(e))
MTGAbility * a = dynamic_cast<MTGAbility*>(e);
if (a != NULL)
{
AManaProducer * manaObject = dynamic_cast<AManaProducer*>(af.getCoreAbility((MTGAbility*)e));
AManaProducer * manaObject = dynamic_cast<AManaProducer*>(af.getCoreAbility(a));
if(manaObject)
{
for (size_t i = 0; i < manaObjects.size(); i++)

View File

@@ -2311,7 +2311,6 @@ int MenuAbility::resolve()
{
this->triggered = 1;
MTGAbility * a = this;
a->target = this->target;
return a->addToGame();
}
@@ -3522,7 +3521,7 @@ void APhaseAction::Update(float dt)
MTGCardInstance * _target = NULL;
if(target)
_target = (MTGCardInstance *) target;
if(!sAbility.size() || (!target||(!_target->currentZone && _target != this->source)))
if(!sAbility.size() || (!target || _target != this->source))
{
this->forceDestroy = 1;
return;
@@ -4159,7 +4158,6 @@ void ATutorialMessage::Render()
posY += 30;
f->DrawString(_(mMessage).c_str(), posX, posY);
posY += 20;
f->SetScale(1);
}

View File

@@ -420,9 +420,6 @@ GameOption& GameOptions::operator[](string optionName)
GameOption * GameOptions::factorNewGameOption(string optionName, string value)
{
if (optionName == "prx_rimom")
int a = 0;
GameOption * result =( Unlockable::unlockables.find(optionName) != Unlockable::unlockables.end())
? NEW GameOptionAward()
: NEW GameOption();
@@ -435,9 +432,6 @@ GameOption * GameOptions::factorNewGameOption(string optionName, string value)
GameOption * GameOptions::get(string optionName)
{
if (optionName == "prx_rimom")
int a = 0;
if (!unknownMap[optionName])
{
unknownMap[optionName] = factorNewGameOption(optionName);

View File

@@ -747,7 +747,7 @@ void GameStateMenu::Render()
}
else
{
mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
PIXEL_TYPE colors[] = {
ARGB(255,3,3,0), ARGB(255,8,8,0), ARGB(255,21,21,10), ARGB(255,50,50,30), };

View File

@@ -22,9 +22,12 @@ void GuiLayer::Add(JGuiObject *object)
{
mObjects.push_back(object);
AbilityFactory af(observer);
if(dynamic_cast<MTGAbility*>(object))
MTGAbility * a = dynamic_cast<MTGAbility*>(object);
if (a != NULL)
{
AManaProducer * manaObject = dynamic_cast<AManaProducer*>(af.getCoreAbility((MTGAbility*)object));
AManaProducer * manaObject = dynamic_cast<AManaProducer*>(af.getCoreAbility(a));
if(manaObject)
{
manaObjects.push_back(object);
@@ -36,9 +39,11 @@ int GuiLayer::Remove(JGuiObject *object)
{
AbilityFactory af(observer);
if(dynamic_cast<MTGAbility*>(object))
MTGAbility * a = dynamic_cast<MTGAbility*>(object);
if (a != NULL)
{
AManaProducer * manaObject = dynamic_cast<AManaProducer*>(af.getCoreAbility((MTGAbility*)object));
AManaProducer * manaObject = dynamic_cast<AManaProducer*>(af.getCoreAbility(a));
if(manaObject)
{
for (size_t i = 0; i < manaObjects.size(); i++)

View File

@@ -154,7 +154,7 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe
firstAmount = ttc->countValidTargets();
firstAmount += mod;
}
mod = 0;
SAFE_DELETE(ttc);
}
}
@@ -911,9 +911,6 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
if (found != string::npos && storedString.empty())
{
size_t real_end = s.find("))", found);
size_t end = s.find(",", found);
if (end == string::npos)
end = real_end;
size_t stypesStartIndex = found + 12;
storedString.append(s.substr(stypesStartIndex, real_end - stypesStartIndex).c_str());
s.erase(stypesStartIndex, real_end - stypesStartIndex);
@@ -2158,9 +2155,6 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
if (found != string::npos && extraTransforms.empty())
{
size_t real_end = transformsParamsString.find("))", found);
size_t end = transformsParamsString.find(",", found);
if (end == string::npos)
end = real_end;
size_t stypesStartIndex = found + 12;
extraTransforms.append(transformsParamsString.substr(stypesStartIndex, real_end - stypesStartIndex).c_str());
transformsParamsString.erase(stypesStartIndex, real_end - stypesStartIndex);
@@ -2442,7 +2436,6 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
MTGAbility * AbilityFactory::parseUpkeepAbility(string s,MTGCardInstance * card,Spell * spell,int restrictions,int id)
{
MTGAbility * a1 = NULL;
bool Cumulative = false;
size_t cumulative = s.find("cumulativeupcost");
if(cumulative != string::npos)
@@ -2681,9 +2674,6 @@ int AbilityFactory::getAbilities(vector<MTGAbility *> * v, Spell * spell, MTGCar
card = spell->source;
if (!card)
return 0;
MTGCardInstance * target = card->target;
if (!target)
target = card;
string magicText;
if (dest)

View File

@@ -759,6 +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
for (int i = 0; i < nb_cards; i++)
{
cards[i] = _cards[i];

View File

@@ -519,7 +519,6 @@ void TaskList::Render()
if (0 == tasks.size())
{
f->DrawString(_("There are no tasks that need to be done. Come again tomorrow.").c_str(), posX, posY);
posY += 20;
return;
}

View File

@@ -1100,9 +1100,8 @@ bool WGuiMenu::nextItem()
while (potential < nbitems - 1 && items[potential]->Selectable() == false)
potential++;
if (potential == nbitems || !items[potential]->Selectable())
potential = -1;
else if (potential != currentItem && (!now || now->Leaving(buttonNext)))
if (potential != currentItem && (!now || now->Leaving(buttonNext)))
{
currentItem = potential;
items[currentItem]->Entering(buttonNext);

View File

@@ -3,10 +3,12 @@
archiveVersion = 1;
classes = {
};
objectVersion = 45;
objectVersion = 46;
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 */; };
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 */; };
@@ -180,6 +182,8 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
122F4B4E1438D553003A9129 /* AIPlayerBaka.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AIPlayerBaka.cpp; sourceTree = "<group>"; };
122F4B4F1438D553003A9129 /* AIPlayerBakaB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AIPlayerBakaB.cpp; sourceTree = "<group>"; };
127D4C6E1376B33200109AB4 /* mtg.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = mtg.txt; path = bin/Res/sets/primitives/mtg.txt; sourceTree = "<group>"; };
12B8121F1404B9E10092E303 /* !Pak0.cpk */ = {isa = PBXFileReference; lastKnownFileType = file; path = "!Pak0.cpk"; sourceTree = "<group>"; };
12B812201404B9E10092E303 /* !Pak1.cpk */ = {isa = PBXFileReference; lastKnownFileType = file; path = "!Pak1.cpk"; sourceTree = "<group>"; };
@@ -785,6 +789,8 @@
CEA376ED1291C60500B9016A /* src */ = {
isa = PBXGroup;
children = (
122F4B4E1438D553003A9129 /* AIPlayerBaka.cpp */,
122F4B4F1438D553003A9129 /* AIPlayerBakaB.cpp */,
12B8124A1404BD0D0092E303 /* IconButton.cpp */,
12B8124C1404BD0D0092E303 /* ObjectAnalytics.cpp */,
CE9E71EA1375A62300759DDC /* ModRules.cpp */,
@@ -1052,8 +1058,11 @@
/* Begin PBXProject section */
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0420;
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "wagic" */;
compatibilityVersion = "Xcode 3.1";
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
@@ -1249,6 +1258,8 @@
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 */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1260,6 +1271,8 @@
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;
@@ -1290,6 +1303,8 @@
);
"New Setting" = "";
PRODUCT_NAME = wagic;
PROVISIONING_PROFILE = "";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = NO;
SDKROOT = iphoneos;
};
@@ -1300,6 +1315,8 @@
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;
@@ -1316,6 +1333,8 @@
"\"$(SDKROOT)/usr/lib/gcc/powerpc-apple-darwin9/4.0.1\"",
);
PRODUCT_NAME = testproject;
PROVISIONING_PROFILE = "";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
@@ -1325,16 +1344,18 @@
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;
PREBINDING = NO;
SDKROOT = iphoneos3.2;
PROVISIONING_PROFILE = "";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
@@ -1345,12 +1366,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";
PREBINDING = NO;
SDKROOT = iphoneos4.2;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;