From 9406beea182124aeb8b9d71dc829a3bcbc31cde7 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Wed, 2 May 2007 16:49:28 +0000 Subject: Backported combat grammar fixes for mimic attack shield blocks to 0.2. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.2@1405 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/Kills.cc | 27 ++++++++++++++++++--------- crawl-ref/source/Kills.h | 3 ++- crawl-ref/source/debug.cc | 4 ++-- crawl-ref/source/externs.h | 7 ++++--- crawl-ref/source/fight.cc | 4 ++-- crawl-ref/source/ghost.cc | 9 +++++++++ crawl-ref/source/mon-util.cc | 22 ++++++++++++++-------- crawl-ref/source/mtransit.cc | 2 +- crawl-ref/source/mtransit.h | 2 +- crawl-ref/source/player.cc | 1 + crawl-ref/source/spells3.cc | 3 +++ crawl-ref/source/tags.cc | 4 ++-- 12 files changed, 59 insertions(+), 29 deletions(-) diff --git a/crawl-ref/source/Kills.cc b/crawl-ref/source/Kills.cc index 8a85e04921..8f16ef81cc 100644 --- a/crawl-ref/source/Kills.cc +++ b/crawl-ref/source/Kills.cc @@ -347,7 +347,16 @@ static bool ends_with(const std::string &s, const char *suffixes[]) return false; } -// For monster names ending with these suffixes, we pluralize directly without +std::string apostrophise(const std::string &name) +{ + if (name.empty()) + return (name); + + const char lastc = name[ name.length() - 1 ]; + return (name + (lastc == 's' || lastc == 'x'? "'" : "'s")); +} + +// For monster names ending with these suffixes, we pluralise directly without // attempting to use the "of" rule. For instance: // // moth of wrath => moths of wrath but @@ -361,18 +370,18 @@ static const char *modifier_suffixes[] = "zombie", "skeleton", "simulacrum", NULL, }; -// Pluralizes a monster name. This'll need to be updated for correctness +// Pluralises a monster name. This'll need to be updated for correctness // whenever new monsters are added. -std::string pluralize(const std::string &name, +std::string pluralise(const std::string &name, const char *no_of[]) { std::string::size_type pos; - // Pluralize first word of names like 'eye of draining', but only if the + // Pluralise first word of names like 'eye of draining', but only if the // whole name is not suffixed by a modifier, such as 'zombie' or 'skeleton' if ( (pos = name.find(" of ")) != std::string::npos && !ends_with(name, no_of) ) - return pluralize(name.substr(0, pos)) + name.substr(pos); + return pluralise(name.substr(0, pos)) + name.substr(pos); else if (ends_with(name, "us")) // Fungus, ufetubus, for instance. return name.substr(0, name.length() - 2) + "i"; @@ -428,14 +437,14 @@ static std::string article_a(const std::string &name) } // For a non-unique monster, prefixes a suitable article if we have only one -// kill, else prefixes a kill count and pluralizes the monster name. +// kill, else prefixes a kill count and pluralises the monster name. static std::string n_names(const std::string &name, int n) { if (n > 1) { char buf[20]; snprintf(buf, sizeof buf, "%d ", n); - return buf + pluralize(name, modifier_suffixes); + return buf + pluralise(name, modifier_suffixes); } else return article_a(name); @@ -545,11 +554,11 @@ std::string kill_def::info(const kill_monster_desc &md) const if (!mons_is_unique(md.monnum)) { - // Pluralize as needed + // Pluralise as needed name = n_names(name, kills); // We brand shapeshifters with the (shapeshifter) qualifier. This - // has to be done after doing pluralize(), else we get very odd plurals + // has to be done after doing pluralise(), else we get very odd plurals // :) if (md.modifier == kill_monster_desc::M_SHAPESHIFTER && md.monnum != MONS_SHAPESHIFTER && diff --git a/crawl-ref/source/Kills.h b/crawl-ref/source/Kills.h index 625b145cba..81f82be2f5 100644 --- a/crawl-ref/source/Kills.h +++ b/crawl-ref/source/Kills.h @@ -12,8 +12,9 @@ #include #include "enum.h" -std::string pluralize(const std::string &name, +std::string pluralise(const std::string &name, const char *no_of[] = NULL); +std::string apostrophise(const std::string &name); struct monsters; diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index 34e4f13530..186fd309d8 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -424,11 +424,11 @@ static void wizard_go_to_level(const level_pos &pos) : DNGN_STONE_STAIRS_UP_I; const int old_level = you.your_level; - const int old_where = you.where_are_you; + const branch_type old_where = you.where_are_you; const bool was_a_labyrinth = you.level_type == LEVEL_LABYRINTH; you.level_type = LEVEL_DUNGEON; - you.where_are_you = pos.id.branch; + you.where_are_you = static_cast(pos.id.branch); you.your_level = abs_depth; load(stair_taken, LOAD_ENTER_LEVEL, was_a_labyrinth, old_level, old_where); diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index c3ab663dc0..6bdf8f1562 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -642,9 +642,9 @@ public: KillMaster kills; - char level_type; + level_area_type level_type; - char where_are_you; + branch_type where_are_you; FixedVector branch_stairs; @@ -924,7 +924,7 @@ public: void timeout_enchantments(int levels); bool needs_transit() const; - void set_transit(level_id destination); + void set_transit(const level_id &destination); bool find_place_to_live(bool near_player = false); bool find_place_near_player(); bool find_home_in(coord_def s, coord_def e); @@ -1121,6 +1121,7 @@ public: private: static int n_extra_ghosts(); static void find_extra_ghosts(std::vector &ghosts, int n); + static void announce_ghost(const ghost_demon &g); private: void add_spells(); diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 8e095747d7..91ab96e859 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -2455,7 +2455,7 @@ bool melee_attack::attack_shield_blocked(bool verbose) mprf("%s %s %s attack.", defender->name(DESC_CAP_THE).c_str(), defender->conj_verb("block").c_str(), - attacker->name(DESC_NOCAP_YOUR).c_str()); + attacker->name(DESC_NOCAP_ITS).c_str()); defender->shield_block_succeeded(); @@ -2794,7 +2794,7 @@ void melee_attack::mons_apply_attack_flavour(const mon_attack_def &attk) mprf("%s %s strength from %s injuries!", attacker->name(DESC_CAP_THE).c_str(), attacker->conj_verb("draw").c_str(), - defender->name(DESC_NOCAP_YOUR).c_str()); + defender->name(DESC_NOCAP_ITS).c_str()); } // 4.1.2 actually drains max hp; we're being nicer and just doing diff --git a/crawl-ref/source/ghost.cc b/crawl-ref/source/ghost.cc index 5e4044dde7..3ca0ee78b9 100644 --- a/crawl-ref/source/ghost.cc +++ b/crawl-ref/source/ghost.cc @@ -534,6 +534,7 @@ std::vector ghost_demon::find_ghosts() ghost_demon player; player.init_player_ghost(); + announce_ghost(player); gs.push_back(player); find_extra_ghosts( gs, n_extra_ghosts() ); @@ -541,6 +542,13 @@ std::vector ghost_demon::find_ghosts() return (gs); } +void ghost_demon::announce_ghost(const ghost_demon &g) +{ +#ifdef DEBUG_DIAGNOSTICS + mprf(MSGCH_DIAGNOSTICS, "Saving ghost: %s", g.name.c_str()); +#endif +} + void ghost_demon::find_extra_ghosts( std::vector &gs, int n ) { for (int i = 0; n > 0 && i < MAX_MONSTERS; ++i) @@ -551,6 +559,7 @@ void ghost_demon::find_extra_ghosts( std::vector &gs, int n ) if (menv[i].type == MONS_PLAYER_GHOST && menv[i].ghost.get()) { // Bingo! + announce_ghost(*menv[i].ghost); gs.push_back( *menv[i].ghost ); --n; } diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 96402499e6..8001357055 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -61,13 +61,13 @@ enum habitat_type }; static bool initialized_randmons = false; -static std::vector monsters_by_habitat[NUM_HABITATS]; +static std::vector monsters_by_habitat[NUM_HABITATS]; static struct monsterentry mondata[] = { #include "mon-data.h" }; -#define MONDATASIZE (sizeof(mondata)/sizeof(struct monsterentry)) +#define MONDATASIZE (sizeof(mondata)/sizeof(monsterentry)) static int mspell_list[][7] = { #include "mon-spll.h" @@ -196,7 +196,7 @@ static void initialize_randmons() if (invalid_monster_class(m)) continue; if (monster_habitable_grid(m, grid)) - monsters_by_habitat[i].push_back(m); + monsters_by_habitat[i].push_back(static_cast(m)); } } initialized_randmons = true; @@ -213,10 +213,10 @@ monster_type random_monster_at_grid(int grid) initialize_randmons(); const habitat_type ht = grid2habitat(grid); - const std::vector &valid_mons = monsters_by_habitat[ht]; + const std::vector &valid_mons = monsters_by_habitat[ht]; ASSERT(!valid_mons.empty()); return valid_mons.empty()? MONS_PROGRAM_BUG - : monster_type(valid_mons[ random2(valid_mons.size()) ]); + : valid_mons[ random2(valid_mons.size()) ]; } monster_type get_monster_by_name(std::string name, bool exact) @@ -2558,7 +2558,13 @@ item_def *monsters::shield() std::string monsters::name(description_level_type desc) const { - return (ptr_monam(this, desc)); + const bool possessive = + (desc == DESC_NOCAP_YOUR || desc == DESC_NOCAP_ITS); + + if (possessive) + desc = DESC_NOCAP_THE; + std::string mname = ptr_monam(this, desc); + return (possessive? apostrophise(mname) : mname); } std::string monsters::name(description_level_type desc, bool force_vis) const @@ -2584,7 +2590,7 @@ std::string monsters::conj_verb(const std::string &verb) const if (verb == "are") return ("is"); - return (pluralize(verb)); + return (pluralise(verb)); } int monsters::id() const @@ -3001,7 +3007,7 @@ bool monsters::needs_transit() const && !mons_is_summoned(this)); } -void monsters::set_transit(level_id dest) +void monsters::set_transit(const level_id &dest) { add_monster_to_transit(dest, *this); } diff --git a/crawl-ref/source/mtransit.cc b/crawl-ref/source/mtransit.cc index 09a50543e5..42a574e85a 100644 --- a/crawl-ref/source/mtransit.cc +++ b/crawl-ref/source/mtransit.cc @@ -40,7 +40,7 @@ static void cull_lost(m_transit_list &mlist, int how_many) mlist.erase( mlist.begin() ); } -void add_monster_to_transit(level_id lid, const monsters &m) +void add_monster_to_transit(const level_id &lid, const monsters &m) { m_transit_list &mlist = the_lost_ones[lid]; mlist.push_back(m); diff --git a/crawl-ref/source/mtransit.h b/crawl-ref/source/mtransit.h index 3ffc0adfc8..b4f4d48f26 100644 --- a/crawl-ref/source/mtransit.h +++ b/crawl-ref/source/mtransit.h @@ -31,7 +31,7 @@ typedef std::map monsters_in_transit; extern monsters_in_transit the_lost_ones; -void add_monster_to_transit(level_id dest, const monsters &m); +void add_monster_to_transit(const level_id &dest, const monsters &m); // Places (some of the) monsters eligible to be placed on this level. void place_transiting_monsters(); diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 9fcff7ce26..e3aee03759 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -74,6 +74,7 @@ std::string pronoun_you(description_level_type desc) case DESC_CAP_YOUR: return "Your"; case DESC_NOCAP_YOUR: + case DESC_NOCAP_ITS: return "your"; } } diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index 7d450a8f7d..2561f94a24 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -556,6 +556,9 @@ bool allow_control_teleport( bool silent ) ret = false; } break; + + default: + break; } } diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc index f5eb692c4c..6b46af1b06 100644 --- a/crawl-ref/source/tags.cc +++ b/crawl-ref/source/tags.cc @@ -999,14 +999,14 @@ static void tag_read_you(struct tagHeader &th, char minorVersion) you.pet_target = unmarshallByte(th); you.max_level = unmarshallByte(th); - you.where_are_you = unmarshallByte(th); + you.where_are_you = static_cast( unmarshallByte(th) ); you.char_direction = unmarshallByte(th); you.your_level = unmarshallByte(th); you.is_undead = unmarshallByte(th); you.special_wield = unmarshallByte(th); you.berserker = unmarshallByte(th); you.berserk_penalty = unmarshallByte(th); - you.level_type = unmarshallByte(th); + you.level_type = static_cast( unmarshallByte(th) ); you.synch_time = unmarshallByte(th); you.disease = unmarshallByte(th); you.species = unmarshallByte(th); -- cgit v1.2.3-54-g00ecf