Mercurial > hg > early-roguelike
comparison srogue/rip.c @ 119:458df24e973d
srogue: use functions from mdport.c.
Shell escape, passwd entries, terminal settings, and most signal
handling is now done with the more portable md_* functions.
author | John "Elwin" Edwards |
---|---|
date | Wed, 30 Apr 2014 14:46:30 -0700 |
parents | ee250e3646fd |
children | 78fa1d0e5d25 |
comparison
equal
deleted
inserted
replaced
118:8d1dfc5a912c | 119:458df24e973d |
---|---|
12 * All rights reserved. | 12 * All rights reserved. |
13 * | 13 * |
14 * See the file LICENSE.TXT for full copyright and licensing information. | 14 * See the file LICENSE.TXT for full copyright and licensing information. |
15 */ | 15 */ |
16 | 16 |
17 #include <signal.h> | |
18 #include <ctype.h> | 17 #include <ctype.h> |
19 #include <string.h> | 18 #include <string.h> |
20 #include <sys/types.h> | 19 #include <sys/types.h> |
21 #include <pwd.h> | |
22 #include <fcntl.h> | 20 #include <fcntl.h> |
23 #include "rogue.h" | 21 #include "rogue.h" |
24 #include "rogue.ext" | 22 #include "rogue.ext" |
25 | 23 |
26 static char scoreline[100]; | 24 static char scoreline[100]; |
125 reg struct sc_ent *scp, *sc2; | 123 reg struct sc_ent *scp, *sc2; |
126 reg int i, fd, prflags = 0; | 124 reg int i, fd, prflags = 0; |
127 reg FILE *outf; | 125 reg FILE *outf; |
128 char *packend; | 126 char *packend; |
129 | 127 |
130 signal(SIGINT, byebye); | 128 md_onsignal_exit(); |
131 signal(SIGQUIT, byebye); | |
132 if (aflag != WINNER) { | 129 if (aflag != WINNER) { |
133 if (aflag == CHICKEN) | 130 if (aflag == CHICKEN) |
134 packend = "when you chickened out"; | 131 packend = "when you chickened out"; |
135 else | 132 else |
136 packend = "at your untimely demise"; | 133 packend = "at your untimely demise"; |
211 top_ten[i].sc_monster, top_ten[i].sc_explvl, | 208 top_ten[i].sc_monster, top_ten[i].sc_explvl, |
212 top_ten[i].sc_exppts, top_ten[i].sc_date); | 209 top_ten[i].sc_exppts, top_ten[i].sc_date); |
213 encwrite((char *) scoreline, 100, outf); | 210 encwrite((char *) scoreline, 100, outf); |
214 } | 211 } |
215 fclose(outf); | 212 fclose(outf); |
216 signal(SIGINT, byebye); | 213 md_onsignal_exit(); |
217 signal(SIGQUIT, byebye); | |
218 clear(); | 214 clear(); |
219 refresh(); | 215 refresh(); |
220 endwin(); | 216 endwin(); |
221 showtop(prflags); /* print top ten list */ | 217 showtop(prflags); /* print top ten list */ |
222 } | 218 } |
298 killer = killname(scp->sc_monster); | 294 killer = killname(scp->sc_monster); |
299 printf(" by a%s %s",vowelstr(killer), killer); | 295 printf(" by a%s %s",vowelstr(killer), killer); |
300 } | 296 } |
301 printf(" [Exp: %d/%ld]",scp->sc_explvl,scp->sc_exppts); | 297 printf(" [Exp: %d/%ld]",scp->sc_explvl,scp->sc_exppts); |
302 if (showname) { | 298 if (showname) { |
303 struct passwd *pp, *getpwuid(); | 299 printf(" (%s)\n", md_getrealname(scp->sc_uid)); |
304 | |
305 if ((pp = getpwuid(scp->sc_uid)) == NULL) | |
306 printf(" (%d)\n", scp->sc_uid); | |
307 else | |
308 printf(" (%s)\n", pp->pw_name); | |
309 } | 300 } |
310 else | 301 else |
311 printf("\n"); | 302 printf("\n"); |
312 } | 303 } |
313 } | 304 } |