OSDN Git Service

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