annotate src/tool-hs.c @ 16:e246e5730173

Removed useless binaries from repository...
author darius
date Wed, 24 Dec 1997 12:36:02 +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 /*
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
20 * This is probably broken in anything but the default config
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
21 */
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
22
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
23 #include "config.h"
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
24
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
25 #include <stdio.h>
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
26 #include <malloc.h>
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
27 #include <sys/types.h>
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
28 #include <sys/stat.h>
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
29 #include "struct.h"
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
30 #include "data.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 int topn = 1;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
33 char name[40] = ""; /* if we want stats for a particular name */
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
34 int nplayers;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
35 struct statentry *database;
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 struct highscore
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 char name[32];
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
40 int di, tkills, tlosses, tarmsbomb, tresbomb, tdooshes, tplanets;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
41 int ticks;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
42 struct highscore *next;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
43 };
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 struct highscore *scores;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
46 int scoresize, nscores;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
47
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
48 void
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
49 subbrag(name, stuff, time, title, descr, num)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
50 char *name;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
51 int stuff, time;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
52 char *title;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
53 char *descr;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
54 int num;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
55 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
56 char full[64];
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
57 char line[80];
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
58 int len, tlen;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
59 int i;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
60 double rate;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
61
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
62 if (title)
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 sprintf(full, "%s: %s", title, name);
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 len = strlen(full);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
67 tlen = title ? strlen(title) : 0;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
68
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
69 for (i = len; i - tlen < 10; i++)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
70 full[i] = ' ';
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
71 full[i] = 0;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
72 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
73 else
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
74 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
75 strcpy(full, name);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
76 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
77
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
78 if (topn != 1)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
79 sprintf(line, "%15s %3d over ", full, stuff);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
80 else
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
81 sprintf(line, "%-30s (%2d) %3d %s, over ", full, num, stuff, descr);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
82
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
83 if (time / 10.0 > 3600)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
84 sprintf(line, "%s%1.2f hours ", line, time / 36000.0);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
85 else
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
86 sprintf(line, "%s%1.2f minutes ", line, time / 600.0);
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 (topn == 1)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
89 sprintf(line, "%s\n%40s", line, "");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
90
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
91 rate = stuff / (time / 600.0);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
92
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
93 if (rate < 1)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
94 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
95 printf(line);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
96 printf("(%1.2f minutes per)\n", 1 / rate);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
97 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
98 else if (rate > 60)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
99 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
100 printf(line);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
101 printf("(%1.2f per hour)\n", rate / 60);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
102 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
103 else
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
104 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
105 printf(line);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
106 printf("(%1.2f per minute)\n", rate);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
107 }
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
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
110 void
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
111 brag(title, descr, offset)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
112 char *title, *descr;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
113 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
114 int i;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
115 if (name[0] != 0)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
116 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
117 for (i = 0; i < nscores; i++)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
118 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
119 if (0 == strcmp(scores[i].name, name))
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
120 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
121 printf("#%5d: ", i + 1);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
122 subbrag("", *(int *) (offset + (char *) &scores[i]),
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
123 scores[i].ticks, title, descr, i);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
124 break;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
125 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
126 }
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 else
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 if (topn != 1)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
131 printf("\n%s (%s)\n", title, descr);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
132 for (i = 0; i < topn && i < nscores; i++)
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 printf("%10s", "");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
135 subbrag(scores[i].name, *(int *) (offset + (char *) &scores[i]),
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
136 scores[i].ticks, topn == 1 ? title : (char *) 0, descr, 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 }
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
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
141 #if __STDC__
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
142 #define COMPUTE(STN) \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
143 do { \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
144 currscore->STN = currplayer.stats.st_ ## STN - \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
145 prevplayer->stats.st_ ## STN; \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
146 } while (0)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
147
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 #define COMPARE(STN) \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
150 int cmp_raw ## STN(a,b) \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
151 struct highscore *a, *b; \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
152 { \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
153 int diff = a->STN - b->STN; \
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 if (diff<0) \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
156 return 1; \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
157 else if (diff==0) \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
158 return 0; \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
159 else \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
160 return -1; \
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 \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
163 int cmp_per ## STN(a,b) \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
164 struct highscore *a, *b; \
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 double diff = a->STN/(double)a->ticks - b->STN/(double)b->ticks; \
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 (diff<0) \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
169 return 1; \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
170 else if (diff==0) \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
171 return 0; \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
172 else \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
173 return -1; \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
174 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
175 #else
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
176 #define COMPUTE(STN) \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
177 do { \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
178 currscore->STN = currplayer.stats.st_/**/STN - \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
179 prevplayer->stats.st_/**/STN; \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
180 } while (0)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
181
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 #define COMPARE(STN) \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
184 int cmp_raw/**/STN(a,b) \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
185 struct highscore *a, *b; \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
186 { \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
187 int diff = a->STN - b->STN; \
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 if (diff<0) \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
190 return 1; \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
191 else if (diff==0) \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
192 return 0; \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
193 else \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
194 return -1; \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
195 } \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
196 \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
197 int cmp_per/**/STN(a,b) \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
198 struct highscore *a, *b; \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
199 { \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
200 double diff = a->STN/(double)a->ticks - b->STN/(double)b->ticks; \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
201 \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
202 if (diff<0) \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
203 return 1; \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
204 else if (diff==0) \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
205 return 0; \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
206 else \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
207 return -1; \
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
208 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
209 #endif
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
210
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
211 COMPARE(di)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
212 COMPARE(tkills)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
213 COMPARE(tlosses)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
214 COMPARE(tarmsbomb)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
215 COMPARE(tresbomb)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
216 COMPARE(tdooshes)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
217 COMPARE(tplanets)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
218 int cmp_ticks(a, b)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
219 struct highscore *a, *b;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
220 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
221 int diff = a->ticks - b->ticks;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
222
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
223 if (diff < 0)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
224 return 1;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
225 else if (diff == 0)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
226 return 0;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
227 else
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
228 return -1;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
229 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
230
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
231 struct statentry zeroplayer;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
232
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
233 int
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
234 different(one, two)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
235 struct highscore *one, *two;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
236 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
237 return 0 != strcmp(one->name, two->name);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
238 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
239
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
240 double atof();
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
241
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
242 int
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
243 main(argc, argv)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
244 int argc;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
245 char **argv;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
246 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
247 struct stat fstats;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
248 FILE *fp;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
249 int i;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
250 int code = 0;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
251 struct statentry currplayer;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
252 char **av;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
253 int usage = 0;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
254 float mintime = 30.0;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
255
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
256 for (av = &argv[1]; *av && (*av)[0] == '-'; av++)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
257 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
258 if (0 == strcmp(*av, "-n") && av[1])
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
259 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
260 topn = atoi(*++av);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
261 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
262 else if (0 == strcmp(*av, "-c") && av[1])
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
263 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
264 code = atoi(*++av);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
265 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
266 else if (0 == strcmp(*av, "-name") && av[1])
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
267 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
268 strcpy(name, *++av);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
269 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
270 else if (0 == strcmp(*av, "-time") && av[1])
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
271 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
272 mintime = atof(*++av);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
273 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
274 else
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
275 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
276 usage = 1;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
277 break;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
278 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
279 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
280 if (argc - (av - argv) != 2)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
281 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
282 usage = 1;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
283 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
284
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
285 if (usage)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
286 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
287 int x;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
288 char message[][255] = {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
289 "\nHigh Scores, created by comparing two databases.\n",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
290 "\n\t'%s -n <num> -c <num> [-name <name>] <old db> <new db>'\n\n",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
291 "Options:\n",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
292 "\t-n num How many high scores to print\n",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
293 "\t-c num Which category (0 is all, max available is 15)\n",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
294 "\t-name string print ranking for a particular player\n",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
295 "\nExample:\t'%s -n 5 -c 1 .players.bak .players'\n\n",
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
296 "\0"
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
297 };
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
298
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
299 fprintf(stderr, "--- %s ---\n", PARAVERS);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
300 for (x = 0; *message[x] != '\0'; x++)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
301 fprintf(stderr, message[x], argv[0]);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
302
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
303 exit(1);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
304 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
305
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
306 fp = fopen(av[0], "r");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
307 if (fp == 0)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
308 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
309 fprintf(stderr, "Couldn't open file %s for read", av[0]);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
310 perror("");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
311 exit(1);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
312 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
313
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
314 if (fstat(fileno(fp), &fstats) < 0)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
315 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
316 fprintf(stderr, "Couldn't fstat file %s", av[0]);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
317 perror("");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
318 exit(1);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
319 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
320
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
321 nplayers = fstats.st_size / sizeof(*database);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
322 database = (struct statentry *) malloc(sizeof(*database) * nplayers);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
323
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
324 i = fread(database, sizeof(*database), nplayers, fp);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
325
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
326 if (i == 0)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
327 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
328 fprintf(stderr, "failed to read any player records from file %s\n", av[0]);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
329 exit(1);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
330 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
331 if (i != nplayers)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
332 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
333 fprintf(stderr, "failed to read all player records from file %s (%d of %d)\n", av[0], i, nplayers);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
334 nplayers = i;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
335 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
336
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
337 fclose(fp);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
338
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
339 fp = fopen(av[1], "r");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
340 if (fp == 0)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
341 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
342 fprintf(stderr, "Couldn't open file %s for read", av[1]);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
343 perror("");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
344 exit(1);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
345 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
346
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
347
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
348 scores = (struct highscore *) malloc(sizeof(*scores) * (scoresize = 256));
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
349 nscores = 0;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
350
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
351 while (1)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
352 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
353 int delta;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
354 int dt;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
355 struct statentry *prevplayer;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
356 struct highscore *currscore;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
357
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
358 i = fread(&currplayer, sizeof(currplayer), 1, fp);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
359 if (i < 0)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
360 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
361 fprintf(stderr, "error reading player record, aborting loop\n");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
362 perror("");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
363 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
364 if (i <= 0)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
365 break;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
366
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
367 for (i = 0; i < nplayers; i++)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
368 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
369 if (0 == strcmp(database[i].name, currplayer.name))
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
370 break;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
371 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
372 if (i < nplayers)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
373 prevplayer = &database[i];
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
374 else
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
375 prevplayer = &zeroplayer;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
376
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
377 dt = currplayer.stats.st_tticks - prevplayer->stats.st_tticks;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
378
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
379 if (dt < mintime /* minutes */ * 60 * 10)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
380 continue;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
381
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
382 if (nscores >= scoresize)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
383 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
384 scores = (struct highscore *) realloc(scores, sizeof(*scores) * (scoresize *= 2));
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
385 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
386 currscore = &scores[nscores++];
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
387 strcpy(currscore->name, currplayer.name);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
388 currscore->ticks = dt;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
389
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
390 COMPUTE(di);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
391 COMPUTE(tkills);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
392 COMPUTE(tlosses);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
393 COMPUTE(tarmsbomb);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
394 COMPUTE(tresbomb);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
395 COMPUTE(tdooshes);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
396 COMPUTE(tplanets);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
397 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
398
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
399
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
400 #define offset(field) ( (int)&(((struct highscore*)0)->field) )
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
401
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
402 if (!code || code == 1)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
403 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
404 qsort(scores, nscores, sizeof(*scores), cmp_rawdi);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
405 brag("Lord of Destruction", "most destruction inflicted", offset(di));
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
406 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
407
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
408 if (!code && topn > 5)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
409 printf("\t@@b\n");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
410
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
411 if (!code || code == 2)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
412 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
413 qsort(scores, nscores, sizeof(*scores), cmp_perdi);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
414 brag("BlitzMeister", "fastest destruction inflicted", offset(di));
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
415 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
416
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
417 if (!code && topn > 5)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
418 printf("\t@@b\n");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
419
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
420 if (!code || code == 3)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
421 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
422 qsort(scores, nscores, sizeof(*scores), cmp_rawtkills);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
423 brag("Hitler", "most opponents defeated", offset(tkills));
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
424 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
425
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
426 if (!code && topn > 5)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
427 printf("\t@@b\n");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
428
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
429 if (!code || code == 4)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
430 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
431 qsort(scores, nscores, sizeof(*scores), cmp_pertkills);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
432 brag("Terminator", "fastest opponents defeated", offset(tkills));
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
433 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
434
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
435 if (!code && topn > 5)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
436 printf("\t@@b\n");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
437
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
438 if (!code || code == 5)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
439 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
440 qsort(scores, nscores, sizeof(*scores), cmp_rawtlosses);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
441 brag("Kamikaze", "most times down in flames", offset(tlosses));
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
442 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
443
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
444 if (!code && topn > 5)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
445 printf("\t@@b\n");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
446
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
447 if (!code || code == 6)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
448 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
449 qsort(scores, nscores, sizeof(*scores), cmp_pertlosses);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
450 brag("Speed Kamikaze", "fastest times down in flames", offset(tlosses));
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
451 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
452
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
453 if (!code && topn > 5)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
454 printf("\t@@b\n");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
455
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
456 if (!code || code == 7)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
457 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
458 qsort(scores, nscores, sizeof(*scores), cmp_rawtarmsbomb);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
459 brag("Carpet Bomber", "most armies bombed", offset(tarmsbomb));
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
460 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
461
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
462 if (!code && topn > 5)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
463 printf("\t@@b\n");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
464
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
465 if (!code || code == 8)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
466 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
467 qsort(scores, nscores, sizeof(*scores), cmp_pertarmsbomb);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
468 brag("NukeMeister", "fastest armies bombed", offset(tarmsbomb));
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
469 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
470
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
471 if (!code && topn > 5)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
472 printf("\t@@b\n");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
473
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
474 if (!code || code == 9)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
475 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
476 qsort(scores, nscores, sizeof(*scores), cmp_rawtresbomb);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
477 brag("Terrorist", "most resources leveled", offset(tresbomb));
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
478 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
479
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
480 if (!code && topn > 5)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
481 printf("\t@@b\n");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
482
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
483 if (!code || code == 10)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
484 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
485 qsort(scores, nscores, sizeof(*scores), cmp_pertresbomb);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
486 brag("Democrat", "fastest resources leveled", offset(tresbomb));
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
487 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
488
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
489 if (!code && topn > 5)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
490 printf("\t@@b\n");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
491
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
492 if (!code || code == 11)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
493 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
494 qsort(scores, nscores, sizeof(*scores), cmp_rawtdooshes);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
495 brag("Executioner", "most armies dooshed", offset(tdooshes));
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
496 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
497
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
498 if (!code && topn > 5)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
499 printf("\t@@b\n");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
500
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
501 if (!code || code == 12)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
502 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
503 qsort(scores, nscores, sizeof(*scores), cmp_pertdooshes);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
504 brag("DooshMeister", "fastest armies dooshed", offset(tdooshes));
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
505 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
506
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
507 if (!code && topn > 5)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
508 printf("\t@@b\n");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
509
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
510 if (!code || code == 13)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
511 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
512 qsort(scores, nscores, sizeof(*scores), cmp_rawtplanets);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
513 brag("Diplomat", "most planets taken", offset(tplanets));
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
514 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
515
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
516 if (!code && topn > 5)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
517 printf("\t@@b\n");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
518
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
519 if (!code || code == 14)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
520 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
521 qsort(scores, nscores, sizeof(*scores), cmp_pertplanets);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
522 brag("speed Diplomat", "fastest planets taken", offset(tplanets));
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
523 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
524
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
525 if (!code && topn > 5)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
526 printf("\t@@b\n");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
527
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
528 if (!code || code == 15)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
529 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
530 qsort(scores, nscores, sizeof(*scores), cmp_ticks);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
531 if (name[0] != 0)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
532 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
533 for (i = 0; i < nscores; i++)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
534 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
535 if (0 == strcmp(scores[i].name, name))
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
536 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
537 printf("#%5d:%30s with %1.2f hours\n", i + 1, scores[i].name,
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
538 scores[i].ticks / 36000.0);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
539 break;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
540 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
541 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
542 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
543 else if (topn > 1)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
544 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
545 int i;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
546 printf("Addicts:\n");
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
547 for (i = 0; i < topn && i < nscores; i++)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
548 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
549 printf("%30s with %1.2f hours\n", scores[i].name, scores[i].ticks / 36000.0);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
550 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
551 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
552 else
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
553 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
554 printf("Addict: %s with %1.2f hours\n", scores[0].name, scores[0].ticks / 36000.0);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
555 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
556 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
557
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
558 exit(0);
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
559 }