size_t LocationManager::FindLocationsInSector(iEngine* engine, iSector* sector, csList<Location*> &list) { size_t count = 0; for(size_t i=0; i<all_locations.GetSize(); i++) { Location* location = all_locations[i]; if(location->GetSector(engine) == sector) { list.PushBack(location); count++; } } return count; }
Location* LocationManager::FindNearestLocation(psWorld* world, csVector3 &pos, iSector* sector, float range, float* found_range) { float min_range = range; Location* min_location = NULL; for(size_t i=0; i<all_locations.GetSize(); i++) { Location* location = all_locations[i]; float dist2 = world->Distance(pos,sector,location->pos,location->GetSector(world->GetEngine())); if(min_range < 0 || dist2 < min_range) { min_range = dist2; min_location = location; } } if(min_location && found_range) *found_range = min_range; return min_location; }