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: jdorje@xxxxxxxxxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: the directional system
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 9 Sep 2001 11:30:44 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Sun, Sep 09, 2001 at 05:08:00AM -0400, Jason Dorje Short wrote:
> Raimar Falke wrote:
> > 
> > On Sun, Sep 09, 2001 at 03:39:51AM -0400, Jason Dorje Short wrote:
> > > Raimar Falke wrote:
> > >
> > > > I still don't understand it. DIR_DX2 is only used in one method. Why
> > > > not just convert this and be fine (at least as an immediate step) with
> > > > one system. Why to switch all over to the DIR_DX2 system? Why is the
> > > > DIR_DX2 inferior to the DIR_DX system (not the naming but the
> > > > ordering)?
> 
> The log entry by Thue says:
> 
>   revision 1.42
>   date: 2001/02/06 20:30:58;  author: thue;  state: Exp;  lines: +154
> -125
>   Layer view; you can choose not to display some map info.
> 
>   Patch by Daniel M Church <dchurch@xxxxxxxxxxxxxxxxxxx> and me.
> 
> Which is not particularly useful.
> 
> 
> I'll let Ross cover the theoretical aspects; all I have to say is one
> thing:
> 
> #define DIR_ADJACENT(dir1, dir2) ((dir1+1)%8==dir2 || (dir2+1)%8==dir1)
> 
> versus
> 
> #define DIR_ADJACENT(dir1, dir2) \
>  ( dir1 == DIR8_NORTH  ? (dir2==DIR8_NORTHEAST || dir2==DIR8_NORTHWEST)
> :
>  ( dir1 == DIR8_NORTHEAST ? (dir2==DIR8_NORTH || dir2==DIR8_EAST) :
>  ( dir1 == DIR8_EAST ? (dir2==DIR8_NORTHEAST || dir2==DIR8_SOUTHEAST) :
>  ( dir1 == DIR8_SOUTHEAST ? (dir2=DIR8_EAST || dir2==DIR8_SOUTH) :
>  ( dir1 == DIR8_SOUTH ? (dir2==DIR8_SOUTHEAST || dir2==DIR8_SOUTHWEST) :
>  ( dir1 == DIR8_SOUTHWEST ? (dir2==DIR8_SOUTH || dir2==DIR8_WEST) :
>  ( dir1 == DIR8_WEST ? (dir2==DIR8_SOUTHWEST || dir2==DIR8_NORTHWEST) :
>  ( dir1 == DIR8_NORTHWEST ? (dir2==DIR8_WEST ||
> dir2==DIR8_NORTH)))))))))

$ grep -Ir DIR_ADJACENT .|wc -l
      0

So I can't comment on this. The second DIR_ADJACENT looks more ugly
but the first one holds knowledge about the ordering.

> This particular macro would take almost all of the work out of
> straightest_direction and dir_ok.

Make a method and a switch statement.

> I really don't see how you can argue the rotational system isn't
> better.

Because the current non-rotational system is in place and works.

> You may claim it's not worth the trouble to fix, but I believe
> cleaning up the code is worth doing in its own right.

It is ok to make the code independent of the ordering. However in the
context the second DIR_ADJACENT is better.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "It is not yet possible to change operating system by writing
  to /proc/sys/kernel/ostype."              sysctl(2) man page


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