diff options
| author | Benjamin Linskey | 2026-06-11 06:29:45 -0400 |
|---|---|---|
| committer | Benjamin Linskey | 2026-06-11 06:29:45 -0400 |
| commit | 33ac314a2120a7e1d24cd367fd033c6c0d685121 (patch) | |
| tree | 4690fd0c9f5b85109ae46f03c11e68b2646ccd9a | |
| parent | 55c0be03a23d3fca4994d4d28018e0826c34fa08 (diff) | |
| download | rogue-33ac314a2120a7e1d24cd367fd033c6c0d685121.tar.gz | |
Fix crash when viewing score file
Fixes a crash when running “rogue -s”. This bug was introduced in 794d1c58ce6e7f1093a6fecb847aa913fad080bc, where I accidentally removed the conditional that ensured new scores were only added to the list if the global variable score_only was false.
| -rw-r--r-- | score.c | 37 |
1 files changed, 20 insertions, 17 deletions
@@ -370,28 +370,31 @@ put_scores(const object *monster, short other) } } - // Find where we rank relative to the saved scores. - rank = numscores; - for (i = 0; i < numscores; i++) { - if (rogue.gold > scores[i].gold) { - rank = i; - break; + if (!score_only) { + + // Find where we rank relative to the saved scores. + rank = numscores; + for (i = 0; i < numscores; i++) { + if (rogue.gold > scores[i].gold) { + rank = i; + break; + } } - } - // If we're in last place, expand the list if there's room. - if (rank == numscores && numscores < NUM_SCORE_ENTRIES) { - numscores++; - } + // If we're in last place, expand the list if there's room. + if (rank == numscores && numscores < NUM_SCORE_ENTRIES) { + numscores++; + } - if (rank < NUM_SCORE_ENTRIES) { - for (i = numscores - 1; i >= rank; i--) { - scores[i] = scores[i - 1]; + if (rank < NUM_SCORE_ENTRIES) { + for (i = numscores - 1; i >= rank; i--) { + scores[i] = scores[i - 1]; + } } - } - /* Put our info in the slot */ - make_score(&scores[rank], monster, other); + /* Put our info in the slot */ + make_score(&scores[rank], monster, other); + } md_ignore_signals(); rewind(fp); |