Mercurial > hg > early-roguelike
comparison arogue5/rip.c @ 63:0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
author | elwin |
---|---|
date | Thu, 09 Aug 2012 22:58:48 +0000 |
parents | |
children | 7aff18a8d508 |
comparison
equal
deleted
inserted
replaced
62:0ef99244acb8 | 63:0ed67132cf10 |
---|---|
1 /* | |
2 * File for the fun ends | |
3 * Death or a total win | |
4 * | |
5 * Advanced Rogue | |
6 * Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T | |
7 * All rights reserved. | |
8 * | |
9 * Based on "Rogue: Exploring the Dungeons of Doom" | |
10 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman | |
11 * All rights reserved. | |
12 * | |
13 * See the file LICENSE.TXT for full copyright and licensing information. | |
14 */ | |
15 | |
16 /* Print flags for scoring */ | |
17 #define REALLIFE 1 /* Print out machine and logname */ | |
18 #define EDITSCORE 2 /* Edit the current score file */ | |
19 #define ADDSCORE 3 /* Add a new score */ | |
20 | |
21 #include <fcntl.h> | |
22 #include <stdio.h> | |
23 #include <stdlib.h> | |
24 #include "curses.h" | |
25 #include <time.h> | |
26 #include <signal.h> | |
27 #include <ctype.h> | |
28 #include <sys/types.h> | |
29 #include "network.h" | |
30 #include "rogue.h" | |
31 #include "mach_dep.h" | |
32 | |
33 /* | |
34 * If you change this structure, change the compatibility routines | |
35 * scoreout() and scorein() to reflect the change. Also update SCORELEN. | |
36 */ | |
37 | |
38 struct sc_ent { | |
39 unsigned long sc_score; | |
40 char sc_name[LINELEN]; | |
41 char sc_system[SYSLEN]; | |
42 char sc_login[LOGLEN]; | |
43 short sc_flgs; | |
44 short sc_level; | |
45 short sc_ctype; | |
46 short sc_monster; | |
47 short sc_quest; | |
48 }; | |
49 | |
50 #define SCORELEN \ | |
51 (sizeof(unsigned long) + LINELEN + SYSLEN + LOGLEN + 5*sizeof(short)) | |
52 | |
53 static char *rip[] = { | |
54 " __________", | |
55 " / \\", | |
56 " / REST \\", | |
57 " / IN \\", | |
58 " / PEACE \\", | |
59 " / \\", | |
60 " | |", | |
61 " | |", | |
62 " | killed by |", | |
63 " | |", | |
64 " | 1984 |", | |
65 " *| * * * | *", | |
66 " ________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______", | |
67 0 | |
68 }; | |
69 | |
70 char *killname(); | |
71 | |
72 | |
73 | |
74 | |
75 | |
76 void | |
77 byebye(sig) | |
78 int sig; | |
79 { | |
80 NOOP(sig); | |
81 if (!isendwin()) { | |
82 clear(); | |
83 endwin(); | |
84 } | |
85 printf("\n"); | |
86 exit(0); | |
87 } | |
88 | |
89 | |
90 /* | |
91 * death: | |
92 * Do something really fun when he dies | |
93 */ | |
94 | |
95 death(monst) | |
96 register short monst; | |
97 { | |
98 register char **dp = rip, *killer; | |
99 register struct tm *lt; | |
100 time_t date; | |
101 char buf[80]; | |
102 struct tm *localtime(); | |
103 | |
104 time(&date); | |
105 lt = localtime(&date); | |
106 clear(); | |
107 move(8, 0); | |
108 while (*dp) | |
109 printw("%s\n", *dp++); | |
110 mvaddstr(14, 28-((strlen(whoami)+1)/2), whoami); | |
111 sprintf(buf, "%lu Points", pstats.s_exp ); | |
112 mvaddstr(15, 28-((strlen(buf)+1)/2), buf); | |
113 killer = killname(monst); | |
114 mvaddstr(17, 28-((strlen(killer)+1)/2), killer); | |
115 mvaddstr(18, 26, (sprintf(prbuf, "%4d", 1900+lt->tm_year), prbuf)); | |
116 move(LINES-1, 0); | |
117 refresh(); | |
118 score(pstats.s_exp, KILLED, monst); | |
119 exit(0); | |
120 } | |
121 | |
122 char * | |
123 killname(monst) | |
124 register short monst; | |
125 { | |
126 static char mons_name[LINELEN]; | |
127 int i; | |
128 | |
129 if (monst > NUMMONST) return("a strange monster"); | |
130 | |
131 if (monst >= 0) { | |
132 switch (monsters[monst].m_name[0]) { | |
133 case 'a': | |
134 case 'e': | |
135 case 'i': | |
136 case 'o': | |
137 case 'u': | |
138 sprintf(mons_name, "an %s", monsters[monst].m_name); | |
139 break; | |
140 default: | |
141 sprintf(mons_name, "a %s", monsters[monst].m_name); | |
142 } | |
143 return(mons_name); | |
144 } | |
145 for (i = 0; i< DEATHNUM; i++) { | |
146 if (deaths[i].reason == monst) | |
147 break; | |
148 } | |
149 if (i >= DEATHNUM) | |
150 return ("strange death"); | |
151 return (deaths[i].name); | |
152 } | |
153 | |
154 | |
155 /* | |
156 * score -- figure score and post it. | |
157 */ | |
158 | |
159 /* VARARGS2 */ | |
160 score(amount, flags, monst) | |
161 unsigned long amount; | |
162 short monst; | |
163 { | |
164 static struct sc_ent top_ten[NUMSCORE]; | |
165 register struct sc_ent *scp; | |
166 register int i; | |
167 register struct sc_ent *sc2; | |
168 register FILE *outf; | |
169 register char *killer; | |
170 register int prflags = 0; | |
171 register int fd; | |
172 short upquest = 0, wintype = 0, uplevel = 0, uptype = 0; /* For network updating */ | |
173 char upsystem[SYSLEN], uplogin[LOGLEN]; | |
174 char *thissys; /* Holds the name of this system */ | |
175 char *compatstr=NULL; /* Holds scores for writing compatible score files */ | |
176 #define REASONLEN 3 | |
177 static char *reason[] = { | |
178 "killed", | |
179 "quit", | |
180 "A total winner", | |
181 "somehow left", | |
182 }; | |
183 char *packend; | |
184 memset(top_ten,0,sizeof(top_ten)); | |
185 signal(SIGINT, byebye); | |
186 if (flags != WINNER && flags != SCOREIT && flags != UPDATE) { | |
187 if (flags == CHICKEN) | |
188 packend = "when you quit"; | |
189 else | |
190 packend = "at your untimely demise"; | |
191 mvaddstr(LINES - 1, 0, retstr); | |
192 refresh(); | |
193 wgetnstr(cw,prbuf,80); | |
194 showpack(packend); | |
195 } | |
196 purse = 0; /* Steal all the gold */ | |
197 | |
198 /* | |
199 * Open file and read list | |
200 */ | |
201 | |
202 if ((fd = open(score_file, O_RDWR | O_CREAT, 0666)) < 0) | |
203 { | |
204 printf("\nCannot open score_file.\n"); | |
205 return; | |
206 } | |
207 outf = (FILE *) fdopen(fd, "w"); | |
208 | |
209 /* Get this system's name */ | |
210 thissys = md_gethostname(); | |
211 | |
212 for (scp = top_ten; scp <= &top_ten[NUMSCORE-1]; scp++) | |
213 { | |
214 scp->sc_score = 0L; | |
215 for (i = 0; i < 80; i++) | |
216 scp->sc_name[i] = rnd(255); | |
217 scp->sc_quest= RN; | |
218 scp->sc_flgs = RN; | |
219 scp->sc_level = RN; | |
220 scp->sc_monster = RN; | |
221 scp->sc_ctype = 0; | |
222 strncpy(scp->sc_system, thissys, SYSLEN); | |
223 scp->sc_login[0] = '\0'; | |
224 } | |
225 | |
226 /* | |
227 * If this is a SCOREIT optin (rogue -s), don't call byebye. The | |
228 * endwin() call in byebye() will result in a core dump. | |
229 */ | |
230 if (flags == SCOREIT) signal(SIGINT, SIG_DFL); | |
231 else signal(SIGINT, byebye); | |
232 | |
233 if (flags != SCOREIT && flags != UPDATE) | |
234 { | |
235 mvaddstr(LINES - 1, 0, retstr); | |
236 refresh(); | |
237 fflush(stdout); | |
238 wgetnstr(stdscr,prbuf,80); | |
239 } | |
240 | |
241 /* Check for special options */ | |
242 if (strcmp(prbuf, "names") == 0) | |
243 prflags = REALLIFE; | |
244 #ifdef WIZARD | |
245 else if (wizard) { | |
246 if (strcmp(prbuf, "edit") == 0) prflags = EDITSCORE; | |
247 else if (strcmp(prbuf, "add") == 0) { | |
248 prflags = ADDSCORE; | |
249 waswizard = FALSE; /* We want the new score recorded */ | |
250 } | |
251 } | |
252 #endif | |
253 | |
254 /* Read the score and convert it to a compatible format */ | |
255 scorein(top_ten, fd); /* Convert it */ | |
256 | |
257 /* Get some values if this is an update */ | |
258 if (flags == UPDATE) { | |
259 int errcheck, errors = 0; | |
260 | |
261 upquest = (short) netread(&errcheck, sizeof(short), stdin); | |
262 if (errcheck) errors++; | |
263 | |
264 if (fread(whoami, 1, LINELEN, stdin) != LINELEN) errors++; | |
265 | |
266 wintype = (short) netread(&errcheck, sizeof(short), stdin); | |
267 if (errcheck) errors++; | |
268 | |
269 uplevel = (short) netread(&errcheck, sizeof(short), stdin); | |
270 if (errcheck) errors++; | |
271 | |
272 uptype = (short) netread(&errcheck, sizeof(short), stdin); | |
273 if (errcheck) errors++; | |
274 | |
275 if (fread(upsystem, 1, SYSLEN, stdin) != SYSLEN) | |
276 errors++; | |
277 if (fread(uplogin, 1, LOGLEN, stdin) != LOGLEN) | |
278 errors++; | |
279 | |
280 if (errors) { | |
281 fclose(outf); | |
282 free(compatstr); | |
283 return; | |
284 } | |
285 } | |
286 | |
287 /* | |
288 * Insert player in list if need be | |
289 */ | |
290 if (!waswizard) { | |
291 char *login = NULL; | |
292 | |
293 if (flags != UPDATE) { | |
294 login = md_getusername(); | |
295 } | |
296 | |
297 if (flags == UPDATE) | |
298 (void) update(top_ten, amount, upquest, whoami, wintype, | |
299 uplevel, monst, uptype, upsystem, uplogin); | |
300 else { | |
301 #ifdef WIZARD | |
302 if (prflags == ADDSCORE) { /* Overlay characteristic by new ones */ | |
303 char buffer[80]; | |
304 int atoi(); | |
305 | |
306 clear(); | |
307 mvaddstr(1, 0, "Score: "); | |
308 mvaddstr(2, 0, "Quest (number): "); | |
309 mvaddstr(3, 0, "Name: "); | |
310 mvaddstr(4, 0, "System: "); | |
311 mvaddstr(5, 0, "Login: "); | |
312 mvaddstr(6, 0, "Level: "); | |
313 mvaddstr(7, 0, "Char type: "); | |
314 mvaddstr(8, 0, "Result: "); | |
315 | |
316 /* Get the score */ | |
317 move(1, 7); | |
318 get_str(buffer, stdscr); | |
319 amount = atol(buffer); | |
320 | |
321 /* Get the character's quest -- must be a number */ | |
322 move(2, 16); | |
323 get_str(buffer, stdscr); | |
324 quest_item = atoi(buffer); | |
325 | |
326 /* Get the character's name */ | |
327 move(3, 6); | |
328 get_str(buffer, stdscr); | |
329 strncpy(whoami, buffer, LINELEN); | |
330 | |
331 /* Get the system */ | |
332 move(4, 8); | |
333 get_str(buffer, stdscr); | |
334 strncpy(thissys, buffer, SYSLEN); | |
335 | |
336 /* Get the login */ | |
337 move(5, 7); | |
338 get_str(buffer, stdscr); | |
339 strncpy(login, buffer, LOGLEN); | |
340 | |
341 /* Get the level */ | |
342 move(6, 7); | |
343 get_str(buffer, stdscr); | |
344 level = max_level = (short) atoi(buffer); | |
345 | |
346 /* Get the character type */ | |
347 move(7, 11); | |
348 get_str(buffer, stdscr); | |
349 switch (buffer[0]) { | |
350 case 'F': | |
351 case 'f': | |
352 default: | |
353 player.t_ctype = C_FIGHTER; | |
354 break; | |
355 | |
356 case 'C': | |
357 case 'c': | |
358 player.t_ctype = C_CLERIC; | |
359 break; | |
360 | |
361 case 'M': | |
362 case 'm': | |
363 player.t_ctype = C_MAGICIAN; | |
364 break; | |
365 | |
366 case 'T': | |
367 case 't': | |
368 player.t_ctype = C_THIEF; | |
369 break; | |
370 } | |
371 | |
372 /* Get the win type */ | |
373 move(8, 8); | |
374 get_str(buffer, stdscr); | |
375 switch (buffer[0]) { | |
376 case 'W': | |
377 case 'w': | |
378 case 'T': | |
379 case 't': | |
380 flags = WINNER; | |
381 break; | |
382 | |
383 case 'Q': | |
384 case 'q': | |
385 flags = CHICKEN; | |
386 break; | |
387 | |
388 case 'k': | |
389 case 'K': | |
390 default: | |
391 flags = KILLED; | |
392 break; | |
393 } | |
394 | |
395 /* Get the monster if player was killed */ | |
396 if (flags == KILLED) { | |
397 mvaddstr(9, 0, "Death type: "); | |
398 get_str(buffer, stdscr); | |
399 if (buffer[0] == 'M' || buffer[0] == 'm') | |
400 monst = makemonster(FALSE); | |
401 else monst = getdeath(); | |
402 } | |
403 } | |
404 #endif | |
405 | |
406 if (update(top_ten, amount, (short) quest_item, whoami, flags, | |
407 (flags == WINNER) ? (short) max_level : (short) level, | |
408 monst, player.t_ctype, thissys, login) | |
409 #ifdef NUMNET | |
410 && fork() == 0 /* Spin off network process */ | |
411 #endif | |
412 ) { | |
413 #ifdef NUMNET | |
414 /* Send this update to the other systems in the network */ | |
415 int i, j; | |
416 char cmd[256]; /* Command for remote execution */ | |
417 FILE *rmf, *popen(); /* For input to remote command */ | |
418 | |
419 for (i=0; i<NUMNET; i++) | |
420 if (Network[i].system[0] != '!' && | |
421 strcmp(Network[i].system, thissys)) { | |
422 sprintf(cmd, | |
423 "usend -s -d%s -uNoLogin -!'%s -u' - 2>/dev/null", | |
424 Network[i].system, Network[i].rogue); | |
425 | |
426 /* Execute the command */ | |
427 if ((rmf=popen(cmd, "w")) != NULL) { | |
428 unsigned long temp; /* Temporary value */ | |
429 | |
430 /* Write out the parameters */ | |
431 (void) netwrite((unsigned long) amount, | |
432 sizeof(unsigned long), rmf); | |
433 | |
434 (void) netwrite((unsigned long) monst, | |
435 sizeof(short), rmf); | |
436 | |
437 (void) netwrite((unsigned long) quest_item, | |
438 sizeof(short), rmf); | |
439 | |
440 (void) fwrite(whoami, 1, strlen(whoami), rmf); | |
441 for (j=strlen(whoami); j<LINELEN; j++) | |
442 putc('\0', rmf); | |
443 | |
444 (void) netwrite((unsigned long) flags, | |
445 sizeof(short), rmf); | |
446 | |
447 temp = (unsigned long) | |
448 (flags==WINNER ? max_level : level); | |
449 (void) netwrite(temp, sizeof(short), rmf); | |
450 | |
451 (void) netwrite((unsigned long) player.t_ctype, | |
452 sizeof(short), rmf); | |
453 | |
454 (void) fwrite(thissys, 1, | |
455 strlen(thissys), rmf); | |
456 for (j=strlen(thissys); j<SYSLEN; j++) | |
457 putc('\0', rmf); | |
458 | |
459 (void) fwrite(login, 1, strlen(login), rmf); | |
460 for (j=strlen(login); j<LOGLEN; j++) | |
461 putc('\0', rmf); | |
462 | |
463 /* Close off the command */ | |
464 (void) pclose(rmf); | |
465 } | |
466 } | |
467 _exit(0); /* Exit network process */ | |
468 #endif | |
469 } | |
470 } | |
471 } | |
472 | |
473 /* | |
474 * SCOREIT -- rogue -s option. Never started curses if this option. | |
475 * UPDATE -- network scoring update. Never started curses if this option. | |
476 * EDITSCORE -- want to delete or change a score. | |
477 */ | |
478 /* if (flags != SCOREIT && flags != UPDATE && prflags != EDITSCORE) | |
479 endwin(); */ | |
480 | |
481 if (flags != UPDATE) { | |
482 if (flags != SCOREIT) { | |
483 clear(); | |
484 refresh(); | |
485 endwin(); | |
486 } | |
487 /* | |
488 * Print the list | |
489 */ | |
490 printf("\nTop %d Adventurers:\nRank Score\tName\n", | |
491 NUMSCORE); | |
492 | |
493 for (scp = top_ten; scp <= &top_ten[NUMSCORE-1]; scp++) { | |
494 char *class; | |
495 | |
496 if (scp->sc_score != 0) { | |
497 switch (scp->sc_ctype) { | |
498 case C_FIGHTER: class = "fighter"; | |
499 when C_MAGICIAN: class = "magician"; | |
500 when C_CLERIC: class = "cleric"; | |
501 when C_THIEF: class = "thief"; | |
502 otherwise: class = "unknown"; | |
503 } | |
504 | |
505 /* Make sure we have an in-bound reason */ | |
506 if (scp->sc_flgs > REASONLEN) scp->sc_flgs = REASONLEN; | |
507 | |
508 printf("%3d %10lu\t%s (%s)", scp - top_ten + 1, | |
509 scp->sc_score, scp->sc_name, class); | |
510 | |
511 if (prflags == REALLIFE) printf(" [in real life %.*s!%.*s]", | |
512 SYSLEN, scp->sc_system, LOGLEN, scp->sc_login); | |
513 printf(":\n\t\t%s on level %d", reason[scp->sc_flgs], | |
514 scp->sc_level); | |
515 | |
516 switch (scp->sc_flgs) { | |
517 case KILLED: | |
518 printf(" by"); | |
519 killer = killname(scp->sc_monster); | |
520 printf(" %s", killer); | |
521 break; | |
522 | |
523 case WINNER: | |
524 printf(" with the %s", | |
525 rel_magic[scp->sc_quest].mi_name); | |
526 break; | |
527 } | |
528 | |
529 if (prflags == EDITSCORE) | |
530 { | |
531 fflush(stdout); | |
532 fgets(prbuf,80,stdin); | |
533 printf("\n"); | |
534 if (prbuf[0] == 'd') { | |
535 for (sc2 = scp; sc2 < &top_ten[NUMSCORE-1]; sc2++) | |
536 *sc2 = *(sc2 + 1); | |
537 top_ten[NUMSCORE-1].sc_score = 0; | |
538 for (i = 0; i < 80; i++) | |
539 top_ten[NUMSCORE-1].sc_name[i] = rnd(255); | |
540 top_ten[NUMSCORE-1].sc_flgs = RN; | |
541 top_ten[NUMSCORE-1].sc_level = RN; | |
542 top_ten[NUMSCORE-1].sc_monster = RN; | |
543 scp--; | |
544 } | |
545 else if (prbuf[0] == 'e') { | |
546 printf("Death type: "); | |
547 fgets(prbuf,80,stdin); | |
548 if (prbuf[0] == 'M' || prbuf[0] == 'm') | |
549 scp->sc_monster = makemonster(FALSE); | |
550 else scp->sc_monster = getdeath(); | |
551 clear(); | |
552 refresh(); | |
553 } | |
554 } | |
555 else printf("\n"); | |
556 } | |
557 } | |
558 if ((flags != SCOREIT) && (flags != UPDATE)) { | |
559 printf("\n[Press return to exit]"); | |
560 fflush(stdout); | |
561 fgets(prbuf,80,stdin); | |
562 } | |
563 /* if (prflags == EDITSCORE) endwin(); */ /* End editing windowing */ | |
564 } | |
565 fseek(outf, 0L, 0); | |
566 /* | |
567 * Update the list file | |
568 */ | |
569 scoreout(top_ten, outf); | |
570 fclose(outf); | |
571 } | |
572 | |
573 /* | |
574 * scorein: | |
575 * Convert a character string that has been translated from a | |
576 * score file by scoreout() back to a score file structure. | |
577 */ | |
578 scorein(scores, fd) | |
579 struct sc_ent scores[]; | |
580 int fd; | |
581 { | |
582 int i; | |
583 char scoreline[100]; | |
584 | |
585 for(i = 0; i < NUMSCORE; i++) | |
586 { | |
587 encread((char *) &scores[i].sc_name, LINELEN, fd); | |
588 encread((char *) &scores[i].sc_system, SYSLEN, fd); | |
589 encread((char *) &scores[i].sc_login, LINELEN, fd); | |
590 encread((char *) scoreline, 100, fd); | |
591 sscanf(scoreline, " %lu %d %d %d %d %d \n", | |
592 &scores[i].sc_score, &scores[i].sc_flgs, | |
593 &scores[i].sc_level, &scores[i].sc_ctype, | |
594 &scores[i].sc_monster, &scores[i].sc_quest); | |
595 } | |
596 } | |
597 | |
598 /* | |
599 * scoreout: | |
600 * Convert a score file structure to a character string. We do | |
601 * this for compatibility sake since some machines write out fields in | |
602 * different orders. | |
603 */ | |
604 scoreout(scores, outf) | |
605 struct sc_ent scores[]; | |
606 FILE *outf; | |
607 { | |
608 int i; | |
609 char scoreline[100]; | |
610 | |
611 for(i = 0; i < NUMSCORE; i++) { | |
612 memset(scoreline,0,100); | |
613 encwrite((char *) scores[i].sc_name, LINELEN, outf); | |
614 encwrite((char *) scores[i].sc_system, SYSLEN, outf); | |
615 encwrite((char *) scores[i].sc_login, LINELEN, outf); | |
616 sprintf(scoreline, " %lu %d %d %d %d %d \n", | |
617 scores[i].sc_score, scores[i].sc_flgs, | |
618 scores[i].sc_level, scores[i].sc_ctype, | |
619 scores[i].sc_monster,scores[i].sc_quest); | |
620 encwrite((char *) scoreline, 100, outf); | |
621 } | |
622 } | |
623 | |
624 /* | |
625 * showpack: | |
626 * Display the contents of the hero's pack | |
627 */ | |
628 showpack(howso) | |
629 char *howso; | |
630 { | |
631 reg char *iname; | |
632 reg int cnt, packnum; | |
633 reg struct linked_list *item; | |
634 reg struct object *obj; | |
635 | |
636 idenpack(); | |
637 cnt = 1; | |
638 clear(); | |
639 mvprintw(0, 0, "Contents of your pack %s:\n",howso); | |
640 packnum = 'a'; | |
641 for (item = pack; item != NULL; item = next(item)) { | |
642 obj = OBJPTR(item); | |
643 iname = inv_name(obj, FALSE); | |
644 mvprintw(cnt, 0, "%c) %s\n",packnum++,iname); | |
645 if (++cnt >= LINES - 2 && | |
646 next(item) != NULL) { | |
647 cnt = 1; | |
648 mvaddstr(LINES - 1, 0, morestr); | |
649 refresh(); | |
650 wait_for(stdscr,' '); | |
651 clear(); | |
652 } | |
653 } | |
654 mvprintw(cnt + 1,0,"--- %d Gold Pieces ---",purse); | |
655 refresh(); | |
656 } | |
657 | |
658 total_winner() | |
659 { | |
660 register struct linked_list *item; | |
661 register struct object *obj; | |
662 register int worth; | |
663 register char c; | |
664 register int oldpurse; | |
665 | |
666 clear(); | |
667 standout(); | |
668 addstr(" \n"); | |
669 addstr(" @ @ @ @ @ @@@ @ @ \n"); | |
670 addstr(" @ @ @@ @@ @ @ @ @ \n"); | |
671 addstr(" @ @ @@@ @ @ @ @ @ @@@ @@@@ @@@ @ @@@ @ \n"); | |
672 addstr(" @@@@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ \n"); | |
673 addstr(" @ @ @ @ @ @ @ @@@@ @ @ @@@@@ @ @ @ \n"); | |
674 addstr(" @ @ @ @ @ @@ @ @ @ @ @ @ @ @ @ @ \n"); | |
675 addstr(" @@@ @@@ @@ @ @ @ @@@@ @@@@ @@@ @@@ @@ @ \n"); | |
676 addstr(" \n"); | |
677 addstr(" Congratulations, you have made it to the light of day! \n"); | |
678 standend(); | |
679 addstr("\nYou have joined the elite ranks of those who have escaped the\n"); | |
680 addstr("Dungeons of Doom alive. You journey home and sell all your loot at\n"); | |
681 addstr("a great profit and are appointed leader of a "); | |
682 switch (player.t_ctype) { | |
683 case C_MAGICIAN:addstr("magic user's guild.\n"); | |
684 when C_FIGHTER: addstr("fighters guild.\n"); | |
685 when C_CLERIC: addstr("monastery.\n"); | |
686 when C_THIEF: addstr("thief's guild.\n"); | |
687 otherwise: addstr("tavern.\n"); | |
688 } | |
689 mvaddstr(LINES - 1, 0, spacemsg); | |
690 refresh(); | |
691 wait_for(stdscr,' '); | |
692 clear(); | |
693 mvaddstr(0, 0, " Worth Item"); | |
694 oldpurse = purse; | |
695 for (c = 'a', item = pack; item != NULL; c++, item = next(item)) | |
696 { | |
697 obj = OBJPTR(item); | |
698 worth = get_worth(obj); | |
699 if (obj->o_group == 0) | |
700 worth *= obj->o_count; | |
701 whatis(item); | |
702 mvprintw(c - 'a' + 1, 0, "%c) %6d %s", c, worth, inv_name(obj, FALSE)); | |
703 purse += worth; | |
704 } | |
705 mvprintw(c - 'a' + 1, 0," %5d Gold Pieces ", oldpurse); | |
706 refresh(); | |
707 score(pstats.s_exp + (long) purse, WINNER, '\0'); | |
708 exit(0); | |
709 } | |
710 | |
711 update(top_ten, amount, quest, whoami, flags, level, monst, ctype, system, login) | |
712 struct sc_ent top_ten[]; | |
713 unsigned long amount; | |
714 short quest, flags, level, monst, ctype; | |
715 char *whoami, *system, *login; | |
716 { | |
717 register struct sc_ent *scp, *sc2; | |
718 int retval=0; /* 1 if a change, 0 otherwise */ | |
719 | |
720 for (scp = top_ten; scp < &top_ten[NUMSCORE]; scp++) { | |
721 if (amount >= scp->sc_score) | |
722 break; | |
723 | |
724 #ifdef LIMITSCORE /* Limits player to one entry per class per uid */ | |
725 /* If this good score is the same class and uid, then forget it */ | |
726 if (strncmp(scp->sc_login, login, LOGLEN) == 0 && | |
727 scp->sc_ctype == ctype && | |
728 strncmp(scp->sc_system, system, SYSLEN) == 0) return(0); | |
729 #endif | |
730 } | |
731 | |
732 if (scp < &top_ten[NUMSCORE]) | |
733 { | |
734 retval = 1; | |
735 | |
736 #ifdef LIMITSCORE /* Limits player to one entry per class per uid */ | |
737 /* If a lower scores exists for the same login and class, delete it */ | |
738 for (sc2 = scp ;sc2 < &top_ten[NUMSCORE]; sc2++) { | |
739 if (sc2->sc_score == 0L) break; /* End of useful scores */ | |
740 | |
741 if (strncmp(sc2->sc_login, login, LOGLEN) == 0 && | |
742 sc2->sc_ctype == ctype && | |
743 strncmp(sc2->sc_system, system, SYSLEN) == 0) { | |
744 /* We want to delete this entry */ | |
745 while (sc2 < &top_ten[NUMSCORE-1]) { | |
746 *sc2 = *(sc2+1); | |
747 sc2++; | |
748 } | |
749 sc2->sc_score = 0L; | |
750 } | |
751 } | |
752 #endif | |
753 | |
754 for (sc2 = &top_ten[NUMSCORE-1]; sc2 > scp; sc2--) | |
755 *sc2 = *(sc2-1); | |
756 scp->sc_score = amount; | |
757 scp->sc_quest = quest; | |
758 strncpy(scp->sc_name, whoami, LINELEN); | |
759 scp->sc_flgs = flags; | |
760 scp->sc_level = level; | |
761 scp->sc_monster = monst; | |
762 scp->sc_ctype = ctype; | |
763 strncpy(scp->sc_system, system, SYSLEN); | |
764 strncpy(scp->sc_login, login, LOGLEN); | |
765 } | |
766 | |
767 return(retval); | |
768 } |