Skip to content

Fix boss spawn bitmap conflict at (25,25)#25

Merged
thogard785 merged 2 commits intomainfrom
fix/boss-spawn-bitmap-conflict
Jul 11, 2025
Merged

Fix boss spawn bitmap conflict at (25,25)#25
thogard785 merged 2 commits intomainfrom
fix/boss-spawn-bitmap-conflict

Conversation

@0x1NotMe
Copy link
Copy Markdown
Contributor

Summary

  • Fixed InvalidLocationBitmap(2, 2) error when moving to boss location (25,25)
  • Updated combat test to accept both survival and death as valid outcomes

Problem

When a player occupies index 1 and attempts to move to location (25,25), the game would revert with InvalidLocationBitmap(2, 2). This happened because the boss spawn logic only checked the monster bitmap, not the player bitmap, before attempting to spawn a boss at the reserved index.

Solution

Modified _checkForAggro in Instances.sol to check both player and monster bitmaps before attempting boss spawn. If a player occupies the boss index, the function now returns (0, false) instead of attempting to spawn and reverting.

Changes

  1. Instances.sol: Added combined bitmap check for boss spawn logic
  2. BattleNadsCombatTest.t.sol: Fixed flaky test that was incorrectly asserting characters must survive combat

Testing

  • Added testBitmapLogic() to verify the fix logic
  • All existing tests pass
  • Combat test no longer flaky - correctly handles both survival and death outcomes

Gas Impact

Minimal - adds one additional bitmap check only for boss spawn scenarios at specific coordinates.

When a player occupies index 1 and a boss tries to spawn at the same
location, the game would revert with InvalidLocationBitmap(2, 2).

This fix checks both player and monster bitmaps before attempting boss
spawn. If a player occupies the boss index, no boss spawns rather than
reverting.

Changes:
- Check combined bitmap (players + monsters) for boss index availability
- Return (0, false) when player occupies boss slot instead of reverting
- Maintain existing behavior when monster already exists at boss index
@0x1NotMe 0x1NotMe requested a review from thogard785 July 11, 2025 08:43
The test was asserting that characters must survive combat, but death
is also a valid combat resolution. Updated test to handle both outcomes
properly.
@0x1NotMe 0x1NotMe force-pushed the fix/boss-spawn-bitmap-conflict branch from c590900 to f8421aa Compare July 11, 2025 08:45
@thogard785
Copy link
Copy Markdown
Contributor

While the description of the problem's solution is innaccurate, this does fix the bug.

The previous version was erroneously checking monsterBitmap & RESERVED_BOSS_INDEX. In your version, you check monsterBitmap & (1<<RESERVED_BOSS_INDEX). I believe this is the solution - the addition of the player bitmap is irrelevant.

Will merge this to also update the test.

@thogard785 thogard785 merged commit f77f4cf into main Jul 11, 2025
2 checks passed
@thogard785 thogard785 deleted the fix/boss-spawn-bitmap-conflict branch July 11, 2025 19:30
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