Source:SLASH'EM 0.0.7E7F2/rip.c

From NetHackWiki
Revision as of 19:38, 7 March 2008 by Kernigh bot (talk | contribs) (SLASH'EM 0.0.7E7F2/rip.c moved to Source:SLASH'EM 0.0.7E7F2/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 SLASH'EM 0.0.7E7F2. To link to a particular line, write [[SLASH'EM 0.0.7E7F2/rip.c#line123]], for example.

The latest source code for vanilla NetHack is at 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.4	2003/01/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 * const killed_by_prefix[];	/* from topten.c */
10.   
11.   #if defined(TTY_GRAPHICS) || defined(X11_GRAPHICS) || defined(GEM_GRAPHICS) || defined(MSWIN_GRAPHICS) || defined(GTK_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.   
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.   
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.                        if (Instant_Death) {
124.                          Strcpy(buf, "instantly ");
125.                          strcat(buf, killed_by_prefix[how]);
126.                        }
127.                        else if (Quick_Death) {
128.                          Strcpy(buf, "quickly ");
129.                          strcat(buf, killed_by_prefix[how]);
130.                        } else Strcpy(buf, killed_by_prefix[how]);
131.  			Strcat(buf, an(killer));
132.  			break;
133.  		case KILLED_BY:
134.                        if (Instant_Death) {
135.                          Strcpy(buf, "instantly ");
136.                          strcat(buf, killed_by_prefix[how]);
137.                        }
138.                        else if (Quick_Death) {
139.                          Strcpy(buf, "quickly ");
140.                          strcat(buf, killed_by_prefix[how]);
141.                        } else Strcpy(buf, killed_by_prefix[how]);
142.  			Strcat(buf, killer);
143.  			break;
144.  		case NO_KILLER_PREFIX:
145.  			Strcpy(buf, killer);
146.  			break;
147.  	}
148.  
149.  	/* Put death type on stone */
150.  	for (line=DEATH_LINE, dpx = buf; line<YEAR_LINE; line++) {
151.  		register int i,i0;
152.  		char tmpchar;
153.  
154.  		if ( (i0=strlen(dpx)) > STONE_LINE_LEN) {
155.  				for(i = STONE_LINE_LEN;
156.  				    ((i0 > STONE_LINE_LEN) && i); i--)
157.  					if(dpx[i] == ' ') i0 = i;
158.  				if(!i) i0 = STONE_LINE_LEN;
159.  		}
160.  		tmpchar = dpx[i0];
161.  		dpx[i0] = 0;
162.  		center(line, dpx);
163.  		if (tmpchar != ' ') {
164.  			dpx[i0] = tmpchar;
165.  			dpx= &dpx[i0];
166.  		} else  dpx= &dpx[i0+1];
167.  	}
168.  
169.  	/* Put year on stone */
170.  	Sprintf(buf, "%4d", getyear());
171.  	center(YEAR_LINE, buf);
172.  
173.  	putstr(tmpwin, 0, "");
174.  	for(; *dp; dp++)
175.  		putstr(tmpwin, 0, *dp);
176.  
177.  	putstr(tmpwin, 0, "");
178.  	putstr(tmpwin, 0, "");
179.  
180.  	for (x = 0; rip_txt[x]; x++) {
181.  		free((genericptr_t)rip[x]);
182.  	}
183.  	free((genericptr_t)rip);
184.  	rip = 0;
185.  }
186.  
187.  #endif	/* TEXT_TOMBSTONE */
188.  
189.  /*rip.c*/