OSDN Git Service

import nethack-3.6.0
[jnethack/source.git] / src / rip.c
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
19 #ifdef TEXT_TOMBSTONE
20
21 #ifndef NH320_DEDICATION
22 /* A normal tombstone for end of game display. */
23 static const char *rip_txt[] = {
24     "                       ----------",
25     "                      /          \\",
26     "                     /    REST    \\",
27     "                    /      IN      \\",
28     "                   /     PEACE      \\",
29     "                  /                  \\",
30     "                  |                  |", /* Name of player */
31     "                  |                  |", /* Amount of $ */
32     "                  |                  |", /* Type of death */
33     "                  |                  |", /* . */
34     "                  |                  |", /* . */
35     "                  |                  |", /* . */
36     "                  |       1001       |", /* Real year of death */
37     "                 *|     *  *  *      | *",
38     "        _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______", 0
39 };
40 #define STONE_LINE_CENT 28 /* char[] element of center of stone face */
41 #else                      /* NH320_DEDICATION */
42 /* NetHack 3.2.x displayed a dual tombstone as a tribute to Izchak. */
43 static const char *rip_txt[] = {
44     "              ----------                      ----------",
45     "             /          \\                    /          \\",
46     "            /    REST    \\                  /    This    \\",
47     "           /      IN      \\                /  release of  \\",
48     "          /     PEACE      \\              /   NetHack is   \\",
49     "         /                  \\            /   dedicated to   \\",
50     "         |                  |            |  the memory of   |",
51     "         |                  |            |                  |",
52     "         |                  |            |  Izchak Miller   |",
53     "         |                  |            |   1935 - 1994    |",
54     "         |                  |            |                  |",
55     "         |                  |            |     Ascended     |",
56     "         |       1001       |            |                  |",
57     "      *  |     *  *  *      | *        * |      *  *  *     | *",
58     " _____)/\\|\\__//(\\/(/\\)/\\//\\/|_)________)/|\\\\_/_/(\\/(/\\)/\\/\\/|_)____",
59     0
60 };
61 #define STONE_LINE_CENT 19 /* char[] element of center of stone face */
62 #endif                     /* NH320_DEDICATION */
63 #define STONE_LINE_LEN                               \
64     16               /* # chars that fit on one line \
65                       * (note 1 ' ' border)          \
66                       */
67 #define NAME_LINE 6  /* *char[] line # for player name */
68 #define GOLD_LINE 7  /* *char[] line # for amount of gold */
69 #define DEATH_LINE 8 /* *char[] line # for death description */
70 #define YEAR_LINE 12 /* *char[] line # for year */
71
72 static char **rip;
73
74 STATIC_OVL void
75 center(line, text)
76 int line;
77 char *text;
78 {
79     register char *ip, *op;
80     ip = text;
81     op = &rip[line][STONE_LINE_CENT - ((strlen(text) + 1) >> 1)];
82     while (*ip)
83         *op++ = *ip++;
84 }
85
86 void
87 genl_outrip(tmpwin, how, when)
88 winid tmpwin;
89 int how;
90 time_t when;
91 {
92     register char **dp;
93     register char *dpx;
94     char buf[BUFSZ];
95     long year;
96     register int x;
97     int line;
98
99     rip = dp = (char **) alloc(sizeof(rip_txt));
100     for (x = 0; rip_txt[x]; ++x)
101         dp[x] = dupstr(rip_txt[x]);
102     dp[x] = (char *) 0;
103
104     /* Put name on stone */
105     Sprintf(buf, "%s", plname);
106     buf[STONE_LINE_LEN] = 0;
107     center(NAME_LINE, buf);
108
109     /* Put $ on stone */
110     Sprintf(buf, "%ld Au", done_money);
111     buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */
112     center(GOLD_LINE, buf);
113
114     /* Put together death description */
115     formatkiller(buf, sizeof buf, how);
116
117     /* Put death type on stone */
118     for (line = DEATH_LINE, dpx = buf; line < YEAR_LINE; line++) {
119         register int i, i0;
120         char tmpchar;
121
122         if ((i0 = strlen(dpx)) > STONE_LINE_LEN) {
123             for (i = STONE_LINE_LEN; ((i0 > STONE_LINE_LEN) && i); i--)
124                 if (dpx[i] == ' ')
125                     i0 = i;
126             if (!i)
127                 i0 = STONE_LINE_LEN;
128         }
129         tmpchar = dpx[i0];
130         dpx[i0] = 0;
131         center(line, dpx);
132         if (tmpchar != ' ') {
133             dpx[i0] = tmpchar;
134             dpx = &dpx[i0];
135         } else
136             dpx = &dpx[i0 + 1];
137     }
138
139     /* Put year on stone */
140     year = yyyymmdd(when) / 10000L;
141     Sprintf(buf, "%4ld", year);
142     center(YEAR_LINE, buf);
143
144     putstr(tmpwin, 0, "");
145     for (; *dp; dp++)
146         putstr(tmpwin, 0, *dp);
147
148     putstr(tmpwin, 0, "");
149     putstr(tmpwin, 0, "");
150
151     for (x = 0; rip_txt[x]; x++) {
152         free((genericptr_t) rip[x]);
153     }
154     free((genericptr_t) rip);
155     rip = 0;
156 }
157
158 #endif /* TEXT_TOMBSTONE */
159
160 /*rip.c*/