Fandom

Wikihack

Source: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 src/rip.c from NetHack 3.4.3. To link to a particular line, write [[rip.c#line123]], for example.

Top of file Edit

1.    /*	SCCS Id: @(#)rip.c	3.4	2003/01/08	*/
2.    /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3.    /* NetHack may be freely redistributed.  See license for details. */
4.    
The NetHack General Public License applies to screenshots, source code and other content from NetHack.
5.    #include "hack.h"
6.    
7.    STATIC_DCL void FDECL(center, (int, char *));
8.    
9.    extern const char * const killed_by_prefix[];	/* from topten.c */
10.   
11.   #if defined(TTY_GRAPHICS) || defined(X11_GRAPHICS) || defined(GEM_GRAPHICS) || defined(MSWIN_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.   

center Edit

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.   

genl_outrip Edit

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.  #ifndef GOLDOBJ
112.  	Sprintf(buf, "%ld Au", u.ugold);
113.  #else
114.  	Sprintf(buf, "%ld Au", done_money);
115.  #endif
116.  	buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */
117.  	center(GOLD_LINE, buf);
118.  
119.  	/* Put together death description */
120.  	switch (killer_format) {
121.  		default: impossible("bad killer format?");
122.  		case KILLED_BY_AN:
123.  			Strcpy(buf, killed_by_prefix[how]);
124.  			Strcat(buf, an(killer));
125.  			break;
126.  		case KILLED_BY:
127.  			Strcpy(buf, killed_by_prefix[how]);
128.  			Strcat(buf, killer);
129.  			break;
130.  		case NO_KILLER_PREFIX:
131.  			Strcpy(buf, killer);
132.  			break;
133.  	}
134.  
135.  	/* Put death type on stone */
136.  	for (line=DEATH_LINE, dpx = buf; line<YEAR_LINE; line++) {
137.  		register int i,i0;
138.  		char tmpchar;
139.  
140.  		if ( (i0=strlen(dpx)) > STONE_LINE_LEN) {
141.  				for(i = STONE_LINE_LEN;
142.  				    ((i0 > STONE_LINE_LEN) && i); i--)
143.  					if(dpx[i] == ' ') i0 = i;
144.  				if(!i) i0 = STONE_LINE_LEN;
145.  		}
146.  		tmpchar = dpx[i0];
147.  		dpx[i0] = 0;
148.  		center(line, dpx);
149.  		if (tmpchar != ' ') {
150.  			dpx[i0] = tmpchar;
151.  			dpx= &dpx[i0];
152.  		} else  dpx= &dpx[i0+1];
153.  	}
154.  
155.  	/* Put year on stone */
156.  	Sprintf(buf, "%4d", getyear());
157.  	center(YEAR_LINE, buf);
158.  
159.  	putstr(tmpwin, 0, "");
160.  	for(; *dp; dp++)
161.  		putstr(tmpwin, 0, *dp);
162.  
163.  	putstr(tmpwin, 0, "");
164.  	putstr(tmpwin, 0, "");
165.  
166.  	for (x = 0; rip_txt[x]; x++) {
167.  		free((genericptr_t)rip[x]);
168.  	}
169.  	free((genericptr_t)rip);
170.  	rip = 0;
171.  }
172.  
173.  #endif	/* TEXT_TOMBSTONE */
174.  
175.  /*rip.c*/

Also on Fandom

Random Wiki