The monster knockback could mess with the monster linked list while the code was going through it for monster movements. (For example, a monster knocked back another into a level teleport trap) Add iter_mons_safe, which first grabs all the monster pointers in the list into an array, and goes over that array instead of relying on the "next monster" pointer. This is possible because dead monsters are not removed from the linked list until after all the monsters have moved. Testing is very minimal, and I'm not sure the vault guard check for migration is correct - it should probably check for more states? Also the iterator could be improved by not continually allocating and freeing the monster pointer array.
41 KiB
41 KiB