[Freeciv-Dev] Re: patch: nicer rand_neighbour()
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
=?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
|
|