Blindfold removal fix
[slashemextended.git] / src / rip.c
blobbe5407ca86a2e73de596c76626faa6700179129a
1 /* SCCS Id: @(#)rip.c 3.4 2003/01/08 */
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 center(int, char *);
9 extern const char * const killed_by_prefix[]; /* from topten.c */
11 #if defined(TTY_GRAPHICS) || defined(CURSES_GRAPHICS) || defined(X11_GRAPHICS) || defined(GEM_GRAPHICS) || defined(MSWIN_GRAPHICS) || defined(GTK_GRAPHICS)
12 # define TEXT_TOMBSTONE
13 #endif
14 #if defined(mac) || defined(__BEOS__) || defined(WIN32_GRAPHICS)
15 # ifndef TEXT_TOMBSTONE
16 # define TEXT_TOMBSTONE
17 # endif
18 #endif
20 #ifdef TEXT_TOMBSTONE
22 #ifndef NH320_DEDICATION
23 /* A normal tombstone for end of game display. */
24 static const char *rip_txt[] = {
25 " ----------",
26 " / \\",
27 " / REST \\",
28 " / IN \\",
29 " / PEACE \\",
30 " / \\",
31 " | |", /* Name of player */
32 " | |", /* Amount of $ */
33 " | |", /* Type of death */
34 " | |", /* . */
35 " | |", /* . */
36 " | |", /* . */
37 " | |", /* . */
38 " | |", /* . */
39 " | 1001 |", /* Real year of death */
40 " *| * * * | *",
41 " _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______",
44 #define STONE_LINE_CENT 28 /* char[] element of center of stone face */
45 #else /* NH320_DEDICATION */
46 /* NetHack 3.2.x displayed a dual tombstone as a tribute to Izchak. */
47 static const char *rip_txt[] = {
48 " ---------- ----------",
49 " / \\ / \\",
50 " / REST \\ / This \\",
51 " / IN \\ / release of \\",
52 " / PEACE \\ / NetHack is \\",
53 " / \\ / dedicated to \\",
54 " | | | the memory of |",
55 " | | | |",
56 " | | | Izchak Miller |",
57 " | | | 1935 - 1994 |",
58 " | | | |",
59 " | | | |",
60 " | | | |",
61 " | | | Ascended |",
62 " | 1001 | | |",
63 " * | * * * | * * | * * * | *",
64 " _____)/\\|\\__//(\\/(/\\)/\\//\\/|_)________)/|\\\\_/_/(\\/(/\\)/\\/\\/|_)____",
67 #define STONE_LINE_CENT 19 /* char[] element of center of stone face */
68 #endif /* NH320_DEDICATION */
69 #define STONE_LINE_LEN 18 /* # chars that fit on one line
70 * (note 1 ' ' border)
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 /* "killed by a hallucinogen-distorted ravenous bugblatter beast of traal, while helpless" --Amy */
76 #define YEAR_LINE 14 /* *char[] line # for year */
78 static char **rip;
80 STATIC_OVL void
81 center(line, text)
82 int line;
83 char *text;
85 register char *ip,*op;
86 ip = text;
87 op = &rip[line][STONE_LINE_CENT - ((strlen(text)+1)>>1)];
88 while(*ip) *op++ = *ip++;
92 void
93 genl_outrip(tmpwin, how)
94 winid tmpwin;
95 int how;
97 register char **dp;
98 register char *dpx;
99 char buf[BUFSZ];
100 register int x;
101 int line;
103 rip = dp = (char **) alloc(sizeof(rip_txt));
104 for (x = 0; rip_txt[x]; x++) {
105 dp[x] = (char *) alloc((unsigned int)(strlen(rip_txt[x]) + 1));
106 strcpy(dp[x], rip_txt[x]);
108 dp[x] = (char *)0;
110 /* Put name on stone */
111 sprintf(buf, "%s", playeraliasname);
112 buf[STONE_LINE_LEN] = 0;
113 center(NAME_LINE, buf);
115 /* Put $ on stone */
116 #ifndef GOLDOBJ
117 sprintf(buf, "%ld Au", u.ugold);
118 #else
119 sprintf(buf, "%ld Au", done_money);
120 #endif
121 buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */
122 center(GOLD_LINE, buf);
124 /* Put together death description */
125 switch (killer_format) {
126 default: impossible("bad killer format?");
127 case KILLED_BY_AN:
128 if (Instant_Death) {
129 strcpy(buf, "instantly ");
130 strcat(buf, killed_by_prefix[how]);
132 else if (Quick_Death) {
133 strcpy(buf, "quickly ");
134 strcat(buf, killed_by_prefix[how]);
135 } else strcpy(buf, killed_by_prefix[how]);
136 strcat(buf, an(killer));
137 break;
138 case KILLED_BY:
139 if (Instant_Death) {
140 strcpy(buf, "instantly ");
141 strcat(buf, killed_by_prefix[how]);
143 else if (Quick_Death) {
144 strcpy(buf, "quickly ");
145 strcat(buf, killed_by_prefix[how]);
146 } else strcpy(buf, killed_by_prefix[how]);
147 strcat(buf, killer);
148 break;
149 case NO_KILLER_PREFIX:
150 strcpy(buf, killer);
151 break;
154 /* Put death type on stone */
155 for (line=DEATH_LINE, dpx = buf; line<YEAR_LINE; line++) {
156 register int i,i0;
157 char tmpchar;
159 if ( (i0=strlen(dpx)) > STONE_LINE_LEN) {
160 for(i = STONE_LINE_LEN;
161 ((i0 > STONE_LINE_LEN) && i); i--)
162 if(dpx[i] == ' ') i0 = i;
163 if(!i) i0 = STONE_LINE_LEN;
165 tmpchar = dpx[i0];
166 dpx[i0] = 0;
167 center(line, dpx);
168 if (tmpchar != ' ') {
169 dpx[i0] = tmpchar;
170 dpx= &dpx[i0];
171 } else dpx= &dpx[i0+1];
174 /* Put year on stone */
175 sprintf(buf, "%4d", getyear());
176 center(YEAR_LINE, buf);
178 putstr(tmpwin, 0, "");
179 for(; *dp; dp++)
180 putstr(tmpwin, 0, *dp);
182 putstr(tmpwin, 0, "");
183 putstr(tmpwin, 0, "");
185 for (x = 0; rip_txt[x]; x++) {
186 free((void *)rip[x]);
188 free((void *)rip);
189 rip = 0;
192 #endif /* TEXT_TOMBSTONE */
194 /*rip.c*/