Source:NetHack 3.6.0/include/dungeon.h

From NetHackWiki
Jump to: navigation, search

Below is the full text to dungeon.h from the source code of NetHack 3.6.0. To link to a particular line, write [[Source:NetHack 3.6.0/include/dungeon.h#line123]], for example.

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

  1.  /* NetHack 3.6	dungeon.h	$NHDT-Date: 1447755969 2015/11/17 10:26:09 $  $NHDT-Branch: master $:$NHDT-Revision: 1.24 $ */
  2.  /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3.  /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5.  #ifndef DUNGEON_H
  6.  #define DUNGEON_H
  7.  
  8.  typedef struct d_flags {     /* dungeon/level type flags */
  9.      Bitfield(town, 1);       /* is this a town? (levels only) */
  10.      Bitfield(hellish, 1);    /* is this part of hell? */
  11.      Bitfield(maze_like, 1);  /* is this a maze? */
  12.      Bitfield(rogue_like, 1); /* is this an old-fashioned presentation? */
  13.      Bitfield(align, 3);      /* dungeon alignment. */
  14.      Bitfield(unused, 1);     /* etc... */
  15.  } d_flags;
  16.  
  17.  typedef struct d_level { /* basic dungeon level element */
  18.      xchar dnum;          /* dungeon number */
  19.      xchar dlevel;        /* level number */
  20.  } d_level;
  21.  
  22.  typedef struct s_level { /* special dungeon level element */
  23.      struct s_level *next;
  24.      d_level dlevel; /* dungeon & level numbers */
  25.      char proto[15]; /* name of prototype file (eg. "tower") */
  26.      char boneid;    /* character to id level in bones files */
  27.      uchar rndlevs;  /* no. of randomly available similar levels */
  28.      d_flags flags;  /* type flags */
  29.  } s_level;
  30.  
  31.  typedef struct stairway { /* basic stairway identifier */
  32.      xchar sx, sy;         /* x / y location of the stair */
  33.      d_level tolev;        /* where does it go */
  34.      char up;              /* what type of stairway (up/down) */
  35.  } stairway;
  36.  
  37.  /* level region types */
  38.  #define LR_DOWNSTAIR 0
  39.  #define LR_UPSTAIR 1
  40.  #define LR_PORTAL 2
  41.  #define LR_BRANCH 3
  42.  #define LR_TELE 4
  43.  #define LR_UPTELE 5
  44.  #define LR_DOWNTELE 6
  45.  
  46.  typedef struct dest_area { /* non-stairway level change identifier */
  47.      xchar lx, ly;          /* "lower" left corner (near [0,0]) */
  48.      xchar hx, hy;          /* "upper" right corner (near [COLNO,ROWNO]) */
  49.      xchar nlx, nly;        /* outline of invalid area */
  50.      xchar nhx, nhy;        /* opposite corner of invalid area */
  51.  } dest_area;
  52.  
  53.  typedef struct dungeon {   /* basic dungeon identifier */
  54.      char dname[24];        /* name of the dungeon (eg. "Hell") */
  55.      char proto[15];        /* name of prototype file (eg. "tower") */
  56.      char boneid;           /* character to id dungeon in bones files */
  57.      d_flags flags;         /* dungeon flags */
  58.      xchar entry_lev;       /* entry level */
  59.      xchar num_dunlevs;     /* number of levels in this dungeon */
  60.      xchar dunlev_ureached; /* how deep you have been in this dungeon */
  61.      int ledger_start,      /* the starting depth in "real" terms */
  62.          depth_start;       /* the starting depth in "logical" terms */
  63.  } dungeon;
  64.  
  65.  /*
  66.   * A branch structure defines the connection between two dungeons.  They
  67.   * will be ordered by the dungeon number/level number of 'end1'.  Ties
  68.   * are resolved by 'end2'.  'Type' uses 'end1' arbitrarily as the primary
  69.   * point.
  70.   */
  71.  typedef struct branch {
  72.      struct branch *next; /* next in the branch chain */
  73.      int id;              /* branch identifier */
  74.      int type;            /* type of branch */
  75.      d_level end1;        /* "primary" end point */
  76.      d_level end2;        /* other end point */
  77.      boolean end1_up;     /* does end1 go up? */
  78.  } branch;
  79.  
  80.  /* branch types */
  81.  #define BR_STAIR 0   /* "Regular" connection, 2 staircases. */
  82.  #define BR_NO_END1 1 /* "Regular" connection.  However, no stair from
  83.                          end1 to end2.  There is a stair from end2 to end1. */
  84.  #define BR_NO_END2 2 /* "Regular" connection.  However, no stair from
  85.                          end2 to end1.  There is a stair from end1 to end2. */
  86.  #define BR_PORTAL 3  /* Connection by magic portals (traps) */
  87.  
  88.  /* A particular dungeon contains num_dunlevs d_levels with dlevel 1..
  89.   * num_dunlevs.  Ledger_start and depth_start are bases that are added
  90.   * to the dlevel of a particular d_level to get the effective ledger_no
  91.   * and depth for that d_level.
  92.   *
  93.   * Ledger_no is a bookkeeping number that gives a unique identifier for a
  94.   * particular d_level (for level.?? files, e.g.).
  95.   *
  96.   * Depth corresponds to the number of floors below the surface.
  97.   */
  98.  #define Is_astralevel(x) (on_level(x, &astral_level))
  99.  #define Is_earthlevel(x) (on_level(x, &earth_level))
  100.  #define Is_waterlevel(x) (on_level(x, &water_level))
  101.  #define Is_firelevel(x) (on_level(x, &fire_level))
  102.  #define Is_airlevel(x) (on_level(x, &air_level))
  103.  #define Is_medusa_level(x) (on_level(x, &medusa_level))
  104.  #define Is_oracle_level(x) (on_level(x, &oracle_level))
  105.  #define Is_valley(x) (on_level(x, &valley_level))
  106.  #define Is_juiblex_level(x) (on_level(x, &juiblex_level))
  107.  #define Is_asmo_level(x) (on_level(x, &asmodeus_level))
  108.  #define Is_baal_level(x) (on_level(x, &baalzebub_level))
  109.  #define Is_wiz1_level(x) (on_level(x, &wiz1_level))
  110.  #define Is_wiz2_level(x) (on_level(x, &wiz2_level))
  111.  #define Is_wiz3_level(x) (on_level(x, &wiz3_level))
  112.  #define Is_sanctum(x) (on_level(x, &sanctum_level))
  113.  #define Is_portal_level(x) (on_level(x, &portal_level))
  114.  #define Is_rogue_level(x) (on_level(x, &rogue_level))
  115.  #define Is_stronghold(x) (on_level(x, &stronghold_level))
  116.  #define Is_bigroom(x) (on_level(x, &bigroom_level))
  117.  #define Is_qstart(x) (on_level(x, &qstart_level))
  118.  #define Is_qlocate(x) (on_level(x, &qlocate_level))
  119.  #define Is_nemesis(x) (on_level(x, &nemesis_level))
  120.  #define Is_knox(x) (on_level(x, &knox_level))
  121.  #define Is_mineend_level(x) (on_level(x, &mineend_level))
  122.  #define Is_sokoend_level(x) (on_level(x, &sokoend_level))
  123.  
  124.  #define In_sokoban(x) ((x)->dnum == sokoban_dnum)
  125.  #define Inhell In_hell(&u.uz) /* now gehennom */
  126.  #define In_endgame(x) ((x)->dnum == astral_level.dnum)
  127.  
  128.  #define within_bounded_area(X, Y, LX, LY, HX, HY) \
  129.      ((X) >= (LX) && (X) <= (HX) && (Y) >= (LY) && (Y) <= (HY))
  130.  
  131.  /* monster and object migration codes */
  132.  
  133.  #define MIGR_NOWHERE (-1) /* failure flag for down_gate() */
  134.  #define MIGR_RANDOM 0
  135.  #define MIGR_APPROX_XY 1 /* approximate coordinates */
  136.  #define MIGR_EXACT_XY 2  /* specific coordinates */
  137.  #define MIGR_STAIRS_UP 3
  138.  #define MIGR_STAIRS_DOWN 4
  139.  #define MIGR_LADDER_UP 5
  140.  #define MIGR_LADDER_DOWN 6
  141.  #define MIGR_SSTAIRS 7      /* dungeon branch */
  142.  #define MIGR_PORTAL 8       /* magic portal */
  143.  #define MIGR_WITH_HERO 9    /* mon: followers; obj: trap door */
  144.  #define MIGR_NOBREAK 1024   /* bitmask: don't break on delivery */
  145.  #define MIGR_NOSCATTER 2048 /* don't scatter on delivery */
  146.  
  147.  /* level information (saved via ledger number) */
  148.  
  149.  struct linfo {
  150.      unsigned char flags;
  151.  #define VISITED 0x01      /* hero has visited this level */
  152.  #define FORGOTTEN 0x02    /* hero will forget this level when reached */
  153.  #define LFILE_EXISTS 0x04 /* a level file exists for this level */
  154.          /* Note:  VISITED and LFILE_EXISTS are currently almost always
  155.           * set at the same time.  However they _mean_ different things.
  156.           */
  157.  #ifdef MFLOPPY
  158.  #define FROMPERM 1 /* for ramdisk use */
  159.  #define TOPERM 2   /* for ramdisk use */
  160.  #define ACTIVE 1
  161.  #define SWAPPED 2
  162.      int where;
  163.      long time;
  164.      long size;
  165.  #endif /* MFLOPPY */
  166.  };
  167.  
  168.  /* types and structures for dungeon map recording
  169.   *
  170.   * It is designed to eliminate the need for an external notes file for some
  171.   * mundane dungeon elements.  "Where was the last altar I passed?" etc...
  172.   * Presumably the character can remember this sort of thing even if, months
  173.   * later in real time picking up an old save game, I can't.
  174.   *
  175.   * To be consistent, one can assume that this map is in the player's mind and
  176.   * has no physical correspondence (eliminating illiteracy/blind/hands/hands
  177.   * free concerns).  Therefore, this map is not exhaustive nor detailed ("some
  178.   * fountains").  This makes it also subject to player conditions (amnesia).
  179.   */
  180.  
  181.  /* Because clearly Nethack needs more ways to specify alignment */
  182.  #define Amask2msa(x) ((x) == 4 ? 3 : (x) &AM_MASK)
  183.  #define Msa2amask(x) ((x) == 3 ? 4 : (x))
  184.  #define MSA_NONE 0 /* unaligned or multiple alignments */
  185.  #define MSA_LAWFUL 1
  186.  #define MSA_NEUTRAL 2
  187.  #define MSA_CHAOTIC 3
  188.  
  189.  /* what the player knows about a single dungeon level */
  190.  /* initialized in mklev() */
  191.  typedef struct mapseen {
  192.      struct mapseen *next; /* next map in the chain */
  193.      branch *br;           /* knows about branch via taking it in goto_level */
  194.      d_level lev;          /* corresponding dungeon level */
  195.      struct mapseen_feat {
  196.          /* feature knowledge that must be calculated from levl array */
  197.          Bitfield(nfount, 2);
  198.          Bitfield(nsink, 2);
  199.          Bitfield(naltar, 2);
  200.          Bitfield(nthrone, 2);
  201.  
  202.          Bitfield(ngrave, 2);
  203.          Bitfield(ntree, 2);
  204.          Bitfield(water, 2);
  205.          Bitfield(lava, 2);
  206.  
  207.          Bitfield(ice, 2);
  208.          /* calculated from rooms array */
  209.          Bitfield(nshop, 2);
  210.          Bitfield(ntemple, 2);
  211.          /* altar alignment; MSA_NONE if there is more than one and
  212.             they aren't all the same */
  213.          Bitfield(msalign, 2);
  214.  
  215.          Bitfield(shoptype, 5);
  216.      } feat;
  217.      struct mapseen_flags {
  218.          Bitfield(unreachable, 1); /* can't get back to this level */
  219.          Bitfield(forgot, 1);      /* player has forgotten about this level */
  220.          Bitfield(knownbones, 1);  /* player aware of bones */
  221.          Bitfield(oracle, 1);
  222.          Bitfield(sokosolved, 1);
  223.          Bitfield(bigroom, 1);
  224.          Bitfield(castle, 1);
  225.          Bitfield(castletune, 1); /* add tune hint to castle annotation */
  226.  
  227.          Bitfield(valley, 1);
  228.          Bitfield(msanctum, 1);
  229.          Bitfield(ludios, 1);
  230.          Bitfield(roguelevel, 1);
  231.          /* quest annotations: quest_summons is for main dungeon level
  232.             with entry portal and is reset once quest has been finished;
  233.             questing is for quest home (level 1) */
  234.          Bitfield(quest_summons, 1); /* heard summons from leader */
  235.          Bitfield(questing, 1); /* quest leader has unlocked quest stairs */
  236.      } flags;
  237.      /* custom naming */
  238.      char *custom;
  239.      unsigned custom_lth;
  240.      struct mapseen_rooms {
  241.          Bitfield(seen, 1);
  242.          Bitfield(untended, 1);         /* flag for shop without shk */
  243.      } msrooms[(MAXNROFROOMS + 1) * 2]; /* same size as rooms[] */
  244.      /* dead heroes; might not have graves or ghosts */
  245.      struct cemetery *final_resting_place; /* same as level.bonesinfo */
  246.  } mapseen;
  247.  
  248.  #endif /* DUNGEON_H */