aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Linskey2026-06-08 15:03:35 -0400
committerBenjamin Linskey2026-06-08 17:01:22 -0400
commit2dbf15a4462b5fae82f6724b1be59d7551f56a7c (patch)
tree6dd9354d36fa4b35eb951ef96dc156006b7a818c
parent794d1c58ce6e7f1093a6fecb847aa913fad080bc (diff)
downloadrogue-2dbf15a4462b5fae82f6724b1be59d7551f56a7c.tar.gz

Fix added space when reading score entry

An error in the score file parsing code caused a space to be prepended to the “death” string, which in turn caused each score record’s death string to be indented by one additional space each time the file was written.

This bug appears to be present in the upstream project; reproducing it there would require populating the score file with scores from at least two users.

-rw-r--r--score.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/score.c b/score.c
index c438803..ac10d8b 100644
--- a/score.c
+++ b/score.c
@@ -297,9 +297,21 @@ read_score_entry(struct score_entry *se, FILE *fp)
if (score_block[x] == 0) {
sf_error();
}
- score_block[x++] = 0;
+ /*
+ * Replace the colon after the username with a null to mark the end of
+ * the username string.
+ */
+ score_block[x] = 0;
strlcpy(se->username, score_block+15, sizeof(se->username));
+ /*
+ * Advance the position marker by two characters: one for the trailing
+ * colon/null after the username, and another for the space that
+ * follows. This leaves x pointing to the first char of the "death"
+ * string.
+ */
+ x += 2;
+
strlcpy(se->death, score_block+x, sizeof(se->death));
strlcpy(se->nickname, nickname_block, sizeof(se->nickname));