During level change, when a monster from mydogs (monsters accompaying hero, usually pets) couldn't be placed because the level was full, it was set to migrate to that level (in order to get another chance to arrive if hero left and returned). The code sequence mon_arrive()-> mnexto()-> m_into_limbo()-> migrate_to_level()-> relmon() tried to remove the monster from the map, but it wasn't necessarily on the map (depending upon whether it couldn't arrive at all, or arrived at the hero's spot and couldn't be moved out of the hero's way). The EXTRA_SANITY_CHECKS for remove_monster() issued impossible "no monster to remove". relmon() now checks whether monster is already off the map. While investigating that, I discovered that pets set to re-migrate to the same level to try again on hero's next visit didn't work at all. migrating_mons gets processed after mydogs so moving something from the latter to the former after arrival failure just resulted in immediate second failure when the more general list was handled during the hero's current arrival. And failure to arrive from migrating_mons would kill the monster instead of scheduling another attempt. The sanest fix for that turned out to be to have all monsters who can't arrive be put back on the migrating_mons list to try again upon hero's next visit. Pets still fail twice but are no longer discarded during the second time, and now do arrive when hero leaves and comes back provided he or she has opened up some space before leaving. If there's still no space on the next visit, monsters who can't arrive then are scheduled to try again on the visit after that. Recent fix for invalid corpses becomes moot. Monsters aren't killed during arrival failure so there are no resulting corpses to deal with.
20 KiB
20 KiB