Skip to content

Commit

Permalink
Random crash when a goal is completed
Browse files Browse the repository at this point in the history
fixes #208
  • Loading branch information
hwoarangmy committed Sep 30, 2014
1 parent 5bb2f16 commit 658047e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions source/Seat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ void Seat::incrementNumClaimedTiles()
unsigned int Seat::checkAllGoals()
{
// Loop over the goals vector and move any goals that have been met to the completed goals vector.
std::vector<Goal*> goalsToAdd;
std::vector<Goal*>::iterator currentGoal = mUncompleteGoals.begin();
while (currentGoal != mUncompleteGoals.end())
{
Expand All @@ -121,7 +122,7 @@ unsigned int Seat::checkAllGoals()

// Add any subgoals upon completion to the list of outstanding goals.
for (unsigned int i = 0; i < goal->numSuccessSubGoals(); ++i)
mUncompleteGoals.push_back(goal->getSuccessSubGoal(i));
goalsToAdd.push_back(goal->getSuccessSubGoal(i));

currentGoal = mUncompleteGoals.erase(currentGoal);

Expand All @@ -135,7 +136,7 @@ unsigned int Seat::checkAllGoals()

// Add any subgoals upon completion to the list of outstanding goals.
for (unsigned int i = 0; i < goal->numFailureSubGoals(); ++i)
mUncompleteGoals.push_back(goal->getFailureSubGoal(i));
goalsToAdd.push_back(goal->getFailureSubGoal(i));

currentGoal = mUncompleteGoals.erase(currentGoal);
}
Expand All @@ -147,6 +148,12 @@ unsigned int Seat::checkAllGoals()
}
}

for(std::vector<Goal*>::iterator it = goalsToAdd.begin(); it != goalsToAdd.end(); ++it)
{
Goal* goal = *it;
mUncompleteGoals.push_back(goal);
}

return numUncompleteGoals();
}

Expand Down

0 comments on commit 658047e

Please sign in to comment.