Skip to content

Fix double space in messages like "X is standing over Y" - #800

Merged
tmewett merged 1 commit into
tmewett:releasefrom
nstoddard:fix-double-space
Jul 23, 2026
Merged

Fix double space in messages like "X is standing over Y"#800
tmewett merged 1 commit into
tmewett:releasefrom
nstoddard:fix-double-space

Conversation

@nstoddard

Copy link
Copy Markdown
Collaborator

No description provided.

@nstoddard
nstoddard changed the base branch from master to release February 14, 2026 22:23
Comment thread src/brogue/Movement.c
Comment on lines +361 to +362
restoreRNG;
return;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this now an exit point? I can't see the relevance to the bug

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way this code worked before was rather strange: it called sprintf with object uninitialized, then called describedItemName to initialize object, then (at the end of the function, outside the nested ifs) it had another identical call to sprintf. I'm guessing this was left over from an incomplete refactoring or similar. (Also note the similarly redundant sprintf that this PR removes, a few lines down. That part isn't strictly necessary for this PR, but it seemed worth fixing that one too.)

After this PR, this call to sprintf is now different from the one at the end of the function, so we have to exit early to stop that one from running.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add a comment here explaining that? saying we can't fall through to the final sprintf because we need one fewer spaces (maybe with an explanation why that is)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

It looks like it might be possible to avoid the separate sprintf call (and maybe others; there's 9 in total in this function) with more work, but given how complicated the function is and how many cases would need to be tested, I'm not sure if it's worth the effort.

nstoddard added a commit to nstoddard/BrogueCE that referenced this pull request Mar 18, 2026
After a recent issue turned out to have been detectable with Valgrind (tmewett#817) and I found some uninitialized variables while working on a PR (tmewett#800), I used Valgrind to look for other similar issues. It found a potential one in `titleMenu()`, and although I'm not sure whether is actually causes issues, it seems worth fixing.
@tmewett
tmewett merged commit 1fc5a59 into tmewett:release Jul 23, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants