Viewing Issue Simple Details Jump to Notes ] Wiki ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0003839 [DCSS] Bug Report minor random 2011-04-20 06:22 2014-07-02 19:01
Reporter reid View Status public  
Assigned To wheals
Priority normal Resolution done  
Status resolved   Product Branch 0.8 ancient branch
Summary 0003839: monster_teleport can teleport a monster to an illegal square
Description From

    if (newpos.origin())
        monster_random_space(mons, newpos, !mons->wont_attack());

    // XXX: If the above function didn't find a good spot, return now
    // rather than continue by slotting the monster (presumably)
    // back into its old location (previous behaviour). This seems
    // to be much cleaner and safer than relying on what appears to
    // have been a mistake.
    if (newpos.origin())

But monster_random_space indicates failure by its return value, not by failing to modify its second argument. The result is that if monster_random_space fails to find a legal square to teleport the monster to, the last square it tries will be used as the teleportation target.

This is usually unlikely, since monster_random_space tries 1000 times to find a legal (unoccupied, habitable by the monster in question, etc.) square. But it can plausibly, if not usefully, happen in a real game: for example, you could fill a treasure trove with jellies from Jiyva's first ability, and teleport one of them; it'll probably land in a wall, but it could land on another jelly (or the player character!) in which case I don't know what would happen--I wouldn't be surprised if the game crashes. In wizard mode you can also create a salamander with &M and then teleport it into a wall or deep water, with hilarious results.
Additional Information
Tags No tags attached.
Attached Files

- Relationships

-  Notes
reid (reporter)
2011-04-20 06:45

Another plausible situation where this could come up is if you got a level with a single fountain (and no water) with an eel in it. It might be intentional that you can teleport the eel onto land, but surely it's not intentional that you can teleport the eel into a wall. (In either case it will die quickly, being out of water.)
reid (reporter)
2011-04-20 06:54

My recommendation here is to do what the comment suggests, namely use the return value of monster_random_space to decide whether to abort monster_teleport. This might produce a surprising lack of messages, but that's much better than teleporting monsters into walls or potentially other undefined behavior. In 0.7 the monster was effectively teleported from its current square back to its current square, so you would see "The <monster> disappears! The <monster> reappears nearby!"; this might be preferable, but it's not a big deal.
wheals (administrator)
2014-07-02 19:01

Fixed, with approximately your suggestion.

- Issue History
Date Modified Username Field Change
2011-04-20 06:22 reid New Issue
2011-04-20 06:45 reid Note Added: 0012726
2011-04-20 06:54 reid Note Added: 0012727
2014-07-02 19:01 wheals Note Added: 0026667
2014-07-02 19:01 wheals Status new => resolved
2014-07-02 19:01 wheals Fixed in Branch => 0.15 development branch
2014-07-02 19:01 wheals Resolution open => done
2014-07-02 19:01 wheals Assigned To => wheals

Mantis 1.1.8[^]
Copyright © 2000 - 2009 Mantis Group
Powered by Mantis Bugtracker