Fix multiple issues in sub_6FC6A8C0#219
Open
AudriusButkevicius wants to merge 1 commit into
Open
Conversation
1. Make coordinate array static const 2. Fix incorrect index calculation (2 * (nParam1 + nParam2) -> nParam1 + nParam2) 3. Hoist monCreate initialization outside loop 4. Fix OOB bounds check (a6 > 2 -> a6 > 1) Fixes ThePhrozenKeep#194
Mw95
reviewed
Apr 25, 2026
| @@ -1538,7 +1538,7 @@ int32_t __fastcall sub_6FC6A810(D2GameStrc* pGame, D2ActiveRoomStrc* pRoom, int3 | |||
| //D2Game.0x6FC6A8C0 | |||
| int32_t __fastcall sub_6FC6A8C0(D2GameStrc* pGame, D2UnitStrc* pUnit, int32_t nMonsterId, int32_t nAnimMode, int32_t nCount, int32_t a6, int16_t nFlags) | |||
Collaborator
There was a problem hiding this comment.
According to the issue description from Nec, we can still rename a6 to bNonWaterSpawn
|
|
||
| int32_t v9 = a6; | ||
| if (a6 < 0 || a6 > 2) | ||
| if (a6 < 0 || a6 > 1) |
Collaborator
There was a problem hiding this comment.
Since the Vanilla code actually really looks like this, I don't know if @Lectem would like to leave this inside a #ifdef NO_BUG_FIX, but it probably doesn't make a lot of sense 😄
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.
Summary
static constfor immutability and performance2 * (nParam1 + nParam2)→nParam1 + nParam2, preventing OOB readsmonCreateinitialization outside the loop (only X/Y change per iteration)a6 > 2→a6 > 1to prevent OOB reads whena6 == 2(vanilla bug)Fixes #194