Suppress display of unused score entries
This commit is contained in:
parent
681b7119af
commit
db01e17fd7
6
hit.c
6
hit.c
@ -250,11 +250,17 @@ lget_number(const char *s)
|
|||||||
{
|
{
|
||||||
short i = 0;
|
short i = 0;
|
||||||
long total = 0;
|
long total = 0;
|
||||||
|
boolean negative = 0;
|
||||||
|
|
||||||
|
if (s[0] == '-') {
|
||||||
|
negative = 1;
|
||||||
|
i = 1;
|
||||||
|
}
|
||||||
while ((s[i] >= '0') && (s[i] <= '9')) {
|
while ((s[i] >= '0') && (s[i] <= '9')) {
|
||||||
total = (10 * total) + (s[i] - '0');
|
total = (10 * total) + (s[i] - '0');
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
if (negative) total = total * -1;
|
||||||
return(total);
|
return(total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
24
score.c
24
score.c
@ -274,9 +274,9 @@ read_score_entry(struct score_entry *se, FILE *fp)
|
|||||||
sf_error();
|
sf_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
xxxx(score_block, sizeof(score_block));
|
/* xxxx(score_block, sizeof(score_block));
|
||||||
xxxx(nickname_block, sizeof(nickname_block));
|
xxxx(nickname_block, sizeof(nickname_block));
|
||||||
|
*/
|
||||||
/* Ensure null termination */
|
/* Ensure null termination */
|
||||||
score_block[sizeof(score_block)-1] = 0;
|
score_block[sizeof(score_block)-1] = 0;
|
||||||
nickname_block[sizeof(nickname_block)-1] = 0;
|
nickname_block[sizeof(nickname_block)-1] = 0;
|
||||||
@ -327,9 +327,9 @@ write_score_entry(const struct score_entry *se, int rank, FILE *fp)
|
|||||||
pad_spaces(score_block, sizeof(score_block));
|
pad_spaces(score_block, sizeof(score_block));
|
||||||
/*pad_spaces(nickname_block, sizeof(nickname_block)); -- wrong! */
|
/*pad_spaces(nickname_block, sizeof(nickname_block)); -- wrong! */
|
||||||
|
|
||||||
xxxx(score_block, sizeof(score_block));
|
/* xxxx(score_block, sizeof(score_block));
|
||||||
xxxx(nickname_block, sizeof(nickname_block));
|
xxxx(nickname_block, sizeof(nickname_block));
|
||||||
|
*/
|
||||||
fwrite(score_block, 1, sizeof(score_block), fp);
|
fwrite(score_block, 1, sizeof(score_block), fp);
|
||||||
fwrite(nickname_block, 1, sizeof(nickname_block), fp);
|
fwrite(nickname_block, 1, sizeof(nickname_block), fp);
|
||||||
}
|
}
|
||||||
@ -359,7 +359,7 @@ put_scores(const object *monster, short other)
|
|||||||
|
|
||||||
/* Initialize scores array */
|
/* Initialize scores array */
|
||||||
for (i = 0; i < NUM_SCORE_ENTRIES; i++) {
|
for (i = 0; i < NUM_SCORE_ENTRIES; i++) {
|
||||||
scores[i].gold = -1;
|
scores[i].gold = -1L;
|
||||||
scores[i].username[0] = '\0';
|
scores[i].username[0] = '\0';
|
||||||
scores[i].death[0] = '\0';
|
scores[i].death[0] = '\0';
|
||||||
scores[i].nickname[0] = '\0';
|
scores[i].nickname[0] = '\0';
|
||||||
@ -377,7 +377,7 @@ put_scores(const object *monster, short other)
|
|||||||
/* found our score */
|
/* found our score */
|
||||||
if (rogue.gold < scores[i].gold) {
|
if (rogue.gold < scores[i].gold) {
|
||||||
/* we didn't do as well as last time */
|
/* we didn't do as well as last time */
|
||||||
score_only = 1;
|
/* score_only = 1;*/
|
||||||
} else {
|
} else {
|
||||||
/* we did better; mark entry for removal */
|
/* we did better; mark entry for removal */
|
||||||
found_player = i;
|
found_player = i;
|
||||||
@ -392,7 +392,7 @@ put_scores(const object *monster, short other)
|
|||||||
/* found our score */
|
/* found our score */
|
||||||
if (rogue.exp_points < scores[i].gold) {
|
if (rogue.exp_points < scores[i].gold) {
|
||||||
/* we didn't do as well as last time */
|
/* we didn't do as well as last time */
|
||||||
score_only = 1;
|
/* score_only = 1;*/
|
||||||
} else {
|
} else {
|
||||||
/* we did better; mark entry for removal */
|
/* we did better; mark entry for removal */
|
||||||
found_player_exp = i;
|
found_player_exp = i;
|
||||||
@ -401,12 +401,14 @@ put_scores(const object *monster, short other)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (found_player == -1 && found_player_exp == -1) score_only = 1;
|
||||||
|
|
||||||
/* Remove superseded entries, if any. */
|
/* Remove superseded entries, if any. */
|
||||||
if (found_player != -1) {
|
if (found_player != -1) {
|
||||||
for (i = found_player; i < FIRST_EXP_SCORE-1; i++) {
|
for (i = found_player; i < FIRST_EXP_SCORE-1; i++) {
|
||||||
scores[i] = scores[i+1];
|
scores[i] = scores[i+1];
|
||||||
}
|
}
|
||||||
scores[i].gold = 0;
|
scores[i].gold = -1L;
|
||||||
scores[i].username[0] = '\0';
|
scores[i].username[0] = '\0';
|
||||||
scores[i].death[0] = '\0';
|
scores[i].death[0] = '\0';
|
||||||
scores[i].nickname[0] = '\0';
|
scores[i].nickname[0] = '\0';
|
||||||
@ -415,7 +417,7 @@ put_scores(const object *monster, short other)
|
|||||||
for (i = found_player_exp; i < NUM_SCORE_ENTRIES-1; i++) {
|
for (i = found_player_exp; i < NUM_SCORE_ENTRIES-1; i++) {
|
||||||
scores[i] = scores[i+1];
|
scores[i] = scores[i+1];
|
||||||
}
|
}
|
||||||
scores[i].gold = 0;
|
scores[i].gold = -1L;
|
||||||
scores[i].username[0] = '\0';
|
scores[i].username[0] = '\0';
|
||||||
scores[i].death[0] = '\0';
|
scores[i].death[0] = '\0';
|
||||||
scores[i].nickname[0] = '\0';
|
scores[i].nickname[0] = '\0';
|
||||||
@ -488,7 +490,7 @@ put_scores(const object *monster, short other)
|
|||||||
mvaddstr(7, 0, "Rank Gold Name");
|
mvaddstr(7, 0, "Rank Gold Name");
|
||||||
|
|
||||||
for (i = 0; i < FIRST_EXP_SCORE; i++) {
|
for (i = 0; i < FIRST_EXP_SCORE; i++) {
|
||||||
if (scores[i].gold == 0) break;
|
if (scores[i].gold == -1L) break;
|
||||||
if (i == rank) {
|
if (i == rank) {
|
||||||
standout();
|
standout();
|
||||||
}
|
}
|
||||||
@ -510,7 +512,7 @@ put_scores(const object *monster, short other)
|
|||||||
mvaddstr(14, 0, "Rank Lvl/Exp Name");
|
mvaddstr(14, 0, "Rank Lvl/Exp Name");
|
||||||
|
|
||||||
for (i = FIRST_EXP_SCORE; i < NUM_SCORE_ENTRIES; i++) {
|
for (i = FIRST_EXP_SCORE; i < NUM_SCORE_ENTRIES; i++) {
|
||||||
if (scores[i].gold == 0) break;
|
if (scores[i].gold == -1L) break;
|
||||||
if (i == rank_exp) {
|
if (i == rank_exp) {
|
||||||
standout();
|
standout();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user