Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2001:
[Freeciv-Dev] Re: the directional system
Home

[Freeciv-Dev] Re: the directional system

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx (Freeciv developers)
Subject: [Freeciv-Dev] Re: the directional system
From: Reinier Post <rp@xxxxxxxxxx>
Date: Mon, 17 Sep 2001 11:20:51 +0200

On Sun, Sep 16, 2001 at 02:08:21PM +0200, Raimar Falke wrote:

> > > diff -urd -X freeciv.current/diff_ignore freeciv.current/common/map.h 
> > > work/common/map.h
> > > --- freeciv.current/common/map.h        Fri Sep 14 09:31:33 2001
> > > +++ work/common/map.h   Fri Sep 14 18:47:39 2001
> > > @@ -442,7 +442,16 @@
> > >  };
> > > 
> > >  /* return the reverse of the direction */
> > > -#define DIR_REVERSE(dir) (7 - (dir))
> > > +#define DIR_REVERSE(dir) \
> > > +((dir)==DIR8_WEST?DIR8_EAST: \
> > > + ((dir)==DIR8_EAST?DIR8_WEST: \
> > > +  ((dir)==DIR8_NORTH?DIR8_SOUTH: \
> > > +   ((dir)==DIR8_SOUTH?DIR8_NORTH: \
> > > +    ((dir)==DIR8_NORTHWEST?DIR8_SOUTHEAST: \
> > > +     ((dir)==DIR8_NORTHEAST?DIR8_SOUTHWEST: \
> > > +      ((dir)==DIR8_SOUTHWEST?DIR8_NORTHEAST: \
> > > +       ((dir)==DIR8_SOUTHEAST?DIR8_NORTHWEST: \
> > > +       (dir)/0))))))))
> > > 
> > >  /* is the direction "cardinal"?  Cardinal directions
> > >   * (also called cartesian) are the four main ones */
> > 
> > This way you hardwire a 'chess-like' grid, which is less general than
> > a general rotational system.  For example, the 3 other types of regular
> > Cartesian grids (triangular, square without diagonals, hexagonal) 
> 
> > cannot be expressed in this way
> 
> Why not?

Triangular only has DIR1 to DIR3, square DIR1 to DIR4,
hexagonal DIR1 to DIR6.

> >, while they would be fairly easy to implement in Freeciv.
> 
> I doubt this. There would be a lot of places which have to change.

Yes, but it can still be done with adjacent square tiles; for
triangular and hexagonal you have to shift the rows by half,
and for triangular you also have to leave holes:

     +-+-+-+-+-+-+-+-+-+-+-+-+
     |   |XXX|   |   |XXX|   |
     +-+-+-+-+-+-+-+-+-+-+-+-+-+
       |   |   |XXX|   |   |XXX|
     +-+-+-+-+-+-+-+-+-+-+-+-+-+
     |   |XXX|   |   |XXX|   |
     +-+-+-+-+-+-+-+-+-+-+-+-+

The correspondence between adjacency on the map and adjacency in the
array is no longer direct, but the interface would hardly change.

> > > So the general form is 1% slower.
> > > 
> > >   Raimar
> > 
> > That's acceptable, and as long as no other grid types are supported,
> > it's obvious makes the code easier to understand.
> 
> I wasn't proposing such a change. We are still in a performance
> discussion ;)

OK, sorry I misunderstood.

>       Raimar
> 
> -- 
>  email: rf13@xxxxxxxxxxxxxxxxx
>  "Transported to a surreal landscape, a young girl kills the first woman
>   she meets and then teams up with three complete strangers to kill again."
>     -- TV listing for the Wizard of Oz in the Marin Independent Journal
> 


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