xref: /dragonfly/games/hack/hack.rip.c (revision 6693db17)
1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.rip.c - version 1.0.2 */
3 /* $FreeBSD: src/games/hack/hack.rip.c,v 1.4 1999/11/16 10:26:37 marcel Exp $ */
4 /* $DragonFly: src/games/hack/hack.rip.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */
5 
6 #include "hack.h"
7 
8 static void center(int, const char *);
9 
10 static char rip[][60] = {
11 "                       ----------",
12 "                      /          \\",
13 "                     /    REST    \\",
14 "                    /      IN      \\",
15 "                   /     PEACE      \\",
16 "                  /                  \\",
17 "                  |                  |",
18 "                  |                  |",
19 "                  |                  |",
20 "                  |                  |",
21 "                  |                  |",
22 "                  |       1001       |",
23 "                 *|     *  *  *      | *",
24 "        _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______\n",
25 };
26 static const int n_rips = sizeof(rip) / sizeof(rip[0]);
27 
28 void
29 outrip(void)
30 {
31 	char *dpx;
32 	char buf[BUFSZ];
33 	int j, x, y;
34 
35 	cls();
36 	strcpy(buf, plname);
37 	buf[16] = 0;
38 	center(6, buf);
39 	sprintf(buf, "%ld AU", u.ugold);
40 	center(7, buf);
41 	sprintf(buf, "killed by%s",
42 		!strncmp(killer, "the ", 4) ? "" :
43 		!strcmp(killer, "starvation") ? "" :
44 		strchr(vowels, *killer) ? " an" : " a");
45 	center(8, buf);
46 	strcpy(buf, killer);
47 	if (strlen(buf) > 16) {
48 		int i, i0, i1;
49 		i0 = i1 = 0;
50 		for (i = 0; i <= 16; i++)
51 			if (buf[i] == ' ')
52 				i0 = i, i1 = i + 1;
53 		if (!i0)
54 			i0 = i1 = 16;
55 		buf[i1 + 16] = 0;
56 		center(10, buf + i1);
57 		buf[i0] = 0;
58 	}
59 	center(9, buf);
60 	sprintf(buf, "%4d", getyear());
61 	center(11, buf);
62 	for (y = 8, j = 0; j < n_rips; y++, j++) {
63 		x = 0;
64 		dpx = rip[j];
65 		while (dpx[x]) {
66 			while (dpx[x] == ' ')
67 				x++;
68 			curs(x, y);
69 			while (dpx[x] && dpx[x] != ' ') {
70 				if (done_stopprint)
71 					return;
72 				curx++;
73 				putchar(dpx[x++]);
74 			}
75 		}
76 	}
77 	getret();
78 }
79 
80 static void
81 center(int line, const char *text)
82 {
83 	const char *ip = text;
84 	char *op;
85 
86 	op = &rip[line][28 - ((strlen(text) + 1) / 2)];
87 	while (*ip)
88 		*op++ = *ip++;
89 }
90