Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2003:
[Freeciv-Dev] Re: (PR#2690) [PATCH] Show unit location in its descriptio
Home

[Freeciv-Dev] Re: (PR#2690) [PATCH] Show unit location in its descriptio

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#2690) [PATCH] Show unit location in its description
From: "Stepan Roh via RT" <rt@xxxxxxxxxxxxxx>
Date: Fri, 3 Jan 2003 03:49:08 -0800
Reply-to: rt@xxxxxxxxxxxxxx



On Fri, 3 Jan 2003, Jason Short via RT wrote:

>
> [stepan@xxxxxxxx - Tue Dec 31 13:37:55 2002]:
>
> > Implemented (without coordinates):
> >
> > > - supported units should have indication of current location
> > > (coordinates and city name or "near <city name>", just like in civ2)
> >
> > Features:
> >
> > - in unit description (used e.g. in supported unit info in city dialog)
> > new line is added below home city: there could be "in <city>", "near
> > <city>", "far from <city>" (if distance is more than 6 tiles) or nothing.
> > Player's own cities have higher precedence than enemy cities if equally
> > distant.
> >
> > Known bugs:
> >
> > - could be slow
> >
> > Patch attached (cvs diff -u agains latest CVS HEAD).
> >
> > Tested with gtk client.
> >
> > Have a nice day.
>
> This is a nice concept.

Thanks (it's inspired by Civ2 except for "far from" which is my
invention).

> Looping over every city to find the one closest to the unit is OK given
> the current users of unit_description.  But since the function is in
> common/ the server might be tempted to use it, and that would be bad.
>
> You could move the function into client/, putting it in
> client/climisc.h.  Then the current implementation could stay.  Or you
> could use an outward_iterate operation to find the nearest city,
> although this will not always be faster.

I tried to, but for unknown reason I was not successful. And if I
understand that macro correctly (is not its name iterate_outward?) it has
max. range so some units would have to have "far away" label without any
city. And it can't prefer player's own cities to enemy ones.

> Another issue is that
>
>   Settlers
>   Moves: 0
>   Washington
>   near Washington
>
> is confusing.  Perhaps it should be "from Washington" instead of just
> "Washington"?

Yeah, good point.

> And perhaps this function is overkill to begin with - it should be left
> up to the GUI code to generate the string (or do whatever layout it
> wants with the data), and all the client-common code should do is
> provide a helper function to find the nearest city.

Yes, sounds good.

> As a side note, as long as you're calculating this information it should
> be displayed elsewhere - for instance on the map panel information for
> the current active unit.

Hm, could be useful in some cases.

> This also argues for another helper function,
> one of
>
>   struct city *get_nearest_city(struct unit *punit, int *sq_dist);
>   struct city *get_nearest_city(struct unit *punit);
>   void get_nearest_city_text(struct unit *punit,
>                              char *buf, size_t bufsz);
>
> What do you think?

Looks good. I'll code a patch this weekend (create get_nearest_*()
functions in climisc.[hc] and use them in gui-gtk's new unit_description()
function (and possibly mark unit_description() in common/ as deprecated)).

Have a nice day.

Stepan Roh




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