summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-05-19 20:51:51 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-05-19 20:51:51 +0000
commit5e05ffc14e57fff49b1f8a9700fa3623b4f1f343 (patch)
tree2cb6bb13f8b3c7b0af877542b1325ee7e3d1bc6e /crawl-ref/source
parent3ecc52d48d75321c18bd0969f461f26e253c6537 (diff)
downloadcrawl-ref-5e05ffc14e57fff49b1f8a9700fa3623b4f1f343.tar.gz
crawl-ref-5e05ffc14e57fff49b1f8a9700fa3623b4f1f343.zip
monam(), moname() and ptr_monam() are gone.
The replacement is str_monam() and mons_type_name(). str_monam() should probably be folded into actor::name. I think. Deaths from zombies, skeletons and simulacra will not handle the name correctly; needs a further hack. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1484 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/Kills.cc8
-rw-r--r--crawl-ref/source/beam.cc22
-rw-r--r--crawl-ref/source/clua.cc4
-rw-r--r--crawl-ref/source/debug.cc25
-rw-r--r--crawl-ref/source/delay.cc5
-rw-r--r--crawl-ref/source/describe.cc4
-rw-r--r--crawl-ref/source/direct.cc2
-rw-r--r--crawl-ref/source/dungeon.cc4
-rw-r--r--crawl-ref/source/fight.cc31
-rw-r--r--crawl-ref/source/files.cc2
-rw-r--r--crawl-ref/source/hiscores.cc24
-rw-r--r--crawl-ref/source/hiscores.h2
-rw-r--r--crawl-ref/source/insult.cc16
-rw-r--r--crawl-ref/source/it_use3.cc9
-rw-r--r--crawl-ref/source/itemname.cc12
-rw-r--r--crawl-ref/source/items.cc4
-rw-r--r--crawl-ref/source/message.h1
-rw-r--r--crawl-ref/source/misc.cc4
-rw-r--r--crawl-ref/source/mon-util.cc308
-rw-r--r--crawl-ref/source/mon-util.h28
-rw-r--r--crawl-ref/source/monplace.cc18
-rw-r--r--crawl-ref/source/monspeak.cc50
-rw-r--r--crawl-ref/source/monstuff.cc44
-rw-r--r--crawl-ref/source/mstuff2.cc10
-rw-r--r--crawl-ref/source/skills2.cc2
-rw-r--r--crawl-ref/source/spells1.cc2
-rw-r--r--crawl-ref/source/spells2.cc12
-rw-r--r--crawl-ref/source/spells3.cc4
-rw-r--r--crawl-ref/source/spells4.cc14
-rw-r--r--crawl-ref/source/stuff.cc4
30 files changed, 271 insertions, 404 deletions
diff --git a/crawl-ref/source/Kills.cc b/crawl-ref/source/Kills.cc
index 24d929d02b..272d91be61 100644
--- a/crawl-ref/source/Kills.cc
+++ b/crawl-ref/source/Kills.cc
@@ -505,14 +505,12 @@ void kill_def::add_place(unsigned short place, bool force)
std::string kill_def::base_name(const kill_monster_desc &md) const
{
- char monnamebuf[ITEMNAME_SIZE]; // Le sigh.
-
+ std::string name;
if (md.monnum == MONS_PANDEMONIUM_DEMON)
- strcpy(monnamebuf, "demon lord");
+ name = "demon lord";
else
- moname(md.monnum, true, DESC_PLAIN, monnamebuf);
+ name = mons_type_name(md.monnum, DESC_PLAIN);
- std::string name = monnamebuf;
switch (md.modifier)
{
case kill_monster_desc::M_ZOMBIE:
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index d00aeba43f..476f566893 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -24,6 +24,7 @@
#include <cstdio>
#include <cstring>
#include <cstdarg>
+#include <iostream>
#include <set>
#ifdef DOS
@@ -1969,7 +1970,7 @@ int mons_ench_f2(struct monsters *monster, struct bolt &pbolt)
case BEAM_INVISIBILITY: /* 5 = invisibility */
// Store the monster name before it becomes an "it" -- bwr
{
- const std::string monster_name = ptr_monam(monster, DESC_CAP_THE);
+ const std::string monster_name = str_monam(*monster, DESC_CAP_THE);
if (!monster->has_ench(ENCH_INVIS)
&& monster->add_ench(ENCH_INVIS))
@@ -2946,7 +2947,7 @@ static std::string beam_zapper(const bolt &beam)
else if (bsrc == MHITNOT)
return ("");
else
- return ptr_monam( &menv[bsrc], DESC_PLAIN );
+ return str_monam( menv[bsrc], DESC_PLAIN );
}
// return amount of extra range used up by affectation of the player
@@ -3512,7 +3513,7 @@ static int affect_monster(struct bolt &beam, struct monsters *mon)
{
mprf(MSGCH_DIAGNOSTICS,
"Monster: %s; Damage: pre-AC: %d; post-AC: %d; post-resist: %d",
- ptr_monam( mon, DESC_PLAIN ), hurt, raw_damage, hurt_final );
+ str_monam(*mon, DESC_PLAIN).c_str(),hurt, raw_damage, hurt_final);
}
#endif
@@ -3584,9 +3585,8 @@ static int affect_monster(struct bolt &beam, struct monsters *mon)
// if the PLAYER cannot see the monster, don't tell them anything!
if (player_monster_visible( &menv[tid] ) && mons_near(mon))
{
- mprf("The %s misses %s.",
- beam.name.c_str(),
- ptr_monam(mon, DESC_NOCAP_THE));
+ msg::stream << "The " << beam.name << " misses "
+ << str_monam(*mon, DESC_NOCAP_THE) << std::endl;
}
return (0);
}
@@ -3595,11 +3595,11 @@ static int affect_monster(struct bolt &beam, struct monsters *mon)
if (mons_near(mon))
{
mprf("The %s %s %s.",
- beam.name.c_str(),
- engulfs? "engulfs" : "hits",
- player_monster_visible(&menv[tid])?
- ptr_monam(mon, DESC_NOCAP_THE)
- : "something");
+ beam.name.c_str(),
+ engulfs? "engulfs" : "hits",
+ player_monster_visible(&menv[tid])?
+ str_monam(*mon, DESC_NOCAP_THE).c_str()
+ : "something");
}
else
{
diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc
index 9a1b16aab2..06a71f61c8 100644
--- a/crawl-ref/source/clua.cc
+++ b/crawl-ref/source/clua.cc
@@ -1996,9 +1996,7 @@ struct MonsterWrap
static int l_mons_name(lua_State *ls, monsters *mons, const char *attr)
{
- char monnamebuf[ITEMNAME_SIZE]; // Le sigh.
- moname(mons->type, true, DESC_PLAIN, monnamebuf);
- lua_pushstring(ls, monnamebuf);
+ lua_pushstring(ls, mons_type_name(mons->type, DESC_PLAIN).c_str());
return (1);
}
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index 6a57d1d069..87dd2c335d 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -927,7 +927,7 @@ void stethoscope(int mwh)
// print type of monster
mprf(MSGCH_DIAGNOSTICS, "%s (id #%d; type=%d loc=(%d,%d) align=%s)",
- monam( &menv[i], menv[i].number, menv[i].type, true, DESC_CAP_THE ),
+ str_monam(menv[i], DESC_CAP_THE, true).c_str(),
i, menv[i].type, menv[i].x, menv[i].y,
((menv[i].attitude == ATT_FRIENDLY) ? "friendly" :
(menv[i].attitude == ATT_HOSTILE) ? "hostile" :
@@ -963,8 +963,7 @@ void stethoscope(int mwh)
((menv[i].foe == MHITYOU) ? "you" :
(menv[i].foe == MHITNOT) ? "none" :
(menv[menv[i].foe].type == -1) ? "unassigned monster"
- : monam( &menv[menv[i].foe], menv[menv[i].foe].number,
- menv[menv[i].foe].type, true, DESC_PLAIN )),
+ : str_monam(menv[menv[i].foe], DESC_PLAIN, true).c_str()),
menv[i].foe,
menv[i].foe_memory,
menv[i].target_x, menv[i].target_y );
@@ -1098,7 +1097,7 @@ void debug_item_scan( void )
if (menv[j].inv[k] == i)
{
mprf("Held by monster #%d: %s at (%d,%d)",
- j, ptr_monam( &menv[j], DESC_CAP_A ),
+ j, str_monam( menv[j], DESC_CAP_A ).c_str(),
menv[j].x, menv[j].y );
}
}
@@ -1155,19 +1154,18 @@ void debug_item_scan( void )
// Quickly scan monsters for "program bug"s.
for (i = 0; i < MAX_MONSTERS; i++)
{
- const struct monsters *const monster = &menv[i];
+ const monsters& monster = menv[i];
- if (monster->type == -1)
+ if (monster.type == -1)
continue;
- moname( monster->type, true, DESC_PLAIN, name );
-
- if (strcmp( name, "program bug" ) == 0)
+ if (str_monam(monster, DESC_PLAIN, true).find("questionable") !=
+ std::string::npos)
{
mprf( MSGCH_WARN, "Program bug detected!" );
mprf( MSGCH_WARN,
"Buggy monster detected: monster #%d; position (%d,%d)",
- i, monster->x, monster->y );
+ i, monster.x, monster.y );
}
}
}
@@ -1683,9 +1681,7 @@ static std::string fsim_time_string()
static void fsim_mon_stats(FILE *o, const monsters &mon)
{
- char buf[ITEMNAME_SIZE];
- fprintf(o, "Monster : %s\n",
- moname(mon.type, true, DESC_PLAIN, buf));
+ fprintf(o, "Monster : %s\n", str_monam(mon, DESC_PLAIN, true).c_str());
fprintf(o, "HD : %d\n", mon.hit_dice);
fprintf(o, "AC : %d\n", mon.ac);
fprintf(o, "EV : %d\n", mon.ev);
@@ -1693,12 +1689,11 @@ static void fsim_mon_stats(FILE *o, const monsters &mon)
static void fsim_title(FILE *o, int mon, int ms)
{
- char buf[ITEMNAME_SIZE];
fprintf(o, CRAWL " version " VERSION "\n\n");
fprintf(o, "Combat simulation: %s %s vs. %s (%ld rounds) (%s)\n",
species_name(you.species, you.experience_level),
you.class_name,
- moname(menv[mon].type, true, DESC_PLAIN, buf),
+ str_monam(menv[mon], DESC_PLAIN, true).c_str(),
Options.fsim_rounds,
fsim_time_string().c_str());
fprintf(o, "Experience: %d\n", you.experience_level);
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index 7f155e9c96..45ccbcd05f 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -934,10 +934,11 @@ inline static void monster_warning(activity_interrupt_type ai,
{
const monsters* mon = static_cast<const monsters*>(at.data);
#ifndef DEBUG_DIAGNOSTICS
- mprf(MSGCH_WARN, "%s comes into view.", ptr_monam(mon, DESC_CAP_A));
+ mprf(MSGCH_WARN, "%s comes into view.",
+ str_monam(*mon, DESC_CAP_A).c_str());
#else
formatted_string fs( channel_to_colour(MSGCH_WARN) );
- fs.cprintf("%s (", ptr_monam(mon, DESC_PLAIN));
+ fs.cprintf("%s (", str_monam(*mon, DESC_PLAIN, true).c_str());
fs.add_glyph( mon );
fs.cprintf(") in view: (%d,%d), see_grid: %s",
mon->x, mon->y,
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index f29688e730..2d324c5853 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -4592,7 +4592,7 @@ void describe_monsters(monsters& mons)
{
std::ostringstream description;
- description << ptr_monam( &mons, DESC_CAP_A ) << "$$";
+ description << str_monam( mons, DESC_CAP_A ) << "$$";
// Note: Nearly all of the "long" descriptions have moved to
// mon-data.h, in an effort to give them some locality with the
@@ -4609,7 +4609,7 @@ void describe_monsters(monsters& mons)
// than what we have today.
//
// -peterb 4/14/07
- description << getLongDescription(ptr_monam(&mons, DESC_PLAIN));
+ description << getLongDescription(str_monam(mons, DESC_PLAIN));
// Now that the player has examined it, he knows it's a mimic.
if (mons_is_mimic(mons.type))
diff --git a/crawl-ref/source/direct.cc b/crawl-ref/source/direct.cc
index d851b4d504..77d3a80d16 100644
--- a/crawl-ref/source/direct.cc
+++ b/crawl-ref/source/direct.cc
@@ -1497,7 +1497,7 @@ static void describe_cell(int mx, int my)
const int mon_wep = menv[i].inv[MSLOT_WEAPON];
const int mon_arm = menv[i].inv[MSLOT_ARMOUR];
- mprf("%s. ('v' to describe)", ptr_monam(&(menv[i]), DESC_CAP_A));
+ mprf("%s. ('v' to describe)", str_monam(menv[i], DESC_CAP_A).c_str());
if (menv[i].type != MONS_DANCING_WEAPON && mon_wep != NON_ITEM)
{
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index b590650b36..99b621df93 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -2213,8 +2213,6 @@ static void fill_monster_pit( spec_room &sr,
#if DEBUG_DIAGNOSTICS
for (i = 0; i < num_types; i++)
{
- char buff[ ITEMNAME_SIZE ];
-
const int delta = ((i > 0) ? pit_list[i].rare - pit_list[i - 1].rare
: pit_list[i].rare);
@@ -2222,7 +2220,7 @@ static void fill_monster_pit( spec_room &sr,
/ static_cast<float>( rare_sum );
mprf( MSGCH_DIAGNOSTICS, "%6.2f%%: %s", perc,
- moname( pit_list[i].type, true, DESC_PLAIN, buff ) );
+ mons_type_name( pit_list[i].type, DESC_PLAIN).c_str() );
}
#endif
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index d3ec6e3725..79f1946632 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -849,12 +849,11 @@ void melee_attack::player_announce_hit()
if (!verb_degree.empty() && verb_degree[0] != ' ')
verb_degree = " " + verb_degree;
- mprf("You %s %s%s%s%s",
- attack_verb.c_str(),
- ptr_monam(def, DESC_NOCAP_THE),
- verb_degree.c_str(),
- debug_damage_number().c_str(),
- attack_strength_punctuation().c_str());
+ msg::stream << "You " << attack_verb << ' '
+ << str_monam(*def, DESC_NOCAP_THE)
+ << verb_degree << debug_damage_number()
+ << attack_strength_punctuation()
+ << std::endl;
}
std::string melee_attack::player_why_missed()
@@ -873,9 +872,8 @@ void melee_attack::player_warn_miss()
if (def->behaviour != BEH_SLEEP)
behaviour_event( def, ME_WHACK, MHITYOU );
- mprf("%s%s.",
- player_why_missed().c_str(),
- ptr_monam(def, DESC_NOCAP_THE));
+ msg::stream << player_why_missed() << str_monam(*def, DESC_NOCAP_THE)
+ << std::endl;
}
bool melee_attack::player_hits_monster()
@@ -1999,9 +1997,8 @@ bool melee_attack::player_check_monster_died()
player_monattk_hit_effects(true);
if (def->type == MONS_GIANT_SPORE || def->type == MONS_BALL_LIGHTNING)
- mprf("You %s %s.", attack_verb.c_str(),
- ptr_monam(def, DESC_NOCAP_THE));
-
+ msg::stream << "You " << attack_verb << ' '
+ << str_monam(*def, DESC_NOCAP_THE) << '.' << std::endl;
monster_die(def, KILL_YOU, 0);
return (true);
@@ -3378,29 +3375,29 @@ static void stab_message( struct monsters *defender, int stab_bonus )
if (r<3)
{
mprf( "You strike %s from a blind spot!",
- ptr_monam(defender, DESC_NOCAP_THE) );
+ str_monam(*defender, DESC_NOCAP_THE).c_str() );
}
else
{
mprf( "You catch %s momentarily off-guard.",
- ptr_monam(defender, DESC_NOCAP_THE) );
+ str_monam(*defender, DESC_NOCAP_THE).c_str() );
}
break;
case 2: // confused/fleeing
if (r<4)
{
mprf( "You catch %s completely off-guard!",
- ptr_monam(defender, DESC_NOCAP_THE) );
+ str_monam(*defender, DESC_NOCAP_THE).c_str() );
}
else
{
mprf( "You strike %s from behind!",
- ptr_monam(defender, DESC_NOCAP_THE) );
+ str_monam(*defender, DESC_NOCAP_THE).c_str() );
}
break;
case 1:
mprf( "%s fails to defend %s.",
- ptr_monam(defender, DESC_CAP_THE),
+ str_monam(*defender, DESC_CAP_THE).c_str(),
mons_pronoun( defender->type, PRONOUN_REFLEXIVE ) );
break;
} // end switch
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index 8993b67efb..21dfb30a40 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -882,7 +882,7 @@ static void grab_followers(std::vector<follower>& followers)
continue;
#if DEBUG_DIAGNOSTICS
- mprf( "%s is following.", ptr_monam( fmenv, DESC_CAP_THE ) );
+ mprf( "%s is following.", str_monam(*fmenv, DESC_CAP_THE).c_str());
#endif
follower f(*fmenv);
diff --git a/crawl-ref/source/hiscores.cc b/crawl-ref/source/hiscores.cc
index ca0136afcb..6def50115d 100644
--- a/crawl-ref/source/hiscores.cc
+++ b/crawl-ref/source/hiscores.cc
@@ -768,7 +768,7 @@ void scorefile_entry::set_score_fields() const
fields->add_field("sc", "%ld", points);
fields->add_field("ktyp", ::kill_method_name(kill_method_type(death_type)));
- fields->add_field("killer", death_source_desc());
+ fields->add_field("killer", death_source_desc().c_str());
fields->add_field("kaux", "%s", auxkilldata.c_str());
@@ -945,8 +945,6 @@ void scorefile_entry::init_death_cause(int dam, int dsrc,
// but now we pass it in as a string through the scorefile
// entry to be appended in hiscores_format_single in long or
// medium scorefile formats.
- // It still isn't used in monam for anything but flying weapons
- // though
if (death_type == KILLED_BY_MONSTER
&& monster->inv[MSLOT_WEAPON] != NON_ITEM)
{
@@ -977,9 +975,7 @@ void scorefile_entry::init_death_cause(int dam, int dsrc,
auxkilldata = mitm[monster->inv[MSLOT_WEAPON]].name(DESC_NOCAP_A);
}
- death_source_name =
- monam( monster, monster->number, monster->type, true,
- DESC_NOCAP_A, monster->inv[MSLOT_WEAPON] );
+ death_source_name = str_monam(*monster, DESC_NOCAP_A, true);
}
}
else
@@ -1196,14 +1192,14 @@ const char *scorefile_entry::damage_verb() const
"Annihilated";
}
-const char *scorefile_entry::death_source_desc() const
+std::string scorefile_entry::death_source_desc() const
{
if (death_type != KILLED_BY_MONSTER && death_type != KILLED_BY_BEAM)
return ("");
+ // XXX no longer handles mons_num correctly! FIXME
return (!death_source_name.empty()?
- death_source_name.c_str()
- : monam( NULL, mon_num, death_source, true, DESC_NOCAP_A ) );
+ death_source_name : mons_type_name(death_source, DESC_NOCAP_A));
}
std::string scorefile_entry::damage_string(bool terse) const
@@ -1498,14 +1494,12 @@ scorefile_entry::death_description(death_desc_verbosity verbosity) const
if (terse)
desc += death_source_desc();
else if (oneline)
- desc += std::string("slain by ") + death_source_desc();
+ desc += "slain by " + death_source_desc();
else
{
- snprintf( scratch, sizeof scratch, "%s by %s",
- damage_verb(),
- death_source_desc() );
-
- desc += scratch;
+ desc += damage_verb();
+ desc += " by ";
+ desc += death_source_desc();
}
// put the damage on the weapon line if there is one
diff --git a/crawl-ref/source/hiscores.h b/crawl-ref/source/hiscores.h
index 88fac529d0..a586d5233c 100644
--- a/crawl-ref/source/hiscores.h
+++ b/crawl-ref/source/hiscores.h
@@ -165,7 +165,7 @@ private:
std::string terse_wild_magic() const;
std::string terse_trap() const;
const char *damage_verb() const;
- const char *death_source_desc() const;
+ std::string death_source_desc() const;
std::string damage_string(bool terse = false) const;
bool parse_obsolete_scoreline(const std::string &line);
diff --git a/crawl-ref/source/insult.cc b/crawl-ref/source/insult.cc
index f2fec225d3..7e721bd540 100644
--- a/crawl-ref/source/insult.cc
+++ b/crawl-ref/source/insult.cc
@@ -41,7 +41,7 @@ void init_cap(char * str)
void imp_taunt( const monsters *mons )
{
char buff[80];
- const char *mon_name = ptr_monam( mons, DESC_CAP_THE );
+ const std::string mon_name = str_monam( *mons, DESC_CAP_THE );
snprintf( buff, sizeof(buff),
"%s, thou %s!",
@@ -51,14 +51,14 @@ void imp_taunt( const monsters *mons )
init_cap( buff );
// XXX: Not pretty, but stops truncation...
- if (strlen( mon_name ) + 11 + strlen( buff ) >= 79)
+ if (mon_name.length() + 11 + strlen( buff ) >= 79)
{
- mprf(MSGCH_TALK, "%s shouts:", mon_name );
+ mprf(MSGCH_TALK, "%s shouts:", mon_name.c_str() );
mprf(MSGCH_TALK, "%s", buff );
}
else
{
- mprf(MSGCH_TALK, "%s shouts, \"%s\"", mon_name, buff );
+ mprf(MSGCH_TALK, "%s shouts, \"%s\"", mon_name.c_str(), buff );
}
}
@@ -82,7 +82,7 @@ void demon_taunt( const monsters *mons )
};
char buff[80];
- const char *mon_name = ptr_monam( mons, DESC_CAP_THE );
+ const std::string mon_name = str_monam( *mons, DESC_CAP_THE );
const char *voice = sound_list[ mons_shouts(mons->type) ];
if (coinflip())
@@ -127,14 +127,14 @@ void demon_taunt( const monsters *mons )
init_cap( buff );
// XXX: Not pretty, but stops truncation...
- if (strlen(mon_name) + strlen(voice) + strlen(buff) + 5 >= 79)
+ if (mon_name.length() + strlen(voice) + strlen(buff) + 5 >= 79)
{
- mprf(MSGCH_TALK, "%s %s:", mon_name, voice );
+ mprf(MSGCH_TALK, "%s %s:", mon_name.c_str(), voice );
mprf(MSGCH_TALK, "%s", buff);
}
else
{
- mprf(MSGCH_TALK, "%s %s, \"%s\"", mon_name, voice, buff );
+ mprf(MSGCH_TALK, "%s %s, \"%s\"", mon_name.c_str(), voice, buff );
}
}
diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc
index 991f38998d..27368ee5e1 100644
--- a/crawl-ref/source/it_use3.cc
+++ b/crawl-ref/source/it_use3.cc
@@ -70,7 +70,7 @@ void special_wielded()
case SPWLD_SING:
if (makes_noise)
{
- const char* suffixes[32] = {
+ const char* suffixes[] = {
"hums a little tune.", "breaks into glorious song!",
"sings.", "sings loudly.", "chimes melodiously.",
"makes a horrible noise.", "sings off-key.",
@@ -84,8 +84,11 @@ void special_wielded()
"makes a popping sound.", "sings a sudden staccato note.",
"says 'Hi! I'm the Singing Sword!'.", "whispers something.",
"speaks gibberish.", "raves incoherently",
- "yells in some weird language." };
- mprf("The Singing Sword %s", suffixes[random2(32)]);
+ "yells in some weird language."
+ };
+ const int num_suffixes = sizeof(suffixes) / sizeof(suffixes[0]);
+ msg::stream << "The Singing Sword "
+ << suffixes[random2(num_suffixes)] << std::endl;
}
break;
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index 0464cdb998..63ee563734 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -1216,11 +1216,7 @@ std::string item_def::name_aux( bool terse, bool ident ) const
if (this->quantity > 1)
buff << "s";
- buff << " of ";
-
- char tmp_buff[ITEMNAME_SIZE];
- moname( it_plus, true, DESC_PLAIN, tmp_buff );
- buff << tmp_buff << " flesh";
+ buff << " of " << mons_type_name(it_plus, DESC_PLAIN) << " flesh";
break;
}
}
@@ -1395,11 +1391,11 @@ std::string item_def::name_aux( bool terse, bool ident ) const
case OBJ_CORPSES:
if (item_typ == CORPSE_BODY && this->special < 100)
+ {
buff << "rotting ";
+ }
{
- char tmp_buff[ITEMNAME_SIZE];
- moname( it_plus, true, DESC_PLAIN, tmp_buff );
- buff << tmp_buff << " ";
+ buff << mons_type_name(it_plus, DESC_PLAIN) << ' ';
if (item_typ == CORPSE_BODY)
buff << "corpse";
else if (item_typ == CORPSE_SKELETON)
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index be498dfb6d..cdaf9f4d97 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -1020,9 +1020,7 @@ static std::string origin_monster_name(const item_def &item)
return ("a player ghost");
else if (monnum == MONS_PANDEMONIUM_DEMON)
return ("a demon");
- char monnamebuf[ITEMNAME_SIZE]; // Le sigh.
- moname(monnum, true, DESC_NOCAP_A, monnamebuf);
- return (monnamebuf);
+ return mons_type_name(monnum, DESC_NOCAP_A);
}
static std::string origin_monster_desc(const item_def &item)
diff --git a/crawl-ref/source/message.h b/crawl-ref/source/message.h
index a5e3385bc3..5be11ce82f 100644
--- a/crawl-ref/source/message.h
+++ b/crawl-ref/source/message.h
@@ -16,6 +16,7 @@
#include <string>
#include <streambuf>
+#include <iostream>
#include "externs.h"
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index c99dd1dfb5..45954cee16 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -1898,9 +1898,9 @@ bool i_feel_safe(bool announce)
// Announce the presence of monsters (Eidolos).
if (mons.size() == 1)
{
- const monsters *m = mons[0];
+ const monsters &m = *mons[0];
mprf(MSGCH_WARN, "Not with %s in view!",
- ptr_monam(m, DESC_NOCAP_A));
+ str_monam(m, DESC_NOCAP_A).c_str());
}
else if (mons.size() > 1)
{
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index a3c6361caf..c85b104f2e 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -190,8 +190,7 @@ void init_monsters(FixedVector < unsigned short, 1000 > &colour)
//unsigned int x = 0; // must be unsigned to match size_t {dlb}
// first, fill static array with dummy values {dlb};
- for (x = 0; x < NUM_MONSTERS; x++)
- mon_entry[x] = -1;
+ mon_entry.init(-1);
// next, fill static array with location of entry in mondata[] {dlb}:
for (x = 0; x < MONDATASIZE; x++)
@@ -1362,103 +1361,81 @@ void define_monster(int index)
mons.enchantments.clear();
} // end define_monster()
-std::string str_monam(const monsters *mon, description_level_type desc,
+std::string str_monam(const monsters& mon, description_level_type desc,
bool force_seen)
{
- return (ptr_monam(mon, desc, force_seen));
-}
+ // Handle non-visible case first
+ if ( !force_seen && !player_monster_visible(&mon) )
+ {
+ switch (desc)
+ {
+ case DESC_CAP_THE: case DESC_CAP_A:
+ return "It";
+ case DESC_NOCAP_THE: case DESC_NOCAP_A: case DESC_PLAIN:
+ return "it";
+ default:
+ mpr("XXX OOPS!", MSGCH_DIAGNOSTICS);
+ return "it (buggy)";
+ }
+ }
-/* ------------------------- monam/moname ------------------------- */
-const char *ptr_monam( const monsters *mon, description_level_type desc,
- bool force_seen )
-{
- // We give an item type description for mimics now, note that
- // since gold mimics only have one description (to match the
- // examine code in direct.cc), we won't bother going through
- // this for them. -- bwr
- if (mons_is_mimic( mon->type ) && mon->type != MONS_GOLD_MIMIC)
- {
- // XXX Ugly hack - FIXME XXX
- static char mimic_name_buff[ ITEMNAME_SIZE ];
+ // Assumed visible from now on
+ // Various special cases:
+ // non-gold mimics, dancing weapons, ghosts, Pan demons
+ if ( mons_is_mimic(mon.type) && mon.type != MONS_GOLD_MIMIC )
+ {
item_def item;
- get_mimic_item( mon, item );
- strncpy(mimic_name_buff, item.name(desc).c_str(),
- sizeof mimic_name_buff);
+ get_mimic_item( &mon, item );
+ return item.name(desc);
+ }
- return (mimic_name_buff);
+ if (mon.type == MONS_DANCING_WEAPON && mon.inv[MSLOT_WEAPON] != NON_ITEM)
+ {
+ item_def item = mitm[mon.inv[MSLOT_WEAPON]];
+ unset_ident_flags( item, ISFLAG_KNOW_CURSE | ISFLAG_KNOW_PLUSES );
+ return item.name(desc);
}
- return (monam( mon, mon->number, mon->type,
- force_seen || player_monster_visible( mon ),
- desc, mon->inv[MSLOT_WEAPON] ));
-}
+ if (mon.type == MONS_PLAYER_GHOST)
+ return mon.ghost->name + "'s ghost";
-const char *monam( const monsters *mon,
- int mons_num, int mons, bool vis,
- description_level_type desc, int mons_wpn )
-{
- static char gmo_n[ ITEMNAME_SIZE ];
- char gmo_n2[ ITEMNAME_SIZE ] = "";
+ if (mon.type == MONS_PANDEMONIUM_DEMON)
+ return mon.ghost->name;
- gmo_n[0] = 0;
+ std::string result;
- // If you can't see the critter, let moname() print [Ii]t.
- if (!vis)
- {
- moname( mons, vis, desc, gmo_n );
- return (gmo_n);
- }
+ // Start building the name string.
- // These need their description level handled here instead of
- // in monam().
- if (mons == MONS_SPECTRAL_THING || mons_genus(mons) == MONS_DRACONIAN)
+ // Start with the prefix.
+ // (Uniques don't get this, because their names are proper nouns.)
+ if ( !mons_is_unique(mon.type) )
{
switch (desc)
{
- case DESC_CAP_THE:
- strcpy(gmo_n, "The");
- break;
- case DESC_NOCAP_THE:
- strcpy(gmo_n, "the");
- break;
- case DESC_CAP_A:
- strcpy(gmo_n, "A");
- break;
- case DESC_NOCAP_A:
- strcpy(gmo_n, "a");
- break;
- case DESC_PLAIN: /* do nothing */ ;
- default:
- break;
- //default: DEBUGSTR("bad desc flag");
+ case DESC_CAP_THE: result = "The "; break;
+ case DESC_NOCAP_THE: result = "the "; break;
+ case DESC_CAP_A: result = "A "; break;
+ case DESC_NOCAP_A: result = "a "; break;
+ case DESC_PLAIN: default: break;
}
}
- switch (mons)
- {
- case MONS_ZOMBIE_SMALL:
- case MONS_ZOMBIE_LARGE:
- moname(mons_num, vis, desc, gmo_n);
- strcat(gmo_n, " zombie");
- break;
-
- case MONS_SKELETON_SMALL:
- case MONS_SKELETON_LARGE:
- moname(mons_num, vis, desc, gmo_n);
- strcat(gmo_n, " skeleton");
- break;
+ // Some monsters might want the name of a different creature.
+ int nametype = mon.type;
- case MONS_SIMULACRUM_SMALL:
- case MONS_SIMULACRUM_LARGE:
- moname(mons_num, vis, desc, gmo_n);
- strcat(gmo_n, " simulacrum");
+ // Tack on other prefixes.
+ switch (mon.type)
+ {
+ case MONS_SPECTRAL_THING:
+ result += "spectral ";
+ nametype = mon.number;
break;
- case MONS_SPECTRAL_THING:
- strcat(gmo_n, " spectral ");
- moname(mons_num, vis, DESC_PLAIN, gmo_n2);
- strcat(gmo_n, gmo_n2);
+ case MONS_ZOMBIE_SMALL: case MONS_ZOMBIE_LARGE:
+ case MONS_SKELETON_SMALL: case MONS_SKELETON_LARGE:
+ case MONS_SIMULACRUM_SMALL: case MONS_SIMULACRUM_LARGE:
+ nametype = mon.number;
break;
case MONS_DRACONIAN_CALLER:
@@ -1468,153 +1445,82 @@ const char *monam( const monsters *mon,
case MONS_DRACONIAN_ANNIHILATOR:
case MONS_DRACONIAN_KNIGHT:
case MONS_DRACONIAN_SCORCHER:
- if (desc != DESC_PLAIN)
- strcat( gmo_n, " " );
-
- switch (mons_num)
+ switch (mon.number)
{
default: break;
- case MONS_BLACK_DRACONIAN: strcat(gmo_n, "black "); break;
- case MONS_MOTTLED_DRACONIAN: strcat(gmo_n, "mottled "); break;
- case MONS_YELLOW_DRACONIAN: strcat(gmo_n, "yellow "); break;
- case MONS_GREEN_DRACONIAN: strcat(gmo_n, "green "); break;
- case MONS_PURPLE_DRACONIAN: strcat(gmo_n, "purple "); break;
- case MONS_RED_DRACONIAN: strcat(gmo_n, "red "); break;
- case MONS_WHITE_DRACONIAN: strcat(gmo_n, "white "); break;
- case MONS_PALE_DRACONIAN: strcat(gmo_n, "pale "); break;
- }
-
- moname( mons, vis, DESC_PLAIN, gmo_n2 );
- strcat( gmo_n, gmo_n2 );
- break;
-
- case MONS_DANCING_WEAPON:
- // safety check -- if we don't have/know the weapon use default name
- if (mons_wpn == NON_ITEM)
- moname( mons, vis, desc, gmo_n );
- else
- {
- item_def item = mitm[mons_wpn];
- unset_ident_flags( item, ISFLAG_KNOW_CURSE | ISFLAG_KNOW_PLUSES );
- strncpy( gmo_n, item.name(desc).c_str(), sizeof gmo_n );
+ case MONS_BLACK_DRACONIAN: result += "black "; break;
+ case MONS_MOTTLED_DRACONIAN: result += "mottled "; break;
+ case MONS_YELLOW_DRACONIAN: result += "yellow "; break;
+ case MONS_GREEN_DRACONIAN: result += "green "; break;
+ case MONS_PURPLE_DRACONIAN: result += "purple "; break;
+ case MONS_RED_DRACONIAN: result += "red "; break;
+ case MONS_WHITE_DRACONIAN: result += "white "; break;
+ case MONS_PALE_DRACONIAN: result += "pale "; break;
}
break;
-
- case MONS_PLAYER_GHOST:
- strcpy(gmo_n, mon->ghost->name.c_str());
- strcat(gmo_n, "'s ghost");
- break;
-
- case MONS_PANDEMONIUM_DEMON:
- strcpy(gmo_n, mon->ghost->name.c_str());
- break;
-
- default:
- moname(mons, vis, desc, gmo_n);
- break;
}
- return (gmo_n);
-} // end monam()
-
-const char *moname(int mons_num, bool vis, description_level_type descrip,
- char glog[ ITEMNAME_SIZE ])
-{
- glog[0] = 0;
+ // Add the base name.
+ result += seekmonster(nametype)->name;
- char gmon_name[ ITEMNAME_SIZE ] = "";
- strcpy( gmon_name, seekmonster( mons_num )->name );
-
- if (!vis)
+ // Add suffixes.
+ switch (mon.type)
{
- switch (descrip)
- {
- case DESC_CAP_THE:
- case DESC_CAP_A:
- strcpy(glog, "It");
- break;
- case DESC_NOCAP_THE:
- case DESC_NOCAP_A:
- case DESC_PLAIN:
- strcpy(glog, "it");
- break;
- case DESC_NOCAP_YOUR:
- strcpy(glog, "its");
- break;
- case DESC_CAP_YOUR:
- strcpy(glog, "Its");
- break;
- default:
- strcpy(glog, "Its buggy");
- }
-
- strcpy(gmon_name, glog);
- return (glog);
+ case MONS_ZOMBIE_SMALL: case MONS_ZOMBIE_LARGE:
+ result += " zombie"; break;
+ case MONS_SKELETON_SMALL: case MONS_SKELETON_LARGE:
+ result += " skeleton"; break;
+ case MONS_SIMULACRUM_SMALL: case MONS_SIMULACRUM_LARGE:
+ result += " simulacrum"; break;
}
- if (!mons_is_unique( mons_num ))
+ // Vowel fix: Change 'a orc' to 'an orc'
+ if ( result.length() >= 3 &&
+ (result[0] == 'a' || result[0] == 'A') &&
+ isblank(result[1]) &&
+ is_vowel(result[2]) )
{
- switch (descrip)
- {
- case DESC_CAP_THE:
- case DESC_CAP_YOUR:
- strcpy(glog, "The ");
- break;
- case DESC_NOCAP_THE:
- case DESC_NOCAP_YOUR:
- strcpy(glog, "the ");
- break;
- case DESC_CAP_A:
- strcpy(glog, "A");
- break;
- case DESC_NOCAP_A:
- strcpy(glog, "a");
- break;
- case DESC_PLAIN:
- default:
- break;
- // default: DEBUGSTR("bad monster descrip flag");
- }
+ result.insert(1, "n");
+ }
- if (descrip == DESC_CAP_A || descrip == DESC_NOCAP_A)
- {
- switch (toupper(gmon_name[0]))
- {
- case 'A':
- case 'E':
- case 'I':
- case 'O':
- case 'U':
- strcat(glog, "n ");
- break;
+ // All done.
+ return result;
+}
- default:
- strcat(glog, " ");
- break;
- }
+std::string mons_type_name(int type, description_level_type desc )
+{
+ std::string result;
+ if ( !mons_is_unique(type) )
+ {
+ switch (desc)
+ {
+ case DESC_CAP_THE: result = "The "; break;
+ case DESC_NOCAP_THE: result = "the "; break;
+ case DESC_CAP_A: result = "A "; break;
+ case DESC_NOCAP_A: result = "a "; break;
+ case DESC_PLAIN: default: break;
}
}
- strcat(glog, gmon_name);
+ result += seekmonster(type)->name;
- if ((descrip == DESC_CAP_YOUR || descrip == DESC_NOCAP_YOUR) && *glog)
+ // Vowel fix: Change 'a orc' to 'an orc'
+ if ( result.length() >= 3 &&
+ (result[0] == 'a' || result[0] == 'A') &&
+ isblank(result[1]) &&
+ is_vowel(result[2]) )
{
- const int lastch = glog[ strlen(glog) - 1 ];
- if (lastch == 's' || lastch == 'x')
- strcat(glog, "'");
- else
- strcat(glog, "'s");
+ result.insert(1, "n");
}
-
- return (glog);
-} // end moname()
+ return result;
+}
/* ********************* END PUBLIC FUNCTIONS ********************* */
// see mons_init for initialization of mon_entry array.
static monsterentry *seekmonster(int p_monsterid)
{
- int me = p_monsterid != -1? mon_entry[p_monsterid] : -1;
+ const int me = p_monsterid != -1? mon_entry[p_monsterid] : -1;
if (me >= 0) // PARANOIA
return (&mondata[me]);
@@ -2415,7 +2321,7 @@ std::string monsters::name(description_level_type desc) const
if (possessive)
desc = DESC_NOCAP_THE;
- std::string mname = ptr_monam(this, desc);
+ std::string mname = str_monam(*this, desc);
return (possessive? apostrophise(mname) : mname);
}
diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h
index a66fa48580..82dfa1b68f 100644
--- a/crawl-ref/source/mon-util.h
+++ b/crawl-ref/source/mon-util.h
@@ -121,22 +121,12 @@ struct monsterentry
* *********************************************************************** */
void init_monsters( FixedVector<unsigned short, 1000>& colour );
-// last updated 12may2000 {dlb}
-/* ***********************************************************************
- * called from: bang - beam - debug - direct - effects - fight - item_use -
- * monstuff - mstuff2 - ouch - spells1 - spells2 - spells3 -
- * spells4
- * *********************************************************************** */
-// mons_wpn only important for dancing weapons -- bwr
-const char *monam(const monsters *mon,
- int mons_num, int mons, bool vis,
- description_level_type desc, int mons_wpn = NON_ITEM);
-
-// these front for monam
-const char *ptr_monam(const monsters *mon, description_level_type desc,
- bool force_seen = false);
-std::string str_monam(const monsters *mon, description_level_type desc,
+// this is the old monam(), ptr_monam()
+std::string str_monam(const monsters& mon, description_level_type desc,
bool force_seen = false);
+
+// this is the old moname()
+std::string mons_type_name(int type, description_level_type desc );
// last updated 12may2000 {dlb}
/* ***********************************************************************
@@ -345,14 +335,6 @@ void mons_load_spells( monsters *mon, int book );
void define_monster(int mid);
-// last updated 12may2000 {dlb}
-/* ***********************************************************************
- * called from: debug - itemname - mon-util
- * *********************************************************************** */
-const char *moname(int mcl, bool vis, description_level_type descrip,
- char glog[ ITEMNAME_SIZE ]);
-
-
#ifdef DEBUG_DIAGNOSTICS
// last updated 25sep2001 {dlb}
/* ***********************************************************************
diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc
index acc68c4ebb..41c23abd48 100644
--- a/crawl-ref/source/monplace.cc
+++ b/crawl-ref/source/monplace.cc
@@ -402,7 +402,7 @@ bool place_monster(int &id, int mon_type, int power, char behaviour,
std::string msg;
if (player_monster_visible( &menv[id] ))
- msg = ptr_monam( &menv[id], DESC_CAP_A );
+ msg = str_monam( menv[id], DESC_CAP_A );
else if (shoved)
msg = "Something";
@@ -1178,14 +1178,12 @@ void mark_interesting_monst(struct monsters* monster, char behaviour)
interesting = false;
// Don't waste time on moname() if user isn't using this option
else if ( Options.note_monsters.size() > 0 )
- {
- char namebuf[ITEMNAME_SIZE];
- moname(monster->type, true, DESC_NOCAP_A, namebuf);
-
- std::string iname = namebuf;
-
- for (unsigned i = 0; i < Options.note_monsters.size(); ++i) {
- if (Options.note_monsters[i].matches(iname)) {
+ {
+ const std::string iname = mons_type_name(monster->type, DESC_NOCAP_A);
+ for (unsigned i = 0; i < Options.note_monsters.size(); ++i)
+ {
+ if (Options.note_monsters[i].matches(iname))
+ {
interesting = true;
break;
}
@@ -1346,7 +1344,7 @@ bool player_angers_monster(monsters *creation)
&& player_monster_visible(creation) )
{
mprf("%s is enraged by your holy aura!",
- ptr_monam(creation, DESC_CAP_THE));
+ str_monam(*creation, DESC_CAP_THE).c_str());
}
}
return (true);
diff --git a/crawl-ref/source/monspeak.cc b/crawl-ref/source/monspeak.cc
index 948061e48e..8459ff91e7 100644
--- a/crawl-ref/source/monspeak.cc
+++ b/crawl-ref/source/monspeak.cc
@@ -154,10 +154,10 @@ bool mons_speaks(const monsters *monster)
// scare the player. In order to accomidate this intent, we're
// falsely categorizing various things in the function as spells and
// danger warning... everything else just goes into the talk channel -- bwr
- int msg_type = MSGCH_TALK;
+ msg_channel_type msg_type = MSGCH_TALK;
- const char *m_name = ptr_monam(monster, DESC_CAP_THE);
- strcpy(info, m_name);
+ const std::string m_name = str_monam(*monster, DESC_CAP_THE);
+ strcpy(info, m_name.c_str());
if (monster->has_ench(ENCH_INVIS))
return false;
@@ -386,8 +386,8 @@ bool mons_speaks(const monsters *monster)
switch (random2(11))
{
case 0:
- snprintf( info, INFO_SIZE, "%s %s, \"WAIT FOR ME!\"", m_name,
- coinflip() ? "shouts" : "yells");
+ snprintf( info, INFO_SIZE, "%s %s, \"WAIT FOR ME!\"",
+ m_name.c_str(), coinflip() ? "shouts" : "yells");
strcat(info, you.your_name);
strcat(info, ", could you help me?\"");
break;
@@ -426,28 +426,29 @@ bool mons_speaks(const monsters *monster)
switch (random2(20)) // speaks for unfriendly fleeing monsters
{
case 0:
- snprintf( info, INFO_SIZE, "%s %s, \"Help!\"", m_name, coinflip()? "yells" : "wails");
+ snprintf( info, INFO_SIZE, "%s %s, \"Help!\"", m_name.c_str(),
+ coinflip()? "yells" : "wails");
break;
case 1:
- snprintf( info, INFO_SIZE, "%s %s, \"Help!\"", m_name,
+ snprintf( info, INFO_SIZE, "%s %s, \"Help!\"", m_name.c_str(),
coinflip() ? "cries" : "screams"); break;
case 2:
snprintf( info, INFO_SIZE, "%s %s, \"Why can't we all just get along?\"",
- m_name, coinflip() ? "begs" : "pleads");
+ m_name.c_str(), coinflip() ? "begs" : "pleads");
break;
case 3:
- snprintf( info, INFO_SIZE, "%s %s trips in trying to escape.", m_name,
+ snprintf( info, INFO_SIZE, "%s %s trips in trying to escape.", m_name.c_str(),
coinflip() ? "nearly" : "almost");
break;
case 4:
- snprintf( info, INFO_SIZE, "%s %s, \"Of all the rotten luck!\"", m_name,
+ snprintf( info, INFO_SIZE, "%s %s, \"Of all the rotten luck!\"", m_name.c_str(),
coinflip() ? "mutters" : "mumbles");
break;
case 5:
- snprintf( info, INFO_SIZE, "%s %s, \"Oh dear! Oh dear!\"", m_name,
+ snprintf( info, INFO_SIZE, "%s %s, \"Oh dear! Oh dear!\"", m_name.c_str(),
coinflip() ? "moans" : "wails");
case 6:
- snprintf( info, INFO_SIZE, "%s %s, \"Damn and blast!\"", m_name,
+ snprintf( info, INFO_SIZE, "%s %s, \"Damn and blast!\"", m_name.c_str(),
coinflip() ? "mutters" : "mumbles");
break;
case 7:
@@ -457,25 +458,25 @@ bool mons_speaks(const monsters *monster)
strcat(info, " shouts, \"No! I'll never do that again!\"");
break;
case 9:
- snprintf( info, INFO_SIZE, "%s %s", m_name,
+ snprintf( info, INFO_SIZE, "%s %s", m_name.c_str(),
coinflip() ? "begs for mercy." : "cries, \"Mercy!\"");
break;
case 10:
- snprintf( info, INFO_SIZE, "%s %s, \"%s!\"", m_name,
+ snprintf( info, INFO_SIZE, "%s %s, \"%s!\"", m_name.c_str(),
coinflip() ? "blubbers" : "cries",
coinflip() ? "Mommeee" : "Daddeee");
break;
case 11:
- snprintf( info, INFO_SIZE, "%s %s, \"Please don't kill me!\"", m_name,
+ snprintf( info, INFO_SIZE, "%s %s, \"Please don't kill me!\"", m_name.c_str(),
coinflip() ? "begs" : "pleads");
break;
case 12:
- snprintf( info, INFO_SIZE, "%s %s, \"Please don't hurt me!\"", m_name,
+ snprintf( info, INFO_SIZE, "%s %s, \"Please don't hurt me!\"", m_name.c_str(),
coinflip() ? "begs" : "pleads");
break;
case 13:
snprintf( info, INFO_SIZE, "%s %s, \"Please, I have a lot of children...\"",
- m_name, coinflip() ? "begs" : "pleads");
+ m_name.c_str(), coinflip() ? "begs" : "pleads");
break;
case 14:
strcat(info, " tries to recover lost courage.");
@@ -486,8 +487,9 @@ bool mons_speaks(const monsters *monster)
strcat(info, " gives up.");
break;
case 19:
- snprintf( info, INFO_SIZE, "%s looks really %s.", m_name,
- coinflip() ? "scared stiff" : "rattled");
+ snprintf( info, INFO_SIZE, "%s looks really %s.",
+ m_name.c_str(),
+ coinflip() ? "scared stiff" : "rattled");
break;
}
}
@@ -586,7 +588,7 @@ bool mons_speaks(const monsters *monster)
break;
case 3:
snprintf( info, INFO_SIZE, "%s shouts, \"%s!!!\"",
- m_name, coinflip() ? "ATTACK" : "DIE");
+ m_name.c_str(), coinflip() ? "ATTACK" : "DIE");
break;
case 4:
strcat(info, " says, \"How do you enjoy it?\"");
@@ -608,14 +610,14 @@ bool mons_speaks(const monsters *monster)
break;
case 10:
snprintf( info, INFO_SIZE, "%s says, \"Don't try to defend, it's %s.\"",
- m_name, coinflip() ? "pointless" : "senseless");
+ m_name.c_str(), coinflip() ? "pointless" : "senseless");
break;
case 11:
strcat(info, " bares his teeth.");
break;
case 12:
snprintf( info, INFO_SIZE, "%s says, \"I'll show you few %s.\"",
- m_name, coinflip() ? "tricks" : "ploys.");
+ m_name.c_str(), coinflip() ? "tricks" : "ploys.");
break;
case 13:
strcat(info, " screams, \"I want your blood.\"");
@@ -849,7 +851,7 @@ bool mons_speaks(const monsters *monster)
strcat(info, " casts a spell.");
mpr(info, MSGCH_MONSTER_SPELL);
- strcpy(info, m_name);
+ strcpy(info, m_name.c_str());
strcat(info, " becomes larger for a moment.");
msg_type = MSGCH_MONSTER_ENCHANT;
break;
@@ -858,7 +860,7 @@ bool mons_speaks(const monsters *monster)
strcat(info, " casts a spell.");
mpr(info, MSGCH_MONSTER_SPELL);
- strcpy(info, m_name);
+ strcpy(info, m_name.c_str());
strcat(info, "'s fingertips start to glow.");
msg_type = MSGCH_MONSTER_ENCHANT;
break;
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index ed83678c2a..bedd380d1c 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -395,7 +395,7 @@ void monster_die(monsters *monster, char killer, int i, bool silent)
monster->type == MONS_PANDEMONIUM_DEMON )
{
take_note(Note(NOTE_KILL_MONSTER, monster->type, 0,
- ptr_monam(monster, DESC_NOCAP_A, true)));
+ str_monam(*monster, DESC_NOCAP_A, true).c_str()));
}
}
@@ -520,7 +520,7 @@ void monster_die(monsters *monster, char killer, int i, bool silent)
{
mprf(MSGCH_MONSTER_DAMAGE, MDAM_DEAD, "You %s %s!",
wounded_damaged(monster->type) ? "destroy" : "kill",
- ptr_monam(monster, DESC_NOCAP_THE));
+ str_monam(*monster, DESC_NOCAP_THE).c_str());
}
if (!created_friendly)
@@ -1064,7 +1064,7 @@ bool monster_polymorph( monsters *monster, int targetc, int power )
&& MONST_INTERESTING(monster))
{
take_note(Note(NOTE_POLY_MONSTER, monster->type, 0,
- ptr_monam(monster, DESC_NOCAP_A, true)));
+ str_monam(*monster, DESC_NOCAP_A, true).c_str()));
}
// messaging: {dlb}
@@ -1083,7 +1083,7 @@ bool monster_polymorph( monsters *monster, int targetc, int power )
str_polymon += "something you cannot see!";
else
{
- str_polymon += monam( NULL, 250, targetc, true, DESC_NOCAP_A );
+ str_polymon += mons_type_name(targetc, DESC_NOCAP_A);
if (targetc == MONS_PULSATING_LUMP)
str_polymon += " of flesh";
@@ -1843,13 +1843,13 @@ bool simple_monster_message(const monsters *monster, const char *event,
int channel, int param,
description_level_type descrip)
{
- char buff[INFO_SIZE];
if (mons_near( monster )
&& (channel == MSGCH_MONSTER_SPELL || player_monster_visible(monster)))
{
+ char buff[INFO_SIZE];
snprintf( buff, sizeof(buff), "%s%s",
- ptr_monam(monster, descrip), event );
+ str_monam(*monster, descrip).c_str(), event );
mpr( buff, channel, param );
return (true);
@@ -3937,7 +3937,7 @@ static bool handle_pickup(monsters *monster)
if (monsterNearby)
{
- mprf("%s picks up %s.", ptr_monam(monster, DESC_CAP_THE),
+ mprf("%s picks up %s.", str_monam(*monster, DESC_CAP_THE).c_str(),
mitm[monster->inv[MSLOT_WEAPON]].name(DESC_NOCAP_A).c_str());
}
break;
@@ -3954,7 +3954,8 @@ static bool handle_pickup(monsters *monster)
{
if (monsterNearby)
{
- mprf("%s picks up %s.", ptr_monam(monster, DESC_CAP_THE),
+ mprf("%s picks up %s.",
+ str_monam(*monster, DESC_CAP_THE).c_str(),
mitm[item].name(DESC_NOCAP_A).c_str());
}
@@ -3977,7 +3978,7 @@ static bool handle_pickup(monsters *monster)
if (monsterNearby)
{
- mprf("%s picks up %s.", ptr_monam(monster, DESC_CAP_THE),
+ mprf("%s picks up %s.", str_monam(*monster, DESC_CAP_THE).c_str(),
mitm[item].name(DESC_NOCAP_A).c_str());
}
break;
@@ -3990,7 +3991,7 @@ static bool handle_pickup(monsters *monster)
if (monsterNearby)
{
- mprf("%s picks up %s.", ptr_monam(monster, DESC_CAP_THE),
+ mprf("%s picks up %s.", str_monam(*monster, DESC_CAP_THE).c_str(),
mitm[item].name(DESC_NOCAP_A).c_str());
}
break;
@@ -4003,7 +4004,7 @@ static bool handle_pickup(monsters *monster)
if (monsterNearby)
{
- mprf("%s picks up %s.", ptr_monam(monster, DESC_CAP_THE),
+ mprf("%s picks up %s.", str_monam(*monster, DESC_CAP_THE).c_str(),
mitm[item].name(DESC_NOCAP_A).c_str());
}
break;
@@ -4016,7 +4017,7 @@ static bool handle_pickup(monsters *monster)
if (monsterNearby)
{
- mprf("%s picks up %s.", ptr_monam(monster, DESC_CAP_THE),
+ mprf("%s picks up %s.", str_monam(*monster, DESC_CAP_THE).c_str(),
mitm[item].name(DESC_NOCAP_A).c_str());
}
break;
@@ -4036,7 +4037,7 @@ static bool handle_pickup(monsters *monster)
if (monsterNearby)
{
- mprf("%s eats %s.", ptr_monam(monster, DESC_CAP_THE),
+ mprf("%s eats %s.", str_monam(*monster, DESC_CAP_THE).c_str(),
mitm[item].name(DESC_NOCAP_THE).c_str());
}
@@ -4047,9 +4048,7 @@ static bool handle_pickup(monsters *monster)
if (monsterNearby)
{
mprf("%s picks up some gold.",
- monam( monster, monster->number, monster->type,
- player_monster_visible( monster ),
- DESC_CAP_THE ));
+ str_monam(*monster, DESC_CAP_THE).c_str());
}
if (monster->inv[MSLOT_GOLD] != NON_ITEM)
@@ -4167,10 +4166,9 @@ static bool monster_swaps_places( monsters *mon, int mx, int my )
if (one_chance_in(2))
{
#ifdef DEBUG_DIAGNOSTICS
- char mname[ITEMNAME_SIZE];
- moname(m2->type, true, DESC_PLAIN, mname);
mprf(MSGCH_DIAGNOSTICS,
- "Alerting monster %s at (%d,%d)", mname, m2->x, m2->y);
+ "Alerting monster %s at (%d,%d)",
+ str_monam(*m2, DESC_PLAIN).c_str(), m2->x, m2->y);
#endif
behaviour_event( m2, ME_ALERT, MHITNOT );
}
@@ -4273,7 +4271,7 @@ void mons_check_pool(monsters *mons, int killer)
// see if something has fallen into the lava
if (message)
mprf("%s falls into the %s!",
- ptr_monam(mons, DESC_CAP_THE),
+ str_monam(*mons, DESC_CAP_THE).c_str(),
(grid == DNGN_LAVA ? "lava" : "water"));
if (grid == DNGN_LAVA && mons_res_fire(mons) > 0)
@@ -4781,7 +4779,7 @@ forget_it:
#if DEBUG_DIAGNOSTICS
mprf(MSGCH_DIAGNOSTICS,
"%s is skipping movement in order to follow.",
- ptr_monam( monster, DESC_CAP_THE ) );
+ str_monam( *monster, DESC_CAP_THE ).c_str() );
#endif
mmov_x = 0;
mmov_y = 0;
@@ -5120,7 +5118,7 @@ bool message_current_target()
{
mprf( MSGCH_PROMPT, "Current target: %s "
"(use p/t/f to fire at it again.)",
- ptr_monam(montarget, DESC_PLAIN) );
+ str_monam(*montarget, DESC_PLAIN).c_str() );
return (true);
}
@@ -5246,7 +5244,7 @@ void seen_monster(monsters *monster)
{
take_note(
Note(NOTE_SEEN_MONSTER, monster->type, 0,
- ptr_monam(monster, DESC_NOCAP_A)) );
+ str_monam(*monster, DESC_NOCAP_A).c_str()));
}
}
diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc
index 59916a7c15..056217d095 100644
--- a/crawl-ref/source/mstuff2.cc
+++ b/crawl-ref/source/mstuff2.cc
@@ -181,7 +181,7 @@ void mons_trap(struct monsters *monster)
if (player_monster_visible( monster ))
{
msg += " and slices into ";
- msg += ptr_monam( monster, DESC_NOCAP_THE );
+ msg += str_monam( *monster, DESC_NOCAP_THE );
}
msg += "!";
mpr(msg.c_str());
@@ -288,7 +288,7 @@ void mons_trap(struct monsters *monster)
mprf("A%s %s %s%s!",
beem.name.c_str(),
(damage_taken >= 0) ? "hits" : "misses",
- ptr_monam( monster, DESC_NOCAP_THE ),
+ str_monam( *monster, DESC_NOCAP_THE ).c_str(),
(damage_taken == 0) ? ", but does no damage" : "");
}
@@ -1226,7 +1226,7 @@ bool mons_throw(struct monsters *monster, struct bolt &pbolt, int hand_used)
// now, if a monster is, for some reason, throwing something really
// stupid, it will have baseHit of 0 and damage of 0. Ah well.
- std::string msg = ptr_monam( monster, DESC_CAP_THE);
+ std::string msg = str_monam(*monster, DESC_CAP_THE);
msg += ((launched) ? " shoots " : " throws ");
if (!pbolt.name.empty())
@@ -1252,13 +1252,13 @@ bool mons_throw(struct monsters *monster, struct bolt &pbolt, int hand_used)
{
snprintf( throw_buff, sizeof(throw_buff), "Shot with a%s %s by %s",
(is_vowel(pbolt.name[0]) ? "n" : ""), pbolt.name.c_str(),
- ptr_monam( monster, DESC_NOCAP_A ) );
+ str_monam( *monster, DESC_NOCAP_A ).c_str() );
}
else
{
snprintf( throw_buff, sizeof(throw_buff), "Hit by a%s %s thrown by %s",
(is_vowel(pbolt.name[0]) ? "n" : ""), pbolt.name.c_str(),
- ptr_monam( monster, DESC_NOCAP_A ) );
+ str_monam( *monster, DESC_NOCAP_A ).c_str() );
}
pbolt.aux_source = throw_buff;
diff --git a/crawl-ref/source/skills2.cc b/crawl-ref/source/skills2.cc
index f3ca671459..019c44a927 100644
--- a/crawl-ref/source/skills2.cc
+++ b/crawl-ref/source/skills2.cc
@@ -1850,7 +1850,7 @@ void show_skills()
int scrln = 3, scrcol = 1;
// Don't want the help line to appear too far down a big window.
- int bottom_line = ((num_lines > 30) ? 30 : num_lines);
+ const int bottom_line = ((num_lines > 30) ? 30 : num_lines);
for (i = 0; i < ndisplayed_skills; ++i)
{
diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc
index 43f5dcb3df..50115801be 100644
--- a/crawl-ref/source/spells1.cc
+++ b/crawl-ref/source/spells1.cc
@@ -534,7 +534,7 @@ static int healing_spell( int healed )
if (heal_monster(monster, healed, false))
{
- mprf("You heal %s.", ptr_monam( monster, DESC_NOCAP_THE ));
+ mprf("You heal %s.", str_monam( *monster, DESC_NOCAP_THE ).c_str());
if (monster->hit_points == monster->max_hit_points)
simple_monster_message( monster, " is completely healed." );
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index 5b363de62a..abd620955c 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -834,7 +834,7 @@ void cast_toxic_radiance(void)
{
// message player re:"miss" where appropriate {dlb}
mprf("The light passes through %s.",
- ptr_monam( monster, DESC_NOCAP_THE ));
+ str_monam( *monster, DESC_NOCAP_THE ).c_str());
}
}
}
@@ -883,7 +883,8 @@ void cast_refrigeration(int pow)
if (mons_near(monster))
{
- mprf("You freeze %s.", ptr_monam( monster, DESC_NOCAP_THE ));
+ mprf("You freeze %s.",
+ str_monam(*monster, DESC_NOCAP_THE).c_str());
hurted = roll_dice( dam_dice );
hurted = mons_adjust_flavoured( monster, beam, hurted );
@@ -940,7 +941,8 @@ void drain_life(int pow)
if (mons_near(monster))
{
- mprf("You draw life from %s.", ptr_monam(monster, DESC_NOCAP_THE));
+ mprf("You draw life from %s.",
+ str_monam(*monster, DESC_NOCAP_THE).c_str());
hurted = 3 + random2(7) + random2(pow);
@@ -1016,7 +1018,7 @@ int vampiric_drain(int pow, const dist &vmove)
hurt_monster(monster, inflicted);
mprf("You feel life coursing from %s into your body!",
- ptr_monam( monster, DESC_NOCAP_THE ));
+ str_monam( *monster, DESC_NOCAP_THE ).c_str());
print_wounds(monster);
@@ -1073,7 +1075,7 @@ char burn_freeze(int pow, char flavour)
(flavour == BEAM_MISSILE) ? "crush" :
(flavour == BEAM_ELECTRICITY) ? "zap"
: "______",
- ptr_monam( monster, DESC_NOCAP_THE ));
+ str_monam( *monster, DESC_NOCAP_THE ).c_str());
int hurted = roll_dice( 1, 3 + pow / 3 );
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc
index a9f5d591a3..a3277a4a17 100644
--- a/crawl-ref/source/spells3.cc
+++ b/crawl-ref/source/spells3.cc
@@ -202,7 +202,7 @@ int cast_smiting(int power, dist &beam)
{
monster = &menv[mgrd[beam.tx][beam.ty]];
- mprf("You smite %s!", ptr_monam( monster, DESC_NOCAP_THE ));
+ mprf("You smite %s!", str_monam( *monster, DESC_NOCAP_THE ).c_str());
// Maxes out at around 40 damage at 27 Invocations, which is plenty
// in my book (the old max damage was around 70, which seems excessive.
@@ -235,7 +235,7 @@ int airstrike(int power, dist &beam)
monster = &menv[mgrd[beam.tx][beam.ty]];
mprf("The air twists around and strikes %s!",
- ptr_monam( monster, DESC_NOCAP_THE ));
+ str_monam( *monster, DESC_NOCAP_THE ).c_str());
hurted = 8 + random2( random2(4) + (random2(power) / 6)
+ (random2(power) / 7) );
diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc
index 1caecd207b..21b8a6f68c 100644
--- a/crawl-ref/source/spells4.cc
+++ b/crawl-ref/source/spells4.cc
@@ -1266,7 +1266,7 @@ static int discharge_monsters( int x, int y, int pow, int garbage )
if (damage)
{
mprf( "%s is struck by lightning.",
- ptr_monam( &(menv[mon]), DESC_CAP_THE));
+ str_monam( menv[mon], DESC_CAP_THE).c_str());
player_hurt_monster( mon, damage );
}
}
@@ -1370,13 +1370,13 @@ static int distortion_monsters(int x, int y, int pow, int message)
else if (coinflip())
{
mprf("Space bends around %s.",
- ptr_monam(defender, DESC_NOCAP_THE));
+ str_monam(*defender, DESC_NOCAP_THE).c_str());
specdam += 1 + random2avg( 7, 2 ) + random2(pow) / 40;
}
else if (coinflip())
{
mprf("Space warps horribly around %s!",
- ptr_monam( defender, DESC_NOCAP_THE ));
+ str_monam(*defender, DESC_NOCAP_THE ).c_str());
specdam += 3 + random2avg( 12, 2 ) + random2(pow) / 25;
}
else if (one_chance_in(3))
@@ -1779,7 +1779,7 @@ static int glamour_monsters(int x, int y, int pow, int garbage)
// why no, there's no message as to which effect happened >:^)
if (!one_chance_in(4))
{
- std::string msg = ptr_monam( &(menv[mon]), DESC_CAP_THE);
+ std::string msg = str_monam(menv[mon], DESC_CAP_THE);
switch (random2(4))
{
@@ -2299,7 +2299,7 @@ static int snake_charm_monsters(int x, int y, int pow, int message)
if (check_mons_resist_magic(&menv[mon], pow)) return 0;
menv[mon].attitude = ATT_FRIENDLY;
- mprf("%s sways back and forth.", ptr_monam( &(menv[mon]), DESC_CAP_THE ));
+ mprf("%s sways back and forth.",str_monam(menv[mon],DESC_CAP_THE).c_str());
return 1;
}
@@ -2357,7 +2357,7 @@ void cast_fragmentation(int pow) // jmf: ripped idea from airstrike
char explode_msg[80];
snprintf( explode_msg, sizeof( explode_msg ), "%s explodes!",
- ptr_monam( &(menv[mon]), DESC_CAP_THE ) );
+ str_monam( menv[mon], DESC_CAP_THE ).c_str() );
switch (menv[mon].type)
{
@@ -2898,7 +2898,7 @@ int cast_apportation(int pow)
mpr( "There are no items there." );
else if (mons_is_mimic( menv[ mon ].type ))
{
- mprf("%s twitches.", ptr_monam( &(menv[ mon ]), DESC_CAP_THE));
+ mprf("%s twitches.", str_monam(menv[mon], DESC_CAP_THE).c_str());
}
else
mpr( "This spell does not work on creatures." );
diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc
index 6f2f5593b7..af677759ce 100644
--- a/crawl-ref/source/stuff.cc
+++ b/crawl-ref/source/stuff.cc
@@ -140,7 +140,7 @@ void tag_followers( void )
#if DEBUG_DIAGNOSTICS
mprf(MSGCH_DIAGNOSTICS, "%s is marked for following.",
- ptr_monam( fmenv, DESC_CAP_THE ) );
+ str_monam( *fmenv, DESC_CAP_THE ).c_str() );
#endif
}
}
@@ -1089,7 +1089,7 @@ void zap_los_monsters()
#ifdef DEBUG_DIAGNOSTICS
mprf(MSGCH_DIAGNOSTICS, "Dismissing %s",
- ptr_monam(mon, DESC_PLAIN) );
+ str_monam(*mon, DESC_PLAIN).c_str() );
#endif
monster_die(mon, KILL_DISMISSED, 0);
}