diff options
author | blackcustard <peterwicksstringfield@gmail.com> | 2013-07-30 14:11:30 -0500 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2013-07-30 16:36:15 -0400 |
commit | ed92a994f664c3d06841dd45e2479d5c037e3316 (patch) | |
tree | 408791ee412f79361cc0d5f94aea0e248e473dff /crawl-ref/source/mon-transit.cc | |
parent | c67cb32cf693618954cf9a0211d99e07e5ed05b4 (diff) | |
download | crawl-ref-ed92a994f664c3d06841dd45e2479d5c037e3316.tar.gz crawl-ref-ed92a994f664c3d06841dd45e2479d5c037e3316.zip |
Fix a Kirke crash by deporkalating transiting hogs correctly.
Normally, monsters are stored in a list (env.mons or menv for short).
There is a grid (env.mgrid or mgrd for short) which maps the position (x,
y) of the monster to its index in the list. Transiting monsters, however,
exist outside both the monster list and the monster grid. They are stored
separately, and they do not really have positions.
The deporkalation code inside dactions.cc was not transiting-monster
aware. It would call monster::move_to_pos on transiting hogs, just as on
non-transiting hogs. When it did so, it would write their index inside the
monster list into the monster grid. Of course, since these hogs were not
in the monster list in the first place, this "index" was bogus.
Within a few turns one of several unrelated parts Crawl would try to
investigate the monster grid and trip over the bogus entry, triggering this
assertion in monster_at inside mon-util.cc:
ASSERT(mindex <= MAX_MONSTERS);
Changes:
1. Make the deporkalation code transiting-monster aware. Do not call
monster::move_to_pos on transiting monsters. (Fixes the crash.)
2. Add some informative comments.
3. Make an implicit type conversion from monster to follower explicit.
Diffstat (limited to 'crawl-ref/source/mon-transit.cc')
-rw-r--r-- | crawl-ref/source/mon-transit.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/crawl-ref/source/mon-transit.cc b/crawl-ref/source/mon-transit.cc index 54550a6b0a..008c035452 100644 --- a/crawl-ref/source/mon-transit.cc +++ b/crawl-ref/source/mon-transit.cc @@ -115,7 +115,7 @@ m_transit_list *get_transit_list(const level_id &lid) void add_monster_to_transit(const level_id &lid, const monster& m) { m_transit_list &mlist = the_lost_ones[lid]; - mlist.push_back(m); + mlist.push_back(follower(m)); dprf("Monster in transit to %s: %s", lid.describe().c_str(), m.name(DESC_PLAIN, true).c_str()); @@ -255,7 +255,7 @@ void apply_daction_to_transit(daction_type act) { monster* mon = &j->mons; if (mons_matches_daction(mon, act)) - apply_daction_to_mons(mon, act, false); + apply_daction_to_mons(mon, act, false, true); } } } |