summaryrefslogtreecommitdiff
path: root/games/sjeng/patches/patch-ac
blob: bdd365f8cbb9088ddecb2af7dc4e83aa5e6df59e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
$NetBSD: patch-ac,v 1.1.1.1 2001/10/25 04:42:52 jlam Exp $

--- newbook.c.orig	Wed Jun  6 18:12:39 2001
+++ newbook.c
@@ -465,14 +465,19 @@
   
   srand(time(0));
   
-  if (Variant == Normal)
-    binbook = gdbm_open("nbook.bin", 16384, GDBM_READER, 0, NULL);
-  else if (Variant == Suicide)
-    binbook = gdbm_open("sbook.bin", 16384, GDBM_READER, 0, NULL);
-  else if (Variant == Losers)
-    binbook = gdbm_open("lbook.bin", 16384, GDBM_READER, 0, NULL);
-  else 
-    binbook = gdbm_open("zbook.bin", 16384, GDBM_READER, 0, NULL);
+  if (Variant == Normal) {
+    if ((binbook = gdbm_open("nbook.bin", 16384, GDBM_READER, 0, NULL)) == NULL)
+      binbook = gdbm_open(BOOKDIR "nbook.bin", 16384, GDBM_READER, 0, NULL);
+  } else if (Variant == Suicide) {
+    if ((binbook = gdbm_open("sbook.bin", 16384, GDBM_READER, 0, NULL)) == NULL)
+      binbook = gdbm_open(BOOKDIR "sbook.bin", 16384, GDBM_READER, 0, NULL);
+  } else if (Variant == Losers) {
+    if ((binbook = gdbm_open("lbook.bin", 16384, GDBM_READER, 0, NULL)) == NULL)
+      binbook = gdbm_open(BOOKDIR "lbook.bin", 16384, GDBM_READER, 0, NULL);
+  } else {
+    if ((binbook = gdbm_open("zbook.bin", 16384, GDBM_READER, 0, NULL)) == NULL)
+      binbook = gdbm_open(BOOKDIR "zbook.bin", 16384, GDBM_READER, 0, NULL);
+  }
     
   
   if (binbook == NULL)
@@ -606,16 +611,21 @@
 
   if (bookidx == 0) return;
   
-  if (Variant == Normal)
-    binbook = gdbm_open("nbook.bin", 16384, GDBM_WRITER, 0, NULL);
-  else if (Variant == Suicide)
-    binbook = gdbm_open("sbook.bin", 16384, GDBM_WRITER, 0, NULL);
-  else if (Variant == Losers)  
-    binbook = gdbm_open("lbook.bin", 16384, GDBM_WRITER, 0, NULL);
-  else if (Variant == Crazyhouse) 
-    binbook = gdbm_open("zbook.bin", 16384, GDBM_WRITER, 0, NULL);
-  else if (Variant == Bughouse)
+  if (Variant == Normal) {
+    if ((binbook = gdbm_open("nbook.bin", 16384, GDBM_WRITER, 0, NULL)) == NULL)
+      binbook = gdbm_open(BOOKDIR "nbook.bin", 16384, GDBM_WRITER, 0, NULL);
+  } else if (Variant == Suicide) {
+    if ((binbook = gdbm_open("sbook.bin", 16384, GDBM_WRITER, 0, NULL)) == NULL)
+      binbook = gdbm_open(BOOKDIR "sbook.bin", 16384, GDBM_WRITER, 0, NULL);
+  } else if (Variant == Losers) {
+    if ((binbook = gdbm_open("lbook.bin", 16384, GDBM_WRITER, 0, NULL)) == NULL)
+      binbook = gdbm_open(BOOKDIR "lbook.bin", 16384, GDBM_WRITER, 0, NULL);
+  } else if (Variant == Crazyhouse) {
+    if ((binbook = gdbm_open("zbook.bin", 16384, GDBM_WRITER, 0, NULL)) == NULL)
+      binbook = gdbm_open(BOOKDIR "zbook.bin", 16384, GDBM_WRITER, 0, NULL);
+  } else if (Variant == Bughouse) {
     return;
+  }
    
   if (binbook == NULL)
     {