Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2003:
[Freeciv-Dev] Re: Waypoints for path-finding
Home

[Freeciv-Dev] Re: Waypoints for path-finding

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Raimar Falke <rf13@xxxxxxxxxxxxxxxxx>
Cc: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: Waypoints for path-finding
From: Gregory Berkolaiko <Gregory.Berkolaiko@xxxxxxxxxxxx>
Date: Tue, 1 Apr 2003 13:05:30 +0100 (BST)

On Tue, 1 Apr 2003, Raimar Falke wrote:

> On Tue, Apr 01, 2003 at 11:27:19AM +0100, Gregory Berkolaiko wrote:
> > 
> > This is how the current behaviour functions:
> > 1. user hits "g"
> > 2. goto map from the unit position is generated
> > 3. user moves mouse, the goto line from the unit position to the mouse 
> >    location is drawn
> > 4. user hits "g" (to add a waypoint)
> > 5. goto map from the waypoint position is generated
> > 6. user moves mouse, the goto line from the waypoint position to the mouse 
> >    location is drawn
> > 7. loop to 4
> > 
> > For details see insert_waypoint and around.
> > 
> > How do you plan to change it and at which stage you would call the 
> > function
> >  struct pf_path *pft_get_path(const struct pf_parameter *const parameter,
> >                               int end_x, int end_y,
> >                               int num_waypoints,
> >                               struct map_position *waypoints);
> 
> The simplest solution: some code remembers the waypoints (like the
> current code does) and every time the mouse moves the above new
> function is called.

*sigh* I wish you thought before writing this.

After k-th waypoint is specified, the paths
        waypoint[0] -> waypoint[1] -> ... -> waypoint[k]
are all fixed.  There is no need to recompute them. All user is interested 
in is the path 
        waypoint[k] -> mouse_location,
which can be obtained by calling
        parameter.x = waypoint[k].x
        parameter.y = waypoint[k].y
        /* The rest of parameter remains the same */
        map = pf_create_map(parameter)
        path = pf_get_path(map, mouse.x, mouse.y)
        draw_segment(path)

G.



[Prev in Thread] Current Thread [Next in Thread]