comparison xrogue/rip.c @ 225:4f6e056438eb

Merge the GCC5 and build fix branches.
author John "Elwin" Edwards
date Wed, 02 Mar 2016 21:28:34 -0500
parents f54901b9c39b
children b49d8b963df3
comparison
equal deleted inserted replaced
224:4d0f53998e8a 225:4f6e056438eb
18 18
19 #define REALLIFE 1 /* Print out machine and logname */ 19 #define REALLIFE 1 /* Print out machine and logname */
20 #define EDITSCORE 2 /* Edit the current score file */ 20 #define EDITSCORE 2 /* Edit the current score file */
21 #define ADDSCORE 3 /* Add a new score */ 21 #define ADDSCORE 3 /* Add a new score */
22 22
23 #include <stdlib.h>
23 #include <curses.h> 24 #include <curses.h>
24 #include <time.h> 25 #include <time.h>
25 #include <signal.h> 26 #include <signal.h>
26 #include <ctype.h> 27 #include <ctype.h>
27 #include <string.h> 28 #include <string.h>
52 " *| * * * |*", 53 " *| * * * |*",
53 " _________)|//\\\\///\\///\\//\\//\\/|(_________", 54 " _________)|//\\\\///\\///\\//\\//\\/|(_________",
54 NULL 55 NULL
55 }; 56 };
56 57
57 char *killname(); 58 int rs_read_scorefile(FILE *savef, struct sc_ent *entries, int count);
59 void rs_write_scorefile(FILE *savef, struct sc_ent *entries, int count);
60
61 char *killname(short monst);
62 void showpack(char *howso);
63 int update(struct sc_ent top_ten[], unsigned long amount, short quest,
64 char *whoami, short flags, short level, short monst, short ctype,
65 char *system, char *login);
58 66
59 extern FILE *scorefi, *logfile; 67 extern FILE *scorefi, *logfile;
60 68
61 /*UNUSED*/ 69 /*UNUSED*/
62 void 70 void
63 byebye(sig) 71 byebye(int sig)
64 int sig;
65 { 72 {
66 NOOP(sig); 73 NOOP(sig);
67 exit_game(EXIT_ENDWIN); 74 exit_game(EXIT_ENDWIN);
68 } 75 }
69 76
71 /* 78 /*
72 * death: 79 * death:
73 * Do something really fun when he dies 80 * Do something really fun when he dies
74 */ 81 */
75 82
76 death(monst) 83 void
77 register short monst; 84 death(short monst)
78 { 85 {
79 register char **dp = rip, *killer; 86 register char **dp = rip, *killer;
80 register struct tm *lt; 87 register struct tm *lt;
81 time_t date; 88 time_t date;
82 char buf[LINELEN]; 89 char buf[LINELEN];
100 score(pstats.s_exp, KILLED, monst); 107 score(pstats.s_exp, KILLED, monst);
101 exit_game(EXIT_ENDWIN); 108 exit_game(EXIT_ENDWIN);
102 } 109 }
103 110
104 char * 111 char *
105 killname(monst) 112 killname(short monst)
106 register short monst;
107 { 113 {
108 static char mons_name[LINELEN/2]; 114 static char mons_name[LINELEN/2];
109 int i; 115 int i;
110 116
111 if (monst > NUMMONST) return("a strange monster"); 117 if (monst > NUMMONST) return("a strange monster");
185 /* 191 /*
186 * score -- figure score and post it. 192 * score -- figure score and post it.
187 */ 193 */
188 194
189 /* VARARGS2 */ 195 /* VARARGS2 */
190 score(amount, flags, monst) 196 void
191 unsigned long amount; 197 score(unsigned long amount, int flags, short monst)
192 int flags;
193 short monst;
194 { 198 {
195 struct sc_ent top_ten[NUMSCORE]; 199 struct sc_ent top_ten[NUMSCORE];
196 register struct sc_ent *scp; 200 register struct sc_ent *scp;
197 register int i; 201 register int i;
198 register struct sc_ent *sc2; 202 register struct sc_ent *sc2;
572 /* 576 /*
573 * showpack: 577 * showpack:
574 * Display the contents of the hero's pack 578 * Display the contents of the hero's pack
575 */ 579 */
576 580
577 showpack(howso) 581 void
578 char *howso; 582 showpack(char *howso)
579 { 583 {
580 reg char *iname; 584 reg char *iname;
581 reg int cnt, packnum; 585 reg int cnt, packnum;
582 reg struct linked_list *item; 586 reg struct linked_list *item;
583 reg struct object *obj; 587 reg struct object *obj;
602 } 606 }
603 mvprintw(cnt + 1,0,"--- %ld Gold Pieces ---",purse); 607 mvprintw(cnt + 1,0,"--- %ld Gold Pieces ---",purse);
604 refresh(); 608 refresh();
605 } 609 }
606 610
607 total_winner() 611 void
612 total_winner(void)
608 { 613 {
609 register struct linked_list *item; 614 register struct linked_list *item;
610 register struct object *obj; 615 register struct object *obj;
611 register long worth; 616 register long worth;
612 register char c; 617 register char c;
663 exit_game(EXIT_ENDWIN); 668 exit_game(EXIT_ENDWIN);
664 } 669 }
665 670
666 671
667 void 672 void
668 delete_score(top_ten, idx) 673 delete_score(struct sc_ent top_ten[NUMSCORE], int idx)
669 struct sc_ent top_ten[NUMSCORE];
670 int idx;
671 { 674 {
672 for(;idx < NUMSCORE-1;idx++) 675 for(;idx < NUMSCORE-1;idx++)
673 top_ten[idx] = top_ten[idx+1]; 676 top_ten[idx] = top_ten[idx+1];
674 677
675 top_ten[NUMSCORE-1].sc_score = 0L; 678 top_ten[NUMSCORE-1].sc_score = 0L;
676 } 679 }
677 680
678 int 681 int
679 insert_score(top_ten, sc) 682 insert_score(struct sc_ent top_ten[NUMSCORE], struct sc_ent *sc)
680 struct sc_ent top_ten[NUMSCORE];
681 struct sc_ent *sc;
682 { 683 {
683 int i,j; 684 int i,j;
684 685
685 if (top_ten[NUMSCORE-1].sc_score > 0) 686 if (top_ten[NUMSCORE-1].sc_score > 0)
686 return(-1); /* no room */ 687 return(-1); /* no room */
697 return(-1); 698 return(-1);
698 } 699 }
699 700
700 /* PCS = player-class-system (used to determines uniqueness of player) */ 701 /* PCS = player-class-system (used to determines uniqueness of player) */
701 702
702 int 703 bool
703 is_pcs_match(sc1,sc2) 704 is_pcs_match(struct sc_ent *sc1, struct sc_ent *sc2)
704 struct sc_ent *sc1;
705 struct sc_ent *sc2;
706 { 705 {
707 return( (strcmp(sc1->sc_name,sc2->sc_name) == 0) && 706 return( (strcmp(sc1->sc_name,sc2->sc_name) == 0) &&
708 (sc1->sc_ctype == sc2->sc_ctype) && 707 (sc1->sc_ctype == sc2->sc_ctype) &&
709 (strcmp(sc1->sc_system, sc2->sc_system)==0) ); 708 (strcmp(sc1->sc_system, sc2->sc_system)==0) );
710 } 709 }
711 710
712 int 711 int
713 count_pcs_matches(top_ten,sc,lowest) 712 count_pcs_matches(struct sc_ent top_ten[NUMSCORE], struct sc_ent *sc,
714 struct sc_ent top_ten[NUMSCORE]; 713 int *lowest)
715 struct sc_ent *sc;
716 int *lowest;
717 { 714 {
718 int i, matches = 0; 715 int i, matches = 0;
719 716
720 *lowest = -1; 717 *lowest = -1;
721 718
727 } 724 }
728 return(matches); 725 return(matches);
729 } 726 }
730 727
731 int 728 int
732 find_most_pcs_matches(top_ten,sc,num,idx) 729 find_most_pcs_matches(struct sc_ent top_ten[NUMSCORE], struct sc_ent *sc,
733 struct sc_ent top_ten[NUMSCORE]; 730 int *num, int *idx)
734 struct sc_ent *sc;
735 int *num, *idx;
736 { 731 {
737 int i, matches, max_match=0, max_match_idx=-1, lowest; 732 int i, matches, max_match=0, max_match_idx=-1, lowest;
738 733
739 for(i = NUMSCORE-1; i > 0; i--) { 734 for(i = NUMSCORE-1; i > 0; i--) {
740 matches = count_pcs_matches(top_ten,&top_ten[i],&lowest); 735 matches = count_pcs_matches(top_ten,&top_ten[i],&lowest);
759 return(0); 754 return(0);
760 } 755 }
761 756
762 757
763 int 758 int
764 add_score(top_ten,sc) 759 add_score(struct sc_ent top_ten[NUMSCORE], struct sc_ent *sc)
765 struct sc_ent top_ten[NUMSCORE];
766 struct sc_ent *sc;
767 { 760 {
768 int idx, count; 761 int idx, count;
769 762
770 if (insert_score(top_ten,sc) == -1) { 763 if (insert_score(top_ten,sc) == -1) {
771 /* Simple insert if space available in table */ 764 /* Simple insert if space available in table */
795 insert_score(top_ten,sc); 788 insert_score(top_ten,sc);
796 } 789 }
797 } 790 }
798 } 791 }
799 792
800 update(top_ten, amount, quest, whoami, flags, level, monst, ctype, system, login) 793 int
801 struct sc_ent top_ten[]; 794 update(struct sc_ent top_ten[], unsigned long amount, short quest, char *whoami,
802 unsigned long amount; 795 short flags, short level, short monst, short ctype, char *system,
803 short quest, flags, level, monst, ctype; 796 char *login)
804 char *whoami, *system, *login;
805 { 797 {
806 struct sc_ent sc; 798 struct sc_ent sc;
807 799
808 sc.sc_score = amount; 800 sc.sc_score = amount;
809 sc.sc_quest = quest; 801 sc.sc_quest = quest;