$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) {