summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-10-27 01:35:41 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-10-27 02:32:06 +0100
commit928479a2ce6674d27d6ef03d7a06f81803ccdfae (patch)
treef9c1a9ddd869efe1e725e870519cfc83b0259f75
parent2c33ddb4c83370db12567cdddaa7f4fe696481c9 (diff)
downloadcrawl-ref-928479a2ce6674d27d6ef03d7a06f81803ccdfae.tar.gz
crawl-ref-928479a2ce6674d27d6ef03d7a06f81803ccdfae.zip
Convert some ints to monster_type.
There's a whole lot of places that pass monster_type as int, often with varying meanings for the value -1. This moves some of these to monster_type, introducing MONS_NO_MONSTER and MONS_PLAYER as new invalid special values. Also improve on the autoexclude descriptions.
-rw-r--r--crawl-ref/source/actor.h2
-rw-r--r--crawl-ref/source/beam.cc2
-rw-r--r--crawl-ref/source/debug.cc26
-rw-r--r--crawl-ref/source/delay.cc6
-rw-r--r--crawl-ref/source/dungeon.cc19
-rw-r--r--crawl-ref/source/enum.h3
-rw-r--r--crawl-ref/source/fight.cc4
-rw-r--r--crawl-ref/source/makeitem.cc3
-rw-r--r--crawl-ref/source/misc.cc16
-rw-r--r--crawl-ref/source/misc.h8
-rw-r--r--crawl-ref/source/mon-util.cc32
-rw-r--r--crawl-ref/source/mon-util.h2
-rw-r--r--crawl-ref/source/monplace.cc30
-rw-r--r--crawl-ref/source/monplace.h2
-rw-r--r--crawl-ref/source/monspeak.cc2
-rw-r--r--crawl-ref/source/monster.h4
-rw-r--r--crawl-ref/source/monstuff.cc14
-rw-r--r--crawl-ref/source/mstuff2.cc9
-rw-r--r--crawl-ref/source/player.cc4
-rw-r--r--crawl-ref/source/player.h2
-rw-r--r--crawl-ref/source/religion.cc2
-rw-r--r--crawl-ref/source/tags.cc4
-rw-r--r--crawl-ref/source/traps.cc2
-rw-r--r--crawl-ref/source/travel.cc13
-rw-r--r--crawl-ref/source/travel.h2
25 files changed, 110 insertions, 103 deletions
diff --git a/crawl-ref/source/actor.h b/crawl-ref/source/actor.h
index 3a31aef341..00b61b039a 100644
--- a/crawl-ref/source/actor.h
+++ b/crawl-ref/source/actor.h
@@ -6,7 +6,7 @@ class actor
public:
virtual ~actor();
- virtual int id() const = 0;
+ virtual monster_type id() const = 0;
virtual int mindex() const = 0;
virtual actor_type atype() const = 0;
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index 0c84604bf6..80a117748e 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -4011,7 +4011,7 @@ void bolt::affect_player()
{
// assumes DVORP_PIERCING, factor: 0.5
int blood = std::min(you.hp, hurted / 2);
- bleed_onto_floor(you.pos(), -1, blood, true);
+ bleed_onto_floor(you.pos(), MONS_PLAYER, blood, true);
}
hurted = check_your_resists(hurted, flavour);
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index 4aa9b6f07e..2a6be21159 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -167,7 +167,7 @@ void DEBUGSTR(const char *format, ...)
}
#endif
-static int _debug_prompt_for_monster( void )
+static monster_type _debug_prompt_for_monster(void)
{
char specs[80];
@@ -175,11 +175,11 @@ static int _debug_prompt_for_monster( void )
if (!cancelable_get_line_autohist(specs, sizeof specs))
{
if (specs[0] == '\0')
- return (-1);
+ return (MONS_NO_MONSTER);
return (get_monster_by_name(specs));
}
- return (-1);
+ return (MONS_NO_MONSTER);
}
//---------------------------------------------------------------
@@ -1202,7 +1202,7 @@ void wizard_create_spec_object()
{
char specs[80];
char keyin;
- int mon;
+ monster_type mon;
object_class_type class_wanted = OBJ_UNASSIGNED;
@@ -1289,7 +1289,7 @@ void wizard_create_spec_object()
{
mon = _debug_prompt_for_monster();
- if (mon == -1 || mon == MONS_PROGRAM_BUG)
+ if (mon == MONS_NO_MONSTER || mon == MONS_PROGRAM_BUG)
{
mpr("No such monster.");
return;
@@ -5655,16 +5655,16 @@ void wizard_make_monster_summoned(monsters* mon)
void wizard_polymorph_monster(monsters* mon)
{
- int old_type = mon->type;
- int type = _debug_prompt_for_monster();
+ monster_type old_type = mon->type;
+ monster_type type = _debug_prompt_for_monster();
- if (type == -1)
+ if (type == NUM_MONSTERS)
{
canned_msg( MSG_OK );
return;
}
- if (invalid_monster_class(type) || type == MONS_PROGRAM_BUG)
+ if (invalid_monster_type(type))
{
mpr("Invalid monster type.", MSGCH_PROMPT);
return;
@@ -5682,7 +5682,7 @@ void wizard_polymorph_monster(monsters* mon)
return;
}
- monster_polymorph(mon, (monster_type) type, PPT_SAME, true);
+ monster_polymorph(mon, type, PPT_SAME, true);
if (!mon->alive())
{
@@ -6609,7 +6609,7 @@ std::string debug_mon_str(const monsters* mon)
void debug_dump_mon(const monsters* mon, bool recurse)
{
const int midx = monster_index(mon);
- if (invalid_monster_index(midx) || invalid_monster_class(mon->type))
+ if (invalid_monster_index(midx) || invalid_monster_type(mon->type))
return;
fprintf(stderr, "<<<<<<<<<" EOL);
@@ -6781,7 +6781,7 @@ void debug_dump_mon(const monsters* mon, bool recurse)
return;
if (!invalid_monster_index(mon->foe) && mon->foe != midx
- && !invalid_monster_class(menv[mon->foe].type))
+ && !invalid_monster_type(menv[mon->foe].type))
{
fprintf(stderr, "Foe:" EOL);
debug_dump_mon(&menv[mon->foe], false);
@@ -6789,7 +6789,7 @@ void debug_dump_mon(const monsters* mon, bool recurse)
if (!invalid_monster_index(target) && target != midx
&& target != mon->foe
- && !invalid_monster_class(menv[target].type))
+ && !invalid_monster_type(menv[target].type))
{
fprintf(stderr, "Target:" EOL);
debug_dump_mon(&menv[target], false);
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index 2fe59e8f2c..8e19ddbeb5 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -468,12 +468,12 @@ void stop_delay( bool stop_stair_travel )
item_def &item = (delay.parm1 ? you.inv[delay.parm2]
: mitm[delay.parm2]);
-
- const bool was_orc = (mons_species(item.plus) == MONS_ORC);
+ monster_type montype = static_cast<monster_type>(item.plus);
+ const bool was_orc = (mons_species(montype) == MONS_ORC);
mpr("All blood oozes out of the corpse!");
- bleed_onto_floor(you.pos(), item.plus, delay.duration, false);
+ bleed_onto_floor(you.pos(), montype, delay.duration, false);
if (mons_skeleton(item.plus) && one_chance_in(3))
turn_corpse_into_skeleton(item);
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index 528fe317f4..5ed80fb079 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -4685,7 +4685,7 @@ int dgn_place_monster(mons_spec &mspec,
{
if (mspec.mid != -1)
{
- const int mid = mspec.mid;
+ const monster_type mid = static_cast<monster_type>(mspec.mid);
const bool m_generate_awake = (generate_awake || mspec.generate_awake);
const bool m_patrolling = (patrolling || mspec.patrolling);
const bool m_band = mspec.band;
@@ -4711,7 +4711,8 @@ int dgn_place_monster(mons_spec &mspec,
return (-1);
}
- const int montype = mons_class_is_zombified(mid) ? mspec.monbase
+ const monster_type montype = mons_class_is_zombified(mid)
+ ? mspec.monbase
: mid;
const habitat_type habitat = mons_class_primary_habitat(montype);
@@ -4720,7 +4721,7 @@ int dgn_place_monster(mons_spec &mspec,
dungeon_terrain_changed(where, habitat2grid(habitat));
}
- mgen_data mg(static_cast<monster_type>(mid));
+ mgen_data mg(mid);
if (mg.cls == RANDOM_MONSTER && mspec.place.is_valid())
{
@@ -5116,19 +5117,19 @@ static void _vault_grid( vault_placement &place,
if (vgrid != '8' && vgrid != '9' && vgrid != '0')
{
monster_type_thing = place.map.mons.get_monster(vgrid - '1');
+ monster_type mt = static_cast<monster_type>(monster_type_thing.mid);
// Is a map for a specific place trying to place a unique which
// somehow already got created?
if (place.map.place.is_valid()
- && !invalid_monster_class(monster_type_thing.mid)
- && mons_is_unique(monster_type_thing.mid)
- && you.unique_creatures[monster_type_thing.mid])
+ && !invalid_monster_type(mt)
+ && mons_is_unique(mt)
+ && you.unique_creatures[mt])
{
mprf(MSGCH_ERROR, "ERROR: %s already generated somewhere "
"else; please file a bug report.",
- mons_type_name(monster_type_thing.mid,
- DESC_CAP_THE).c_str());
+ mons_type_name(mt, DESC_CAP_THE).c_str());
// Force it to be generated anyway.
- you.unique_creatures[monster_type_thing.mid] = false;
+ you.unique_creatures[mt] = false;
}
}
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index 91f4749898..921aef7dcf 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -2094,6 +2094,9 @@ enum monster_type // (int) menv[].type
MONS_TEST_SPAWNER,
NUM_MONSTERS, // used for polymorph
+ MONS_NO_MONSTER,
+ MONS_PLAYER,
+
RANDOM_MONSTER = 1000, // used to distinguish between a random monster and using program bugs for error trapping {dlb}
// A random draconian, either base coloured drac or specialised.
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index f544fbd617..c769a4f563 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -5114,8 +5114,6 @@ void melee_attack::mons_perform_attack_rounds()
mons_announce_hit(attk);
check_defender_train_armour();
- const int type = defender->id();
-
if (defender->can_bleed()
&& !defender->is_summoned()
&& !defender->submerged())
@@ -5126,7 +5124,7 @@ void melee_attack::mons_perform_attack_rounds()
if (blood > defender->stat_hp())
blood = defender->stat_hp();
- bleed_onto_floor(pos, type, blood, true);
+ bleed_onto_floor(pos, defender->id(), blood, true);
}
if (decapitate_hydra(damage_done,
diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc
index 82fd6aecde..d44531c53d 100644
--- a/crawl-ref/source/makeitem.cc
+++ b/crawl-ref/source/makeitem.cc
@@ -4044,6 +4044,9 @@ static void _give_ammo(monsters *mon, int level,
qty += random2(4);
break;
+
+ default:
+ break;
}
if (weap_type == -1)
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index 9b38407047..5c65a8e799 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -124,8 +124,8 @@ static void _create_monster_hide(const item_def corpse)
break;
}
- int mtype = corpse.orig_monnum - 1;
- if (!invalid_monster_class(mtype) && mons_is_unique(mtype))
+ monster_type mtype = static_cast<monster_type>(corpse.orig_monnum - 1);
+ if (!invalid_monster_type(mtype) && mons_is_unique(mtype))
item.inscription = mons_type_name(mtype, DESC_PLAIN);
move_item_to_grid(&o, you.pos());
@@ -156,12 +156,12 @@ void turn_corpse_into_skeleton(item_def &item)
void turn_corpse_into_chunks(item_def &item)
{
ASSERT(item.base_type == OBJ_CORPSES && item.sub_type == CORPSE_BODY);
-
- const int max_chunks = mons_weight(item.plus) / 150;
+ const monster_type montype = static_cast<monster_type>(item.plus);
+ const int max_chunks = mons_weight(montype) / 150;
// Only fresh corpses bleed enough to colour the ground.
if (!food_is_rotten(item))
- bleed_onto_floor(you.pos(), item.plus, max_chunks, true);
+ bleed_onto_floor(you.pos(), montype, max_chunks, true);
item.base_type = OBJ_FOOD;
item.sub_type = FOOD_CHUNK;
@@ -1126,15 +1126,15 @@ static void _maybe_bloodify_square(const coord_def& where, int amount,
// Currently flavour only: colour ground (and possibly adjacent squares) red.
// "damage" depends on damage taken (or hitpoints, if damage higher),
// or, for sacrifices, on the number of chunks possible to get out of a corpse.
-void bleed_onto_floor(const coord_def& where, int montype,
+void bleed_onto_floor(const coord_def& where, monster_type montype,
int damage, bool spatter, bool smell_alert)
{
ASSERT(in_bounds(where));
- if (montype == -1 && !you.can_bleed())
+ if (montype == MONS_PLAYER && !you.can_bleed())
return;
- if (montype != -1)
+ if (montype != NUM_MONSTERS)
{
monsters m;
m.type = montype;
diff --git a/crawl-ref/source/misc.h b/crawl-ref/source/misc.h
index 37ced6dae7..c6efd53cd2 100644
--- a/crawl-ref/source/misc.h
+++ b/crawl-ref/source/misc.h
@@ -33,13 +33,13 @@ long remove_oldest_blood_potion( item_def &stack );
void remove_newest_blood_potion( item_def &stack, int quant = -1 );
void merge_blood_potion_stacks(item_def &source, item_def &dest, int quant);
-bool can_bottle_blood_from_corpse( int mons_type );
-int num_blood_potions_from_corpse( int mons_class, int chunk_type = -1 );
+bool can_bottle_blood_from_corpse(int mons_type);
+int num_blood_potions_from_corpse(int mons_class, int chunk_type = -1);
void turn_corpse_into_blood_potions (item_def &item);
void turn_corpse_into_skeleton_and_blood_potions(item_def &item);
-void split_potions_into_decay( int obj, int amount, bool need_msg = true );
+void split_potions_into_decay(int obj, int amount, bool need_msg = true);
-void bleed_onto_floor(const coord_def& where, int mon, int damage,
+void bleed_onto_floor(const coord_def& where, monster_type mon, int damage,
bool spatter = false, bool smell_alert = true);
void generate_random_blood_spatter_on_level();
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 617d8a1bd5..dd2e773592 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -132,11 +132,12 @@ static void _initialise_randmons()
for (int m = 0; m < NUM_MONSTERS; ++m)
{
- if (invalid_monster_class(m))
+ monster_type mt = static_cast<monster_type>(m);
+ if (invalid_monster_type(mt))
continue;
- if (monster_habitable_grid(m, grid))
- monsters_by_habitat[i].push_back(static_cast<monster_type>(m));
+ if (monster_habitable_grid(mt, grid))
+ monsters_by_habitat[i].push_back(mt);
}
}
initialised_randmons = true;
@@ -694,12 +695,11 @@ bool invalid_monster(const monsters *mon)
return (!mon || mon->type == -1);
}
-bool invalid_monster_class(int mclass)
+bool invalid_monster_type(monster_type mt)
{
- return (mclass < 0
- || mclass >= NUM_MONSTERS
- || mon_entry[mclass] == -1
- || mon_entry[mclass] == mon_entry[MONS_PROGRAM_BUG]);
+ return (mt < 0 || mt >= NUM_MONSTERS
+ || mon_entry[mt] == -1
+ || mon_entry[mt] == mon_entry[MONS_PROGRAM_BUG]);
}
bool invalid_monster_index(int i)
@@ -2035,9 +2035,9 @@ monster_type draconian_colour_by_name(const std::string &name)
static std::string _str_monam(const monsters& mon, description_level_type desc,
bool force_seen)
{
- if (mon.type == -1)
+ if (mon.type == MONS_NO_MONSTER)
return ("DEAD MONSTER");
- else if (invalid_monster_class(mon.type) && mon.type != MONS_PROGRAM_BUG)
+ else if (invalid_monster_type(mon.type) && mon.type != MONS_PROGRAM_BUG)
return make_stringf("INVALID MONSTER (#%d)", mon.type);
const bool arena_submerged = crawl_state.arena && !force_seen
@@ -2091,7 +2091,7 @@ static std::string _str_monam(const monsters& mon, description_level_type desc,
return (apostrophise(mon.mname) + " ghost");
// Some monsters might want the name of a different creature.
- int nametype = mon.type;
+ monster_type nametype = mon.type;
// Tack on other prefixes.
switch (mon.type)
@@ -2207,7 +2207,7 @@ static std::string _str_monam(const monsters& mon, description_level_type desc,
else
{
// Add the base name.
- if (invalid_monster_class(nametype) && nametype != MONS_PROGRAM_BUG)
+ if (invalid_monster_type(nametype) && nametype != MONS_PROGRAM_BUG)
result += make_stringf("INVALID MONSTER (#%d)", nametype);
else
result += get_monster_data(nametype)->name;
@@ -3560,7 +3560,7 @@ bool monster_senior(const monsters *m1, const monsters *m2, bool fleeing)
// monsters methods
monsters::monsters()
- : type(-1), hit_points(0), max_hit_points(0), hit_dice(0),
+ : type(MONS_NO_MONSTER), hit_points(0), max_hit_points(0), hit_dice(0),
ac(0), ev(0), speed(0), speed_increment(0),
target(), patrol_point(), travel_target(MTRAV_NONE),
inv(NON_ITEM), spells(), attitude(ATT_HOSTILE), behaviour(BEH_WANDER),
@@ -3597,7 +3597,7 @@ void monsters::reset()
flags = 0;
experience = 0L;
- type = -1;
+ type = MONS_NO_MONSTER;
base_monster = MONS_PROGRAM_BUG;
hit_points = 0;
max_hit_points = 0;
@@ -5802,7 +5802,7 @@ std::string monsters::arm_name(bool plural, bool *can_plural) const
return (str);
}
-int monsters::id() const
+monster_type monsters::id() const
{
return (type);
}
@@ -6176,7 +6176,7 @@ void monsters::teleport(bool now, bool)
bool monsters::alive() const
{
- return (hit_points > 0 && type != -1);
+ return (hit_points > 0 && type != MONS_NO_MONSTER);
}
god_type monsters::deity() const
diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h
index 664516032f..f712b310de 100644
--- a/crawl-ref/source/mon-util.h
+++ b/crawl-ref/source/mon-util.h
@@ -842,7 +842,7 @@ bool mons_has_blood(int mc);
bool mons_is_submerged(const monsters *m);
bool invalid_monster(const monsters *mon);
-bool invalid_monster_class(int mclass);
+bool invalid_monster_type(monster_type mt);
bool invalid_monster_index(int i);
bool monster_shover(const monsters *m);
diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc
index e2658e05e2..e0515efdfd 100644
--- a/crawl-ref/source/monplace.cc
+++ b/crawl-ref/source/monplace.cc
@@ -111,8 +111,8 @@ bool monster_habitable_grid(const monsters *m,
dungeon_feature_type actual_grid)
{
// Zombified monsters enjoy the same habitat as their original.
- const int montype = mons_is_zombified(m) ? mons_zombie_base(m)
- : m->type;
+ const monster_type montype = mons_is_zombified(m) ? mons_zombie_base(m)
+ : m->type;
return (monster_habitable_grid(montype, actual_grid, mons_flies(m),
mons_cannot_move(m)));
@@ -133,7 +133,7 @@ inline static bool _mons_airborne(int mcls, int flies, bool paralysed)
// one check, so we no longer care if a water elemental springs into existence
// on dry land, because they're supposed to be able to move onto dry land
// anyway.
-bool monster_habitable_grid(int monster_class,
+bool monster_habitable_grid(monster_type montype,
dungeon_feature_type actual_grid,
int flies, bool paralysed)
{
@@ -142,17 +142,17 @@ bool monster_habitable_grid(int monster_class,
return (false);
const dungeon_feature_type feat_preferred =
- habitat2grid(mons_class_primary_habitat(monster_class));
+ habitat2grid(mons_class_primary_habitat(montype));
const dungeon_feature_type feat_nonpreferred =
- habitat2grid(mons_class_secondary_habitat(monster_class));
+ habitat2grid(mons_class_secondary_habitat(montype));
// Special check for fire elementals since their habitat is floor which
// is generally considered compatible with shallow water.
- if (monster_class == MONS_FIRE_ELEMENTAL && feat_is_watery(actual_grid))
+ if (montype == MONS_FIRE_ELEMENTAL && feat_is_watery(actual_grid))
return (false);
// Krakens are too large for shallow water.
- if (monster_class == MONS_KRAKEN && actual_grid == DNGN_SHALLOW_WATER)
+ if (montype == MONS_KRAKEN && actual_grid == DNGN_SHALLOW_WATER)
return (false);
if (feat_compatible(feat_preferred, actual_grid)
@@ -165,7 +165,7 @@ bool monster_habitable_grid(int monster_class,
// [dshaligram] Flying creatures are all DNGN_FLOOR, so we
// only have to check for the additional valid grids of deep
// water and lava.
- if (_mons_airborne(monster_class, flies, paralysed)
+ if (_mons_airborne(montype, flies, paralysed)
&& (actual_grid == DNGN_LAVA || actual_grid == DNGN_DEEP_WATER))
{
return (true);
@@ -695,8 +695,8 @@ static bool _valid_monster_generation_location(
if (!in_bounds(mg_pos) || actor_at(mg_pos))
return (false);
- const int montype = (mons_class_is_zombified(mg.cls) ? mg.base_type
- : mg.cls);
+ const monster_type montype = (mons_class_is_zombified(mg.cls) ? mg.base_type
+ : mg.cls);
if (!monster_habitable_grid(montype, grd(mg_pos),
mons_class_flies(montype), false)
|| (mg.behaviour != BEH_FRIENDLY && is_sanctuary(mg_pos)))
@@ -1003,7 +1003,7 @@ static int _place_monster_aux(const mgen_data &mg,
// Gotta be able to pick an ID.
for (id = 0; id < MAX_MONSTERS; id++)
- if (menv[id].type == -1)
+ if (menv[id].type == MONS_NO_MONSTER)
break;
// Too many monsters on level?
@@ -1012,8 +1012,8 @@ static int _place_monster_aux(const mgen_data &mg,
menv[id].reset();
- const int montype = (mons_class_is_zombified(mg.cls) ? mg.base_type
- : mg.cls);
+ const monster_type montype = (mons_class_is_zombified(mg.cls) ? mg.base_type
+ : mg.cls);
// Setup habitat and placement.
// If the space is occupied, try some neighbouring square instead.
@@ -3215,8 +3215,8 @@ bool monster_pathfind::traversable(const coord_def p)
// its preferred habit and capability of flight or opening doors.
bool monster_pathfind::mons_traversable(const coord_def p)
{
- const int montype = mons_is_zombified(mons) ? mons_zombie_base(mons)
- : mons->type;
+ const monster_type montype = mons_is_zombified(mons) ? mons_zombie_base(mons)
+ : mons->type;
if (!monster_habitable_grid(montype, grd(p)))
return (false);
diff --git a/crawl-ref/source/monplace.h b/crawl-ref/source/monplace.h
index 8d05ee2e21..9d97a84365 100644
--- a/crawl-ref/source/monplace.h
+++ b/crawl-ref/source/monplace.h
@@ -319,7 +319,7 @@ bool feat_compatible(dungeon_feature_type grid_wanted,
dungeon_feature_type actual_grid);
bool monster_habitable_grid(const monsters *m,
dungeon_feature_type actual_grid);
-bool monster_habitable_grid(int monster_class,
+bool monster_habitable_grid(monster_type montype,
dungeon_feature_type actual_grid,
int flies = -1,
bool paralysed = false);
diff --git a/crawl-ref/source/monspeak.cc b/crawl-ref/source/monspeak.cc
index 56b725984c..17f41b05da 100644
--- a/crawl-ref/source/monspeak.cc
+++ b/crawl-ref/source/monspeak.cc
@@ -358,7 +358,7 @@ static bool _polyd_can_speak(const monsters* monster)
// Returns true if something is said.
bool mons_speaks(monsters *monster)
{
- ASSERT(!invalid_monster_class(monster->type));
+ ASSERT(!invalid_monster_type(monster->type));
// Monsters always talk on death, even if invisible/silenced/etc.
int duration = 1;
diff --git a/crawl-ref/source/monster.h b/crawl-ref/source/monster.h
index 133c0df54f..41c17ecbfd 100644
--- a/crawl-ref/source/monster.h
+++ b/crawl-ref/source/monster.h
@@ -62,7 +62,7 @@ public:
public:
std::string mname;
- int type;
+ monster_type type;
int hit_points;
int max_hit_points;
int hit_dice;
@@ -187,7 +187,7 @@ public:
actor *get_foe() const;
// actor interface
- int id() const;
+ monster_type id() const;
int mindex() const;
int get_experience_level() const;
god_type deity() const;
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 74bc150b01..5db6f375b4 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -1667,7 +1667,7 @@ int monster_die(monsters *monster, killer_type killer,
// If the killer is already dead treat it like an
// anonymous monster.
- if (killer_mon->type == -1)
+ if (killer_mon->type == MONS_NO_MONSTER)
anon = true;
}
@@ -1991,6 +1991,7 @@ int monster_die(monsters *monster, killer_type killer,
return (corpse);
}
+// Clean up after a dead monster.
void monster_cleanup(monsters *monster)
{
crawl_state.mon_gone(monster);
@@ -2093,7 +2094,7 @@ void alert_nearby_monsters(void)
}
}
-static bool _valid_morph(monsters *monster, int new_mclass)
+static bool _valid_morph(monsters *monster, monster_type new_mclass)
{
const dungeon_feature_type current_tile = grd(monster->pos());
@@ -8217,9 +8218,10 @@ static bool _monster_eat_single_corpse(monsters *monster, item_def& item,
if (item.base_type != OBJ_CORPSES || item.sub_type != CORPSE_BODY)
return (false);
+ monster_type mt = static_cast<monster_type>(item.plus);
if (do_heal)
{
- monster->hit_points += 1 + random2(mons_weight(item.plus)) / 100;
+ monster->hit_points += 1 + random2(mons_weight(mt)) / 100;
// Limited growth factor here - should 77 really be the cap? {dlb}:
monster->hit_points = std::min(100, monster->hit_points);
@@ -8237,13 +8239,13 @@ static bool _monster_eat_single_corpse(monsters *monster, item_def& item,
// from misc.cc:turn_corpse_into_chunks() and the butchery-related
// delays in delay.cc:stop_delay().
- const int max_chunks = mons_weight(item.plus) / 150;
+ const int max_chunks = mons_weight(mt) / 150;
// Only fresh corpses bleed enough to colour the ground.
if (!food_is_rotten(item))
- bleed_onto_floor(monster->pos(), item.plus, max_chunks, true);
+ bleed_onto_floor(monster->pos(), mt, max_chunks, true);
- if (mons_skeleton(item.plus) && one_chance_in(3))
+ if (mons_skeleton(mt) && one_chance_in(3))
turn_corpse_into_skeleton(item);
else
destroy_item(item.index());
diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc
index e2d90b544b..65c9732ec8 100644
--- a/crawl-ref/source/mstuff2.cc
+++ b/crawl-ref/source/mstuff2.cc
@@ -1319,11 +1319,12 @@ void monster_teleport(monsters *monster, bool instan, bool silent)
mgrd(monster->pos()) = monster_index(monster);
// Mimics change form/colour when teleported.
- if (mons_is_mimic( monster->type ))
+ if (mons_is_mimic(monster->type))
{
- int old_type = monster->type;
- monster->type = MONS_GOLD_MIMIC + random2(5);
- monster->colour = get_mimic_colour( monster );
+ monster_type old_type = monster->type;
+ monster->type = static_cast<monster_type>(
+ MONS_GOLD_MIMIC + random2(5));
+ monster->colour = get_mimic_colour(monster);
// If it's changed form, you won't recognise it.
// This assumes that a non-gold mimic turning into another item of
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index bb9224de52..007a679cfc 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -6425,9 +6425,9 @@ std::string player::arm_name(bool plural, bool *can_plural) const
return (str);
}
-int player::id() const
+monster_type player::id() const
{
- return (-1);
+ return (MONS_PLAYER);
}
int player::mindex() const
diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h
index b3ecedef1d..5a19614fca 100644
--- a/crawl-ref/source/player.h
+++ b/crawl-ref/source/player.h
@@ -326,7 +326,7 @@ public:
item_def *slot_item(equipment_type eq);
// actor
- int id() const;
+ monster_type id() const;
int mindex() const;
int get_experience_level() const;
actor_type atype() const { return ACT_PLAYER; }
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 24fd09d1d1..b0354671f3 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -7154,7 +7154,7 @@ void offer_and_butcher_corpse(int corpse)
did_god_conduct(DID_DEDICATED_BUTCHERY, 10);
// ritual sacrifice can also bloodify the ground
- const int mons_class = mitm[corpse].plus;
+ const monster_type mons_class = static_cast<monster_type>(mitm[corpse].plus);
const int max_chunks = mons_weight(mons_class) / 150;
bleed_onto_floor(you.pos(), mons_class, max_chunks, true);
destroy_item(corpse);
diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc
index ab02149019..6678f498de 100644
--- a/crawl-ref/source/tags.cc
+++ b/crawl-ref/source/tags.cc
@@ -2174,7 +2174,7 @@ static void unmarshall_monster(reader &th, monsters &m)
}
m.ench_countdown = unmarshallByte(th);
- m.type = unmarshallShort(th);
+ m.type = static_cast<monster_type>(unmarshallShort(th));
m.hit_points = unmarshallShort(th);
m.max_hit_points = unmarshallShort(th);
m.number = unmarshallShort(th);
@@ -2217,7 +2217,7 @@ static void tag_read_level_monsters(reader &th, char minorVersion)
monsters &m = menv[i];
unmarshall_monster(th, m);
// place monster
- if (m.type != -1)
+ if (m.type != MONS_NO_MONSTER)
{
#if defined(DEBUG) || defined(DEBUG_MONS_SCAN)
int midx = mgrd(m.pos());
diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc
index adf833ca02..664d3edb18 100644
--- a/crawl-ref/source/traps.cc
+++ b/crawl-ref/source/traps.cc
@@ -442,7 +442,7 @@ void trap_def::trigger(actor& triggerer, bool flat_footed)
const int damage = (you.your_level * 2) + random2avg(29, 2)
- random2(1 + player_AC());
ouch(damage, NON_MONSTER, KILLED_BY_TRAP, "blade");
- bleed_onto_floor(you.pos(), -1, damage, true);
+ bleed_onto_floor(you.pos(), MONS_PLAYER, damage, true);
}
}
else if (m)
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index 7ea50c042f..0e083e903e 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -533,10 +533,10 @@ void set_exclude(const coord_def &p, int radius, bool autoexcl, bool vaultexcl)
}
else
{
- monster_type montype = NUM_MONSTERS;
+ monster_type montype = MONS_NO_MONSTER;
const monsters *m = monster_at(p);
- if (m && mons_near(m) && you.can_see(m))
- montype = static_cast<monster_type>(m->type);
+ if (m && you.can_see(m))
+ montype = m->type;
curr_excludes.push_back(travel_exclude(p, radius, autoexcl,
montype, vaultexcl));
@@ -564,9 +564,8 @@ std::string get_exclusion_desc()
int count_other = 0;
for (unsigned int i = 0; i < curr_excludes.size(); ++i)
{
- if (curr_excludes[i].mon != NON_MONSTER)
- monsters.push_back("unknown monster");
- // FIXME: mondata[curr_excludes[i].mon].name);
+ if (!invalid_monster_type(curr_excludes[i].mon))
+ monsters.push_back(mons_type_name(curr_excludes[i].mon, DESC_PLAIN));
else
count_other++;
}
@@ -3659,7 +3658,7 @@ void LevelInfo::load(reader& inf, char minorVersion)
unmarshallCoord(inf, c);
const int radius = unmarshallShort(inf);
bool autoexcl = false;
- monster_type mon = NUM_MONSTERS;
+ monster_type mon = MONS_NO_MONSTER;
if (minorVersion >= TAG_ANNOTATE_EXCL)
{
autoexcl = unmarshallBoolean(inf);
diff --git a/crawl-ref/source/travel.h b/crawl-ref/source/travel.h
index d1c5e55ddd..cfc8f95c9a 100644
--- a/crawl-ref/source/travel.h
+++ b/crawl-ref/source/travel.h
@@ -364,7 +364,7 @@ struct travel_exclude
bool vault; // Is this exclusion set by a vault?
travel_exclude(const coord_def &p, int r = LOS_RADIUS,
- bool autoex = false, monster_type mons = NUM_MONSTERS,
+ bool autoex = false, monster_type mons = MONS_NO_MONSTER,
bool vault = false);
int radius_sq() const;