Gold and exp dual score display working
This commit is contained in:
parent
ccb43e061b
commit
38c31fabe9
34
score.c
34
score.c
@ -227,10 +227,9 @@ struct score_entry {
|
|||||||
char nickname[30];
|
char nickname[30];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Gold&Glory: NUM_SCORE_ENTRIES must be sum of NUM_GOLD_SCORES and NUM_EXP_SCORES */
|
/* Gold&Glory: Number of experience top scores = NUM_SCORE_ENTRIES - NUM_GOLD_SCORES */
|
||||||
#define NUM_GOLD_SCORES 5
|
|
||||||
#define NUM_EXP_SCORES 5
|
|
||||||
#define NUM_SCORE_ENTRIES 10
|
#define NUM_SCORE_ENTRIES 10
|
||||||
|
#define NUM_GOLD_SCORES 5
|
||||||
|
|
||||||
static void make_score(struct score_entry *, const object *, int, int);
|
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();
|
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;
|
||||||
@ -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(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);
|
||||||
}
|
}
|
||||||
@ -339,12 +338,11 @@ write_score_entry(const struct score_entry *se, int rank, FILE *fp)
|
|||||||
void
|
void
|
||||||
put_scores(const object *monster, short other)
|
put_scores(const object *monster, short other)
|
||||||
{
|
{
|
||||||
short i, rank=-1, found_player = -1, numscores = NUM_SCORE_ENTRIES;
|
short i, rank, rank_exp;
|
||||||
short rank_exp=-1, expscore = FIRST_EXP_SCORE, found_player_exp = -1;
|
|
||||||
struct score_entry scores[NUM_SCORE_ENTRIES];
|
struct score_entry scores[NUM_SCORE_ENTRIES];
|
||||||
const char *name;
|
const char *name;
|
||||||
FILE *fp;
|
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);
|
md_lock(1);
|
||||||
|
|
||||||
@ -403,7 +401,7 @@ put_scores(const object *monster, short other)
|
|||||||
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';
|
||||||
}
|
} else already_top_gold = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -424,13 +422,14 @@ put_scores(const object *monster, short other)
|
|||||||
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';
|
||||||
}
|
} else already_top_exp = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
score_update = 0;
|
score_update = 0;
|
||||||
|
|
||||||
|
if (!already_top_gold) {
|
||||||
/* Did rogueist make the top gold list? */
|
/* Did rogueist make the top gold list? */
|
||||||
for (rank = 0; rank < NUM_GOLD_SCORES; ++ rank) {
|
for (rank = 0; rank < NUM_GOLD_SCORES; ++ rank) {
|
||||||
if (rogue.gold >= scores[rank].gold) {
|
if (rogue.gold >= scores[rank].gold) {
|
||||||
@ -442,18 +441,21 @@ put_scores(const object *monster, short other)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!already_top_exp) {
|
||||||
/* Did rogueist make the top exp list? */
|
/* Did rogueist make the top exp list? */
|
||||||
for (rank_exp = NUM_GOLD_SCORES; rank_exp < NUM_SCORE_ENTRIES; ++ rank_exp) {
|
for (rank_exp = NUM_GOLD_SCORES; rank_exp < NUM_SCORE_ENTRIES; ++ rank_exp) {
|
||||||
if (rogue.exp_points >= scores[rank_exp].gold) {
|
if (rogue.exp_points >= scores[rank_exp].gold) {
|
||||||
score_update = 1;
|
score_update = 1;
|
||||||
for (i = (NUM_SCORE_ENRIES - 1); i > rank_exp; -- i) {
|
for (i = (NUM_SCORE_ENTRIES - 1); i > rank_exp; -- i) {
|
||||||
scores[i] = scores[i-1];
|
scores[i] = scores[i-1];
|
||||||
}
|
}
|
||||||
make_score(&scores[rank_exp], monster, other, TOP_EXP);
|
make_score(&scores[rank_exp], monster, other, TOP_EXP);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (score_update) {
|
if (score_update) {
|
||||||
/* Now rewrite the score file */
|
/* Now rewrite the score file */
|
||||||
@ -461,7 +463,7 @@ put_scores(const object *monster, short other)
|
|||||||
rewind(fp);
|
rewind(fp);
|
||||||
(void)xxx(1);
|
(void)xxx(1);
|
||||||
|
|
||||||
for (i = 0; i < numscores; i++) {
|
for (i = 0; i < NUM_SCORE_ENTRIES; i++) {
|
||||||
write_score_entry(&scores[i], i, fp);
|
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");
|
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 (scores[i].gold == -1L) break;
|
||||||
if (i == rank_exp) {
|
if (i == rank_exp) {
|
||||||
standout();
|
standout();
|
||||||
@ -509,7 +511,7 @@ put_scores(const object *monster, short other)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mvprintw(i+10, 0, "%2d %2d/%-6ld %s: %s",
|
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);
|
name, scores[i].death);
|
||||||
|
|
||||||
if (i == rank_exp) {
|
if (i == rank_exp) {
|
||||||
|
Loading…
Reference in New Issue
Block a user