1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.rumors.c - version 1.0.3 */
3 /* $FreeBSD: src/games/hack/hack.rumors.c,v 1.3 1999/11/16 02:57:10 billf Exp $ */
5 #include "hack.h" /* for RUMORFILE and BSD (index) */
6 #define CHARSZ 8 /* number of bits in a char */
8 int n_used_rumors
= -1;
11 static void init_rumors(FILE *);
12 static bool skipline(FILE *);
13 static void outline(FILE *);
14 static bool used(int);
17 init_rumors(FILE *rumf
)
22 while (skipline(rumf
))
25 i
= n_rumors
/ CHARSZ
;
26 usedbits
= alloc((unsigned)(i
+ 1));
37 if (!fgets(line
, sizeof(line
), rumf
))
39 if (strchr(line
, '\n'))
50 if (!fgets(line
, sizeof(line
), rumf
))
52 if ((ep
= strchr(line
, '\n')) != NULL
)
54 pline("This cookie has a scrap of paper inside! It reads: ");
64 if (n_rumors
<= n_used_rumors
||
65 (rumf
= fopen(RUMORFILE
, "r")) == NULL
)
67 if (n_used_rumors
< 0)
71 rn
= rn2(n_rumors
- n_used_rumors
);
73 while (rn
|| used(i
)) {
79 usedbits
[i
/ CHARSZ
] |= (1 << (i
% CHARSZ
));
89 return (usedbits
[i
/ CHARSZ
] & (1 << (i
% CHARSZ
)));