Mercurial > ~darius > hgwebdir.cgi > paradise_server
comparison src/tool-heraldry.c @ 8:0836fb919dfa
First entry of Paradise Server 2.9 patch 10 Beta
author | darius |
---|---|
date | Sat, 06 Dec 1997 04:37:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
7:814de70c9f67 | 8:0836fb919dfa |
---|---|
1 /*-------------------------------------------------------------------------- | |
2 NETREK II -- Paradise | |
3 | |
4 Permission to use, copy, modify, and distribute this software and its | |
5 documentation, or any derivative works thereof, for any NON-COMMERCIAL | |
6 purpose and without fee is hereby granted, provided that this copyright | |
7 notice appear in all copies. No representations are made about the | |
8 suitability of this software for any purpose. This software is provided | |
9 "as is" without express or implied warranty. | |
10 | |
11 Xtrek Copyright 1986 Chris Guthrie | |
12 Netrek (Xtrek II) Copyright 1989 Kevin P. Smith | |
13 Scott Silvey | |
14 Paradise II (Netrek II) Copyright 1993 Larry Denys | |
15 Kurt Olsen | |
16 Brandon Gillespie | |
17 --------------------------------------------------------------------------*/ | |
18 | |
19 /* | |
20 * Robert Forsman | |
21 * | |
22 * Scans the score file for royalty. | |
23 */ | |
24 | |
25 #include "config.h" | |
26 | |
27 #include <stdio.h> | |
28 #include <sys/types.h> | |
29 #include <sys/file.h> | |
30 #include <pwd.h> | |
31 #include "defs.h" | |
32 #include "struct.h" | |
33 #include "data.h" | |
34 | |
35 | |
36 struct person | |
37 { | |
38 int royal; | |
39 char name[16]; | |
40 struct person *next; | |
41 }; | |
42 | |
43 int | |
44 compare_people(a, b) | |
45 struct person *a, *b; | |
46 { | |
47 if (a->royal > b->royal) | |
48 return 1; | |
49 else | |
50 return -1; | |
51 } | |
52 | |
53 int | |
54 main(argc, argv) | |
55 int argc; | |
56 char **argv; | |
57 { | |
58 struct statentry plstats; | |
59 struct person *head = 0; | |
60 int royalty; | |
61 | |
62 printf("Reading players file from stdin..."); | |
63 while (1 == fread(&plstats, sizeof(plstats), 1, stdin)) | |
64 { | |
65 if (plstats.stats.st_royal > 0) | |
66 { | |
67 /* royalty! insert into linked list. */ | |
68 struct person **scan; | |
69 struct person *dude; | |
70 dude = (struct person *) malloc(sizeof(*dude)); | |
71 dude->royal = plstats.stats.st_royal; | |
72 strncpy(dude->name, plstats.name, sizeof(dude->name)); | |
73 for (scan = &head; | |
74 *scan && 0 > compare_people(dude, *scan); | |
75 scan = &(*scan)->next) | |
76 ; | |
77 dude->next = *scan; | |
78 *scan = dude; | |
79 } | |
80 } | |
81 printf("done.\n"); | |
82 | |
83 | |
84 royalty = -1; | |
85 while (head) | |
86 { | |
87 struct person *temp; | |
88 if (royalty != head->royal) | |
89 { | |
90 royalty = head->royal; | |
91 printf("%s:\n", royal[royalty].name); | |
92 } | |
93 printf(" %s\n", head->name); | |
94 temp = head; | |
95 head = head->next; | |
96 free(temp); | |
97 } | |
98 | |
99 exit(0); | |
100 } |