Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2000:
[Freeciv-Dev] Re: patch: nicer rand_neighbour()
Home

[Freeciv-Dev] Re: patch: nicer rand_neighbour()

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: patch: nicer rand_neighbour()
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Tue, 25 Jan 2000 13:31:45 +1100 (EST)

=?ISO-8859-1?B?vbKr7bXY?= <iquin@xxxxxxxxxx> wrote:

> > +  int xoff[] = { -1,  0,  1, -1,  1, -1,  0,  1 };
> > +  int yoff[] = { -1, -1, -1,  0,  0,  1,  1,  1 };
> 
> I believe these arrays appear more than thrice in the entire freeciv source

Indeed.

> To not using such arrays:
> 
>   int dr=myrand(8);
>   if(dr&3)
>     *x += dr&4 ? 1 : -1;
>   dr+=2;
>   if(dr&3)
>     *y += dr&4 ? 1 : -1;

Sure, but, frankly, yuck.  And it doesn't allow (conveniently) using 
the myrand(5) method for y limits.  Better would be a patch providing 
general macros or functions doing something similar to this.  And make 
sure its well documented.

-- David

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