diff options
author | Adam Borowski <kilobyte@angband.pl> | 2013-11-29 00:48:38 +0100 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2013-11-29 01:07:36 +0100 |
commit | ec5babf52457f197efca55ab2292050a270e34f9 (patch) | |
tree | 5f70061d5f564355fe3ce7a6abaa3c0ee3526543 | |
parent | c433d949e7be797fb8662d2efa3ec73c12c6469a (diff) | |
download | crawl-ref-ec5babf52457f197efca55ab2292050a270e34f9.tar.gz crawl-ref-ec5babf52457f197efca55ab2292050a270e34f9.zip |
Restrict mpr() to literals only.
The translation project is stalled, but this makes all of such static strings
trivially gatherable without any extra work.
26 files changed, 66 insertions, 66 deletions
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index e3e91a7690..fdc14412f3 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -1764,7 +1764,7 @@ static void _keyhelp_query_descriptions() viewwindow(); if (!error.empty()) - mpr(error); + mprf("%s", error.c_str()); } static int _keyhelp_keyfilter(int ch) diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 8c57b66857..48951793e5 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -3999,7 +3999,7 @@ static void _describe_cell(const coord_def& where, bool in_range) #endif if (crawl_state.game_is_hints() && hints_monster_interesting(mon)) { - string msg; + const char *msg; #ifdef USE_TILE_LOCAL msg = "(<w>Right-click</w> for more information.)"; #else diff --git a/crawl-ref/source/fineff.cc b/crawl-ref/source/fineff.cc index f49b78e8cd..8b51f0b1d9 100644 --- a/crawl-ref/source/fineff.cc +++ b/crawl-ref/source/fineff.cc @@ -308,7 +308,7 @@ void starcursed_merge_fineff::fire() void delayed_action_fineff::fire() { - if (final_msg.length()) + if (final_msg) mpr(final_msg); add_daction(action); } diff --git a/crawl-ref/source/fineff.h b/crawl-ref/source/fineff.h index ce8db09dcf..447406993b 100644 --- a/crawl-ref/source/fineff.h +++ b/crawl-ref/source/fineff.h @@ -156,9 +156,9 @@ public: class delayed_action_fineff : public final_effect { public: - delayed_action_fineff(daction_type _action, string _final_msg) + delayed_action_fineff(daction_type _action, const char* _final_msg) : final_effect(0, 0, coord_def()), - action(_action),final_msg(_final_msg) + action(_action), final_msg(_final_msg) { } @@ -167,13 +167,13 @@ public: protected: daction_type action; - string final_msg; + const char *final_msg; }; class kirke_death_fineff : public delayed_action_fineff { public: - kirke_death_fineff(string _final_msg) + kirke_death_fineff(const char *_final_msg) : delayed_action_fineff(DACT_KIRKE_HOGS, _final_msg) { } diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc index c203bb413f..ff27f1b019 100644 --- a/crawl-ref/source/invent.cc +++ b/crawl-ref/source/invent.cc @@ -2064,7 +2064,7 @@ bool item_is_evokable(const item_def &item, bool reach, bool known, return true; if (msg) - mpr(error); + mprf("%s", error.c_str()); return false; } @@ -2104,7 +2104,7 @@ bool item_is_evokable(const item_def &item, bool reach, bool known, if (!wielded) { if (msg) - mpr(error); + mprf("%s", error.c_str()); return false; } return true; @@ -2118,7 +2118,7 @@ bool item_is_evokable(const item_def &item, bool reach, bool known, if (!wielded) { if (msg) - mpr(error); + mprf("%s", error.c_str()); return false; } return true; @@ -2131,7 +2131,7 @@ bool item_is_evokable(const item_def &item, bool reach, bool known, if (!wielded) { if (msg) - mpr(error); + mprf("%s", error.c_str()); return false; } return true; @@ -2146,7 +2146,7 @@ bool item_is_evokable(const item_def &item, bool reach, bool known, if (!wielded) { if (msg) - mpr(error); + mprf("%s", error.c_str()); return false; } return true; diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index cdd1cd4abe..a6855583f4 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -3157,7 +3157,7 @@ void read_scroll(int slot) case SCR_REMOVE_CURSE: if (!alreadyknown) { - mpr(pre_succ_msg); + mprf("%s", pre_succ_msg.c_str()); id_the_scroll = remove_curse(false); } else @@ -3304,7 +3304,7 @@ void read_scroll(int slot) case SCR_CURSE_JEWELLERY: if (!alreadyknown) { - mpr(pre_succ_msg); + mprf("%s", pre_succ_msg.c_str()); if (curse_item(which_scroll == SCR_CURSE_ARMOUR, false)) bad_effect = true; else diff --git a/crawl-ref/source/main.cc b/crawl-ref/source/main.cc index f5192d824e..9f8f4bb4d6 100644 --- a/crawl-ref/source/main.cc +++ b/crawl-ref/source/main.cc @@ -2142,9 +2142,8 @@ void process_command(command_type cmd) default: if (crawl_state.game_is_hints()) { - string msg = "Unknown command. (For a list of commands type " - "<w>?\?<lightgrey>.)"; - mpr(msg); + mpr("Unknown command. (For a list of commands type " + "<w>?\?<lightgrey>.)"); } else // well, not examine, but... mprf(MSGCH_EXAMINE_FILTER, "Unknown command."); diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc index 48997ab811..417e5b89d3 100644 --- a/crawl-ref/source/message.cc +++ b/crawl-ref/source/message.cc @@ -44,7 +44,7 @@ static void _mpr(string text, msg_channel_type channel=MSGCH_PLAIN, int param=0, bool nojoin=false, bool cap=true); -void mpr(string text) +void mpr(const char *text) { _mpr(text); } diff --git a/crawl-ref/source/mon-death.cc b/crawl-ref/source/mon-death.cc index 16f31739dc..fd1806e3b0 100644 --- a/crawl-ref/source/mon-death.cc +++ b/crawl-ref/source/mon-death.cc @@ -67,7 +67,7 @@ void pikel_band_neutralise() visible_slaves++; } } - string final_msg; + const char* final_msg; if (visible_slaves == 1) final_msg = "With Pikel's spell broken, the former slave thanks you for freedom."; else if (visible_slaves > 1) @@ -129,7 +129,7 @@ void hogs_to_humans() human++; } - string final_msg; + const char* final_msg; if (any == 1) { diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc index ac98e76a42..824b44439e 100644 --- a/crawl-ref/source/monster.cc +++ b/crawl-ref/source/monster.cc @@ -2955,10 +2955,9 @@ bool monster::fumbles_attack(bool verbose) { if (you.can_see(this)) { - mpr(name(DESC_THE) - + (liquefied(pos()) - ? " becomes momentarily stuck in the liquid earth." - : " splashes around in the water.")); + mprf("%s %s", name(DESC_THE).c_str(), liquefied(pos()) + ? " becomes momentarily stuck in the liquid earth." + : " splashes around in the water."); } else if (player_can_hear(pos(), LOS_RADIUS)) mprf(MSGCH_SOUND, "You hear a splashing noise."); diff --git a/crawl-ref/source/mpr.h b/crawl-ref/source/mpr.h index 0e2d14f5d8..3c22165a62 100644 --- a/crawl-ref/source/mpr.h +++ b/crawl-ref/source/mpr.h @@ -86,7 +86,7 @@ enum diag_type msg_colour_type msg_colour(int colour); -void mpr(string text); +void mpr(const char *text); void mpr_nojoin(msg_channel_type channel, string text); // 4.1-style mpr, currently named mprf for minimal disruption. diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index 7c1f50cfc5..9098ccc4ce 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -387,7 +387,8 @@ int check_your_resists(int hurted, beam_type flavour, string source, return hurted; } -void splash_with_acid(int acid_strength, int death_source, bool corrode_items, string hurt_message) +void splash_with_acid(int acid_strength, int death_source, bool corrode_items, + const char* hurt_msg) { int dam = 0; const bool wearing_cloak = player_wearing_slot(EQ_CLOAK); @@ -425,7 +426,7 @@ void splash_with_acid(int acid_strength, int death_source, bool corrode_items, s if (post_res_dam > 0) { - mpr(hurt_message.empty() ? "The acid burns!" : hurt_message); + mpr(hurt_msg ? "The acid burns!" : hurt_msg); if (post_res_dam < dam) canned_msg(MSG_YOU_RESIST); diff --git a/crawl-ref/source/ouch.h b/crawl-ref/source/ouch.h index 5752157ce5..8a75958667 100644 --- a/crawl-ref/source/ouch.h +++ b/crawl-ref/source/ouch.h @@ -65,7 +65,7 @@ enum kill_method_type int check_your_resists(int hurted, beam_type flavour, string source, bolt *beam = 0, bool doEffects = true); void splash_with_acid(int acid_strength, int death_source, - bool corrode_items = true, string hurt_msg = ""); + bool corrode_items = true, const char* hurt_msg = nullptr); class actor; int actor_to_death_source(const actor* agent); diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index cbe8ec1ff5..11a176d986 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -4142,7 +4142,7 @@ static void _display_tohit() */ } -static string _attack_delay_desc(int attack_delay) +static const char* _attack_delay_desc(int attack_delay) { return (attack_delay >= 200) ? "extremely slow" : (attack_delay >= 155) ? "very slow" : @@ -4174,10 +4174,10 @@ static void _display_attack_delay() if (you.duration[DUR_FINESSE]) avg = max(20, avg / 2); - string msg = "Your attack speed is " + _attack_delay_desc(avg) - + (you.wizard ? make_stringf(" (%d)", avg) : "") + "."; - - mpr(msg); + if (you.wizard) + mprf("Your attack speed is %s (%d).", _attack_delay_desc(avg), avg); + else + mprf("Your attack speed is %s.", _attack_delay_desc(avg)); } // forward declaration @@ -4294,7 +4294,7 @@ void display_char_status() for (unsigned i = 0; i < ARRAYSZ(statuses); ++i) { if (fill_status_info(statuses[i], &inf) && !inf.long_text.empty()) - mpr(inf.long_text); + mprf("%s", inf.long_text.c_str()); } string cinfo = _constriction_description(); if (!cinfo.empty()) @@ -4974,7 +4974,7 @@ void contaminate_player(int change, bool controlled, bool msg) dprf("change: %d radiation: %d", change, you.magic_contamination); if (msg && new_level >= 1 && old_level <= 1 && new_level != old_level) - mpr(describe_contamination(new_level)); + mprf("%s", describe_contamination(new_level).c_str()); else if (msg && new_level != old_level) { if (old_level == 1 && new_level == 0) @@ -7976,10 +7976,9 @@ bool player::attempt_escape(int attempts) } else { - string emsg = "Your attempt to break free from "; - emsg += themonst->name(DESC_THE, true); - emsg += " fails, but you feel that another attempt might succeed."; - mpr(emsg); + mprf("Your attempt to break free from %s fails, but you feel that " + "another attempt might succeed.", + themonst->name(DESC_THE, true).c_str()); turn_is_over = true; return false; } diff --git a/crawl-ref/source/potion.cc b/crawl-ref/source/potion.cc index 8d8599ec6d..48a8dee801 100644 --- a/crawl-ref/source/potion.cc +++ b/crawl-ref/source/potion.cc @@ -523,7 +523,7 @@ bool potion_effect(potion_type pot_eff, int pow, item_def *potion, bool was_know { set_ident_flags(*potion, ISFLAG_IDENT_MASK); set_ident_type(*potion, ID_KNOWN_TYPE); - mpr("It was a " + potion->name(DESC_QUALNAME) + "."); + mprf("It was a %s.", potion->name(DESC_QUALNAME).c_str()); } return true; diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index b51124bca1..1f82122b6c 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -3268,8 +3268,8 @@ void nemelex_death_message() { const piety_gain_t piety_gain = static_cast<piety_gain_t> (min(random2(you.piety) / 30, (int)PIETY_LOTS)); - mpr(_sacrifice_message(_Sacrifice_Messages[GOD_NEMELEX_XOBEH][piety_gain], - "Your body", you.backlit(), false, piety_gain)); + mprf("%s", _sacrifice_message(_Sacrifice_Messages[GOD_NEMELEX_XOBEH][piety_gain], + "Your body", you.backlit(), false, piety_gain).c_str()); } bool god_hates_attacking_friend(god_type god, const actor *fr) diff --git a/crawl-ref/source/skills.cc b/crawl-ref/source/skills.cc index 863348406c..c7894b0a95 100644 --- a/crawl-ref/source/skills.cc +++ b/crawl-ref/source/skills.cc @@ -399,7 +399,7 @@ static void _check_start_train() ++it; if (!skills.empty()) - mpr("You resume training " + skill_names(skills) + "."); + mprf("You resume training %s.", skill_names(skills).c_str()); you.start_train.clear(); } @@ -430,7 +430,7 @@ static void _check_stop_train() if (!skills.empty()) { - mpr("You stop training " + skill_names(skills) + "."); + mprf("You stop training %s.", skill_names(skills).c_str()); check_selected_skills(); } diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index 572ae96059..d91f0ef5cb 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -1048,7 +1048,7 @@ static bool _spellcasting_aborted(spell_type spell, string msg; if (!wiz_cast && spell_is_uncastable(spell, msg)) { - mpr(msg); + mprf("%s", msg.c_str()); return true; } diff --git a/crawl-ref/source/spl-damage.cc b/crawl-ref/source/spl-damage.cc index ff0d7fb6bd..84a9d58719 100644 --- a/crawl-ref/source/spl-damage.cc +++ b/crawl-ref/source/spl-damage.cc @@ -560,8 +560,8 @@ spret_type cast_los_attack_spell(spell_type spell, int pow, actor* agent, monster* mons = agent ? agent->as_monster() : NULL; colour_t flash_colour = BLACK; - string player_msg, global_msg, mons_vis_msg, mons_invis_msg, - harm_msg = "harm"; + const char *player_msg = nullptr, *global_msg = nullptr, + *mons_vis_msg = nullptr, *mons_invis_msg = nullptr; bool (*vulnerable)(const actor *, const actor *) = NULL; bool (*vul_hitfunc)(const actor *) = NULL; int (*damage_player)(actor *, int, int, bool, bool) = NULL; @@ -617,7 +617,7 @@ spret_type cast_los_attack_spell(spell_type spell, int pow, actor* agent, ASSERT(actual); targetter_los hitfunc(&you, LOS_NO_TRANS); { - if (allow_cancel && stop_attack_prompt(hitfunc, harm_msg, vul_hitfunc)) + if (allow_cancel && stop_attack_prompt(hitfunc, "harm", vul_hitfunc)) return SPRET_ABORT; } fail_check(); @@ -633,7 +633,7 @@ spret_type cast_los_attack_spell(spell_type spell, int pow, actor* agent, if (!agent) mpr(global_msg); else if (you.can_see(agent)) - simple_monster_message(mons, mons_vis_msg.c_str()); + simple_monster_message(mons, mons_vis_msg); else if (you.see_cell(agent->pos())) mpr(mons_invis_msg); diff --git a/crawl-ref/source/spl-goditem.cc b/crawl-ref/source/spl-goditem.cc index a401f448c7..ad2240cf97 100644 --- a/crawl-ref/source/spl-goditem.cc +++ b/crawl-ref/source/spl-goditem.cc @@ -638,7 +638,7 @@ static bool _selectively_remove_curse(string *pre_msg) } if (!used && pre_msg) - mpr(*pre_msg); + mprf("%s", pre_msg->c_str()); do_uncurse_item(item, true, false, false); used = true; @@ -684,7 +684,7 @@ bool remove_curse(bool alreadyknown, string *pre_msg) if (success) { if (pre_msg) - mpr(*pre_msg); + mprf("%s", pre_msg->c_str()); mpr("You feel as if something is helping you."); learned_something_new(HINT_REMOVED_CURSE); } @@ -693,7 +693,7 @@ bool remove_curse(bool alreadyknown, string *pre_msg) else { if (pre_msg) - mpr(*pre_msg); + mprf("%s", pre_msg->c_str()); canned_msg(MSG_NOTHING_HAPPENS); } @@ -726,7 +726,7 @@ static bool _selectively_curse_item(bool armour, string *pre_msg) } if (pre_msg) - mpr(*pre_msg); + mprf("%s", pre_msg->c_str()); do_curse_item(item, false); return true; } @@ -762,7 +762,7 @@ bool curse_item(bool armour, bool alreadyknown, string *pre_msg) else { if (pre_msg) - mpr(*pre_msg); + mprf("%s", pre_msg->c_str()); canned_msg(MSG_NOTHING_HAPPENS); } @@ -773,7 +773,7 @@ bool curse_item(bool armour, bool alreadyknown, string *pre_msg) return _selectively_curse_item(armour, pre_msg); if (pre_msg) - mpr(*pre_msg); + mprf("%s", pre_msg->c_str()); // Make the name before we curse it. do_curse_item(you.inv[you.equip[affected]], false); learned_something_new(HINT_YOU_CURSED); diff --git a/crawl-ref/source/spl-summoning.cc b/crawl-ref/source/spl-summoning.cc index c7bd50c6e7..af0026260d 100644 --- a/crawl-ref/source/spl-summoning.cc +++ b/crawl-ref/source/spl-summoning.cc @@ -136,7 +136,7 @@ spret_type cast_sticks_to_snakes(int pow, god_type god, bool fail) // Don't enchant sticks marked with {!D}. if (!check_warning_inscriptions(wpn, OPER_DESTROY)) { - mpr(abort_msg); + mprf("%s", abort_msg.c_str()); return SPRET_ABORT; } @@ -149,7 +149,7 @@ spret_type cast_sticks_to_snakes(int pow, god_type god, bool fail) if (!item_is_snakable(wpn)) { - mpr(abort_msg); + mprf("%s", abort_msg.c_str()); return SPRET_ABORT; } else @@ -183,7 +183,7 @@ spret_type cast_sticks_to_snakes(int pow, god_type god, bool fail) if (!count) { - mpr(abort_msg); + mprf("%s", abort_msg.c_str()); return SPRET_SUCCESS; } @@ -1460,8 +1460,10 @@ static void _display_undead_motions(int motions) if (motions_list.size() > 3) mpr("The dead have arisen!"); else - mpr("The dead are " + comma_separated_line(motions_list.begin(), - motions_list.end()) + "!"); + { + mprf("The dead are %s!", comma_separated_line(motions_list.begin(), + motions_list.end()).c_str()); + } } static bool _raise_remains(const coord_def &pos, int corps, beh_type beha, diff --git a/crawl-ref/source/stairs.cc b/crawl-ref/source/stairs.cc index fef318a596..834df54b4f 100644 --- a/crawl-ref/source/stairs.cc +++ b/crawl-ref/source/stairs.cc @@ -710,7 +710,7 @@ void down_stairs(dungeon_feature_type force_stair, bool force_known_shaft) howfar = make_stringf(" for %d floors", shaft_depth); if (!you.flight_mode() || force_stair) - mpr("You fall through a shaft" + howfar + "!"); + mprf("You fall through a shaft %s!", howfar.c_str()); else mpr("You dive down through the shaft."); diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc index 92dd4d0ed6..7f57736d8c 100644 --- a/crawl-ref/source/stuff.cc +++ b/crawl-ref/source/stuff.cc @@ -644,9 +644,9 @@ bool yesno(const char *str, bool safe, int safeanswer, bool clear_after, status->text = pr; #else if (message) - mpr(pr); + mpr(pr.c_str()); else - cprintf(("\n" + pr + "\n").c_str()); + cprintf("\n%s\n", pr.c_str()); #endif } } diff --git a/crawl-ref/source/throw.cc b/crawl-ref/source/throw.cc index da7bd06e23..73ab8cd7db 100644 --- a/crawl-ref/source/throw.cc +++ b/crawl-ref/source/throw.cc @@ -203,7 +203,7 @@ void fire_target_behaviour::pick_fire_item_from_inventory() } else if (!err.empty()) { - mpr(err); + mprf("%s", err.c_str()); more(); } set_prompt(); diff --git a/crawl-ref/source/transform.cc b/crawl-ref/source/transform.cc index 571a416db9..6846b5019e 100644 --- a/crawl-ref/source/transform.cc +++ b/crawl-ref/source/transform.cc @@ -1015,7 +1015,7 @@ bool transform(int pow, transformation_type which_trans, bool involuntary, you.duration[DUR_STONESKIN] = 0; // Give the transformation message. - mpr(msg); + mprf("%s", msg.c_str()); // Update your status. you.form = which_trans; diff --git a/crawl-ref/source/wiz-fsim.cc b/crawl-ref/source/wiz-fsim.cc index fc42c4b51e..fffdfa21e7 100644 --- a/crawl-ref/source/wiz-fsim.cc +++ b/crawl-ref/source/wiz-fsim.cc @@ -511,7 +511,7 @@ static void _fsim_simple_scale(FILE * o, monster* mon, bool defense) fight_data fdata = _get_fight_data(*mon, iter_limit, defense); const string line = make_stringf(" %2d | %s", i, _fight_string(fdata).c_str()); - mpr(line); + mprf("%s", line.c_str()); fprintf(o, "%s\n", line.c_str()); fflush(o); |