Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2002:
[Freeciv-Dev] (PR#2476) myrand does the wrong thing
Home

[Freeciv-Dev] (PR#2476) myrand does the wrong thing

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: cameron@xxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#2476) myrand does the wrong thing
From: "Guest via RT" <rt@xxxxxxxxxxxxxx>
Date: Mon, 2 Dec 2002 14:54:18 -0800
Reply-to: rt@xxxxxxxxxxxxxx

I was testing what happens on very small maps, and I found that the
system broke consistently with a ysize less than 18. A bit of gdb, and
the problem is that myrand is being called with a value of zero, which
returns a random number between zero and MAX_UINT32. If we're looking
for a very small random number, getting a very large random number will
produce problems.

This patch makes myrand(size) return zero immediately if its argument is
less than or equal to 1. Additionally, it fixes the only place where
myrand(0) is explicitely called (in client initialization), so now it
calls myrand(MAX_UINT32). If you want a random number between zero and
MAX_UINT32, why not ask for one?

Attachment: myrand.diff
Description: myrand.diff


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