Monster respawn time is tenths of a second, not milliseconds - #2291
Open
denislauri1999 wants to merge 2 commits into
Open
Monster respawn time is tenths of a second, not milliseconds#2291denislauri1999 wants to merge 2 commits into
denislauri1999 wants to merge 2 commits into
Conversation
…onds monster.dat, PREATT, fifth field. An ordinary wolf carries 400, which is forty seconds. Both call sites read it as milliseconds, so every monster in the game came back in four tenths of a second - a hundred times too fast. Nothing reported it: no exception, no log, just maps that never empty and a monster reappearing on top of whoever had just killed it. Two independent confirmations of the unit: the atlagaming API exposes the same field as respTimeSek and gives 40.0 for that 400, and the older emulator divides it by ten. The conversion moves into one place, RespawnTiming, because the two call sites had already drifted into two copies of the same arithmetic. It keeps the one-second floor that was there: some event monsters declare zero, and respawning them the instant they die means never letting them die. Four tests, including the two that would pass a wrong implementation quietly - a zero time, and a value large enough to overflow the multiplication if it is not done in 64 bits.
The unit is the only non-obvious thing here; two lines cover it. The test's name already says what a failure would mean. Two files had also picked up a UTF-8 BOM, which showed as a whole-line diff against master. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Warning Review limit reachedNext included review available in 25 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
monster.dat,PREATT, fifth field. An ordinary wolf carries 400, which is forty seconds. Both call sites —MonsterRespawnHandlerandCaptureService— read it as milliseconds, so every monster in the game came back in four tenths of a second: a hundred times too fast.Nothing reported it. No exception, no log, just maps that never empty and a monster reappearing on top of whoever had just killed it — the kind of mistake only noticed by counting.
Two independent confirmations of the unit:
respTimeSekand gives40.0for that400;The conversion moves into one place,
RespawnTiming, because the two call sites had already drifted into two copies of the same arithmetic. It keeps the one-second floor that was there: some event monsters declare zero, and respawning them the instant they die would mean never letting them die.Tests
Four, including the two that would pass a wrong implementation quietly — a declared time of zero, and a value large enough to overflow the multiplication if it is not done in 64 bits.
Zero warnings, all tests pass.