[freeciv-ai] Re: Goto coordinates and ai roles
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Sat, Jan 18, 2003 at 12:05:39PM -0500, Ross W. Wetmore wrote:
>
> If you cannot rely on an arbitrary map_position to represent an invalid
> position (i.e. all map positions are potentially valid), then you need an
> extra bit of information somewhere. There are two common ways to do this.
>
> Set a goto_active guard bit and do things like
> if (punit->goto_active) {
> /* punit->goto_dest_x, punit->goto_dest_y accesses */
> }
>
> Make the goto_dest a map_position pointer and use null as the guard test.
> if (punit->goto_dest) {
> /* punit->goto_dest->x, punit->goto_dest->y accesses */
> }
>
> Note, the pointer can point back into the punit structure, so you don't
> need to track extra memory allocations, and can in fact directly access
> the punit goto(x,y) values if necessary, bypassing the guard check. The
> pointer acts very much as a guard test that allows you to turn the goto
> map_position on and off.
>
> Both of these mean breaking backwards compatibility for the (-1,-1)
> error assumptions including over network communications. But the tests
> are much simpler than a same_pos() or some unnormalized version to
> detect the special case.
yes, either of these is far better than (-1,-1) which I've never ever had a
good feeling about. Take your pick really, but I prefer the the map_position
pointer because it's cleaner...
-mike
- [freeciv-ai] Re: Goto coordinates and ai roles, Ross W. Wetmore, 2003/01/18
- [freeciv-ai] Re: Goto coordinates and ai roles,
Mike Kaufman <=
- [freeciv-ai] Re: Goto coordinates and ai roles, Per I. Mathisen, 2003/01/20
- Message not available
- [freeciv-ai] Re: Goto coordinates and ai roles, Raimar Falke, 2003/01/21
- [freeciv-ai] Re: Goto coordinates and ai roles, Ross W. Wetmore, 2003/01/23
- [freeciv-ai] Re: Goto coordinates and ai roles, Raimar Falke, 2003/01/24
- [freeciv-ai] Re: Goto coordinates and ai roles, Gregory Berkolaiko, 2003/01/27
- [freeciv-ai] Re: Goto coordinates and ai roles, Ross Wetmore, 2003/01/27
- [freeciv-ai] Re: Goto coordinates and ai roles, Gregory Berkolaiko, 2003/01/28
- [freeciv-ai] Re: Goto coordinates and ai roles, Per I. Mathisen, 2003/01/28
- [freeciv-ai] Re: Goto coordinates and ai roles, Raimar Falke, 2003/01/29
- [freeciv-ai] Re: Goto coordinates and ai roles, Gregory Berkolaiko, 2003/01/29
|
|