home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Games / NetHack 3.1.3 / source / src / rip.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-01  |  3.3 KB  |  136 lines  |  [TEXT/R*ch]

  1. /*    SCCS Id: @(#)rip.c    3.1    93/04/26    */
  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 void FDECL(center, (int, char *));
  8.  
  9. extern const char *killed_by_prefix[];
  10.  
  11. #if defined(TTY_GRAPHICS) || defined(X11_GRAPHICS) || defined(mac)
  12.  
  13. static const char *rip_txt[] = {
  14. "                       ----------",
  15. "                      /          \\",
  16. "                     /    REST    \\",
  17. "                    /      IN      \\",
  18. "                   /     PEACE      \\",
  19. "                  /                  \\",
  20. "                  |                  |", /* Name of player */
  21. "                  |                  |", /* Amount of $ */
  22. "                  |                  |", /* Type of death */
  23. "                  |                  |", /* . */
  24. "                  |                  |", /* . */
  25. "                  |                  |", /* . */
  26. "                  |       1001       |", /* Real year of death */
  27. "                 *|     *  *  *      | *",
  28. "        _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______",
  29. 0
  30. };
  31.  
  32. #define STONE_LINE_CENT 28    /* char[] element of center of stone face */
  33. #define STONE_LINE_LEN 16    /* # chars that fit on one line
  34.                  * (note 1 ' ' border)
  35.                  */
  36. #define NAME_LINE 6        /* *char[] line # for player name */
  37. #define GOLD_LINE 7        /* *char[] line # for amount of gold */
  38. #define DEATH_LINE 8        /* *char[] line # for death description */
  39. #define YEAR_LINE 12        /* *char[] line # for year */
  40.  
  41. char **rip;
  42.  
  43. static void
  44. center(line, text)
  45. int line;
  46. char *text;
  47. {
  48.     register char *ip,*op;
  49.     ip = text;
  50.     op = &rip[line][STONE_LINE_CENT - ((strlen(text)+1)>>1)];
  51.     while(*ip) *op++ = *ip++;
  52. }
  53.  
  54.  
  55. void
  56. genl_outrip(tmpwin, how)
  57. winid tmpwin;
  58. int how;
  59. {
  60.     register char **dp;
  61.     register char *dpx;
  62.     char buf[BUFSZ];
  63.     register int x;
  64.     int line;
  65.  
  66.     rip = dp = (char **) alloc(sizeof(rip_txt));
  67.     if (!dp) return;
  68.     for (x = 0; rip_txt[x]; x++) {
  69.         dp[x] = (char *) alloc((unsigned int)(strlen(rip_txt[x]) + 1));
  70.         if (!dp[x]) return;
  71.         Strcpy(dp[x], rip_txt[x]);
  72.     }
  73.     dp[x] = (char *)0;
  74.  
  75.     /* Put name on stone */
  76.     Sprintf(buf, "%s", plname);
  77.     buf[STONE_LINE_LEN] = 0;
  78.     center(NAME_LINE, buf);
  79.  
  80.     /* Put $ on stone */
  81.     Sprintf(buf, "%ld Au", u.ugold);
  82.     buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */
  83.     center(GOLD_LINE, buf);
  84.  
  85.     /* Put together death description */
  86.     switch (killer_format) {
  87.         default: impossible("bad killer format?");
  88.         case KILLED_BY_AN:
  89.             Strcpy(buf, killed_by_prefix[how]);
  90.             Strcat(buf, an(killer));
  91.             break;
  92.         case KILLED_BY:
  93.             Strcpy(buf, killed_by_prefix[how]);
  94.             Strcat(buf, killer);
  95.             break;
  96.         case NO_KILLER_PREFIX:
  97.             Strcpy(buf, killer);
  98.             break;
  99.     }
  100.  
  101.     /* Put death type on stone */
  102.     for (line=DEATH_LINE, dpx = buf; line<YEAR_LINE; line++) {
  103.         register int i,i0;
  104.         char tmpchar;
  105.  
  106.         if ( (i0=strlen(dpx)) > STONE_LINE_LEN) {
  107.                 for(i = STONE_LINE_LEN;
  108.                     ((i0 > STONE_LINE_LEN) && i); i--)
  109.                     if(dpx[i] == ' ') i0 = i;
  110.                 if(!i) i0 = STONE_LINE_LEN;
  111.         }
  112.         tmpchar = dpx[i0];
  113.         dpx[i0] = 0;
  114.         center(line, dpx);
  115.         if (tmpchar != ' ') {
  116.             dpx[i0] = tmpchar;
  117.             dpx= &dpx[i0];
  118.         } else  dpx= &dpx[i0+1];
  119.     }
  120.  
  121.     /* Put year on stone */
  122.     Sprintf(buf, "%4d", getyear());
  123.     center(YEAR_LINE, buf);
  124.  
  125.     putstr(tmpwin, 0, "");
  126.     for(; *dp; dp++)
  127.         putstr(tmpwin, 0, *dp);
  128.  
  129.     putstr(tmpwin, 0, "");
  130.     putstr(tmpwin, 0, "");
  131. }
  132.  
  133. #endif
  134.  
  135. /*rip.c*/
  136.