Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2003:
[Freeciv-Dev] Re: (PR#1870) borders patch feedback
Home

[Freeciv-Dev] Re: (PR#1870) borders patch feedback

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: ben@xxxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#1870) borders patch feedback
From: "ChrisK@xxxxxxxx" <ChrisK@xxxxxxxx>
Date: Fri, 4 Jul 2003 05:22:19 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Thu, Jul 03, 2003 at 09:27:51AM -0700, Ben Webb wrote:

> > > > 2. The radius calculation is not exact, which results in ugly "circles".
> > > >    Should be calculated from tile center to tile center. Guess there is 
> > > > a
> > > >    int() instead of a round() somewhere.
> > > We use the standard map_distance_vector function to calculate the
> > > distance - what's wrong with it? The borders won't be circles, because
> > > units can move diagonally at the same rate as horizontally and
> > > vertically, even though the distance is greater.
> > So the borders are squares? I don't understand. I'm talking of non-iso.
> 
> No, the borders will be straight lines, because they come between tiles;
> they will approximate circles though. The calculation is of course
> exact; all tiles whose squared map distance is less than or equal to
> game.borders squared will be claimed. No rounding is involved, as map
> distances are always integers. See common/map.c.

Ok. I'm referring to non-iso now. Your borders are circles around cities.
That means it is easier to attack from a corner, diagonally. This has some
drawbacks, but why not. It's fun :)

But your circles are ugly circles, because you do int(), not round(), to
determine whether a tile is own territory. If you do

diff -Nur -Xmyborders/diff_ignore borders0630/server/maphand.c 
myborders/server/maphand.c
--- borders0630/server/maphand.c        Tue Jul  1 12:48:19 2003
+++ myborders/server/maphand.c  Fri Jul  4 14:04:50 2003
@@ -1534,7 +1534,7 @@
   closest = map_get_adjc_city(x, y);
   if (!closest) {
     int distsq;    /* Squared distance to city */
-    int cldistsq = game.borders * game.borders;
+    int cldistsq = (game.borders + 0.5) * (game.borders + 0.5);
     int cont = map_get_continent(x, y);
 
     if (!is_ocean(map_get_terrain(x, y)) || is_claimed_ocean(x, y, &cont)) {

the circles are a bit nicer. I'd prefer this.

Christian

-- 
Christian Knoke     * * *      http://www.enter.de/~c.knoke/
* * * * * * * * *  Ceterum censeo Microsoft esse dividendum.



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