Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2004:
[Freeciv-Dev] (PR#7350) Map radius change with city size
Home

[Freeciv-Dev] (PR#7350) Map radius change with city size

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: remi.bonnet@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#7350) Map radius change with city size
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 9 Apr 2004 19:50:40 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7350 >

For iso-tileset, you use a citydlg width and height (in tiles) of

  (city_map_width(pcity) - 1)

This works with the current setup becuse to fill a full square would
take city_map_width tiles; 1 tile is chopped off of each side saving a
half-tile width of display on each side.

But as the city map grows larger this will no longer work perfectly. 
With a larger circle more than one tile may be lopped off.  And with an
appropriately smaller circle less than one tile may be lopped off.  For
instance if the citymap is

 X X X
 X X X
 X X X

then radius == 1, width == 3, and the width of the citydlg must be 3
tiles in both iso and non-iso view.

Moreover I don't see a good way to predict this.

Therefore I suggest a workaround: figure it out at runtime!  We can just
look at the positions of all the tiles, see what the maximum/minimum X
and Y values are, and determine the width/height from that.  This in
turn is sufficient information for the city<->canvas conversion.

A disadvantage is we have to be sure to recalculate these values at the
proper times: when the tileset or topology changes.  Another
disadvantage is it's harder to have the width and height change between
cities (although this is only one of many problems).

Attached is a demo patch.  It's pretty straightforward.  However it
extends map_to_gui_pos/gui_to_map_pos a bit past what its name indicates
it does.  What we really want here are functions
cartesian_to_gui_pos/gui_to_cartesian_pos, which can be used for
map<->gui, city<->canvas, and vector<->canvas [1] conversions.

[1] See move_unit_map_canvas and draw_segment.

jason

Attachment: recalculate.diff
Description: Binary data


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