1    | /*	SCCS Id: @(#)rip.c	3.3	97/11/08	*/
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    | extern const char *killed_by_prefix[];
10   | 
11   | #if defined(TTY_GRAPHICS) || defined(X11_GRAPHICS) || defined(GEM_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
19   | 
20   | #ifdef TEXT_TOMBSTONE
21   | 
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   | "                  |       1001       |", /* Real year of death */
38   | "                 *|     *  *  *      | *",
39   | "        _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______",
40   | 0
41   | };
42   | #define STONE_LINE_CENT 28	/* char[] element of center of stone face */
43   | #else	/* NH320_DEDICATION */
44   | /* NetHack 3.2.x displayed a dual tombstone as a tribute to Izchak. */
45   | static const char *rip_txt[] = {
46   | "              ----------                      ----------",
47   | "             /          \\                    /          \\",
48   | "            /    REST    \\                  /    This    \\",
49   | "           /      IN      \\                /  release of  \\",
50   | "          /     PEACE      \\              /   NetHack is   \\",
51   | "         /                  \\            /   dedicated to   \\",
52   | "         |                  |            |  the memory of   |",
53   | "         |                  |            |                  |",
54   | "         |                  |            |  Izchak Miller   |",
55   | "         |                  |            |   1935 - 1994    |",
56   | "         |                  |            |                  |",
57   | "         |                  |            |     Ascended     |",
58   | "         |       1001       |            |                  |",
59   | "      *  |     *  *  *      | *        * |      *  *  *     | *",
60   | " _____)/\\|\\__//(\\/(/\\)/\\//\\/|_)________)/|\\\\_/_/(\\/(/\\)/\\/\\/|_)____",
61   | 0
62   | };
63   | #define STONE_LINE_CENT 19	/* char[] element of center of stone face */
64   | #endif	/* NH320_DEDICATION */
65   | #define STONE_LINE_LEN 16	/* # chars that fit on one line
66   | 				 * (note 1 ' ' border)
67   | 				 */
68   | #define NAME_LINE 6		/* *char[] line # for player name */
69   | #define GOLD_LINE 7		/* *char[] line # for amount of gold */
70   | #define DEATH_LINE 8		/* *char[] line # for death description */
71   | #define YEAR_LINE 12		/* *char[] line # for year */
72   | 
73   | static char **rip;
74   | 
75   | STATIC_OVL void
76   | center(line, text)
77   | int line;
78   | char *text;
79   | {
80   | 	register char *ip,*op;
81   | 	ip = text;
82   | 	op = &rip[line][STONE_LINE_CENT - ((strlen(text)+1)>>1)];
83   | 	while(*ip) *op++ = *ip++;
84   | }
85   | 
86   | 
87   | void
88   | genl_outrip(tmpwin, how)
89   | winid tmpwin;
90   | int how;
91   | {
92   | 	register char **dp;
93   | 	register char *dpx;
94   | 	char buf[BUFSZ];
95   | 	register int x;
96   | 	int line;
97   | 
98   | 	rip = dp = (char **) alloc(sizeof(rip_txt));
99   | 	for (x = 0; rip_txt[x]; x++) {
100  | 		dp[x] = (char *) alloc((unsigned int)(strlen(rip_txt[x]) + 1));
101  | 		Strcpy(dp[x], rip_txt[x]);
102  | 	}
103  | 	dp[x] = (char *)0;
104  | 
105  | 	/* Put name on stone */
106  | 	Sprintf(buf, "%s", plname);
107  | 	buf[STONE_LINE_LEN] = 0;
108  | 	center(NAME_LINE, buf);
109  | 
110  | 	/* Put $ on stone */
111  | 	Sprintf(buf, "%ld Au", u.ugold);
112  | 	buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */
113  | 	center(GOLD_LINE, buf);
114  | 
115  | 	/* Put together death description */
116  | 	switch (killer_format) {
117  | 		default: impossible("bad killer format?");
118  | 		case KILLED_BY_AN:
119  | 			Strcpy(buf, killed_by_prefix[how]);
120  | 			Strcat(buf, an(killer));
121  | 			break;
122  | 		case KILLED_BY:
123  | 			Strcpy(buf, killed_by_prefix[how]);
124  | 			Strcat(buf, killer);
125  | 			break;
126  | 		case NO_KILLER_PREFIX:
127  | 			Strcpy(buf, killer);
128  | 			break;
129  | 	}
130  | 
131  | 	/* Put death type on stone */
132  | 	for (line=DEATH_LINE, dpx = buf; line<YEAR_LINE; line++) {
133  | 		register int i,i0;
134  | 		char tmpchar;
135  | 
136  | 		if ( (i0=strlen(dpx)) > STONE_LINE_LEN) {
137  | 				for(i = STONE_LINE_LEN;
138  | 				    ((i0 > STONE_LINE_LEN) && i); i--)
139  | 					if(dpx[i] == ' ') i0 = i;
140  | 				if(!i) i0 = STONE_LINE_LEN;
141  | 		}
142  | 		tmpchar = dpx[i0];
143  | 		dpx[i0] = 0;
144  | 		center(line, dpx);
145  | 		if (tmpchar != ' ') {
146  | 			dpx[i0] = tmpchar;
147  | 			dpx= &dpx[i0];
148  | 		} else  dpx= &dpx[i0+1];
149  | 	}
150  | 
151  | 	/* Put year on stone */
152  | 	Sprintf(buf, "%4d", getyear());
153  | 	center(YEAR_LINE, buf);
154  | 
155  | 	putstr(tmpwin, 0, "");
156  | 	for(; *dp; dp++)
157  | 		putstr(tmpwin, 0, *dp);
158  | 
159  | 	putstr(tmpwin, 0, "");
160  | 	putstr(tmpwin, 0, "");
161  | 
162  | 	for (x = 0; rip_txt[x]; x++) {
163  | 		free((genericptr_t)rip[x]);
164  | 	}
165  | 	free((genericptr_t)rip);
166  | 	rip = 0;
167  | }
168  | 
169  | #endif	/* TEXT_TOMBSTONE */
170  | 
171  | /*rip.c*/