From dc9332dc08d03101dc83c4dff8fb7aa42507bd3e Mon Sep 17 00:00:00 2001
From: Allanis <allanis@saracraft.net>
Date: Fri, 9 Aug 2013 16:35:31 +0100
Subject: [PATCH] [Change] Made RNG() more robust.

---
 src/rng.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/rng.h b/src/rng.h
index 95a3069..ba9fc12 100644
--- a/src/rng.h
+++ b/src/rng.h
@@ -1,6 +1,7 @@
 #pragma once
 
-#define RNG(L,H)  ((int)L + (int)((double)(H-L+1) * randfp())) /* L <= RNG <= H */
+#define RNG(L,H)       (((L)>(H)) ? RNG_SANE((H), (L)) : RNG_SANE((L),(H)))
+#define RNG_SANE(L,H)  ((int)L + (int)((double)(H-L+1) * randfp())) /* L <= RNG <= H */
 #define RNGF()  (randfp()) /* 0. <= RNGF <= 1. */
 
 void rng_init(void);