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

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

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: stepan@xxxxxxxx
Subject: [Freeciv-Dev] (PR#2690) [PATCH] Show unit location in its description
From: "Jason Short via RT" <rt@xxxxxxxxxxxxxx>
Date: Fri, 3 Jan 2003 03:02:15 -0800
Reply-to: rt@xxxxxxxxxxxxxx

[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.

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.

Another issue is that

  Settlers
  Moves: 0
  Washington
  near Washington

is confusing.  Perhaps it should be "from Washington" instead of just
"Washington"?

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.

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.  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?

jason



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