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

Function create_altar

src/sp_lev.c:2445–2486  ·  view source on GitHub ↗

* Create an altar in a room. */

Source from the content-addressed store, hash-verified

2443 * Create an altar in a room.
2444 */
2445staticfn void
2446create_altar(altar *a, struct mkroom *croom)
2447{
2448 schar sproom;
2449 coordxy x = -1, y = -1;
2450 unsigned int amask;
2451 boolean croom_is_temple = TRUE;
2452
2453 if (croom) {
2454 get_free_room_loc(&x, &y, croom, a->coord);
2455 if (croom->rtype != TEMPLE)
2456 croom_is_temple = FALSE;
2457 } else {
2458 get_location_coord(&x, &y, DRY, croom, a->coord);
2459 if ((sproom = (schar) *in_rooms(x, y, TEMPLE)) != 0)
2460 croom = &svr.rooms[sproom - ROOMOFFSET];
2461 else
2462 croom_is_temple = FALSE;
2463 }
2464
2465 /* check for existing features */
2466 if (!set_levltyp(x, y, ALTAR))
2467 return;
2468
2469 amask = sp_amask_to_amask(a->sp_amask);
2470
2471 levl[x][y].altarmask = amask;
2472
2473 if (a->shrine < 0)
2474 a->shrine = rn2(2); /* handle random case */
2475
2476 if (!croom_is_temple || !a->shrine)
2477 return;
2478
2479 if (a->shrine) { /* Is it a shrine or sanctum? */
2480 priestini(&u.uz, croom, x, y, (a->shrine > 1));
2481 levl[x][y].altarmask |= AM_SHRINE;
2482 if (a->shrine == 2) /* high altar or sanctum */
2483 levl[x][y].altarmask |= AM_SANCTUM;
2484 svl.level.flags.has_temple = TRUE;
2485 }
2486}
2487
2488/*
2489 * Search for a door in a room on a specified wall.

Callers 1

lspo_altarFunction · 0.85

Calls 7

get_free_room_locFunction · 0.85
get_location_coordFunction · 0.85
in_roomsFunction · 0.85
set_levltypFunction · 0.85
sp_amask_to_amaskFunction · 0.85
rn2Function · 0.85
priestiniFunction · 0.85

Tested by

no test coverage detected