Rev 1 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1 | Rev 9 | ||
---|---|---|---|
Line 8... | Line 8... | ||
8 | * using this software in any fashion, you are agreeing to be bound by the |
8 | * using this software in any fashion, you are agreeing to be bound by the |
9 | * terms of this license. |
9 | * terms of this license. |
10 | * |
10 | * |
11 | * You must not remove this notice, or any other, from this software. |
11 | * You must not remove this notice, or any other, from this software. |
12 | */ |
12 | */ |
- | 13 | ||
- | 14 | #include <stdlib.h> // Pierre-Marie Baty -- for qsort() |
|
- | 15 | #include <string.h> // Pierre-Marie Baty -- for memcmp() |
|
13 | 16 | ||
14 | #include "system.h" |
17 | #include "system.h" |
15 | #include "game.h" |
18 | #include "game.h" |
16 | #include "screens.h" |
19 | #include "screens.h" |
17 | 20 | ||
Line 30... | Line 33... | ||
30 | #define TOPLEFT_X 116 |
33 | #define TOPLEFT_X 116 |
31 | #define TOPLEFT_Y 64 |
34 | #define TOPLEFT_Y 64 |
32 | #define NAMEPOS_X 120 |
35 | #define NAMEPOS_X 120 |
33 | #define NAMEPOS_Y 160 |
36 | #define NAMEPOS_Y 160 |
34 | #define AUTOREPEAT_TMOUT 100 |
37 | #define AUTOREPEAT_TMOUT 100 |
- | 38 | ||
- | 39 | ||
- | 40 | // Pierre-Marie Baty -- external prototype |
|
- | 41 | extern int sort_hscores (const void *q1, const void *q2); |
|
35 | 42 | ||
36 | 43 | ||
37 | /* |
44 | /* |
38 | * prototypes |
45 | * prototypes |
39 | */ |
46 | */ |
Line 152... | Line 159... | ||
152 | if (!(control_status & CONTROL_FIRE)) |
159 | if (!(control_status & CONTROL_FIRE)) |
153 | { |
160 | { |
154 | if (x == 5 && y == 4) |
161 | if (x == 5 && y == 4) |
155 | { |
162 | { |
156 | /* end */ |
163 | /* end */ |
157 | i = 0; |
- | |
158 | 164 | ||
- | 165 | // Pierre-Marie Baty -- discard empty names |
|
- | 166 | if (memcmp (name, "@@@@@@@@@@", 10) != 0) |
|
- | 167 | { |
|
- | 168 | // Pierre-Marie Baty -- look if this same name already exists in the hiscore table |
|
- | 169 | for (i = 0; i < 8; i++) |
|
159 |
|
170 | if (memcmp (game_hscores[i].name, name, 10) == 0) |
- | 171 | break; |
|
- | 172 | if (i == 8) // new name ? |
|
160 |
|
173 | { |
- | 174 | i = 0; |
|
161 | 175 | ||
- | 176 | while (game_score < game_hscores[i].score) |
|
162 |
|
177 | i++; |
163 | 178 | ||
164 |
|
179 | j = 7; |
165 | { |
- | |
166 | game_hscores[j].score = game_hscores[j - 1].score; |
- | |
167 | 180 | ||
168 |
|
181 | while (j > i) |
- | 182 | { |
|
169 | game_hscores[j]. |
183 | game_hscores[j].score = game_hscores[j - 1].score; |
170 | 184 | ||
171 |
|
185 | for (x = 0; x < 10; x++) |
172 | |
186 | game_hscores[j].name[x] = game_hscores[j - 1].name[x]; |
173 | 187 | ||
174 |
|
188 | j--; |
- | 189 | } |
|
175 | 190 | ||
- | 191 | game_hscores[i].score = game_score; |
|
- | 192 | ||
176 | for (x = 0; x < 10; x++) |
193 | for (x = 0; x < 10; x++) |
177 | game_hscores[i].name[x] = name[x]; |
194 | game_hscores[i].name[x] = name[x]; |
- | 195 | } |
|
- | 196 | else if (game_score > game_hscores[i].score) // existing name: update only if score is higher, else discard |
|
- | 197 | { |
|
- | 198 | game_hscores[i].score = game_score; |
|
- | 199 | qsort (game_hscores, 8, sizeof (hscore_t), sort_hscores); |
|
- | 200 | } |
|
- | 201 | } |
|
178 | 202 | ||
179 | seq = 99; |
203 | seq = 99; |
180 | } |
204 | } |
181 | else |
205 | else |
182 | { |
206 | { |
Line 256... | Line 280... | ||
256 | if (i == 26 && p < 10) |
280 | if (i == 26 && p < 10) |
257 | name[p++] = '.'; |
281 | name[p++] = '.'; |
258 | if (i == 27 && p < 10) |
282 | if (i == 27 && p < 10) |
259 | name[p++] = '@'; |
283 | name[p++] = '@'; |
260 | if (i == 28 && p > 0) |
284 | if (i == 28 && p > 0) |
261 | p--; |
285 | name[p--] = '@'; |
262 | } |
286 | } |
263 | 287 | ||
264 | 288 | ||
265 | static void name_draw (void) |
289 | static void name_draw (void) |
266 | { |
290 | { |