]> granicus.if.org Git - nethack/commitdiff
Use rn2() instead of Rand() for selection_do_randline()
authorTung Nguyen <tungtn3@gmail.com>
Fri, 1 Apr 2016 04:15:50 +0000 (15:15 +1100)
committerTung Nguyen <tungtn3@gmail.com>
Sat, 2 Apr 2016 01:41:35 +0000 (12:41 +1100)
That is, use NetHack's RNG instead of the direct system RNG.  This fixes
maps generated with randlines to interact correctly with potential
future RNG system changes e.g. switching PRNG algorithms, supporting
NAO343's RNG reseeding, and even supporting replays like NetHack 4.

Based on DynaHack commit e464f63 (lev_comp: Fix system RNG use in
randline) by me.

src/sp_lev.c

index 30476bb398b6ac692f809ac53d4a51aa1a93f2be..c4c7f37654f1443060dc1caca99833498ec382d9 100644 (file)
@@ -4089,8 +4089,8 @@ struct opvar *ov;
         my = ((y1 + y2) / 2);
     } else {
         do {
-            dx = (Rand() % rough) - (rough / 2);
-            dy = (Rand() % rough) - (rough / 2);
+            dx = rn2(rough) - (rough / 2);
+            dy = rn2(rough) - (rough / 2);
             mx = ((x1 + x2) / 2) + dx;
             my = ((y1 + y2) / 2) + dy;
         } while ((mx > COLNO - 1 || mx < 0 || my < 0 || my > ROWNO - 1));