Rev 4263 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4263 | Rev 4327 | ||
---|---|---|---|
Line 115... | Line 115... | ||
115 | /** Copy from hiscore table score with index src to dest |
115 | /** Copy from hiscore table score with index src to dest |
116 | * |
116 | * |
117 | */ |
117 | */ |
118 | static void copyhiscore(int dest, int src) |
118 | static void copyhiscore(int dest, int src) |
119 | { |
119 | { |
120 | strcpy(scores[dest].hs_name, scores[src].hs_name); |
120 | str_cpy(scores[dest].hs_name, STR_BOUNDS(MAXLOGNAME) + 1, |
- | 121 | scores[src].hs_name); |
|
121 | scores[dest].hs_score = scores[src].hs_score; |
122 | scores[dest].hs_score = scores[src].hs_score; |
122 | scores[dest].hs_level = scores[src].hs_level; |
123 | scores[dest].hs_level = scores[src].hs_level; |
123 | } |
124 | } |
124 | 125 | ||
125 | void insertscore(int score, int level) |
126 | void insertscore(int score, int level) |
Line 129... | Line 130... | ||
129 | kbd_event_t ev; |
130 | kbd_event_t ev; |
130 | 131 | ||
131 | clear_screen(); |
132 | clear_screen(); |
132 | moveto(10 , 10); |
133 | moveto(10 , 10); |
133 | puts("Insert your name: "); |
134 | puts("Insert your name: "); |
134 | strncpy(scores[NUMSPOTS - 1].hs_name, "Player", MAXLOGNAME); |
135 | str_cpy(scores[NUMSPOTS - 1].hs_name, STR_BOUNDS(MAXLOGNAME) + 1, |
- | 136 | "Player"); |
|
135 | i = 6; off = 6; |
137 | i = 6; off = 6; |
136 | 138 | ||
137 | moveto(10 , 28); |
139 | moveto(10 , 28); |
138 | printf("%s%.*s",scores[NUMSPOTS - 1].hs_name,MAXLOGNAME-i,"........................................"); |
140 | printf("%s%.*s",scores[NUMSPOTS - 1].hs_name,MAXLOGNAME-i,"........................................"); |
139 | 141 | ||
Line 193... | Line 195... | ||
193 | 195 | ||
194 | void initscores(void) |
196 | void initscores(void) |
195 | { |
197 | { |
196 | int i; |
198 | int i; |
197 | for(i = 0; i < NUMSPOTS; i++) { |
199 | for(i = 0; i < NUMSPOTS; i++) { |
198 | strncpy(scores[i].hs_name, "HelenOS Team", MAXLOGNAME); |
200 | str_cpy(scores[i].hs_name, STR_BOUNDS(MAXLOGNAME) + 1, "HelenOS Team"); |
199 | scores[i].hs_score = (NUMSPOTS - i) * 200; |
201 | scores[i].hs_score = (NUMSPOTS - i) * 200; |
200 | scores[i].hs_level = (i + 1 > MAXLEVEL?MAXLEVEL:i + 1); |
202 | scores[i].hs_level = (i + 1 > MAXLEVEL?MAXLEVEL:i + 1); |
201 | } |
203 | } |
202 | } |
204 | } |
203 | 205 | ||
Line 287... | Line 289... | ||
287 | /* * Otherwise add new score at end (there is always room). */ |
289 | /* * Otherwise add new score at end (there is always room). */ |
288 | /* *\/ */ |
290 | /* *\/ */ |
289 | /* change = 0; */ |
291 | /* change = 0; */ |
290 | /* me = thisuser(); */ |
292 | /* me = thisuser(); */ |
291 | /* for (i = 0, sp = &scores[0]; i < nscores; i++, sp++) { */ |
293 | /* for (i = 0, sp = &scores[0]; i < nscores; i++, sp++) { */ |
292 | /* if (sp->hs_level != level || strcmp(sp->hs_name, me) != 0) */ |
294 | /* if (sp->hs_level != level || str_cmp(sp->hs_name, me) != 0) */ |
293 | /* continue; */ |
295 | /* continue; */ |
294 | /* if (score > sp->hs_score) { */ |
296 | /* if (score > sp->hs_score) { */ |
295 | /* (void)printf("%s bettered %s %d score of %d!\n", */ |
297 | /* (void)printf("%s bettered %s %d score of %d!\n", */ |
296 | /* "\nYou", "your old level", level, */ |
298 | /* "\nYou", "your old level", level, */ |
297 | /* sp->hs_score * sp->hs_level); */ |
299 | /* sp->hs_score * sp->hs_level); */ |
Line 415... | Line 417... | ||
415 | /* for (i = 0, sp = hs; i < num;) { */ |
417 | /* for (i = 0, sp = hs; i < num;) { */ |
416 | /* /\* */ |
418 | /* /\* */ |
417 | /* * This is O(n^2), but do you think we care? */ |
419 | /* * This is O(n^2), but do you think we care? */ |
418 | /* *\/ */ |
420 | /* *\/ */ |
419 | /* for (j = 0, pu = count; j < numnames; j++, pu++) */ |
421 | /* for (j = 0, pu = count; j < numnames; j++, pu++) */ |
420 | /* if (strcmp(sp->hs_name, pu->name) == 0) */ |
422 | /* if (str_cmp(sp->hs_name, pu->name) == 0) */ |
421 | /* break; */ |
423 | /* break; */ |
422 | /* if (j == numnames) { */ |
424 | /* if (j == numnames) { */ |
423 | /* /\* */ |
425 | /* /\* */ |
424 | /* * Add new user, set per-user count to 1. */ |
426 | /* * Add new user, set per-user count to 1. */ |
425 | /* *\/ */ |
427 | /* *\/ */ |
Line 552... | Line 554... | ||
552 | /* * we only get one score per level. */ |
554 | /* * we only get one score per level. */ |
553 | /* *\/ */ |
555 | /* *\/ */ |
554 | /* if (me != NULL && */ |
556 | /* if (me != NULL && */ |
555 | /* sp->hs_level == level && */ |
557 | /* sp->hs_level == level && */ |
556 | /* sp->hs_score == score && */ |
558 | /* sp->hs_score == score && */ |
557 | /* strcmp(sp->hs_name, me) == 0) { */ |
559 | /* str_cmp(sp->hs_name, me) == 0) { */ |
558 | /* putpad(SOstr); */ |
560 | /* putpad(SOstr); */ |
559 | /* highlight = 1; */ |
561 | /* highlight = 1; */ |
560 | /* } */ |
562 | /* } */ |
561 | /* (void)printf("%s", buf); */ |
563 | /* (void)printf("%s", buf); */ |
562 | /* if (highlight) { */ |
564 | /* if (highlight) { */ |