Conversation
Account for pet hunger while away from a level
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Monsters put to sleep for a fixed duration can still be blinded by light.
This addresses an existing BUG comment in the source. The change is recorded in doc/fixes5-0-1.txt.
A monster put to sleep for a fixed duration can still be blinded by light:
sleep_monst()usesmfrozen, whileresists_blnd()recognizes only indefinite sleep throughmsleeping. Checking all frozen monsters would incorrectly protect paralysis and delays such as donning armor.Record whether the active frozen interval represents timed sleep, then include that state in light-blindness resistance. Reuse the existing unused long slot in struct monst, retaining its type and position. Clear the marker when paralysis or an armor/jelly delay replaces sleep, and when the normal timer expires. Require an active timer and blocked movement, so an explicit thaw makes any leftover marker ineffective. Existing noise, attack, and timer behavior is unchanged.
Validation: source-extracted C tests compiled with AddressSanitizer and UndefinedBehaviorSanitizer reproduce three failing expectations in the baseline; the patched version passes all 17 checks. Cases cover timed and indefinite sleep, expiry, paralysis, replacement by paralysis, explicit thaw, resisted sleep, duration caps, and inactive stale markers. The actual old/new monster declarations have identical size and checked member offsets on this macOS x86-64 build. A raw-structure round trip preserves the marker. All five modified C translation units plus save, restore, and serialization translation units pass clang syntax checking. The exported patch applies to the installed build's source.
Legacy saves cannot reveal whether an already-frozen monster was asleep or paralyzed, because the old format never recorded that distinction. Those existing intervals retain the old behavior; sleep applied after the patch gets the new protection. No attempt is made to guess the cause.
Full-game integration on macOS x86-64 now passes six sleep scenarios: a timed sleeper resists a light flash; a paralyzed monster is blinded; protection survives a full save/reload and a level round trip; both persistence cases also pass with elapsed turns. The saved sleeper resumed with 97 turns remaining; after three local turns and ten turns on another level, the returning sleeper had 87 turns remaining and still resisted the flash. Tests used wizard-only fixture hooks calling the real sleep and flash routines, real game turns, and normal save/restore and level-teleport commands. External save compression was blocked by the sandbox, so save/reload was verified with NetHack's retained uncompressed save. Bones and other platform ABIs remain untested.