Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2003:
[Freeciv-Dev] (PR#5431) Unecessary Global Variable in mapgen.c
Home

[Freeciv-Dev] (PR#5431) Unecessary Global Variable in mapgen.c

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#5431) Unecessary Global Variable in mapgen.c
From: "Cameron Morland" <cameron@xxxxxxxxxx>
Date: Wed, 27 Aug 2003 19:18:48 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Wed, Aug 27, 2003 at 01:26:56PM -0700, Jason Short wrote:
> [cameron - Tue Aug 26 19:41:46 2003]:
>
> > totalweight is a global variable, but there is no reason for it to be
> > so. And the way it is treated in mapgenerator2 is both bizarre and
> > useless. This patch makes the code easier to read, and is separate from
> > a gen2 bug I'm trying to track down.
>
> But you still make it static?  Why?

... No, that was an error. It shouldn't be static.

> This code is just amazing:
>
> -  totalweight= 0;
> -  for (i = game.nplayers; i > 0; i--)
> -    totalweight+= 70;
> -  for (i = game.nplayers; i > 0; i--)
> -    totalweight+= 20;
> -  for (i = game.nplayers; i > 0; i--)
> -    totalweight+= 10;
> +  totalweight = 100 * game.nplayers;
>
> Is there something I'm missing?  Seems like it's worth a patch all on
> its own.

Yeah, when I saw that I was struck dumb, blinked, looked again, and
saw that it was still there. Then I had to get a second opinion to
verify that it actually did what I thought, and that I wasn't going
crazy. I just can't imagine what they were thinking.

> And, this change:
>
> -  } else if(checkmass>map.xsize+map.ysize+totalweight) {
> +  } else if(checkmass>map.xsize+map.ysize) {
>
> Why is it there?

totalweight isn't used in gen3, so it isn't defined. Previously,
unless we were using gen3 after trying some other generator, its value
would have been unpredictable.



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