//loop over on feature list until all connections are made
while (feature_list.empty()==false)
{
for (vector<Feature>::iterator i=feature_list.begin(); i!=feature_list.end(); ++i)
{
feat=(*i).Search_New_Connection(my_level, &area, spot);
//remove the feature if it doesn't have space
if (feat==-1)
{
//create left-over connections before removing it
(*i).Create_Connections(my_level);
feature_list.erase(i);
break;
}
else
{
//break when new item is added
Pop_Feature(spot, area, feat);
break;
}
}
}
the static analysis is detecting that feature_list is always empty.There is one strange warning that Visual Studio generates. It says "unreachable code" after the first line of this piece, but it is some kind of false positive, because the code inside that while loop is reached and it seems to work just fine. I think VS is seeing something strange about that while loop.
Code://loop over on feature list until all connections are made while (feature_list.empty()==false) { for (vector<Feature>::iterator i=feature_list.begin(); i!=feature_list.end(); ++i) { feat=(*i).Search_New_Connection(my_level, &area, spot); //remove the feature if it doesn't have space if (feat==-1) { //create left-over connections before removing it (*i).Create_Connections(my_level); feature_list.erase(i); break; } else { //break when new item is added Pop_Feature(spot, area, feat); break; } } }
int amt_of_branches=0;
while (feature_list.size()>0)
{
vector<Feature>::iterator i=feature_list.begin();
feat=(*i).Search_New_Connection(my_level, &area, spot);
//no new places found from this feature
if (feat==-1)
{
//create left-over connections to the last feature before removing it
(*i).Create_Connections(my_level);
feature_list.erase(i);
}
else
{
//or add a new feature
Add_Feature(spot, area, feat);
amt_of_branches++;
}
}