Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2001:
[Freeciv-Dev] Re: Round world/flat world
Home

[Freeciv-Dev] Re: Round world/flat world

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Paul Zastoupil <paulz@xxxxxxxxxxxx>
Cc: "Miguel Farah F." <miguel@xxxxxxxxxxxxx>, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Round world/flat world
From: Thue <thue@xxxxxxx>
Date: Sat, 10 Feb 2001 22:35:20 +0100

On Saturday 10 February 2001 21:36, Paul Zastoupil wrote:
> On Sat, Feb 10, 2001 at 07:58:10PM +0100, Erik Sigra wrote:
> > onsdagen den  7 februari 2001 02:18 skrev Miguel Farah F.:
> > > I recently finished a scenario map, and had to put a "barrier" at its
> > > eastmost edge because in Freeciv the world is always round, which is
> > > not desirable in certain situations (such as my map, which is supposed
> > > to happen on a flat world; the scenarios in data/scenario/ suffer the
> > > same problem).
> > >
> > > As you know, Civ II *does* have both modes available, and I think
> > > Freeciv should, too.
> >
> > This should be mentioned at <http://www.freeciv.org/roadmap.html>.
>
> Yes, yes, please someone code this.

As I have mentioned before, this can be done by changing all instances of 
things like

for (x1=x-1;x1<=x+1; x1++) {
   for (y1=y-1;y1<=y+1;y1++) {
      /* do stuff */
   }
}

to 

for (x1=x-1;x1<=x+1; x1++) {
   for (y1=y-1;y1<=y+1;y1++) {
      int x2 = x1, y2 = y1;
      if (normalize_map_pos(&x2, &y2)) {
         /* do stuff */
      }
   }
}

int normalize_map_pos(int *x, int *y) return whether the tile is off the map 
and wraps the values x and y point to, ie currently it will reject y values 
<0 or >= map.ysize, and bring x in between 0 and map.xsize.

Then just by editing normalize_map_pos you can reject x values less than 0 or 
>= than map.xsize, which will give you a flat map. As a side effect you will 
fix a load of buglets where you are working on y values < 0 or >=map.ysize.
(the client drawing and map generator will need some minor updates of course)

Note that the last iteration is equivalent to
square_iterate(x, y, 1, x1, y1) {
   /* do stuff */
} square_iterate_end;
Which is much more readable and modular.

Another example: find the square to the east of x, y which in much of the 
current code looks like

x1 = x+1; y1 = y
/* do stuff */

should be coded like this:
x1 = x+1; y1 = y;
if (normalize_map_pos(&x1, &y1)) {
   /* do stuff */
} else {
   /* do stuff if the tile is off the map. */
}

> I will put it in the roadmap unless someone beats me to it.

You might want to also remove isometric view from 2.1.

-Thue



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