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

Function region_safety

src/region.c:1367–1405  ·  view source on GitHub ↗

for fixing trouble at end of prayer; danger detected at start of prayer might have expired by now */

Source from the content-addressed store, hash-verified

1365/* for fixing trouble at end of prayer;
1366 danger detected at start of prayer might have expired by now */
1367void
1368region_safety(void)
1369{
1370 NhRegion *r = 0;
1371 int i, f_indx, n = 0;
1372
1373 for (i = 0; i < svn.n_regions; i++) {
1374 /* only care about regions that hero is in */
1375 if (!hero_inside(gr.regions[i]))
1376 continue;
1377 f_indx = gr.regions[i]->inside_f;
1378 /* the only type of region we understand is gas_cloud */
1379 if (f_indx == INSIDE_GAS_CLOUD) {
1380 if (!n++ && gr.regions[i]->ttl >= 0)
1381 r = gr.regions[i];
1382 }
1383 }
1384
1385 if (n > 1 || (n == 1 && !r)) {
1386 /* multiple overlapping cloud regions or non-expiring one */
1387 (void) safe_teleds(TELEDS_NO_FLAGS);
1388 /* maybe there's no safe place available; must get hero out of danger
1389 or prayer's "fix all troubles" result will get stuck in a loop */
1390 if (region_danger()) {
1391 set_itimeout(&HMagical_breathing, (long) (d(4, 4) + 4));
1392 /* not already Breathless or wouldn't be in region danger */
1393 You_feel("able to breathe.");
1394 }
1395 } else if (r) {
1396 remove_region(r);
1397 pline_The("gas cloud enveloping you dissipates.");
1398 } else {
1399 /* cloud dissipated on its own, so nothing needs to be done */
1400 pline_The("gas cloud has dissipated.");
1401 }
1402 /* maybe cure blindness too */
1403 if (BlindedTimeout == 1L)
1404 make_blinded(0L, TRUE);
1405}
1406#endif /* !SFCTOOL */
1407
1408/*region.c*/

Callers 1

fix_worst_troubleFunction · 0.85

Calls 8

safe_teledsFunction · 0.85
region_dangerFunction · 0.85
set_itimeoutFunction · 0.85
dFunction · 0.85
You_feelFunction · 0.85
remove_regionFunction · 0.85
pline_TheFunction · 0.85
make_blindedFunction · 0.85

Tested by

no test coverage detected