annotate src/tool-hr.c @ 19:de685799a432

Made torps wobbly when going through nebulous terrain. Only happens if nebula_effect contains photon.
author darius
date Wed, 24 Dec 1997 12:40:04 +0000
parents 0836fb919dfa
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1 /*--------------------------------------------------------------------------
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
2 NETREK II -- Paradise
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
3
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
4 Permission to use, copy, modify, and distribute this software and its
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
5 documentation, or any derivative works thereof, for any NON-COMMERCIAL
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
6 purpose and without fee is hereby granted, provided that this copyright
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
7 notice appear in all copies. No representations are made about the
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
8 suitability of this software for any purpose. This software is provided
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
9 "as is" without express or implied warranty.
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
10
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
11 Xtrek Copyright 1986 Chris Guthrie
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
12 Netrek (Xtrek II) Copyright 1989 Kevin P. Smith
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
13 Scott Silvey
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
14 Paradise II (Netrek II) Copyright 1993 Larry Denys
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
15 Kurt Olsen
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
16 Brandon Gillespie
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
17 --------------------------------------------------------------------------*/
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
18
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
19 #include "config.h"
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
20
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
21 #include <stdio.h>
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
22 #include <malloc.h>
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
23 #include <sys/types.h>
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
24 #include <sys/stat.h>
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
25 #include <errno.h>
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
26 #include "defs.h"
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
27 #include "data.h"
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
28 #include "struct.h"
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
29 #include "shmem.h"
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
30 #include "path.h"
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
31
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
32 #ifdef sparc
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
33 extern char *sys_errlist[];
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
34 #define strerror(EN) sys_errlist[(EN)]
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
35 #endif
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
36
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
37 #define LINESPERPAGE 38
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
38
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
39 struct statentry *database;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
40 struct statentry **playertab;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
41 int topn, motd = 0;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
42
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
43 void header();
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
44
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
45 void
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
46 printUsage(me)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
47 char *me;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
48 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
49 int x;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
50 char message[][255] = {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
51 "\nHonor Roll of players in the current database.\n",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
52 "\n\t'%s n [options]'\n\n",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
53 "Where n is the number of scores to print (top n)\n",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
54 "\nOptions:\n",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
55 "\t-f file Use \"file\" as player file (default: $NETREKDIR/etc/db.players)\n",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
56 "\t-m Format output for use in server MOTD\n\n",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
57 ""
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
58 };
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
59
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
60 fprintf(stderr, "--- Netrek II (Paradise), %s ---\n", PARAVERS);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
61 for (x = 0; *message[x] != '\0'; x++)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
62 fprintf(stderr, message[x], me);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
63
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
64 exit(1);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
65 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
66
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
67 int
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
68 cmp_func(a, b)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
69 struct statentry **a, **b;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
70 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
71 float di_diff = (*a)->stats.st_di - (*b)->stats.st_di;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
72 int rk_diff = (*a)->stats.st_rank - (*b)->stats.st_rank;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
73
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
74 /* rank takes precedent over DI */
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
75 if (rk_diff < 0)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
76 return 1;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
77 else if (rk_diff > 0)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
78 return -1;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
79
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
80 if (di_diff < 0)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
81 return 1;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
82 else if (di_diff > 0)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
83 return -1;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
84
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
85 return strcmp((*a)->name, (*b)->name);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
86 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
87
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
88 #if 0
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
89 static char *rankh[] = {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
90 "Recruits:",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
91 "Specialists:",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
92 "Cadets:",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
93 "Midshipmen:",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
94 "Ensigns, Junior Grade:",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
95 "Ensigns:",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
96 "Lieutenants, Junior Grade:",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
97 "Lieutenants:",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
98 "Lieutenant Commanders:",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
99 "Commanders:",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
100 "Captains:",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
101 "Fleet Captains:",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
102 "Commodores:",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
103 "Moffs:",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
104 "Grand Moffs:",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
105 "Rear Admirals:",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
106 "Admirals:",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
107 "Grand Admirals:",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
108 };
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
109 #endif
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
110
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
111 int
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
112 main(argc, argv)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
113 int argc;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
114 char *argv[];
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
115 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
116 int i, nplayers, j, count = 0;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
117 FILE *fp;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
118 struct stat fstats;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
119 char *fn;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
120 struct stats *s;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
121
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
122 if (argc < 2)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
123 printUsage(argv[0]);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
124
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
125 if (!(topn = atoi(argv[1])))
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
126 printUsage(argv[0]);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
127
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
128 fn = build_path(PLAYERFILE);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
129
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
130 for (i = 2; i < argc; i++)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
131 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
132 if (!strcmp(argv[i], "-f"))
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
133 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
134 if (i + 1 == argc)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
135 printUsage(argv[0]);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
136 fn = argv[++i];
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
137 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
138 else if (!strcmp(argv[i], "-m"))
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
139 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
140 motd = 1;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
141 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
142 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
143
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
144 if (!(fp = fopen(fn, "r")))
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
145 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
146 fprintf(stderr, "Couldn't open file %s: %s\n", fn, strerror(errno));
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
147 exit(1);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
148 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
149
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
150 if (fstat(fileno(fp), &fstats) < 0)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
151 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
152 fprintf(stderr, "Couldn't fstat file %s: %s\n", fn, strerror(errno));
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
153 exit(1);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
154 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
155
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
156 nplayers = fstats.st_size / sizeof(*database);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
157 database = malloc(sizeof(*database) * nplayers);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
158
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
159 i = fread(database, sizeof(*database), nplayers, fp);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
160 if (i != nplayers)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
161 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
162 fprintf(stderr, "failed to read all player records from file %s (%d of %d)\n", fn, i, nplayers);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
163 nplayers = i;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
164 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
165
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
166 fclose(fp);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
167
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
168 if (topn < 0 || topn > nplayers)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
169 topn = nplayers;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
170
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
171 /* Make an array of pointers to the database. */
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
172 playertab = malloc(sizeof(playertab) * nplayers);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
173
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
174 for (i = 0; i < nplayers; i++)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
175 playertab[i] = &(database[i]);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
176
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
177 /* sort the pointers */
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
178 qsort(playertab, nplayers, sizeof(playertab), cmp_func);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
179
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
180 header();
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
181 count = 1;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
182
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
183 j = 18;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
184 for (i = 0; i < topn; i++)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
185 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
186 s = &(playertab[i]->stats);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
187 if (j > s->st_rank)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
188 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
189 j = s->st_rank;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
190 if (motd)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
191 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
192 count += 2;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
193 if (count >= LINESPERPAGE)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
194 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
195 header();
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
196 count = 3;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
197 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
198 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
199 printf("\n%s\n", ranks[j].name);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
200 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
201 if (motd && (++count > LINESPERPAGE))
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
202 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
203 header();
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
204 printf("\n");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
205 count = 3;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
206 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
207 printf("%4d. %15s %8.2f %6d %6d %6d %4d %5d %5d %7.2f\n", i + 1,
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
208 playertab[i]->name, s->st_di, s->st_tkills, s->st_tlosses,
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
209 s->st_tarmsbomb, s->st_tresbomb, s->st_tplanets,
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
210 s->st_tdooshes, (float) (s->st_tticks / 36000.0));
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
211 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
212 exit(1);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
213 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
214
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
215 void
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
216 header()
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
217 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
218 if (motd)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
219 printf("\t@@b\n");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
220 printf("TOP %-4d Name DI Wins Losses Armies Rsrcs Plnts Dshs Hours\n", topn);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
221 printf("-------------------------------------------------------------------------------");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
222 }