xref: /dragonfly/games/hack/hack.rip.c (revision 5dfd06ac)
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 		index(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] == ' ') i0 = i, i1 = i+1;
52 		if(!i0) i0 = i1 = 16;
53 		buf[i1 + 16] = 0;
54 		center(10, buf+i1);
55 		buf[i0] = 0;
56 	}
57 	center(9, buf);
58 	sprintf(buf, "%4d", getyear());
59 	center(11, buf);
60 	for(y = 8, j = 0; j < n_rips; y++, j++){
61 		x = 0;
62 		dpx = rip[j];
63 		while(dpx[x]) {
64 			while(dpx[x] == ' ') x++;
65 			curs(x,y);
66 			while(dpx[x] && dpx[x] != ' '){
67 				if(done_stopprint)
68 					return;
69 				curx++;
70 				putchar(dpx[x++]);
71 			}
72 		}
73 	}
74 	getret();
75 }
76 
77 static void
78 center(int line, const char *text)
79 {
80 	const char *ip = text;
81 	char *op;
82 
83 	op = &rip[line][28 - ((strlen(text)+1)/2)];
84 	while(*ip) *op++ = *ip++;
85 }
86