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

Function movebubbles

src/mkmaze.c:1538–1685  ·  view source on GitHub ↗

augment the Planes of Water (for bubbles) and Air (for clouds); called from goto_level() when arriving and moveloop_core() when on the level */

Source from the content-addressed store, hash-verified

1536/* augment the Planes of Water (for bubbles) and Air (for clouds); called
1537 from goto_level() when arriving and moveloop_core() when on the level */
1538void
1539movebubbles(void)
1540{
1541 static const struct rm water_pos = {
1542 cmap_b_to_glyph(S_water), WATER, 0, 0, 0, 0, 0, 0, 0, 0
1543 }, air_pos = {
1544 cmap_b_to_glyph(S_cloud), AIR, 0, 0, 0, 1, 0, 0, 0, 0
1545 };
1546 static boolean up = FALSE;
1547 struct bubble *b;
1548 struct container *cons;
1549 struct trap *btrap;
1550 coordxy x, y;
1551 int i, j, bcpin = 0;
1552
1553 /* set up the portal the first time bubbles are moved */
1554 if (!gw.wportal)
1555 set_wportal();
1556
1557 vision_recalc(2);
1558
1559 hero_bubble = NULL;
1560
1561 if (Is_waterlevel(&u.uz)) {
1562 /* keep attached ball&chain separate from bubble objects */
1563 if (Punished)
1564 bcpin = unplacebc_and_covet_placebc();
1565
1566 /*
1567 * Pick up everything inside of a bubble then fill all bubble
1568 * locations.
1569 */
1570 for (b = up ? svb.bbubbles : ge.ebubbles; b;
1571 b = up ? b->next : b->prev) {
1572 if (b->cons)
1573 panic("movebubbles: cons != null");
1574 for (i = 0, x = b->x; i < (int) b->bm[0]; i++, x++)
1575 for (j = 0, y = b->y; j < (int) b->bm[1]; j++, y++)
1576 if (b->bm[j + 2] & (1 << i)) {
1577 if (!isok(x, y)) {
1578 impossible("movebubbles: bad pos (%d,%d)", x, y);
1579 continue;
1580 }
1581
1582 /* pick up objects, monsters, hero, and traps */
1583 if (OBJ_AT(x, y)) {
1584 struct obj *olist = (struct obj *) 0, *otmp;
1585
1586 while ((otmp = svl.level.objects[x][y]) != 0) {
1587 remove_object(otmp);
1588 otmp->ox = otmp->oy = 0;
1589 otmp->nexthere = olist;
1590 olist = otmp;
1591 }
1592
1593 cons = (struct container *) alloc(sizeof *cons);
1594 cons->x = x;
1595 cons->y = y;

Callers 2

allmain.cFile · 0.85
goto_levelFunction · 0.85

Calls 15

set_wportalFunction · 0.85
vision_recalcFunction · 0.85
isokFunction · 0.85
remove_objectFunction · 0.85
remove_wormFunction · 0.85
newsymFunction · 0.85
t_atFunction · 0.85
block_pointFunction · 0.85
recalc_block_pointFunction · 0.85
rn2Function · 0.85
mv_bubbleFunction · 0.85

Tested by

no test coverage detected