summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJude Brown <bookofjude@users.sourceforge.net>2009-12-05 14:47:58 +1000
committerJude Brown <bookofjude@users.sourceforge.net>2009-12-05 14:47:58 +1000
commit75be79355430d15ed4783ef7fa2725a940642646 (patch)
treed9dc756443533b164a94884a216aea7c85f2597e
parent98b441d511bd1538c6803f8fab3a7777c51dc90b (diff)
downloadcrawl-ref-75be79355430d15ed4783ef7fa2725a940642646.tar.gz
crawl-ref-75be79355430d15ed4783ef7fa2725a940642646.zip
Apply extra_monster_flags earlier to fix "comes into view" errors.
Rebranded monsters (ie, "kobold name:Durwent name_replace") who are created with Lua and dgn.create_monster while the player is resting will generate a "XYZ comes into view" warning message. However, as this message is triggered by handle_seen_interrupt, which is triggered before the additional flags are applied, it will disregard MF_NAME_SUFFIX, MF_NAME_REPLACE, MF_NAME_ADJECTIVE, etc. Applying these flags earlier fixes this.
-rw-r--r--crawl-ref/source/dungeon.cc7
-rw-r--r--crawl-ref/source/mgen_data.h10
-rw-r--r--crawl-ref/source/mon-place.cc3
3 files changed, 17 insertions, 3 deletions
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index 7640048c11..8c91a76616 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -4967,6 +4967,9 @@ int dgn_place_monster(mons_spec &mspec,
if (m_band)
mg.flags |= MG_PERMIT_BANDS;
+ // Store any extra flags here.
+ mg.extra_flags |= mspec.extra_monster_flags;
+
const int mindex = place_monster(mg, true);
if (mindex != -1)
{
@@ -4975,7 +4978,9 @@ int dgn_place_monster(mons_spec &mspec,
_dgn_give_mon_spec_items(mspec, mindex, mid, monster_level);
if (mspec.explicit_spells)
mons.spells = mspec.spells;
- mons.flags |= mspec.extra_monster_flags;
+ // These are applied earlier to prevent issues with renamed monsters
+ // and "<monster> comes into view" (see delay.cc:_monster_warning).
+ //mons.flags |= mspec.extra_monster_flags;
if (mons.is_priest() && mons.god == GOD_NO_GOD)
mons.god = GOD_NAMELESS;
}
diff --git a/crawl-ref/source/mgen_data.h b/crawl-ref/source/mgen_data.h
index 2719b71b94..360ebf3f54 100644
--- a/crawl-ref/source/mgen_data.h
+++ b/crawl-ref/source/mgen_data.h
@@ -90,6 +90,10 @@ struct mgen_data
int hd;
int hp;
+ // These flags will be appended to the monster's flags after placement.
+ // These flags are MF_XXX, rather than MG_XXX flags.
+ unsigned long extra_flags;
+
// XXX: Rather hackish.
std::string mname;
@@ -113,6 +117,7 @@ struct mgen_data
proximity_type prox = PROX_ANYWHERE,
level_area_type ltype = you.level_type,
int mhd = 0, int mhp = 0,
+ unsigned long mflags = 0,
std::string monname = "",
std::string nas = "")
@@ -120,7 +125,8 @@ struct mgen_data
abjuration_duration(abj), summon_type(st), pos(p), foe(mfoe),
flags(monflags), god(which_god), number(monnumber), colour(moncolour),
power(monpower), proximity(prox), level_type(ltype), map_mask(0),
- hd(mhd), hp(mhp), mname(monname), non_actor_summoner(nas)
+ hd(mhd), hp(mhp), extra_flags(mflags), mname(monname),
+ non_actor_summoner(nas)
{
ASSERT(summon_type == 0 || (abj >= 1 && abj <= 6)
|| mt == MONS_BALL_LIGHTNING);
@@ -157,7 +163,7 @@ struct mgen_data
return mgen_data(mt, BEH_HOSTILE, 0, abj, st, p,
alert ? MHITYOU : MHITNOT,
monflags, god, base, 0, BLACK, you.your_level,
- PROX_ANYWHERE, you.level_type, 0, 0, "", summoner);
+ PROX_ANYWHERE, you.level_type, 0, 0, 0, "", summoner);
}
};
diff --git a/crawl-ref/source/mon-place.cc b/crawl-ref/source/mon-place.cc
index c3f487b319..59dafc75bc 100644
--- a/crawl-ref/source/mon-place.cc
+++ b/crawl-ref/source/mon-place.cc
@@ -1188,6 +1188,9 @@ static int _place_monster_aux(const mgen_data &mg,
mon->hit_points = mg.hp;
}
+ // Store the extra flags here.
+ mon->flags |= mg.extra_flags;
+
// The return of Boris is now handled in monster_die(). Not setting
// this for Boris here allows for multiple Borises in the dungeon at
// the same time. - bwr