Flagged numerous peices of code that have local variables that are masking either member variables or variables scoped outside the current scope.

I've marked all the ones I found with the following TODO comment:

TODO: C6246: <blah blah>

a few in particular are the ones related to "oneShot" and "_target".  These are local variables that are declared that
mask either a method parameter or a member variable.
This commit is contained in:
techdragon.nguyen@gmail.com
2011-04-21 10:04:32 +00:00
parent 8ed84aa97d
commit 8bf983e2e5
13 changed files with 70 additions and 53 deletions

View File

@@ -1618,11 +1618,11 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
size_t end = s.find("]", start);
string s1 = s.substr(start + 1, end - start - 1);
int phase = Constants::MTG_PHASE_UPKEEP;
for (int i = 0; i < Constants::NB_MTG_PHASES; i++)
for (int phaseIdx = 0; phaseIdx < Constants::NB_MTG_PHASES; phaseIdx++)
{
if (s1.find(Constants::MTGPhaseCodeNames[i]) != string::npos)
if (s1.find(Constants::MTGPhaseCodeNames[phaseIdx]) != string::npos)
{
phase = i;
phase = phaseIdx;
}
}
bool opponentturn = true,myturn = true;
@@ -1685,13 +1685,13 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
int once = 0;
if (seperator != string::npos)
{
for (int i = 0; i < Constants::NB_MTG_PHASES; i++)
for (int phaseIdx = 0; phaseIdx < Constants::NB_MTG_PHASES; phaseIdx++)
{
if (s1.find("next") != string::npos)
once = 1;
if (s1.find(Constants::MTGPhaseCodeNames[i]) != string::npos)
if (s1.find(Constants::MTGPhaseCodeNames[phaseIdx]) != string::npos)
{
phase = i;
phase = phaseIdx;
}
}
s1 = s1.substr(0, seperator - 1);
@@ -2297,12 +2297,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
}
//Cast/Play Restrictions
for (size_t i = 0; i < kMaxCastKeywordsCount; ++i)
for (size_t castPlayIdx = 0; castPlayIdx < kMaxCastKeywordsCount; ++castPlayIdx)
{
found = s.find(kMaxCastKeywords[i]);
found = s.find(kMaxCastKeywords[castPlayIdx]);
if (found != string::npos)
{
size_t header = kMaxCastKeywords[i].size();
size_t header = kMaxCastKeywords[castPlayIdx].size();
size_t end = s.find(")");
string targetsString = s.substr(found + header, end - found - header);
TargetChooserFactory tcf;
@@ -2329,7 +2329,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
{
return NEW AInstantCastRestrictionUEOT(id, card, t, castTargets, value, modifyExisting, kMaxCastZones[i], who);
}
return NEW ACastRestriction(id, card, t, castTargets, value, modifyExisting, kMaxCastZones[i], who);
return NEW ACastRestriction(id, card, t, castTargets, value, modifyExisting, kMaxCastZones[castPlayIdx], who);
//TODO NEW ACastRestrictionUntilEndOfTurn(id, card, t, value, modifyExisting, kMaxCastZones[i], who);
}
}
@@ -2578,9 +2578,11 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
{
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;
stypesStartIndex = found + 12;
extraTransforms.append(transformsParamsString.substr(stypesStartIndex, real_end - stypesStartIndex).c_str());
transformsParamsString.erase(stypesStartIndex, real_end - stypesStartIndex);
}
@@ -2597,14 +2599,13 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
vector<string> newAbilitiesList;
storedString.erase();
storedString.append(extraTransforms);
extraTransforms.erase();
for (unsigned int i = 0 ; i < abilities.size() ; i++)
{
if(abilities[i].empty())
abilities.erase(abilities.begin()+i);
}
extraTransforms.erase();
for(unsigned int j = 0;j < abilities.size();j++)
{
if (abilities[j].empty())
continue;
if(abilities[j].find("setpower=") != string::npos)
{
newpowerfound = true;
@@ -3205,8 +3206,10 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card, int
if (dryMode)
{
result = abilityEfficiency(a, card->controller(), mode, tc);
for (size_t i = 0; i < v.size(); ++i)
SAFE_DELETE(v[i]);
for (vector<MTGAbility *>::iterator it = v.begin(); it != v.end(); ++it )
SAFE_DELETE(*it);
return result;
}
@@ -3488,6 +3491,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell)
MTGInPlay * inplay = game->players[i]->game->inPlay;
for (int j = inplay->nb_cards - 1; j >= 0; j--)
{
// TODO: C6246: Clarify card, is this independant of the "card" declared outside this scope?
MTGCardInstance * card = inplay->cards[j];
if (card->owner == player && card->hasType(Subtypes::TYPE_ARTIFACT))
{
@@ -3644,14 +3648,14 @@ void AbilityFactory::addAbilities(int _id, Spell * spell)
case 3410: //Seed of Innocence
{
GameObserver * game = GameObserver::GetInstance();
for (int i = 0; i < 2; i++)
for (int playerIdx = 0; playerIdx < 2; playerIdx++)
{
for (int j = 0; j < game->players[i]->game->inPlay->nb_cards; j++)
for (int j = 0; j < game->players[playerIdx]->game->inPlay->nb_cards; j++)
{
MTGCardInstance * current = game->players[i]->game->inPlay->cards[j];
MTGCardInstance * current = game->players[playerIdx]->game->inPlay->cards[j];
if (current->hasType("Artifact"))
{
game->players[i]->game->putInGraveyard(current);
game->players[playerIdx]->game->putInGraveyard(current);
current->controller()->gainLife(current->getManaCost()->getConvertedCost());
}
}
@@ -3808,7 +3812,6 @@ void AbilityFactory::addAbilities(int _id, Spell * spell)
if (card->hasType(Subtypes::TYPE_INSTANT) || card->hasType(Subtypes::TYPE_SORCERY))
{
MTGPlayerCards * zones = card->controller()->game;
if (card->alternateCostPaid[ManaCost::MANA_PAID_WITH_BUYBACK] > 0)
{
zones->putInZone(card, zones->stack, zones->hand);