Complete.Org: Mailing Lists: Archives: freeciv-ai: January 2003:
[freeciv-ai] Re: Goto coordinates and ai roles
Home

[freeciv-ai] Re: Goto coordinates and ai roles

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Cc: Freeciv AI development <freeciv-ai@xxxxxxxxxxx>
Subject: [freeciv-ai] Re: Goto coordinates and ai roles
From: Gregory Berkolaiko <Gregory.Berkolaiko@xxxxxxxxxxxx>
Date: Mon, 27 Jan 2003 18:06:29 +0000 (GMT)

On Thu, 23 Jan 2003, Ross W. Wetmore wrote:

> The map_position pointer (to independently allocated storage) is a bit
> of a maintenance headache as Raimar suggests. Go the step further and
> just don't do it that way.
> 
> Instead, add the pointer to the punit struct, and point it back at the
> goto_dest_x, goto_dest_y elements which you can convert to an unnamed
> map_position, or a union of the existing elements and a map_position
> if you need to preserve backwards compatibility. There is no need to
> worry about managing memory - ever as that is done when the punit struct
> is created and destroyed, and it is the only one to use this memory.
> 
> If the pointer is null the goto_dest locations are not valid, if it is
> non-null it is pointed correctly and can be used to access the values,
> i.e. to set a goto_dest, fill in the values (just like now) and point
> to the &punit->goto_dest_x or however you reference it. To mark it as
> invalid, just null out the pointer.

This is a rather imaginative approach, which invokes some rather rude 
associations in my dirty mind.

If I understand it correctly, this pointer will have only two possible 
values: pointing to the unit itself, or just NULL.  I think there is a 
special name for a variable which takes only two values (and it doesn't 
invoke any rude associations in my mind, yet).  Why not use it?

Best wishes,
G.



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