Source:NetHack 3.6.0/src/rip.c

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

Below is the full text to rip.c from the source code of NetHack 3.6.0. To link to a particular line, write [[Source:NetHack 3.6.0/src/rip.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	rip.c	$NHDT-Date: 1436753522 2015/07/13 02:12:02 $  $NHDT-Branch: master $:$NHDT-Revision: 1.18 $ */
  2.  /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3.  /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5.  #include "hack.h"
  6.  
  7.  STATIC_DCL void FDECL(center, (int, char *));
  8.  
  9.  #if defined(TTY_GRAPHICS) || defined(X11_GRAPHICS) || defined(GEM_GRAPHICS) \
  10.      || defined(MSWIN_GRAPHICS)
  11.  #define TEXT_TOMBSTONE
  12.  #endif
  13.  #if defined(mac) || defined(__BEOS__) || defined(WIN32_GRAPHICS)
  14.  #ifndef TEXT_TOMBSTONE
  15.  #define TEXT_TOMBSTONE
  16.  #endif
  17.  #endif
  18.  

Tombstone graphics

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

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);
  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.      putstr(tmpwin, 0, "");
  60.      for (; *dp; dp++)
  61.          putstr(tmpwin, 0, *dp);
  62.  
  63.      putstr(tmpwin, 0, "");
  64.      putstr(tmpwin, 0, "");
  65.  
  66.      for (x = 0; rip_txt[x]; x++) {
  67.          free((genericptr_t) rip[x]);
  68.      }
  69.      free((genericptr_t) rip);
  70.      rip = 0;
  71.  }
  72.  
  73.  #endif /* TEXT_TOMBSTONE */
  74.  
  75.  /*rip.c*/