diff --git a/roguegg b/roguegg index e5f4c54..0586567 100755 Binary files a/roguegg and b/roguegg differ diff --git a/score.c b/score.c index cbf074e..46065b8 100644 --- a/score.c +++ b/score.c @@ -227,10 +227,9 @@ struct score_entry { char nickname[30]; }; -/* Gold&Glory: NUM_SCORE_ENTRIES must be sum of NUM_GOLD_SCORES and NUM_EXP_SCORES */ -#define NUM_GOLD_SCORES 5 -#define NUM_EXP_SCORES 5 +/* Gold&Glory: Number of experience top scores = NUM_SCORE_ENTRIES - NUM_GOLD_SCORES */ #define NUM_SCORE_ENTRIES 10 +#define NUM_GOLD_SCORES 5 static void make_score(struct score_entry *, const object *, int, int); @@ -276,9 +275,9 @@ read_score_entry(struct score_entry *se, FILE *fp) sf_error(); } - /* xxxx(score_block, sizeof(score_block)); + xxxx(score_block, sizeof(score_block)); xxxx(nickname_block, sizeof(nickname_block)); - */ + /* Ensure null termination */ score_block[sizeof(score_block)-1] = 0; nickname_block[sizeof(nickname_block)-1] = 0; @@ -329,9 +328,9 @@ write_score_entry(const struct score_entry *se, int rank, FILE *fp) pad_spaces(score_block, sizeof(score_block)); /*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)); - */ + fwrite(score_block, 1, sizeof(score_block), fp); fwrite(nickname_block, 1, sizeof(nickname_block), fp); } @@ -339,12 +338,11 @@ write_score_entry(const struct score_entry *se, int rank, FILE *fp) void put_scores(const object *monster, short other) { - short i, rank=-1, found_player = -1, numscores = NUM_SCORE_ENTRIES; - short rank_exp=-1, expscore = FIRST_EXP_SCORE, found_player_exp = -1; + short i, rank, rank_exp; struct score_entry scores[NUM_SCORE_ENTRIES]; const char *name; FILE *fp; - boolean dopause = score_only, score_update; + boolean dopause = score_only, score_update, already_top_gold = 0, already_top_exp = 0; md_lock(1); @@ -403,7 +401,7 @@ put_scores(const object *monster, short other) scores[i].username[0] = '\0'; scores[i].death[0] = '\0'; scores[i].nickname[0] = '\0'; - } + } else already_top_gold = 1; break; } } @@ -424,34 +422,38 @@ put_scores(const object *monster, short other) scores[i].username[0] = '\0'; scores[i].death[0] = '\0'; scores[i].nickname[0] = '\0'; - } + } else already_top_exp = 1; break; } } score_update = 0; - /* Did rogueist make the top gold list? */ - for (rank = 0; rank < NUM_GOLD_SCORES; ++ rank) { - if (rogue.gold >= scores[rank].gold) { - score_update = 1; - for (i = (NUM_GOLD_SCORES - 1); i > rank; -- i) { - scores[i] = scores[i-1]; + if (!already_top_gold) { + /* Did rogueist make the top gold list? */ + for (rank = 0; rank < NUM_GOLD_SCORES; ++ rank) { + if (rogue.gold >= scores[rank].gold) { + score_update = 1; + for (i = (NUM_GOLD_SCORES - 1); i > rank; -- i) { + scores[i] = scores[i-1]; + } + make_score(&scores[rank], monster, other, TOP_GOLD); + break; } - make_score(&scores[rank], monster, other, TOP_GOLD); - break; } } - /* Did rogueist make the top exp list? */ - for (rank_exp = NUM_GOLD_SCORES; rank_exp < NUM_SCORE_ENTRIES; ++ rank_exp) { - if (rogue.exp_points >= scores[rank_exp].gold) { - score_update = 1; - for (i = (NUM_SCORE_ENRIES - 1); i > rank_exp; -- i) { - scores[i] = scores[i-1]; + if (!already_top_exp) { + /* Did rogueist make the top exp list? */ + for (rank_exp = NUM_GOLD_SCORES; rank_exp < NUM_SCORE_ENTRIES; ++ rank_exp) { + if (rogue.exp_points >= scores[rank_exp].gold) { + score_update = 1; + for (i = (NUM_SCORE_ENTRIES - 1); i > rank_exp; -- i) { + scores[i] = scores[i-1]; + } + make_score(&scores[rank_exp], monster, other, TOP_EXP); + break; } - make_score(&scores[rank_exp], monster, other, TOP_EXP); - break; } } @@ -461,7 +463,7 @@ put_scores(const object *monster, short other) rewind(fp); (void)xxx(1); - for (i = 0; i < numscores; i++) { + for (i = 0; i < NUM_SCORE_ENTRIES; i++) { write_score_entry(&scores[i], i, fp); } } @@ -496,7 +498,7 @@ put_scores(const object *monster, short other) mvaddstr(14, 0, "Rank Lvl/Exp Name"); - for (i = FIRST_EXP_SCORE; i < NUM_SCORE_ENTRIES; i++) { + for (i = NUM_GOLD_SCORES; i < NUM_SCORE_ENTRIES; i++) { if (scores[i].gold == -1L) break; if (i == rank_exp) { standout(); @@ -509,7 +511,7 @@ put_scores(const object *monster, short other) } mvprintw(i+10, 0, "%2d %2d/%-6ld %s: %s", - i+1 - expscore, get_exp_level(scores[i].gold), scores[i].gold, + i+1 - NUM_GOLD_SCORES, get_exp_level(scores[i].gold), scores[i].gold, name, scores[i].death); if (i == rank_exp) {