int g = 0;
bool hascar = type == cop_car;
+ ;
+ SPInfo* n = 0;
while(!pq.empty()){
node = pq.top();
pq.pop();
- //cerr << "Vector with size: " << w.size() << endl;
- //cerr << "Looking at: " << node->name << endl;
- //copy(w.begin(), w.end(), ostream_iterator<string>(cerr, " : "));
g = goal(node);
if (g < 0)
}
node->settled = true;
- Intersection& inter = _intersections[node->name];
- for (hash_map<string,StreetType>::const_iterator street = inter.connections.begin();
- street != inter.connections.end(); ++street){
+ hash_map<string,Intersection>::const_iterator intersection = _intersections.find(node->name);
+ if (intersection == _intersections.end()){ //Sanity check, should never be true..
+ cerr << "BUG: Could not find intersection: " << node->name << endl;
+ continue;
+ }
+ for (hash_map<string,StreetType>::const_iterator street = intersection->second.connections.begin();
+ street != intersection->second.connections.end(); ++street){
hash_map<string,SPInfo>::iterator newNode = nodes.find(street->first);
bool travelStreet = false;
if (hascar){
if (reverse){
if (street->second != foot){
- hash_map<string,StreetType>::const_iterator st = _intersections[street->first].connections.find(node->name);
- if (st != _intersections[street->first].connections.end())
- travelStreet = st->second != foot;
- else
- travelStreet = false;
+ hash_map<string,Intersection>::const_iterator newInter = _intersections.find(street->first);
+ if (newInter != _intersections.end()){
+ hash_map<string,StreetType>::const_iterator st = newInter->second.connections.find(node->name);
+ if (st != newInter->second.connections.end())
+ travelStreet = st->second != foot;
+ }
}else
travelStreet = true;
}else
}
if (travelStreet){
//cerr << "Adding street: " << street->first << endl;
- SPInfo* n = 0;
if (newNode == nodes.end()){
n = &nodes[street->first];
n->name = street->first;