Source:NetHack 3.6.1/src/rip.c

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

Below is the full text to rip.c from the source code of NetHack 3.6.1. To link to a particular line, write [[Source:NetHack 3.6.1/src/rip.c#line123]], for example.

Top of file

  1.  /* NetHack 3.6	rip.c	$NHDT-Date: 1488788514 2017/03/06 08:21:54 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.23 $ */
  2.  /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3.  /*-Copyright (c) Robert Patrick Rankin, 2017. */
  4.  /* NetHack may be freely redistributed.  See license for details. */

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.  
  2.  #include "hack.h"
  3.  
  4.  STATIC_DCL void FDECL(center, (int, char *));
  5.  
  6.  #if defined(TTY_GRAPHICS) || defined(X11_GRAPHICS) || defined(GEM_GRAPHICS) \
  7.      || defined(MSWIN_GRAPHICS) || defined(DUMPLOG)
  8.  #define TEXT_TOMBSTONE
  9.  #endif
  10.  #if defined(mac) || defined(__BEOS__) || defined(WIN32_GRAPHICS)
  11.  #ifndef TEXT_TOMBSTONE
  12.  #define TEXT_TOMBSTONE
  13.  #endif
  14.  #endif
  15.  
  16.  #ifdef TEXT_TOMBSTONE
  17.  
  18.  #ifndef NH320_DEDICATION
  19.  /* A normal tombstone for end of game display. */
  20.  static const char *rip_txt[] = {
  21.      "                       ----------",
  22.      "                      /          \\",
  23.      "                     /    REST    \\",
  24.      "                    /      IN      \\",
  25.      "                   /     PEACE      \\",
  26.      "                  /                  \\",
  27.      "                  |                  |", /* Name of player */
  28.      "                  |                  |", /* Amount of $ */
  29.      "                  |                  |", /* Type of death */
  30.      "                  |                  |", /* . */
  31.      "                  |                  |", /* . */
  32.      "                  |                  |", /* . */
  33.      "                  |       1001       |", /* Real year of death */
  34.      "                 *|     *  *  *      | *",
  35.      "        _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______", 0
  36.  };
  37.  #define STONE_LINE_CENT 28 /* char[] element of center of stone face */
  38.  #else                      /* NH320_DEDICATION */
  39.  /* NetHack 3.2.x displayed a dual tombstone as a tribute to Izchak. */
  40.  static const char *rip_txt[] = {
  41.      "              ----------                      ----------",
  42.      "             /          \\                    /          \\",
  43.      "            /    REST    \\                  /    This    \\",
  44.      "           /      IN      \\                /  release of  \\",
  45.      "          /     PEACE      \\              /   NetHack is   \\",
  46.      "         /                  \\            /   dedicated to   \\",
  47.      "         |                  |            |  the memory of   |",
  48.      "         |                  |            |                  |",
  49.      "         |                  |            |  Izchak Miller   |",
  50.      "         |                  |            |   1935 - 1994    |",
  51.      "         |                  |            |                  |",
  52.      "         |                  |            |     Ascended     |",
  53.      "         |       1001       |            |                  |",
  54.      "      *  |     *  *  *      | *        * |      *  *  *     | *",
  55.      " _____)/\\|\\__//(\\/(/\\)/\\//\\/|_)________)/|\\\\_/_/(\\/(/\\)/\\/\\/|_)____",
  56.      0
  57.  };
  58.  #define STONE_LINE_CENT 19 /* char[] element of center of stone face */
  59.  #endif                     /* NH320_DEDICATION */
  60.  #define STONE_LINE_LEN                               \
  61.      16               /* # chars that fit on one line \
  62.                        * (note 1 ' ' border)          \
  63.                        */
  64.  #define NAME_LINE 6  /* *char[] line # for player name */
  65.  #define GOLD_LINE 7  /* *char[] line # for amount of gold */
  66.  #define DEATH_LINE 8 /* *char[] line # for death description */
  67.  #define YEAR_LINE 12 /* *char[] line # for year */
  68.  
  69.  static char **rip;
  70.  

center

  1.  STATIC_OVL void
  2.  center(line, text)
  3.  int line;
  4.  char *text;
  5.  {
  6.      register char *ip, *op;
  7.      ip = text;
  8.      op = &rip[line][STONE_LINE_CENT - ((strlen(text) + 1) >> 1)];
  9.      while (*ip)
  10.          *op++ = *ip++;
  11.  }
  12.  

genl_outrip

  1.  void
  2.  genl_outrip(tmpwin, how, when)
  3.  winid tmpwin;
  4.  int how;
  5.  time_t when;
  6.  {
  7.      register char **dp;
  8.      register char *dpx;
  9.      char buf[BUFSZ];
  10.      long year;
  11.      register int x;
  12.      int line;
  13.  
  14.      rip = dp = (char **) alloc(sizeof(rip_txt));
  15.      for (x = 0; rip_txt[x]; ++x)
  16.          dp[x] = dupstr(rip_txt[x]);
  17.      dp[x] = (char *) 0;
  18.  
  19.      /* Put name on stone */
  20.      Sprintf(buf, "%s", plname);
  21.      buf[STONE_LINE_LEN] = 0;
  22.      center(NAME_LINE, buf);
  23.  
  24.      /* Put $ on stone */
  25.      Sprintf(buf, "%ld Au", done_money);
  26.      buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */
  27.      center(GOLD_LINE, buf);
  28.  
  29.      /* Put together death description */
  30.      formatkiller(buf, sizeof buf, how, FALSE);
  31.  
  32.      /* Put death type on stone */
  33.      for (line = DEATH_LINE, dpx = buf; line < YEAR_LINE; line++) {
  34.          register int i, i0;
  35.          char tmpchar;
  36.  
  37.          if ((i0 = strlen(dpx)) > STONE_LINE_LEN) {
  38.              for (i = STONE_LINE_LEN; ((i0 > STONE_LINE_LEN) && i); i--)
  39.                  if (dpx[i] == ' ')
  40.                      i0 = i;
  41.              if (!i)
  42.                  i0 = STONE_LINE_LEN;
  43.          }
  44.          tmpchar = dpx[i0];
  45.          dpx[i0] = 0;
  46.          center(line, dpx);
  47.          if (tmpchar != ' ') {
  48.              dpx[i0] = tmpchar;
  49.              dpx = &dpx[i0];
  50.          } else
  51.              dpx = &dpx[i0 + 1];
  52.      }
  53.  
  54.      /* Put year on stone */
  55.      year = yyyymmdd(when) / 10000L;
  56.      Sprintf(buf, "%4ld", year);
  57.      center(YEAR_LINE, buf);
  58.  
  59.  #ifdef DUMPLOG
  60.      if (tmpwin == 0)
  61.          dump_forward_putstr(0, 0, "Game over:", TRUE);
  62.      else
  63.  #endif
  64.          putstr(tmpwin, 0, "");
  65.  
  66.      for (; *dp; dp++)
  67.          putstr(tmpwin, 0, *dp);
  68.  
  69.      putstr(tmpwin, 0, "");
  70.  #ifdef DUMPLOG
  71.      if (tmpwin != 0)
  72.  #endif
  73.          putstr(tmpwin, 0, "");
  74.  
  75.      for (x = 0; rip_txt[x]; x++) {
  76.          free((genericptr_t) rip[x]);
  77.      }
  78.      free((genericptr_t) rip);
  79.      rip = 0;
  80.  }
  81.  
  82.  #endif /* TEXT_TOMBSTONE */
  83.  
  84.  /*rip.c*/