Source:NetHack 3.6.0/src/allmain.c

From NetHackWiki
(Redirected from Source:Allmain.c)
Jump to: navigation, search

Below is the full text to allmain.c from the source code of NetHack 3.6.0. To link to a particular line, write [[Source:NetHack 3.6.0/src/allmain.c#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.

Top of file

  1.  /* NetHack 3.6	allmain.c	$NHDT-Date: 1446975459 2015/11/08 09:37:39 $  $NHDT-Branch: master $:$NHDT-Revision: 1.66 $ */
  2.  /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3.  /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5.  /* various code that was replicated in *main.c */
  6.  
  7.  #include "hack.h"
  8.  
  9.  #ifndef NO_SIGNAL
  10.  #include <signal.h>
  11.  #endif
  12.  
  13.  #ifdef POSITIONBAR
  14.  STATIC_DCL void NDECL(do_positionbar);
  15.  #endif
  16.  

moveloop

  1.  void
  2.  moveloop(resuming)
  3.  boolean resuming;
  4.  {
  5.  #if defined(MICRO) || defined(WIN32)
  6.      char ch;
  7.      int abort_lev;
  8.  #endif
  9.      int moveamt = 0, wtcap = 0, change = 0;
  10.      boolean monscanmove = FALSE;
  11.  
  12.      /* Note:  these initializers don't do anything except guarantee that
  13.              we're linked properly.
  14.      */
  15.      decl_init();
  16.      monst_init();
  17.      monstr_init(); /* monster strengths */
  18.      objects_init();
  19.  
  20.      if (wizard)
  21.          add_debug_extended_commands();
  22.  
  23.      /* if a save file created in normal mode is now being restored in
  24.         explore mode, treat it as normal restore followed by 'X' command
  25.         to use up the save file and require confirmation for explore mode */
  26.      if (resuming && iflags.deferred_X)
  27.          (void) enter_explore_mode();
  28.  
  29.      /* side-effects from the real world */
  30.      flags.moonphase = phase_of_the_moon();
  31.      if (flags.moonphase == FULL_MOON) {
  32.          You("are lucky!  Full moon tonight.");
  33.          change_luck(1);
  34.      } else if (flags.moonphase == NEW_MOON) {
  35.          pline("Be careful!  New moon tonight.");
  36.      }
  37.      flags.friday13 = friday_13th();
  38.      if (flags.friday13) {
  39.          pline("Watch out!  Bad things can happen on Friday the 13th.");
  40.          change_luck(-1);
  41.      }
  42.  
  43.      if (!resuming) { /* new game */
  44.          context.rndencode = rnd(9000);
  45.          set_wear((struct obj *) 0); /* for side-effects of starting gear */
  46.          (void) pickup(1);      /* autopickup at initial location */
  47.      } else {                   /* restore old game */
  48.  #ifndef WIN32
  49.          update_inventory(); /* for perm_invent */
  50.  #endif
  51.          read_engr_at(u.ux, u.uy); /* subset of pickup() */
  52.      }
  53.  #ifdef WIN32
  54.      update_inventory(); /* for perm_invent */
  55.  #endif
  56.  
  57.      (void) encumber_msg(); /* in case they auto-picked up something */
  58.      if (defer_see_monsters) {
  59.          defer_see_monsters = FALSE;
  60.          see_monsters();
  61.      }
  62.      initrack();
  63.  
  64.      u.uz0.dlevel = u.uz.dlevel;
  65.      youmonst.movement = NORMAL_SPEED; /* give the hero some movement points */
  66.      context.move = 0;
  67.  
  68.      program_state.in_moveloop = 1;
  69.      for (;;) {
  70.  #ifdef SAFERHANGUP
  71.          if (program_state.done_hup)
  72.              end_of_input();
  73.  #endif
  74.          get_nh_event();
  75.  #ifdef POSITIONBAR
  76.          do_positionbar();
  77.  #endif
  78.  
  79.          if (context.move) {
  80.              /* actual time passed */
  81.              youmonst.movement -= NORMAL_SPEED;
  82.  
  83.              do { /* hero can't move this turn loop */
  84.                  wtcap = encumber_msg();
  85.  
  86.                  context.mon_moving = TRUE;
  87.                  do {
  88.                      monscanmove = movemon();
  89.                      if (youmonst.movement >= NORMAL_SPEED)
  90.                          break; /* it's now your turn */
  91.                  } while (monscanmove);
  92.                  context.mon_moving = FALSE;
  93.  
  94.                  if (!monscanmove && youmonst.movement < NORMAL_SPEED) {
  95.                      /* both you and the monsters are out of steam this round
  96.                       */
  97.                      /* set up for a new turn */
  98.                      struct monst *mtmp;
  99.                      mcalcdistress(); /* adjust monsters' trap, blind, etc */
  100.  
  101.                      /* reallocate movement rations to monsters */
  102.                      for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
  103.                          mtmp->movement += mcalcmove(mtmp);
  104.  
  105.                      if (!rn2(u.uevent.udemigod
  106.                                   ? 25
  107.                                   : (depth(&u.uz) > depth(&stronghold_level))
  108.                                         ? 50
  109.                                         : 70))
  110.                          (void) makemon((struct permonst *) 0, 0, 0,
  111.                                         NO_MM_FLAGS);
  112.  
  113.                      /* calculate how much time passed. */
  114.                      if (u.usteed && u.umoved) {
  115.                          /* your speed doesn't augment steed's speed */
  116.                          moveamt = mcalcmove(u.usteed);
  117.                      } else {
  118.                          moveamt = youmonst.data->mmove;
  119.  
  120.                          if (Very_fast) { /* speed boots or potion */
  121.                              /* average movement is 1.67 times normal */
  122.                              moveamt += NORMAL_SPEED / 2;
  123.                              if (rn2(3) == 0)
  124.                                  moveamt += NORMAL_SPEED / 2;
  125.                          } else if (Fast) {
  126.                              /* average movement is 1.33 times normal */
  127.                              if (rn2(3) != 0)
  128.                                  moveamt += NORMAL_SPEED / 2;
  129.                          }
  130.                      }
  131.  
  132.                      switch (wtcap) {
  133.                      case UNENCUMBERED:
  134.                          break;
  135.                      case SLT_ENCUMBER:
  136.                          moveamt -= (moveamt / 4);
  137.                          break;
  138.                      case MOD_ENCUMBER:
  139.                          moveamt -= (moveamt / 2);
  140.                          break;
  141.                      case HVY_ENCUMBER:
  142.                          moveamt -= ((moveamt * 3) / 4);
  143.                          break;
  144.                      case EXT_ENCUMBER:
  145.                          moveamt -= ((moveamt * 7) / 8);
  146.                          break;
  147.                      default:
  148.                          break;
  149.                      }
  150.  
  151.                      youmonst.movement += moveamt;
  152.                      if (youmonst.movement < 0)
  153.                          youmonst.movement = 0;
  154.                      settrack();
  155.  
  156.                      monstermoves++;
  157.                      moves++;
  158.  
  159.                      /********************************/
  160.                      /* once-per-turn things go here */
  161.                      /********************************/
  162.  
  163.                      if (Glib)
  164.                          glibr();
  165.                      nh_timeout();
  166.                      run_regions();
  167.  
  168.                      if (u.ublesscnt)
  169.                          u.ublesscnt--;
  170.                      if (flags.time && !context.run)
  171.                          context.botl = 1;
  172.  
  173.                      /* One possible result of prayer is healing.  Whether or
  174.                       * not you get healed depends on your current hit points.
  175.                       * If you are allowed to regenerate during the prayer, the
  176.                       * end-of-prayer calculation messes up on this.
  177.                       * Another possible result is rehumanization, which
  178.                       * requires
  179.                       * that encumbrance and movement rate be recalculated.
  180.                       */
  181.                      if (u.uinvulnerable) {
  182.                          /* for the moment at least, you're in tiptop shape */
  183.                          wtcap = UNENCUMBERED;
  184.                      } else if (Upolyd && youmonst.data->mlet == S_EEL
  185.                                 && !is_pool(u.ux, u.uy)
  186.                                 && !Is_waterlevel(&u.uz)) {
  187.                          /* eel out of water loses hp, same as for monsters;
  188.                             as hp gets lower, rate of further loss slows down
  189.                             */
  190.                          if (u.mh > 1 && rn2(u.mh) > rn2(8)
  191.                              && (!Half_physical_damage || !(moves % 2L))) {
  192.                              u.mh--;
  193.                              context.botl = 1;
  194.                          } else if (u.mh < 1)
  195.                              rehumanize();
  196.                      } else if (Upolyd && u.mh < u.mhmax) {
  197.                          if (u.mh < 1)
  198.                              rehumanize();
  199.                          else if (Regeneration
  200.                                   || (wtcap < MOD_ENCUMBER && !(moves % 20))) {
  201.                              context.botl = 1;
  202.                              u.mh++;
  203.                          }
  204.                      } else if (u.uhp < u.uhpmax
  205.                                 && (wtcap < MOD_ENCUMBER || !u.umoved
  206.                                     || Regeneration)) {
  207.                          if (u.ulevel > 9 && !(moves % 3)) {
  208.                              int heal, Con = (int) ACURR(A_CON);
  209.  
  210.                              if (Con <= 12) {
  211.                                  heal = 1;
  212.                              } else {
  213.                                  heal = rnd(Con);
  214.                                  if (heal > u.ulevel - 9)
  215.                                      heal = u.ulevel - 9;
  216.                              }
  217.                              context.botl = 1;
  218.                              u.uhp += heal;
  219.                              if (u.uhp > u.uhpmax)
  220.                                  u.uhp = u.uhpmax;
  221.                          } else if (Regeneration
  222.                                     || (u.ulevel <= 9
  223.                                         && !(moves
  224.                                              % ((MAXULEV + 12) / (u.ulevel + 2)
  225.                                                 + 1)))) {
  226.                              context.botl = 1;
  227.                              u.uhp++;
  228.                          }
  229.                      }
  230.  
  231.                      /* moving around while encumbered is hard work */
  232.                      if (wtcap > MOD_ENCUMBER && u.umoved) {
  233.                          if (!(wtcap < EXT_ENCUMBER ? moves % 30
  234.                                                     : moves % 10)) {
  235.                              if (Upolyd && u.mh > 1) {
  236.                                  u.mh--;
  237.                              } else if (!Upolyd && u.uhp > 1) {
  238.                                  u.uhp--;
  239.                              } else {
  240.                                  You("pass out from exertion!");
  241.                                  exercise(A_CON, FALSE);
  242.                                  fall_asleep(-10, FALSE);
  243.                              }
  244.                          }
  245.                      }
  246.  
  247.                      if ((u.uen < u.uenmax)
  248.                          && ((wtcap < MOD_ENCUMBER
  249.                               && (!(moves % ((MAXULEV + 8 - u.ulevel)
  250.                                              * (Role_if(PM_WIZARD) ? 3 : 4)
  251.                                              / 6)))) || Energy_regeneration)) {
  252.                          u.uen += rn1(
  253.                              (int) (ACURR(A_WIS) + ACURR(A_INT)) / 15 + 1, 1);
  254.                          if (u.uen > u.uenmax)
  255.                              u.uen = u.uenmax;
  256.                          context.botl = 1;
  257.                      }
  258.  
  259.                      if (!u.uinvulnerable) {
  260.                          if (Teleportation && !rn2(85)) {
  261.                              xchar old_ux = u.ux, old_uy = u.uy;
  262.                              tele();
  263.                              if (u.ux != old_ux || u.uy != old_uy) {
  264.                                  if (!next_to_u()) {
  265.                                      check_leash(old_ux, old_uy);
  266.                                  }
  267.                                  /* clear doagain keystrokes */
  268.                                  pushch(0);
  269.                                  savech(0);
  270.                              }
  271.                          }
  272.                          /* delayed change may not be valid anymore */
  273.                          if ((change == 1 && !Polymorph)
  274.                              || (change == 2 && u.ulycn == NON_PM))
  275.                              change = 0;
  276.                          if (Polymorph && !rn2(100))
  277.                              change = 1;
  278.                          else if (u.ulycn >= LOW_PM && !Upolyd
  279.                                   && !rn2(80 - (20 * night())))
  280.                              change = 2;
  281.                          if (change && !Unchanging) {
  282.                              if (multi >= 0) {
  283.                                  if (occupation)
  284.                                      stop_occupation();
  285.                                  else
  286.                                      nomul(0);
  287.                                  if (change == 1)
  288.                                      polyself(0);
  289.                                  else
  290.                                      you_were();
  291.                                  change = 0;
  292.                              }
  293.                          }
  294.                      }
  295.  
  296.                      if (Searching && multi >= 0)
  297.                          (void) dosearch0(1);
  298.                      dosounds();
  299.                      do_storms();
  300.                      gethungry();
  301.                      age_spells();
  302.                      exerchk();
  303.                      invault();
  304.                      if (u.uhave.amulet)
  305.                          amulet();
  306.                      if (!rn2(40 + (int) (ACURR(A_DEX) * 3)))
  307.                          u_wipe_engr(rnd(3));
  308.                      if (u.uevent.udemigod && !u.uinvulnerable) {
  309.                          if (u.udg_cnt)
  310.                              u.udg_cnt--;
  311.                          if (!u.udg_cnt) {
  312.                              intervene();
  313.                              u.udg_cnt = rn1(200, 50);
  314.                          }
  315.                      }
  316.                      restore_attrib();
  317.                      /* underwater and waterlevel vision are done here */
  318.                      if (Is_waterlevel(&u.uz) || Is_airlevel(&u.uz))
  319.                          movebubbles();
  320.                      else if (Is_firelevel(&u.uz))
  321.                          fumaroles();
  322.                      else if (Underwater)
  323.                          under_water(0);
  324.                      /* vision while buried done here */
  325.                      else if (u.uburied)
  326.                          under_ground(0);
  327.  
  328.                      /* when immobile, count is in turns */
  329.                      if (multi < 0) {
  330.                          if (++multi == 0) { /* finished yet? */
  331.                              unmul((char *) 0);
  332.                              /* if unmul caused a level change, take it now */
  333.                              if (u.utotype)
  334.                                  deferred_goto();
  335.                          }
  336.                      }
  337.                  }
  338.              } while (youmonst.movement
  339.                       < NORMAL_SPEED); /* hero can't move loop */
  340.  
  341.              /******************************************/
  342.              /* once-per-hero-took-time things go here */
  343.              /******************************************/
  344.  
  345.              if (context.bypasses)
  346.                  clear_bypasses();
  347.              if ((u.uhave.amulet || Clairvoyant) && !In_endgame(&u.uz)
  348.                  && !BClairvoyant && !(moves % 15) && !rn2(2))
  349.                  do_vicinity_map();
  350.              if (u.utrap && u.utraptype == TT_LAVA)
  351.                  sink_into_lava();
  352.              /* when/if hero escapes from lava, he can't just stay there */
  353.              else if (!u.umoved)
  354.                  (void) pooleffects(FALSE);
  355.  
  356.          } /* actual time passed */
  357.  
  358.          /****************************************/
  359.          /* once-per-player-input things go here */
  360.          /****************************************/
  361.  
  362.          clear_splitobjs();
  363.          find_ac();
  364.          if (!context.mv || Blind) {
  365.              /* redo monsters if hallu or wearing a helm of telepathy */
  366.              if (Hallucination) { /* update screen randomly */
  367.                  see_monsters();
  368.                  see_objects();
  369.                  see_traps();
  370.                  if (u.uswallow)
  371.                      swallowed(0);
  372.              } else if (Unblind_telepat) {
  373.                  see_monsters();
  374.              } else if (Warning || Warn_of_mon)
  375.                  see_monsters();
  376.  
  377.              if (vision_full_recalc)
  378.                  vision_recalc(0); /* vision! */
  379.          }
  380.          if (context.botl || context.botlx) {
  381.              bot();
  382.              curs_on_u();
  383.          }
  384.  
  385.          context.move = 1;
  386.  
  387.          if (multi >= 0 && occupation) {
  388.  #if defined(MICRO) || defined(WIN32)
  389.              abort_lev = 0;
  390.              if (kbhit()) {
  391.                  if ((ch = pgetchar()) == ABORT)
  392.                      abort_lev++;
  393.                  else
  394.                      pushch(ch);
  395.              }
  396.              if (!abort_lev && (*occupation)() == 0)
  397.  #else
  398.              if ((*occupation)() == 0)
  399.  #endif
  400.                  occupation = 0;
  401.              if (
  402.  #if defined(MICRO) || defined(WIN32)
  403.                  abort_lev ||
  404.  #endif
  405.                  monster_nearby()) {
  406.                  stop_occupation();
  407.                  reset_eat();
  408.              }
  409.  #if defined(MICRO) || defined(WIN32)
  410.              if (!(++occtime % 7))
  411.                  display_nhwindow(WIN_MAP, FALSE);
  412.  #endif
  413.              continue;
  414.          }
  415.  
  416.          if (iflags.sanity_check)
  417.              sanity_check();
  418.  
  419.  #ifdef CLIPPING
  420.          /* just before rhack */
  421.          cliparound(u.ux, u.uy);
  422.  #endif
  423.  
  424.          u.umoved = FALSE;
  425.  
  426.          if (multi > 0) {
  427.              lookaround();
  428.              if (!multi) {
  429.                  /* lookaround may clear multi */
  430.                  context.move = 0;
  431.                  if (flags.time)
  432.                      context.botl = 1;
  433.                  continue;
  434.              }
  435.              if (context.mv) {
  436.                  if (multi < COLNO && !--multi)
  437.                      context.travel = context.travel1 = context.mv =
  438.                          context.run = 0;
  439.                  domove();
  440.              } else {
  441.                  --multi;
  442.                  rhack(save_cm);
  443.              }
  444.          } else if (multi == 0) {
  445.  #ifdef MAIL
  446.              ckmailstatus();
  447.  #endif
  448.              rhack((char *) 0);
  449.          }
  450.          if (u.utotype)       /* change dungeon level */
  451.              deferred_goto(); /* after rhack() */
  452.          /* !context.move here: multiple movement command stopped */
  453.          else if (flags.time && (!context.move || !context.mv))
  454.              context.botl = 1;
  455.  
  456.          if (vision_full_recalc)
  457.              vision_recalc(0); /* vision! */
  458.          /* when running in non-tport mode, this gets done through domove() */
  459.          if ((!context.run || flags.runmode == RUN_TPORT)
  460.              && (multi && (!context.travel ? !(multi % 7) : !(moves % 7L)))) {
  461.              if (flags.time && context.run)
  462.                  context.botl = 1;
  463.              display_nhwindow(WIN_MAP, FALSE);
  464.          }
  465.      }
  466.  }
  467.  

stop_occupation

  1.  void
  2.  stop_occupation()
  3.  {
  4.      if (occupation) {
  5.          if (!maybe_finished_meal(TRUE))
  6.              You("stop %s.", occtxt);
  7.          occupation = 0;
  8.          context.botl = 1; /* in case u.uhs changed */
  9.          nomul(0);
  10.          pushch(0);
  11.      }
  12.  }
  13.  

display_gamewindows

  1.  void
  2.  display_gamewindows()
  3.  {
  4.      WIN_MESSAGE = create_nhwindow(NHW_MESSAGE);
  5.  #ifdef STATUS_VIA_WINDOWPORT
  6.      status_initialize(0);
  7.  #else
  8.      WIN_STATUS = create_nhwindow(NHW_STATUS);
  9.  #endif
  10.      WIN_MAP = create_nhwindow(NHW_MAP);
  11.      WIN_INVEN = create_nhwindow(NHW_MENU);
  12.  
  13.  #ifdef MAC
  14.      /* This _is_ the right place for this - maybe we will
  15.       * have to split display_gamewindows into create_gamewindows
  16.       * and show_gamewindows to get rid of this ifdef...
  17.       */
  18.      if (!strcmp(windowprocs.name, "mac"))
  19.          SanePositions();
  20.  #endif
  21.  
  22.      /*
  23.       * The mac port is not DEPENDENT on the order of these
  24.       * displays, but it looks a lot better this way...
  25.       */
  26.  #ifndef STATUS_VIA_WINDOWPORT
  27.      display_nhwindow(WIN_STATUS, FALSE);
  28.  #endif
  29.      display_nhwindow(WIN_MESSAGE, FALSE);
  30.      clear_glyph_buffer();
  31.      display_nhwindow(WIN_MAP, FALSE);
  32.  }
  33.  

newgame

  1.  void
  2.  newgame()
  3.  {
  4.      int i;
  5.  
  6.  #ifdef MFLOPPY
  7.      gameDiskPrompt();
  8.  #endif
  9.  
  10.      context.botlx = 1;
  11.      context.ident = 1;
  12.      context.stethoscope_move = -1L;
  13.      context.warnlevel = 1;
  14.      context.next_attrib_check = 600L; /* arbitrary first setting */
  15.      context.tribute.enabled = TRUE;   /* turn on 3.6 tributes    */
  16.      context.tribute.tributesz = sizeof(struct tribute_info);
  17.  
  18.      for (i = 0; i < NUMMONS; i++)
  19.          mvitals[i].mvflags = mons[i].geno & G_NOCORPSE;
  20.  
  21.      init_objects(); /* must be before u_init() */
  22.  
  23.      flags.pantheon = -1; /* role_init() will reset this */
  24.      role_init();         /* must be before init_dungeons(), u_init(),
  25.                            * and init_artifacts() */
  26.  
  27.      init_dungeons();  /* must be before u_init() to avoid rndmonst()
  28.                         * creating odd monsters for any tins and eggs
  29.                         * in hero's initial inventory */
  30.      init_artifacts(); /* before u_init() in case $WIZKIT specifies
  31.                         * any artifacts */
  32.      u_init();
  33.  
  34.  #ifndef NO_SIGNAL
  35.      (void) signal(SIGINT, (SIG_RET_TYPE) done1);
  36.  #endif
  37.  #ifdef NEWS
  38.      if (iflags.news)
  39.          display_file(NEWS, FALSE);
  40.  #endif
  41.      load_qtlist();          /* load up the quest text info */
  42.      /* quest_init();  --  Now part of role_init() */
  43.  
  44.      mklev();
  45.      u_on_upstairs();
  46.      if (wizard)
  47.          obj_delivery(FALSE); /* finish wizkit */
  48.      vision_reset();          /* set up internals for level (after mklev) */
  49.      check_special_room(FALSE);
  50.  
  51.      if (MON_AT(u.ux, u.uy))
  52.          mnexto(m_at(u.ux, u.uy));
  53.      (void) makedog();
  54.      docrt();
  55.  
  56.      if (flags.legacy) {
  57.          flush_screen(1);
  58.          com_pager(1);
  59.      }
  60.  
  61.  #ifdef INSURANCE
  62.      save_currentstate();
  63.  #endif
  64.      program_state.something_worth_saving++; /* useful data now exists */
  65.  
  66.      urealtime.realtime = 0L;
  67.  #if defined(BSD) && !defined(POSIX_TYPES)
  68.      (void) time((long *) &urealtime.restored);
  69.  #else
  70.      (void) time(&urealtime.restored);
  71.  #endif
  72.  
  73.      /* Success! */
  74.      welcome(TRUE);
  75.      return;
  76.  }
  77.  

welcome

  1.  /* show "welcome [back] to nethack" message at program startup */
  2.  void
  3.  welcome(new_game)
  4.  boolean new_game; /* false => restoring an old game */
  5.  {
  6.      char buf[BUFSZ];
  7.      boolean currentgend = Upolyd ? u.mfemale : flags.female;
  8.  
  9.      /*
  10.       * The "welcome back" message always describes your innate form
  11.       * even when polymorphed or wearing a helm of opposite alignment.
  12.       * Alignment is shown unconditionally for new games; for restores
  13.       * it's only shown if it has changed from its original value.
  14.       * Sex is shown for new games except when it is redundant; for
  15.       * restores it's only shown if different from its original value.
  16.       */
  17.      *buf = '\0';
  18.      if (new_game || u.ualignbase[A_ORIGINAL] != u.ualignbase[A_CURRENT])
  19.          Sprintf(eos(buf), " %s", align_str(u.ualignbase[A_ORIGINAL]));
  20.      if (!urole.name.f
  21.          && (new_game
  22.                  ? (urole.allow & ROLE_GENDMASK) == (ROLE_MALE | ROLE_FEMALE)
  23.                  : currentgend != flags.initgend))
  24.          Sprintf(eos(buf), " %s", genders[currentgend].adj);
  25.  
  26.      pline(new_game ? "%s %s, welcome to NetHack!  You are a%s %s %s."
  27.                     : "%s %s, the%s %s %s, welcome back to NetHack!",
  28.            Hello((struct monst *) 0), plname, buf, urace.adj,
  29.            (currentgend && urole.name.f) ? urole.name.f : urole.name.m);
  30.  }
  31.  

do_positionbar

  1.  #ifdef POSITIONBAR
  2.  STATIC_DCL void
  3.  do_positionbar()
  4.  {
  5.      static char pbar[COLNO];
  6.      char *p;
  7.  
  8.      p = pbar;
  9.      /* up stairway */
  10.      if (upstair.sx
  11.          && (glyph_to_cmap(level.locations[upstair.sx][upstair.sy].glyph)
  12.                  == S_upstair
  13.              || glyph_to_cmap(level.locations[upstair.sx][upstair.sy].glyph)
  14.                     == S_upladder)) {
  15.          *p++ = '<';
  16.          *p++ = upstair.sx;
  17.      }
  18.      if (sstairs.sx
  19.          && (glyph_to_cmap(level.locations[sstairs.sx][sstairs.sy].glyph)
  20.                  == S_upstair
  21.              || glyph_to_cmap(level.locations[sstairs.sx][sstairs.sy].glyph)
  22.                     == S_upladder)) {
  23.          *p++ = '<';
  24.          *p++ = sstairs.sx;
  25.      }
  26.  
  27.      /* down stairway */
  28.      if (dnstair.sx
  29.          && (glyph_to_cmap(level.locations[dnstair.sx][dnstair.sy].glyph)
  30.                  == S_dnstair
  31.              || glyph_to_cmap(level.locations[dnstair.sx][dnstair.sy].glyph)
  32.                     == S_dnladder)) {
  33.          *p++ = '>';
  34.          *p++ = dnstair.sx;
  35.      }
  36.      if (sstairs.sx
  37.          && (glyph_to_cmap(level.locations[sstairs.sx][sstairs.sy].glyph)
  38.                  == S_dnstair
  39.              || glyph_to_cmap(level.locations[sstairs.sx][sstairs.sy].glyph)
  40.                     == S_dnladder)) {
  41.          *p++ = '>';
  42.          *p++ = sstairs.sx;
  43.      }
  44.  
  45.      /* hero location */
  46.      if (u.ux) {
  47.          *p++ = '@';
  48.          *p++ = u.ux;
  49.      }
  50.      /* fence post */
  51.      *p = 0;
  52.  
  53.      update_positionbar(pbar);
  54.  }
  55.  #endif
  56.  
  57.  /*allmain.c*/