Improved the CHANCE implementation a bit.
This makes the implementation more uniform (avoiding skew caused by %).
This commit is contained in:
parent
bc4a022db8
commit
344c5d3c82
|
@ -29,8 +29,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define WRAP_ADD(x, y, a, b) x = (((x) + (y)) + \
|
#define WRAP_ADD(x, y, a, b) x = (((x) + (y)) + \
|
||||||
((x) + (y) < (a) ? ((b) - (a)) : 0) + \
|
((x) + (y) < (a) ? ((b) - (a)) : 0) + \
|
||||||
((x) + (y) > (b) ? ((a) - (b)) : 0))
|
((x) + (y) > (b) ? ((a) - (b)) : 0))
|
||||||
#define CHANCE(x) ((rand() % RAND_MAX) < ((x) * RAND_MAX))
|
#define CHANCE(x) (((double)rand() / ((double)RAND_MAX+1)) < (x))
|
||||||
#define RANDRANGE(x, y) (((x) < (y)) ? ((x) + (rand() % (long)(1 + (y) - (x)))) : (x))
|
#define RANDRANGE(x, y) (((x) < (y)) ? \
|
||||||
|
((x) + (rand() % (long)(1 + (y) - (x)))) : (x))
|
||||||
#define DRAND ((double)rand() / RAND_MAX)
|
#define DRAND ((double)rand() / RAND_MAX)
|
||||||
#define _(s) gettext(s)
|
#define _(s) gettext(s)
|
||||||
#define CSDLP(x) (((x) == SDL_PRESSED) ? 1 : 0)
|
#define CSDLP(x) (((x) == SDL_PRESSED) ? 1 : 0)
|
||||||
|
|
Loading…
Reference in New Issue