OSDN Git Service

update year to 2020
[jnethack/source.git] / src / rip.c
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. */
5
6 /* JNetHack Copyright */
7 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000  */
8 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2020            */
9 /* JNetHack may be freely redistributed.  See license for details. */
10
11 #include "hack.h"
12
13 #if defined(TTY_GRAPHICS) || defined(X11_GRAPHICS) || defined(GEM_GRAPHICS) \
14     || defined(MSWIN_GRAPHICS) || defined(DUMPLOG) || defined(CURSES_GRAPHICS)
15 #define TEXT_TOMBSTONE
16 #endif
17 #if defined(mac) || defined(__BEOS__) || defined(WIN32_GRAPHICS)
18 #ifndef TEXT_TOMBSTONE
19 #define TEXT_TOMBSTONE
20 #endif
21 #endif
22
23 #ifdef TEXT_TOMBSTONE
24 STATIC_DCL void FDECL(center, (int, char *));
25
26 #ifndef NH320_DEDICATION
27 /* A normal tombstone for end of game display. */
28 static const char *rip_txt[] = {
29     "                       ----------",
30     "                      /          \\",
31     "                     /    REST    \\",
32     "                    /      IN      \\",
33     "                   /     PEACE      \\",
34     "                  /                  \\",
35     "                  |                  |", /* Name of player */
36     "                  |                  |", /* Amount of $ */
37     "                  |                  |", /* Type of death */
38     "                  |                  |", /* . */
39     "                  |                  |", /* . */
40     "                  |                  |", /* . */
41     "                  |       1001       |", /* Real year of death */
42     "                 *|     *  *  *      | *",
43     "        _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______", 0
44 };
45 #define STONE_LINE_CENT 28 /* char[] element of center of stone face */
46 #else                      /* NH320_DEDICATION */
47 /* NetHack 3.2.x displayed a dual tombstone as a tribute to Izchak. */
48 static const char *rip_txt[] = {
49     "              ----------                      ----------",
50     "             /          \\                    /          \\",
51     "            /    REST    \\                  /    This    \\",
52     "           /      IN      \\                /  release of  \\",
53     "          /     PEACE      \\              /   NetHack is   \\",
54     "         /                  \\            /   dedicated to   \\",
55     "         |                  |            |  the memory of   |",
56     "         |                  |            |                  |",
57     "         |                  |            |  Izchak Miller   |",
58     "         |                  |            |   1935 - 1994    |",
59     "         |                  |            |                  |",
60     "         |                  |            |     Ascended     |",
61     "         |       1001       |            |                  |",
62     "      *  |     *  *  *      | *        * |      *  *  *     | *",
63     " _____)/\\|\\__//(\\/(/\\)/\\//\\/|_)________)/|\\\\_/_/(\\/(/\\)/\\/\\/|_)____",
64     0
65 };
66 #define STONE_LINE_CENT 19 /* char[] element of center of stone face */
67 #endif                     /* NH320_DEDICATION */
68 #define STONE_LINE_LEN                               \
69     16               /* # chars that fit on one line \
70                       * (note 1 ' ' border)          \
71                       */
72 #define NAME_LINE 6  /* *char[] line # for player name */
73 #define GOLD_LINE 7  /* *char[] line # for amount of gold */
74 #define DEATH_LINE 8 /* *char[] line # for death description */
75 #define YEAR_LINE 12 /* *char[] line # for year */
76
77 static char **rip;
78
79 STATIC_OVL void
80 center(line, text)
81 int line;
82 char *text;
83 {
84     register char *ip, *op;
85     ip = text;
86     op = &rip[line][STONE_LINE_CENT - ((strlen(text) + 1) >> 1)];
87     while (*ip)
88         *op++ = *ip++;
89 }
90
91 void
92 genl_outrip(tmpwin, how, when)
93 winid tmpwin;
94 int how;
95 time_t when;
96 {
97     register char **dp;
98     register char *dpx;
99     char buf[BUFSZ];
100     long year;
101     register int x;
102     int line;
103
104     rip = dp = (char **) alloc(sizeof(rip_txt));
105     for (x = 0; rip_txt[x]; ++x)
106         dp[x] = dupstr(rip_txt[x]);
107     dp[x] = (char *) 0;
108
109     /* Put name on stone */
110     Sprintf(buf, "%s", plname);
111     buf[STONE_LINE_LEN] = 0;
112     center(NAME_LINE, buf);
113
114     /* Put $ on stone */
115     Sprintf(buf, "%ld Au", done_money);
116     buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */
117     center(GOLD_LINE, buf);
118
119     /* Put together death description */
120     formatkiller(buf, sizeof buf, how, FALSE);
121
122     /* Put death type on stone */
123     for (line = DEATH_LINE, dpx = buf; line < YEAR_LINE; line++) {
124         register int i, i0;
125         char tmpchar;
126 #if 1 /*JP*/
127         unsigned char *uc;
128         int jstone_line;
129
130         if ((i0 = strlen(dpx)) <= STONE_LINE_LEN)
131             jstone_line = STONE_LINE_LEN;
132         else if (i0 / 2 <= STONE_LINE_LEN )
133             jstone_line = ((i0 + 3) / 4) * 2;
134         else if (i0 / 3 <= STONE_LINE_LEN )
135             jstone_line = ((i0 + 5) / 6) * 2;
136         else
137             jstone_line = ((i0 + 7) / 8) * 2;
138 #endif
139
140         if ((i0 = strlen(dpx)) > STONE_LINE_LEN) {
141             for (i = STONE_LINE_LEN; ((i0 > STONE_LINE_LEN) && i); i--)
142                 if (dpx[i] == ' ')
143                     i0 = i;
144             if (!i)
145 #if 0 /*JP*/
146                 i0 = STONE_LINE_LEN;
147 #else
148                 {
149                     i0 = 0;
150                     while(i0 < jstone_line){
151                         uc = (unsigned char *)(dpx + i0);
152                         if(*uc < 128)
153                             ++i0;
154                         else
155                             i0 += 2;
156                     }
157                 }
158 #endif
159         }
160         tmpchar = dpx[i0];
161         dpx[i0] = 0;
162         center(line, dpx);
163         if (tmpchar != ' ') {
164             dpx[i0] = tmpchar;
165             dpx = &dpx[i0];
166         } else
167             dpx = &dpx[i0 + 1];
168     }
169
170     /* Put year on stone */
171     year = yyyymmdd(when) / 10000L;
172     Sprintf(buf, "%4ld", year);
173     center(YEAR_LINE, buf);
174
175 #ifdef DUMPLOG
176     if (tmpwin == 0)
177         dump_forward_putstr(0, 0, "Game over:", TRUE);
178     else
179 #endif
180         putstr(tmpwin, 0, "");
181
182     for (; *dp; dp++)
183         putstr(tmpwin, 0, *dp);
184
185     putstr(tmpwin, 0, "");
186 #ifdef DUMPLOG
187     if (tmpwin != 0)
188 #endif
189         putstr(tmpwin, 0, "");
190
191     for (x = 0; rip_txt[x]; x++) {
192         free((genericptr_t) rip[x]);
193     }
194     free((genericptr_t) rip);
195     rip = 0;
196 }
197
198 #endif /* TEXT_TOMBSTONE */
199
200 /*rip.c*/