SPDXify the code.
[open-adventure.git] / misc.c
diff --git a/misc.c b/misc.c
index 302e61cc641d4faeac7b176839ddd2aa05cac9a1..aa164728d54366942e282de3e1fdcee704b81877 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -1,3 +1,11 @@
+/*
+ * I/O and support riutines.
+ *
+ * Copyright (c) 1977, 2005 by Will Crowther and Don Woods
+ * Copyright (c) 2017 by Eric S. Raymond
+ * SPDX-License-Identifier: BSD-2-clause
+ */
+     
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -646,8 +654,10 @@ bool tstbit(long mask, int bit)
 void set_seed(int32_t seedval)
 /* Set the LCG seed */
 {
-    game.lcg_x = (uint32_t) seedval % LCG_M;
-
+    game.lcg_x = seedval % LCG_M;
+    if (game.lcg_x < 0) {
+        game.lcg_x = LCG_M + game.lcg_x;
+    }
     // once seed is set, we need to generate the Z`ZZZ word
     for (int i = 0; i < 5; ++i) {
         game.zzword[i] = 'A' + randrange(26);