-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhack.rip.c
103 lines (95 loc) · 2.25 KB
/
hack.rip.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* hack.rip.c - version 1.0.2 */
#include <stdio.h>
#include "hack.h"
static char *rip[] = {
" ----------",
" / \\",
" / REST \\",
" / IN \\",
" / PEACE \\",
" / \\",
" | |",
" | |",
" | |",
" | |",
" | |",
" | 1001 |",
" *| * * * | *",
" _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______\n",
0
};
// Big rewrite here to account for the fact we can't modify constant strings
// these days! We copy each line to a buffer, then centre a string within it
// on particular lines.
void outrip(void) {
char *dpx;
char outbuf[BUFSZ];
char buf[BUFSZ];
int x,y;
int line;
char *thisline;
char *line10 = buf;
char *ip,*op;
y = 8;
cls();
for (line = 0; rip[line]; ++line) {
strcpy(outbuf, rip[line]);
strcat(outbuf, "\n");
buf[0] = 0;
thisline = buf;
switch (line) {
default:
break;
case 6:
(void) strcpy(buf, plname);
buf[16] = 0;
break;
case 7:
(void) sprintf(buf, "%ld AU", u.ugold);
break;
case 8:
(void) sprintf(buf, "killed by%s",
!strncmp(killer, "the ", 4) ? "" :
!strcmp(killer, "starvation") ? "" :
index(vowels, *killer) ? " an" : " a");
break;
case 9:
(void) strcpy(buf, killer);
if(strlen(buf) > 16) {
int i,i0,i1;
i0 = i1 = 0;
for(i = 0; i <= 16; i++)
if(buf[i] == ' ') i0 = i, i1 = i+1;
if(!i0) i0 = i1 = 16;
buf[i1 + 16] = 0;
line10 = buf+i1;
buf[i0] = 0;
}
break;
case 10:
thisline = line10;
break;
case 11:
(void) sprintf(buf, "%4d", getyear());
break;
}
ip = buf;
op = &outbuf[28 - ((strlen(thisline)+1)/2)];
while(*ip) *op++ = *ip++;
x = 0;
dpx = outbuf;
while(dpx[x]) {
while(dpx[x] == ' ') x++;
curs(x,y);
while(dpx[x] && dpx[x] != ' '){
if(done_stopprint)
return;
curx++;
(void) putchar(dpx[x++]);
}
}
++y;
}
getret();
}