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: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Cc: jdorje@xxxxxxxxxxxxxxxxxxxxx, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: the directional system
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 11 Sep 2001 10:05:26 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Mon, Sep 10, 2001 at 07:42:01PM -0400, Ross W. Wetmore wrote:
> At 12:26 PM 01/09/10 +0200, Raimar Falke wrote:
> >On Mon, Sep 10, 2001 at 06:06:45AM -0400, Jason Dorje Short wrote:
> [...]
> >So we may have:
> >extern int _DIR_REVERSE[8],_DIR_PREV[8],_DIR_NEXT[8];
> >#define DIR_REVERSE(dir) (_DIR_REVERSE[dir])
> >...
> >
> >The arrays are filled once at runtime. I like this since this will be
> >system independent.
> 
> Actually, since you are using macros, how you implement them is a matter
> of changing a few lines of header code, and should not be a cause for
> great debate or concern.

Ack.

> It is probably foolish to define arrays for either the rotational or
> array based order reverse operations since they have a simple more
> efficient expression implementation. Provided you aren't doing shared 
> object loads where you might mix systems with incompatible shared
> objects and this will have otehr worse problems, this will work fine.
> 
> Filling arrays once at runtime is a recipe for disaster. Better to define
> them at compile time as const objects and never have to worry about the
> setup order etc.

If all stuff is moved to a certain place (dir.h) it is ok to provide
system depending macros.

So what do you thing about a dir.[ch]?

> For just next and previous (note next implies clockwise)

No. There are other directions of rotation. The mathematical positive
rotation comes to mind.

> or left and right
> again in a rotational system the expression works well. But for an array
> based system, the array is definitely the way to go.
> 

> Except, that you don't want to limit yourself to single steps. You really
> want a DIR_LEFT(n, dir) and DIR_RIGHT(n, dir) where in fact you don't put
> any limits on how many elements there are in the array. For the 2nd ring
> outwards there are 16 elements, in a hexagonal map there are 6.

If you show me code which needs this.

> Again these are simple expressions in a rotational system, and the only
> arrays needed are the primary ones for X and Y increments.
> 
> The array technique may be useful when more complex systems are tried
> but there is no need to go overboard until it is needed - it is a good
> fallback to have on the shelf though.
> 
> >BTW: NEXT and PREV aren't good names. CLOCKWISE and COUNTERCLOCKWISE
> >would be better.
> 
> Not really. They are both too long when simpler choices exist. Unless
> you want to go for CW and CCW.

DIR_CW and DIR_CCW is ok for me.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  Windows: From the people who brought you edlin...


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