MCPcopy Create free account
hub / github.com/NetHack/NetHack / rumor_check

Function rumor_check

src/rumors.c:195–302  ·  view source on GitHub ↗

test that the true/false rumor boundaries are valid and show the first two and very last epitaphs, engravings, and bogus monsters */

Source from the content-addressed store, hash-verified

193/* test that the true/false rumor boundaries are valid and show the first
194 two and very last epitaphs, engravings, and bogus monsters */
195void
196rumor_check(void)
197{
198 dlb *rumors;
199 winid tmpwin = WIN_ERR;
200 char *endp, line[BUFSZ], xbuf[BUFSZ], rumor_buf[BUFSZ];
201
202 rumors = (gt.true_rumor_size >= 0) ? dlb_fopen(RUMORFILE, "r") : 0;
203 if (rumors) {
204 long ftell_rumor_start = 0L;
205
206 rumor_buf[0] = '\0';
207 if (gt.true_rumor_size == 0L) { /* if this is 1st outrumor() */
208 init_rumors(rumors);
209 if (gt.true_rumor_size < 0L) {
210 rumors = (dlb *) 0; /* init_rumors() closes it upon failure */
211 goto no_rumors; /* init failed */
212 }
213 }
214 tmpwin = create_nhwindow(NHW_TEXT);
215
216 /*
217 * reveal the values.
218 */
219 Sprintf(rumor_buf,
220 "T start=%06ld (%06lx), end=%06ld (%06lx), size=%06ld (%06lx)",
221 (long) gt.true_rumor_start, gt.true_rumor_start,
222 gt.true_rumor_end, (unsigned long) gt.true_rumor_end,
223 gt.true_rumor_size,(unsigned long) gt.true_rumor_size);
224 putstr(tmpwin, 0, rumor_buf);
225 Sprintf(rumor_buf,
226 "F start=%06ld (%06lx), end=%06ld (%06lx), size=%06ld (%06lx)",
227 (long) gf.false_rumor_start, gf.false_rumor_start,
228 gf.false_rumor_end, (unsigned long) gf.false_rumor_end,
229 gf.false_rumor_size, (unsigned long) gf.false_rumor_size);
230 putstr(tmpwin, 0, rumor_buf);
231
232 /*
233 * check the first rumor (start of true rumors) by
234 * skipping the first two lines.
235 *
236 * Then seek to the start of the false rumors (based on
237 * the value read in rumors, and display it.
238 */
239 rumor_buf[0] = '\0';
240 (void) dlb_fseek(rumors, (long) gt.true_rumor_start, SEEK_SET);
241 ftell_rumor_start = dlb_ftell(rumors);
242 (void) dlb_fgets(line, sizeof line, rumors);
243 if ((endp = strchr(line, '\n')) != 0)
244 *endp = 0;
245 Sprintf(rumor_buf, "T %06ld %s", ftell_rumor_start,
246 xcrypt(line, xbuf));
247 putstr(tmpwin, 0, rumor_buf);
248 /* find last true rumor */
249 while (dlb_fgets(line, sizeof line, rumors)
250 && dlb_ftell(rumors) < gt.true_rumor_end)
251 continue;
252 if ((endp = strchr(line, '\n')) != 0)

Callers 1

wiz_rumor_checkFunction · 0.85

Calls 10

dlb_fopenFunction · 0.85
init_rumorsFunction · 0.85
dlb_fseekFunction · 0.85
dlb_ftellFunction · 0.85
dlb_fgetsFunction · 0.85
xcryptFunction · 0.85
dlb_fcloseFunction · 0.85
couldnt_open_fileFunction · 0.85
others_checkFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected