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

Function flip_level

src/sp_lev.c:532–922  ·  view source on GitHub ↗

transpose top with bottom or left with right or both; sometimes called for new special levels, or for any level via the #wizfliplevel command */

Source from the content-addressed store, hash-verified

530/* transpose top with bottom or left with right or both; sometimes called
531 for new special levels, or for any level via the #wizfliplevel command */
532void
533flip_level(
534 int flp, /* mask for orientation(s) to transpose */
535 boolean extras) /* False: level creation; True: #wizfliplevel is
536 * altering an active level so more needs to be done */
537{
538 int x, y, i, itmp;
539 coordxy minx, miny, maxx, maxy;
540 struct rm trm;
541 struct trap *ttmp;
542 struct obj *otmp;
543 struct monst *mtmp;
544 struct engr *etmp;
545 struct mkroom *sroom;
546 timer_element *timer;
547 boolean ball_active = FALSE, ball_fliparea = FALSE;
548 stairway *stway;
549 struct exclusion_zone *ez;
550
551 /* nothing to do unless (flp & 1) or (flp & 2) or both */
552 if ((flp & 3) == 0)
553 return;
554
555 get_level_extends(&minx, &miny, &maxx, &maxy);
556 /* get_level_extends() returns -1,-1 to COLNO,ROWNO at max */
557 if (miny < 0)
558 miny = 0;
559 if (minx < 1)
560 minx = 1;
561 if (maxx >= COLNO)
562 maxx = (COLNO - 1);
563 if (maxy >= ROWNO)
564 maxy = (ROWNO - 1);
565
566 if (extras) {
567 if (Punished && uball->where != OBJ_FREE) {
568 ball_active = TRUE;
569 /* if hero and ball and chain are all inside flip area,
570 flip b&c coordinates along with other objects; if they
571 are all outside, leave them to be rejected when flipping
572 so that they stay as is; if some are inside and some are
573 outside, un-place here and subsequently re-place them on
574 hero's [possibly new] spot below */
575 if (carried(uball))
576 uball->ox = u.ux, uball->oy = u.uy;
577 ball_fliparea = ((inFlipArea(uball->ox, uball->oy)
578 == inFlipArea(uchain->ox, uchain->oy))
579 && (inFlipArea(uball->ox, uball->oy)
580 == inFlipArea(u.ux, u.uy)));
581 if (!ball_fliparea)
582 unplacebc();
583 }
584 }
585
586 /* stairs and ladders */
587 for (stway = gs.stairs; stway; stway = stway->next) {
588 if (flp & 1)
589 stway->sy = FlipY(stway->sy);

Callers 3

nhl_flip_levelFunction · 0.85
wiz_flip_levelFunction · 0.85
flip_level_rndFunction · 0.85

Calls 14

get_level_extendsFunction · 0.85
unplacebcFunction · 0.85
flip_encoded_dir_bitsFunction · 0.85
flip_vault_guardFunction · 0.85
flip_worm_segs_verticalFunction · 0.85
on_levelFunction · 0.85
flip_dbridge_verticalFunction · 0.85
flip_dbridge_horizontalFunction · 0.85
placebcFunction · 0.85
fix_wall_spinesFunction · 0.85
set_wall_stateFunction · 0.85

Tested by

no test coverage detected