Source:NetHack 3.3.0/rip.c

From NetHackWiki
Revision as of 11:38, 4 March 2008 by Kernigh bot (talk | contribs) (NetHack 3.3.0/rip.c moved to Source:NetHack 3.3.0/rip.c: Robot: moved page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Below is the full text to rip.c from the source code of NetHack 3.3.0. To link to a particular line, write [[NetHack 3.3.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.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

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