BrogueCE icon indicating copy to clipboard operation
BrogueCE copied to clipboard

Fix wizard double initialize

Open brturn opened this issue 1 month ago • 2 comments

Fix for bug mentioned in Discord by azrealiraizaI: https://discord.com/channels/622393898064543759/647802299783184384/1442960368723820666

brturn avatar Nov 26 '25 23:11 brturn

thank you - could you explain how this fixes the bug? it's not obvious to me

tmewett avatar Dec 01 '25 20:12 tmewett

When a creature is created via the wizard command, it calls generateMonster():

https://github.com/tmewett/BrogueCE/blob/af0d25995221a51591ae7da4ba95c2fd28b1acc0/src/brogue/Wizard.c#L364

generateMonster() calls initializeMonster():

https://github.com/tmewett/BrogueCE/blob/af0d25995221a51591ae7da4ba95c2fd28b1acc0/src/brogue/Monsters.c#L92

initializeMonster() modifies the turns-till-regen value inside the monster.info struct (multiplies it by 1000).

After creating the monster, the wizard code calls initializeMonster() again after setting the mutation:

https://github.com/tmewett/BrogueCE/blob/af0d25995221a51591ae7da4ba95c2fd28b1acc0/src/brogue/Wizard.c#L370

This second call to initializeMonster() multiplies the turns-till-regen by 1000 again, effectively terminating regeneration.

The IF statement blocks the second multiplication from occurring.

brturn avatar Dec 02 '25 04:12 brturn