Ejemplo n.º 1
0
static WaypointPtr
FindWaypoint(Waypoints &way_points, const TCHAR *name)
{
  auto wp = way_points.LookupName(name);
  if (wp != nullptr)
    return wp;

  // TODO: Comments please! What is this supposed to do? Why do we need it?
  size_t name_length = _tcslen(name);
  TCHAR buffer[name_length + 4];
  _tcscpy(buffer, name);
  _tcscpy(buffer + name_length, _T(" AF"));
  wp = way_points.LookupName(buffer);
  if (wp != nullptr)
    return wp;

  _tcscpy(buffer + name_length, _T(" AD"));
  wp = way_points.LookupName(buffer);
  if (wp != nullptr)
    return wp;

  return nullptr;
}
Ejemplo n.º 2
0
static void
TestLookups(const Waypoints &waypoints, const GeoPoint &center)
{
  WaypointPtr waypoint;

  ok1((waypoint = waypoints.LookupId(0)) == NULL);
  ok1((waypoint = waypoints.LookupId(1)) != NULL);
  ok1(waypoint->original_id == 0);
  ok1((waypoint = waypoints.LookupId(151)) != NULL);
  ok1(waypoint->original_id == 150);
  ok1((waypoint = waypoints.LookupId(152)) == NULL);
  ok1((waypoint = waypoints.LookupId(160)) == NULL);

  ok1((waypoint = waypoints.LookupLocation(center, fixed(0))) != NULL);
  ok1(waypoint->original_id == 0);

  ok1((waypoint = waypoints.LookupName(_T("Waypoint #5"))) != NULL);
  ok1(waypoint->original_id == 4);

  ok1((waypoint = waypoints.LookupLocation(waypoint->location, fixed(10000))) != NULL);
  ok1(waypoint->original_id == 4);
}