void psPathNetwork::ListWaypoints(const char * pattern)
{
    csPDelArray<Waypoint>::Iterator iter(waypoints.GetIterator());
    Waypoint *wp;
    CPrintf(CON_CMDOUTPUT, "Waypoints\n");
    CPrintf(CON_CMDOUTPUT, "%9s %-30s %-45s %-6s %-6s %-30s\n", "WP", "Name", "Position","Radius","Dist","PI");
    while (iter.HasNext())
    {
        wp = iter.Next();

        if (!pattern || strstr(wp->GetName(),pattern))
        {
            CPrintf(CON_CMDOUTPUT, "%9d %-30s %-45s %6.2f %6.1f %-30s" ,
                    wp->loc.id,wp->GetName(),toString(wp->loc.pos,wp->loc.sector).GetDataSafe(),
                    wp->loc.radius,wp->distance,
                    (wp->pi?wp->pi->GetName():""));

            for (size_t i = 0; i < wp->links.GetSize(); i++)
            {
                CPrintf(CON_CMDOUTPUT," %s%s(%d,%.1f)",(wp->edges[i]->NoWander()?"#":""),
                        wp->links[i]->GetName(),wp->links[i]->GetID(),wp->dists[i]);
            }

            CPrintf(CON_CMDOUTPUT,"\n");
        }
    }

    CPrintf(CON_CMDOUTPUT, "Waypoint groups\n");

    for (size_t i = 0; i < waypointGroupNames.GetSize(); i++)
    {
        CPrintf(CON_CMDOUTPUT,"%s\n  ",waypointGroupNames[i].GetDataSafe());
        csList<Waypoint*>::Iterator iter(waypointGroups[i]);
        bool first = true;
        while (iter.HasNext())
        {
           Waypoint *wp = iter.Next();
           CPrintf(CON_CMDOUTPUT,"%s%s(%d)",first?"":", ",wp->GetName(),wp->GetID());
           first = false;
        }
        CPrintf(CON_CMDOUTPUT,"\n");
    }
    
}
Waypoint *psPathNetwork::FindWaypoint(const char * name, WaypointAlias** alias)
{
    csPDelArray<Waypoint>::Iterator iter(waypoints.GetIterator());
    Waypoint *wp;

    while (iter.HasNext())
    {
        wp = iter.Next();

        // Check name
        if (strcasecmp(wp->GetName(),name)==0)
        {
            if (alias)
            {
                *alias = NULL;
            }
            
            return wp;
        }
        // Check for aliases
        for (size_t i = 0; i < wp->aliases.GetSize(); i++)
        {
            if (strcasecmp(wp->aliases[i]->alias,name)==0)
            {
                if (alias)
                {
                    *alias = wp->aliases[i];
                }

                return wp; // Found name in aliases
            }
        }
    }
    
    return NULL;
}