Fandom

Wikihack

Source:NetHack 3.2.0/rip.c

2,034pages on
this wiki
Add New Page
Talk0

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Below is the full text to rip.c from the source code of NetHack 3.2.0. To link to a particular line, write [[NetHack 3.2.0/rip.c#line123]], for example.

Warning! This is the source code from an old release. For the latest release, see Source code

The NetHack General Public License applies to screenshots, source code and other content from NetHack.
1.    /*	SCCS Id: @(#)rip.c	3.2	95/05/01	*/
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 void FDECL(center, (int, char *));
8.    
9.    extern const char *killed_by_prefix[];
10.   
11.   #if defined(TTY_GRAPHICS) || defined(X11_GRAPHICS) || defined(mac)
12.   
13.   static const char *rip_txt[] = {
14.   "              ----------                      ----------",
15.   "             /          \\                    /          \\",
16.   "            /    REST    \\                  /    This    \\",
17.   "           /      IN      \\                /  release of  \\",
18.   "          /     PEACE      \\              /   NetHack is   \\",
19.   "         /                  \\            /   dedicated to   \\",
20.   "         |                  |            |  the memory of   |",
21.   "         |                  |            |                  |",
22.   "         |                  |            |  Izchak Miller   |",
23.   "         |                  |            |   1935 - 1994    |",
24.   "         |                  |            |                  |",
25.   "         |                  |            |     Ascended     |",
26.   "         |       1001       |            |                  |",
27.   "      *  |     *  *  *      | *        * |      *  *  *     | *",
28.   " _____)/\\|\\__//(\\/(/\\)/\\//\\/|_)________)/|\\\\_/_/(\\/(/\\)/\\/\\/|_)____",
29.   0
30.   };
31.   
32.   #define STONE_LINE_CENT 19	/* char[] element of center of stone face */
33.   #define STONE_LINE_LEN 16	/* # chars that fit on one line
34.   				 * (note 1 ' ' border)
35.   				 */
36.   #define NAME_LINE 6		/* *char[] line # for player name */
37.   #define GOLD_LINE 7		/* *char[] line # for amount of gold */
38.   #define DEATH_LINE 8		/* *char[] line # for death description */
39.   #define YEAR_LINE 12		/* *char[] line # for year */
40.   
41.   char **rip;
42.   
43.   static void
44.   center(line, text)
45.   int line;
46.   char *text;
47.   {
48.   	register char *ip,*op;
49.   	ip = text;
50.   	op = &rip[line][STONE_LINE_CENT - ((strlen(text)+1)>>1)];
51.   	while(*ip) *op++ = *ip++;
52.   }
53.   
54.   
55.   void
56.   genl_outrip(tmpwin, how)
57.   winid tmpwin;
58.   int how;
59.   {
60.   	register char **dp;
61.   	register char *dpx;
62.   	char buf[BUFSZ];
63.   	register int x;
64.   	int line;
65.   
66.   	rip = dp = (char **) alloc(sizeof(rip_txt));
67.   	for (x = 0; rip_txt[x]; x++) {
68.   		dp[x] = (char *) alloc((unsigned int)(strlen(rip_txt[x]) + 1));
69.   		Strcpy(dp[x], rip_txt[x]);
70.   	}
71.   	dp[x] = (char *)0;
72.   
73.   	/* Put name on stone */
74.   	Sprintf(buf, "%s", plname);
75.   	buf[STONE_LINE_LEN] = 0;
76.   	center(NAME_LINE, buf);
77.   
78.   	/* Put $ on stone */
79.   	Sprintf(buf, "%ld Au", u.ugold);
80.   	buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */
81.   	center(GOLD_LINE, buf);
82.   
83.   	/* Put together death description */
84.   	switch (killer_format) {
85.   		default: impossible("bad killer format?");
86.   		case KILLED_BY_AN:
87.   			Strcpy(buf, killed_by_prefix[how]);
88.   			Strcat(buf, an(killer));
89.   			break;
90.   		case KILLED_BY:
91.   			Strcpy(buf, killed_by_prefix[how]);
92.   			Strcat(buf, killer);
93.   			break;
94.   		case NO_KILLER_PREFIX:
95.   			Strcpy(buf, killer);
96.   			break;
97.   	}
98.   
99.   	/* Put death type on stone */
100.  	for (line=DEATH_LINE, dpx = buf; line<YEAR_LINE; line++) {
101.  		register int i,i0;
102.  		char tmpchar;
103.  
104.  		if ( (i0=strlen(dpx)) > STONE_LINE_LEN) {
105.  				for(i = STONE_LINE_LEN;
106.  				    ((i0 > STONE_LINE_LEN) && i); i--)
107.  					if(dpx[i] == ' ') i0 = i;
108.  				if(!i) i0 = STONE_LINE_LEN;
109.  		}
110.  		tmpchar = dpx[i0];
111.  		dpx[i0] = 0;
112.  		center(line, dpx);
113.  		if (tmpchar != ' ') {
114.  			dpx[i0] = tmpchar;
115.  			dpx= &dpx[i0];
116.  		} else  dpx= &dpx[i0+1];
117.  	}
118.  
119.  	/* Put year on stone */
120.  	Sprintf(buf, "%4d", getyear());
121.  	center(YEAR_LINE, buf);
122.  
123.  	putstr(tmpwin, 0, "");
124.  	for(; *dp; dp++)
125.  		putstr(tmpwin, 0, *dp);
126.  
127.  	putstr(tmpwin, 0, "");
128.  	putstr(tmpwin, 0, "");
129.  
130.  	for (x = 0; rip_txt[x]; x++) {
131.  		free((genericptr_t)rip[x]);
132.  	}
133.  	free((genericptr_t)rip);
134.  }
135.  
136.  #endif
137.  
138.  /*rip.c*/

Also on Fandom

Random Wiki