mplayer.c formatting
[aNetHack.git] / src / rip.c
blob64bd8dd01842ac072dd6024ce9a8a3a55c2b6fac
1 /* NetHack 3.6 rip.c $NHDT-Date: 1450432760 2015/12/18 09:59:20 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.22 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed. See license for details. */
5 #include "hack.h"
7 STATIC_DCL void FDECL(center, (int, char *));
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
19 #ifdef TEXT_TOMBSTONE
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
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 " _____)/\\|\\__//(\\/(/\\)/\\//\\/|_)________)/|\\\\_/_/(\\/(/\\)/\\/\\/|_)____",
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) \
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 */
72 static char **rip;
74 STATIC_OVL void
75 center(line, text)
76 int line;
77 char *text;
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++;
86 void
87 genl_outrip(tmpwin, how, when)
88 winid tmpwin;
89 int how;
90 time_t when;
92 register char **dp;
93 register char *dpx;
94 char buf[BUFSZ];
95 long year;
96 register int x;
97 int line;
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;
104 /* Put name on stone */
105 Sprintf(buf, "%s", plname);
106 buf[STONE_LINE_LEN] = 0;
107 center(NAME_LINE, buf);
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);
114 /* Put together death description */
115 formatkiller(buf, sizeof buf, how, FALSE);
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;
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;
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];
139 /* Put year on stone */
140 year = yyyymmdd(when) / 10000L;
141 Sprintf(buf, "%4ld", year);
142 center(YEAR_LINE, buf);
144 putstr(tmpwin, 0, "");
145 for (; *dp; dp++)
146 putstr(tmpwin, 0, *dp);
148 putstr(tmpwin, 0, "");
149 putstr(tmpwin, 0, "");
151 for (x = 0; rip_txt[x]; x++) {
152 free((genericptr_t) rip[x]);
154 free((genericptr_t) rip);
155 rip = 0;
158 #endif /* TEXT_TOMBSTONE */
160 /*rip.c*/