Skip to content

Remove dead stores from the options and status builders - #52

Merged
Critlist merged 1 commit into
Critlist:masterfrom
neuhaus:fix/b5-dead-stores
Nov 18, 2026
Merged

Critlist merged 1 commit into
Critlist:masterfrom
neuhaus:fix/b5-dead-stores

Conversation

@neuhaus

@neuhaus neuhaus commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Trimmed to the modern code only: the trailing len/remaining updates in the options string and status line that nothing reads. The 1984 dead stores in bchit(), dothrow(), hitmm(), stackobj() and killed() are untouched. Verified: GCC 14 and Clang 22 build with no warnings.

@Critlist Critlist left a comment

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.

Thanks for this one! You're right that these are dead stores, but most of them are original 1.0.3 lines. Since restoHack is focused on preserving the original source, I'd like to leave those lines intact:

  • bchx -= ddx; bchy -= ddy; in bchit() (hack.apply.c)
  • mon = 0; and mon = 0; /* he died */ in dothrow() (hack.do.c)
  • magr->data = pa = &dog; / &la_dog in hitmm() (hack.fight.c)
  • struct obj *otmp = fobj; in stackobj() (hack.invent.c)
  • nk = 1; and nk = u.nr_killed[tmp] (hack.mon.c)

The len += ones in the options and status code are ours, though, so those are fair game.

Could you trim this down to just the modern ones? The compiler drops the original stores anyway, so there's no cost to leaving them. If any of them trip a warning you'd like gone, wrapping them in a /* Original 1984: ... */ comment is totally fine. If you're ever unsure, the untouched source is in docs/historical/original-source/.

@neuhaus neuhaus changed the title Remove dead stores Remove dead stores from the options and status builders Nov 11, 2026
@Critlist

Copy link
Copy Markdown
Owner

Thanks, this is exactly what I asked for! One catch, though, and it's my fault for merging in this order: #59 just landed, and it changed bot() to write the hunger status at newbot + len. That means the len += updates in hack.pri.c aren't dead anymore. With them removed, len falls behind and "Hungry" would overwrite the Exp field on the status line. Git also flags it as a conflict now.

Could you rebase onto master and drop the hack.pri.c part? The hack.options.c change is still good, and I'll merge it once it's rebased.

@neuhaus
neuhaus force-pushed the fix/b5-dead-stores branch 2 times, most recently from 8975bfd to 472b828 Compare November 15, 2026 16:28
Only the modern code is touched: the trailing len/remaining updates that
nothing reads while building the options string. The 1984 dead stores in
bchit(), dothrow(), hitmm(), stackobj() and killed() stay as they are;
the compiler drops them anyway and the original source is the point.

The status-line half is left out: since Critlist#59 bot() appends at newbot + len,
so len is live there and the updates cannot be dropped.
@neuhaus

neuhaus commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto master and dropped the hack.pri.c part, so this is now just the hack.options.c change. Rebuilt clean with GCC 14 and Clang 22, no warnings.

@neuhaus
neuhaus requested a review from Critlist November 18, 2026 06:40
@Critlist
Critlist merged commit 9db2301 into Critlist:master Nov 18, 2026
7 checks passed
Critlist added a commit that referenced this pull request Nov 18, 2026
@neuhaus
neuhaus deleted the fix/b5-dead-stores branch November 20, 2026 08:50
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