BrogueCE icon indicating copy to clipboard operation
BrogueCE copied to clipboard

fillSpawnMap() does not auto-promote tiles containing the player

Open brturn opened this issue 1 month ago • 0 comments

Reported by azrealiraizaI on Discord

Player is hasted, uses staff of obstruction on nearby enemies, encasing the player in obstruction crystal. Normally, the obstruction crystal would "melt" before the player's next turn, allowing them to move. But in this recording the hasted player remains encased in crystal on their next move.

This happens in a very specific situation:

  • The player is hasted and in-between environment updates
  • The obstruction crystal only spawns ONCE over the player's location (the crystals will "spill" from the point of impact to nearby tiles, each of which then "spills" to tiles around that one, possibly spawning over the same tile more than once)

The reason this happens is that crystals "melt" in two phases, from FORCEFIELD to FORCEFIELD_MELT to NOTHING. Each transition requires a call to promoteTile to force the promotion.

If the player is not hasted, then applyInstantTileEffectsToCreature will get applied TWICE to the player, once in the environment update here:

https://github.com/tmewett/BrogueCE/blob/af0d25995221a51591ae7da4ba95c2fd28b1acc0/src/brogue/Time.c#L2415

And once at the end of the player cleanup here:

https://github.com/tmewett/BrogueCE/blob/af0d25995221a51591ae7da4ba95c2fd28b1acc0/src/brogue/Time.c#L2559

However, in the case of the crystal spawning over the player only once AND the player is hasted, the auto-promotion of the FORCEFIELD to FORCEFIELD_MELT will happen correctly, but the recursive promotion fails due to a HAS_MONSTER restriction in fillSpawnMap:

https://github.com/tmewett/BrogueCE/blob/af0d25995221a51591ae7da4ba95c2fd28b1acc0/src/brogue/Architect.c#L3254

This means the player remains obstructed due to the FORCEFIELD_MELT tile during their next turn.

POSSIBLE FIX:

Add HAS_PLAYER to the recursive promotion check in fillSpawnMap, like so:

if (pmap[i][j].flags & (HAS_MONSTER | HAS_PLAYER)) {

brturn avatar Dec 06 '25 19:12 brturn