diff options
35 files changed, 535 insertions, 866 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc index a43a74912f..17485c495b 100644 --- a/crawl-ref/source/abl-show.cc +++ b/crawl-ref/source/abl-show.cc @@ -698,9 +698,7 @@ bool activate_ability(void) // don't check for hell serpents - they get hell fire, // never regular fire (GDL) - - snprintf( info, INFO_SIZE, "You breathe fire%c", (power < 15)?'.':'!'); - mpr(info); + mprf("You breathe fire%c", (power < 15)?'.':'!'); zapping( ZAP_BREATHE_FIRE, power, beam); break; @@ -1338,10 +1336,8 @@ bool activate_ability(void) const int piety_cost = abil.piety_cost + random2((abil.piety_cost + 1) / 2 + 1); #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "Cost: mp=%d; hp=%d; food=%d; piety=%d", - abil.mp_cost, abil.hp_cost, food_cost, piety_cost ); - - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "Cost: mp=%d; hp=%d; food=%d; piety=%d", + abil.mp_cost, abil.hp_cost, food_cost, piety_cost ); #endif if (abil.mp_cost) diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 5b1adf5913..98569ea0db 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -421,8 +421,7 @@ static void handle_wizard_command( void ) } else { - snprintf( info, INFO_SIZE, "randart val: %d", randart_value( you.inv[i] ) ); - mpr( info ); + mprf("randart val: %d", randart_value(you.inv[i])); } break; @@ -696,19 +695,15 @@ static void handle_wizard_command( void ) int old_piety = you.piety; gain_piety(50); - snprintf( info, INFO_SIZE, "Congratulations, your piety went from %d to %d!", - old_piety, you.piety); - mpr(info); + mprf("Congratulations, your piety went from %d to %d!", + old_piety, you.piety); } break; case '=': - snprintf( info, INFO_SIZE, - "Cost level: %d Skill points: %d Next cost level: %d", - you.skill_cost_level, you.total_skill_points, - skill_cost_needed( you.skill_cost_level + 1 ) ); - - mpr( info ); + mprf( "Cost level: %d Skill points: %d Next cost level: %d", + you.skill_cost_level, you.total_skill_points, + skill_cost_needed( you.skill_cost_level + 1 ) ); break; case '_': @@ -721,17 +716,15 @@ static void handle_wizard_command( void ) if (mitm[i].link == NON_ITEM) continue; - snprintf( info, INFO_SIZE, "item:%3d link:%3d cl:%3d ty:%3d pl:%3d pl2:%3d sp:%3ld q:%3d", - i, mitm[i].link, - mitm[i].base_type, mitm[i].sub_type, - mitm[i].plus, mitm[i].plus2, mitm[i].special, - mitm[i].quantity ); - - mpr(info); + mprf("item:%3d link:%3d cl:%3d ty:%3d pl:%3d pl2:%3d " + "sp:%3ld q:%3d", + i, mitm[i].link, + mitm[i].base_type, mitm[i].sub_type, + mitm[i].plus, mitm[i].plus2, mitm[i].special, + mitm[i].quantity ); } - strcpy(info, "igrid:"); - mpr(info); + mpr("igrid:"); for (i = 0; i < GXM; i++) { @@ -739,13 +732,12 @@ static void handle_wizard_command( void ) { if (igrd[i][j] != NON_ITEM) { - snprintf( info, INFO_SIZE, "%3d at (%2d,%2d), cl:%3d ty:%3d pl:%3d pl2:%3d sp:%3ld q:%3d", - igrd[i][j], i, j, - mitm[i].base_type, mitm[i].sub_type, - mitm[i].plus, mitm[i].plus2, mitm[i].special, - mitm[i].quantity ); - - mpr(info); + mprf("%3d at (%2d,%2d), cl:%3d ty:%3d pl:%3d pl2:%3d " + "sp:%3ld q:%3d", + igrd[i][j], i, j, + mitm[i].base_type, mitm[i].sub_type, + mitm[i].plus, mitm[i].plus2, mitm[i].special, + mitm[i].quantity ); } } } @@ -929,13 +921,10 @@ static void input() viewwindow(true, false); } -static int toggle_flag( bool* flag, const char* flagname ) +static bool toggle_flag( bool* flag, const char* flagname ) { - char buf[INFO_SIZE]; *flag = !(*flag); - sprintf( buf, "%s is now %s.", flagname, - (*flag) ? "on" : "off" ); - mpr(buf); + mprf( "%s is now %s.", flagname, (*flag) ? "on" : "off" ); return *flag; } @@ -996,22 +985,18 @@ static void go_downstairs() static void experience_check() { - snprintf( info, INFO_SIZE, "You are a level %d %s %s.", - you.experience_level, - species_name(you.species,you.experience_level), - you.class_name); - mpr(info); + mprf("You are a level %d %s %s.", + you.experience_level, species_name(you.species,you.experience_level), + you.class_name); if (you.experience_level < 27) { int xp_needed = (exp_needed(you.experience_level+2)-you.experience)+1; - snprintf( info, INFO_SIZE, - "Level %d requires %ld experience (%d point%s to go!)", - you.experience_level + 1, - exp_needed(you.experience_level + 2) + 1, - xp_needed, - (xp_needed > 1) ? "s" : ""); - mpr(info); + mprf( "Level %d requires %ld experience (%d point%s to go!)", + you.experience_level + 1, + exp_needed(you.experience_level + 2) + 1, + xp_needed, + (xp_needed > 1) ? "s" : ""); } else { @@ -1024,12 +1009,8 @@ static void experience_check() const time_t curr = you.real_time + (time(NULL) - you.start_time); char buff[200]; - make_time_string( curr, buff, sizeof(buff) ); - - snprintf( info, INFO_SIZE, "Play time: %s (%ld turns)", - buff, you.num_turns ); - - mpr( info ); + mprf("Play time: %s (%ld turns)", + make_time_string(curr, buff, sizeof buff), you.num_turns ); } #ifdef DEBUG_DIAGNOSTICS if (wearing_amulet(AMU_THE_GOURMAND)) @@ -2025,8 +2006,7 @@ static void decrement_durations() you.confusing_touch--; else if (you.confusing_touch == 1) { - snprintf( info, INFO_SIZE, "Your %s stop glowing.", your_hand(true) ); - mpr( info, MSGCH_DURATION ); + mprf(MSGCH_DURATION, "Your %s stop glowing.", your_hand(true) ); you.confusing_touch = 0; } @@ -2198,8 +2178,7 @@ static void world_reacts() #if 0 // too annoying for regular diagnostics - snprintf( info, INFO_SIZE, "stealth: %d", stealth ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "stealth: %d", stealth ); #endif if (you.special_wield != SPWLD_NONE) @@ -3146,11 +3125,8 @@ static void move_player(int move_x, int move_y) ig2++; } - snprintf( info, INFO_SIZE, "Number of monsters present: %d", ig2 ); - mpr( info, MSGCH_DIAGNOSTICS ); - - snprintf( info, INFO_SIZE, "Number of clouds present: %d", env.cloud_no ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf( MSGCH_DIAGNOSTICS, "Number of monsters present: %d", ig2); + mprf( MSGCH_DIAGNOSTICS, "Number of clouds present: %d", env.cloud_no); #endif } diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 38dbf92dac..188307de76 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -200,8 +200,7 @@ void zapping(char ztype, int power, struct bolt &pbolt) { #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "zapping: power=%d", power ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "zapping: power=%d", power ); #endif // GDL: note that rangeMax is set to 0, which means that max range is @@ -3242,10 +3241,8 @@ static int affect_player( struct bolt &beam ) } #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "Player damage: rolled=%d; after AC=%d", - roll, hurted ); - - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, + "Player damage: rolled=%d; after AC=%d", roll, hurted ); #endif if (you.equip[EQ_BODY_ARMOUR] != -1) @@ -3321,8 +3318,7 @@ static int affect_player( struct bolt &beam ) expose_player_to_element(BEAM_SPORE, burn_power); #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "Damage: %d", hurted ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "Damage: %d", hurted ); #endif beam_ouch( hurted, beam ); @@ -3757,10 +3753,8 @@ static int affect_monster_enchantment(struct bolt &beam, struct monsters *mon) && mons_holiness(mon) == MH_UNDEAD) { #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "HD: %d; pow: %d", - mon->hit_dice, beam.ench_power ); - - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, + "HD: %d; pow: %d", mon->hit_dice, beam.ench_power ); #endif if (check_mons_resist_magic( mon, beam.ench_power )) @@ -3778,10 +3772,8 @@ static int affect_monster_enchantment(struct bolt &beam, struct monsters *mon) && mons_holiness(mon) == MH_DEMONIC) { #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "HD: %d; pow: %d", - mon->hit_dice, beam.ench_power ); - - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, + "HD: %d; pow: %d", mon->hit_dice, beam.ench_power ); #endif if (mon->hit_dice * 7 >= random2(beam.ench_power) @@ -4103,13 +4095,11 @@ void explosion( struct bolt &beam, bool hole_in_the_middle ) beam.in_explosion_phase = true; #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, - "explosion at (%d, %d) : t=%d c=%d f=%d hit=%d dam=%dd%d", - beam.target_x, beam.target_y, - beam.type, beam.colour, beam.flavour, - beam.hit, beam.damage.num, beam.damage.size ); - - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, + "explosion at (%d, %d) : t=%d c=%d f=%d hit=%d dam=%dd%d", + beam.target_x, beam.target_y, + beam.type, beam.colour, beam.flavour, + beam.hit, beam.damage.num, beam.damage.size ); #endif // for now, we don't support explosions greater than 9 radius diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index 85e7c61c5a..846e777c45 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -283,18 +283,13 @@ static void adjust_spells(void) you.spell_letter_table[index_1] = tmp; // print out spell in new slot (now at input_2) - snprintf( info, INFO_SIZE, "%c - %s", input_2, - spell_title( get_spell_by_letter(input_2) ) ); - - mpr(info); + mprf("%c - %s", input_2, spell_title( get_spell_by_letter(input_2) ) ); // print out other spell if one was involved (now at input_1) spell = get_spell_by_letter( input_1 ); + if (spell != SPELL_NO_SPELL) - { - snprintf( info, INFO_SIZE, "%c - %s", input_1, spell_title(spell) ); - mpr(info); - } + mprf("%c - %s", input_1, spell_title(spell) ); } // end adjust_spells() static void adjust_ability(void) @@ -358,10 +353,7 @@ static void adjust_ability(void) } // print out targeted spell: - snprintf( info, INFO_SIZE, "%c - %s", input_1, - get_ability_name_by_index( index_1 ) ); - - mpr(info); + mprf("%c - %s", input_1, get_ability_name_by_index( index_1 ) ); mpr( "Adjust to which letter?", MSGCH_PROMPT ); @@ -413,17 +405,10 @@ static void adjust_ability(void) // This is because nothing actually moves until generate_abilities is // called again... fortunately that has to be done everytime because // that's the silly way this system currently works. -- bwr - snprintf( info, INFO_SIZE, "%c - %s", input_2, - get_ability_name_by_index( index_1 ) ); - - mpr(info); + mprf("%c - %s", input_2, get_ability_name_by_index( index_1 ) ); if (you.ability_letter_table[index_1] != ABIL_NON_ABILITY) - { - snprintf( info, INFO_SIZE, "%c - %s", input_1, - get_ability_name_by_index( index_2 ) ); - mpr(info); - } + mprf("%c - %s", input_1, get_ability_name_by_index( index_2 ) ); } // end adjust_ability() void list_armour(void) diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index 90792b5b7e..8469f76639 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -836,16 +836,14 @@ void tweak_object(void) if (keyin != 'c' && keyin != 'e') { const short *const ptr = static_cast< short * >( field_ptr ); - snprintf( info, INFO_SIZE, "Old value: %d (0x%04x)", *ptr, *ptr ); + mprf("Old value: %d (0x%04x)", *ptr, *ptr ); } else { const long *const ptr = static_cast< long * >( field_ptr ); - snprintf( info, INFO_SIZE, "Old value: %ld (0x%08lx)", *ptr, *ptr ); + mprf("Old value: %ld (0x%08lx)", *ptr, *ptr ); } - mpr( info ); - mpr( "New value? ", MSGCH_PROMPT ); get_input_line( specs, sizeof( specs ) ); @@ -910,17 +908,14 @@ void stethoscope(int mwh) if (env.cgrid[steth_x][steth_y] != EMPTY_CLOUD) { - snprintf( info, INFO_SIZE, "cloud type: %d delay: %d", - env.cloud[ env.cgrid[steth_x][steth_y] ].type, - env.cloud[ env.cgrid[steth_x][steth_y] ].decay ); - - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "cloud type: %d delay: %d", + env.cloud[ env.cgrid[steth_x][steth_y] ].type, + env.cloud[ env.cgrid[steth_x][steth_y] ].decay ); } if (mgrd[steth_x][steth_y] == NON_MONSTER) { - snprintf( info, INFO_SIZE, "item grid = %d", igrd[steth_x][steth_y] ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "item grid = %d", igrd[steth_x][steth_y] ); return; } @@ -928,68 +923,56 @@ void stethoscope(int mwh) } // print type of monster - snprintf( info, INFO_SIZE, "%s (id #%d; type=%d loc=(%d,%d) align=%s)", - monam( &menv[i], menv[i].number, menv[i].type, true, - DESC_CAP_THE ), - i, menv[i].type, - menv[i].x, menv[i].y, - ((menv[i].attitude == ATT_FRIENDLY) ? "friendly" : - (menv[i].attitude == ATT_HOSTILE) ? "hostile" : - (menv[i].attitude == ATT_NEUTRAL) ? "neutral" - : "unknown alignment") ); - - mpr( info, MSGCH_DIAGNOSTICS ); + 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 ), + i, menv[i].type, menv[i].x, menv[i].y, + ((menv[i].attitude == ATT_FRIENDLY) ? "friendly" : + (menv[i].attitude == ATT_HOSTILE) ? "hostile" : + (menv[i].attitude == ATT_NEUTRAL) ? "neutral" + : "unknown alignment") ); // print stats and other info - snprintf( info, INFO_SIZE,"HD=%d HP=%d/%d AC=%d EV=%d MR=%d SP=%d energy=%d num=%d flags=%04lx", - menv[i].hit_dice, - menv[i].hit_points, menv[i].max_hit_points, - menv[i].ac, menv[i].ev, - mons_resist_magic( &menv[i] ), - menv[i].speed, menv[i].speed_increment, - menv[i].number, menv[i].flags ); - - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, + "HD=%d HP=%d/%d AC=%d EV=%d MR=%d SP=%d energy=%d num=%d flags=%04lx", + menv[i].hit_dice, + menv[i].hit_points, menv[i].max_hit_points, + menv[i].ac, menv[i].ev, + mons_resist_magic( &menv[i] ), + menv[i].speed, menv[i].speed_increment, + menv[i].number, menv[i].flags ); // print behaviour information const int hab = monster_habitat( menv[i].type ); - snprintf( info, INFO_SIZE, "hab=%s beh=%s(%d) foe=%s(%d) mem=%d target=(%d,%d)", - ((hab == DNGN_DEEP_WATER) ? "water" : - (hab == DNGN_LAVA) ? "lava" - : "floor"), - - ((menv[i].behaviour == BEH_SLEEP) ? "sleep" : - (menv[i].behaviour == BEH_WANDER) ? "wander" : - (menv[i].behaviour == BEH_SEEK) ? "seek" : - (menv[i].behaviour == BEH_FLEE) ? "flee" : - (menv[i].behaviour == BEH_CORNERED) ? "cornered" - : "unknown"), - menv[i].behaviour, - - ((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 )), - menv[i].foe, - menv[i].foe_memory, - - menv[i].target_x, menv[i].target_y ); - - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, + "hab=%s beh=%s(%d) foe=%s(%d) mem=%d target=(%d,%d)", + ((hab == DNGN_DEEP_WATER) ? "water" : + (hab == DNGN_LAVA) ? "lava" + : "floor"), + ((menv[i].behaviour == BEH_SLEEP) ? "sleep" : + (menv[i].behaviour == BEH_WANDER) ? "wander" : + (menv[i].behaviour == BEH_SEEK) ? "seek" : + (menv[i].behaviour == BEH_FLEE) ? "flee" : + (menv[i].behaviour == BEH_CORNERED) ? "cornered" + : "unknown"), + menv[i].behaviour, + ((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 )), + menv[i].foe, + menv[i].foe_memory, + menv[i].target_x, menv[i].target_y ); // print resistances - snprintf( info, INFO_SIZE, "resist: fire=%d cold=%d elec=%d pois=%d neg=%d", - mons_res_fire( &menv[i] ), - mons_res_cold( &menv[i] ), - mons_res_elec( &menv[i] ), - mons_res_poison( &menv[i] ), - mons_res_negative_energy( &menv[i] ) ); - - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "resist: fire=%d cold=%d elec=%d pois=%d neg=%d", + mons_res_fire( &menv[i] ), + mons_res_cold( &menv[i] ), + mons_res_elec( &menv[i] ), + mons_res_poison( &menv[i] ), + mons_res_negative_energy( &menv[i] ) ); mprf(MSGCH_DIAGNOSTICS, "ench: %s", comma_separated_line(menv[i].enchantments.begin(), @@ -1018,22 +1001,15 @@ static void dump_item( const char *name, int num, const item_def &item ) { mpr( name, MSGCH_WARN ); - snprintf( info, INFO_SIZE, " item #%d: base: %d; sub: %d; plus: %d; plus2: %d; special: %ld", - num, item.base_type, item.sub_type, + mprf(" item #%d: base: %d; sub: %d; plus: %d; plus2: %d; special: %ld", + num, item.base_type, item.sub_type, item.plus, item.plus2, item.special ); - mpr( info ); - - snprintf( info, INFO_SIZE, " quant: %d; colour: %d; ident: 0x%08lx; ident_type: %d", - item.quantity, item.colour, item.flags, - get_ident_type( item.base_type, item.sub_type ) ); - - mpr( info ); - - snprintf( info, INFO_SIZE, " x: %d; y: %d; link: %d", - item.x, item.y, item.link ); + mprf(" quant: %d; colour: %d; ident: 0x%08lx; ident_type: %d", + item.quantity, item.colour, item.flags, + get_ident_type( item.base_type, item.sub_type ) ); - mpr( info ); + mprf(" x: %d; y: %d; link: %d", item.x, item.y, item.link ); } //--------------------------------------------------------------- @@ -1074,8 +1050,7 @@ void debug_item_scan( void ) // Check that item knows what stack it's in if (mitm[obj].x != x || mitm[obj].y != y) { - snprintf( info, INFO_SIZE, "Item position incorrect at (%d,%d)!", x, y); - mpr( info, MSGCH_WARN ); + mprf(MSGCH_WARN,"Item position incorrect at (%d,%d)!",x,y); dump_item( mitm[obj].name(DESC_PLAIN).c_str(), obj, mitm[obj] ); } @@ -1084,8 +1059,8 @@ void debug_item_scan( void ) // this will also keep this from being an infinite loop. if (mitm[obj].flags & ISFLAG_DEBUG_MARK) { - snprintf( info, INFO_SIZE, "Potential INFINITE STACK at (%d, %d)", x, y); - mpr( info, MSGCH_WARN ); + mprf(MSGCH_WARN, + "Potential INFINITE STACK at (%d, %d)", x, y); break; } @@ -1109,9 +1084,8 @@ void debug_item_scan( void ) mpr( "Unlinked item:", MSGCH_WARN ); dump_item( name, i, mitm[i] ); - snprintf( info, INFO_SIZE, "igrd(%d,%d) = %d", mitm[i].x, mitm[i].y, - igrd[ mitm[i].x ][ mitm[i].y ] ); - mpr( info ); + mprf("igrd(%d,%d) = %d", + mitm[i].x, mitm[i].y, igrd[ mitm[i].x ][ mitm[i].y ] ); // Let's check to see if it's an errant monster object: for (int j = 0; j < MAX_MONSTERS; j++) @@ -1120,11 +1094,9 @@ void debug_item_scan( void ) { if (menv[j].inv[k] == i) { - snprintf( info, INFO_SIZE, "Held by monster #%d: %s at (%d,%d)", - j, ptr_monam( &menv[j], DESC_CAP_A ), - menv[j].x, menv[j].y ); - - mpr( info ); + mprf("Held by monster #%d: %s at (%d,%d)", + j, ptr_monam( &menv[j], DESC_CAP_A ), + menv[j].x, menv[j].y ); } } } @@ -1189,13 +1161,10 @@ void debug_item_scan( void ) if (strcmp( name, "program bug" ) == 0) { - mpr( "Program bug detected!", MSGCH_WARN ); - - snprintf( info, INFO_SIZE, - "Buggy monster detected: monster #%d; position (%d,%d)", - i, monster->x, monster->y ); - - mpr( info, MSGCH_WARN ); + mprf( MSGCH_WARN, "Program bug detected!" ); + mprf( MSGCH_WARN, + "Buggy monster detected: monster #%d; position (%d,%d)", + i, monster->x, monster->y ); } } } @@ -1368,10 +1337,9 @@ bool debug_add_mutation(void) mpr("I can't warp you that way!"); else { - snprintf( info, INFO_SIZE, "Found: %s", mutation_name( mutation, 1 ) ); - mpr( info ); + mprf("Found: %s", mutation_name( mutation, 1 ) ); - int levels = debug_prompt_for_int( "How many levels? ", false ); + const int levels = debug_prompt_for_int( "How many levels? ", false ); if (levels == 0) { diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc index 2167676223..9db98525e2 100644 --- a/crawl-ref/source/decks.cc +++ b/crawl-ref/source/decks.cc @@ -789,10 +789,9 @@ static void cards(unsigned char which_card) { dvar1 = 179 + you.religion; - snprintf( info, INFO_SIZE, "An altar grows from the floor %s!", - (you.species == SP_NAGA || you.species == SP_CENTAUR) - ? "before you" : "at your feet"); - mpr(info); + mprf("An altar grows from the floor %s!", + (you.species == SP_NAGA || you.species == SP_CENTAUR) + ? "before you" : "at your feet"); grd[you.x_pos][you.y_pos] = dvar1; } break; diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index 5d3fc4334f..7f155e9c96 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -356,10 +356,8 @@ void handle_delay( void ) if (delay.duration > 0) { #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "Delay type: %d (%s), duration: %d", - delay.type, delay_name(delay.type), delay.duration ); - - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "Delay type: %d (%s), duration: %d", + delay.type, delay_name(delay.type), delay.duration ); #endif // delay.duration-- *must* be done before multidrop, because // multidrop is now a parent delay, which means other delays @@ -537,10 +535,9 @@ static void finish_delay(const delay_queue_item &delay) } case DELAY_BUTCHER: - snprintf(info, INFO_SIZE, "You finish %s the corpse into pieces.", - (you.species == SP_TROLL || - you.species == SP_GHOUL) ? "ripping" : "chopping" ); - mpr(info); + mprf("You finish %s the corpse into pieces.", + (you.species==SP_TROLL || you.species == SP_GHOUL) ? "ripping" + : "chopping"); turn_corpse_into_chunks( mitm[ delay.parm1 ] ); @@ -577,11 +574,8 @@ static void finish_delay(const delay_queue_item &delay) } else { - snprintf( info, INFO_SIZE, "You drop %s.", - quant_name(you.inv[delay.parm1], delay.parm2, - DESC_NOCAP_A).c_str()); - mpr(info); - + mprf("You drop %s.", quant_name(you.inv[delay.parm1], delay.parm2, + DESC_NOCAP_A).c_str()); dec_inv_item_quantity( delay.parm1, delay.parm2 ); } break; diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index cf25b6d3af..7e0ade7933 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -441,14 +441,11 @@ void random_uselessness(unsigned char ru, unsigned char sc_read_2) break; case 6: - strcpy(info, "Your "); - temp_rand = random2(3); - - strcat(info, (temp_rand == 0) ? "ears itch." : - (temp_rand == 1) ? "brain hurts!" - : "nose twitches suddenly!"); - mpr(info); + mprf("Your %s", + (temp_rand == 0) ? "ears itch." : + (temp_rand == 1) ? "brain hurts!" + : "nose twitches suddenly!"); break; case 7: @@ -827,11 +824,9 @@ bool acquirement(unsigned char force_class, int agent) which_book: #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, - "acquirement: iteration = %d, best_spell = %d", - iteration, best_spell ); - - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, + "acquirement: iteration = %d, best_spell = %d", + iteration, best_spell ); #endif //jmf: debugging switch (best_spell) diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index 72379982ad..6d7d3028ac 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -943,8 +943,7 @@ found_stair: val -= (stepdown_value( check_stealth(), 50, 50, 150, 150 ) / 10); #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "arrival time: %d", val ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "arrival time: %d", val ); #endif if (val > 0) @@ -1114,9 +1113,8 @@ void load_ghost(void) { fclose(gfile); #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "Ghost file \"%s\" seems to be invalid.", - cha_fil.c_str()); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, + "Ghost file \"%s\" seems to be invalid.", cha_fil.c_str()); more(); #endif return; diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc index 6b45115643..07f03f5dc7 100644 --- a/crawl-ref/source/food.cc +++ b/crawl-ref/source/food.cc @@ -946,11 +946,9 @@ static void eating(unsigned char item_class, int item_type) mpr("That meat ration really hit the spot!"); break; case FOOD_BEEF_JERKY: - strcpy(info, "That beef jerky was "); - strcat(info, (one_chance_in(4)) ? "jerk-a-riffic" - : "delicious"); - strcat(info, "!"); - mpr(info); + mprf("That beef jerky was %s!", + one_chance_in(4) ? "jerk-a-riffic" + : "delicious"); break; default: break; @@ -967,12 +965,11 @@ static void eating(unsigned char item_class, int item_type) case FOOD_PEAR: case FOOD_APPLE: case FOOD_APRICOT: - strcpy(info, "Mmmm... Yummy "); - strcat(info, (item_type == FOOD_APPLE) ? "apple." : - (item_type == FOOD_PEAR) ? "pear." : - (item_type == FOOD_APRICOT) ? "apricot." - : "fruit."); - mpr(info); + mprf("Mmmm... Yummy %s.", + (item_type == FOOD_APPLE) ? "apple." : + (item_type == FOOD_PEAR) ? "pear." : + (item_type == FOOD_APRICOT) ? "apricot." + : "fruit."); break; case FOOD_CHOKO: mpr("That choko was very bland."); @@ -1026,39 +1023,33 @@ static void eating(unsigned char item_class, int item_type) break; case FOOD_PIZZA: if (SysEnv.crawl_pizza && !one_chance_in(3)) - snprintf(info, INFO_SIZE, "Mmm... %s", SysEnv.crawl_pizza); + mprf("Mmm... %s.", SysEnv.crawl_pizza); else { temp_rand = random2(9); - - snprintf(info, INFO_SIZE, "Mmm... %s", - (temp_rand == 0) ? "Ham and pineapple." : - (temp_rand == 2) ? "Vegetable." : - (temp_rand == 3) ? "Pepperoni." : - (temp_rand == 4) ? "Yeuchh - Anchovies!" : - (temp_rand == 5) ? "Cheesy." : - (temp_rand == 6) ? "Supreme." : - (temp_rand == 7) ? "Super Supreme!" - : "Chicken."); + mprf("Mmm... %s", + (temp_rand == 0) ? "Ham and pineapple." : + (temp_rand == 2) ? "Vegetable." : + (temp_rand == 3) ? "Pepperoni." : + (temp_rand == 4) ? "Yeuchh - Anchovies!" : + (temp_rand == 5) ? "Cheesy." : + (temp_rand == 6) ? "Supreme." : + (temp_rand == 7) ? "Super Supreme!" + : "Chicken."); } - mpr(info); break; case FOOD_CHEESE: - strcpy(info, "Mmm... "); temp_rand = random2(9); - - strcat(info, (temp_rand == 0) ? "Cheddar" : - (temp_rand == 1) ? "Edam" : - (temp_rand == 2) ? "Wensleydale" : - (temp_rand == 3) ? "Camembert" : - (temp_rand == 4) ? "Goat cheese" : - (temp_rand == 5) ? "Fruit cheese" : - (temp_rand == 6) ? "Mozzarella" : - (temp_rand == 7) ? "Sheep cheese" - : "Yak cheese"); - - strcat(info, "."); - mpr(info); + mprf("Mmm...%s.", + (temp_rand == 0) ? "Cheddar" : + (temp_rand == 1) ? "Edam" : + (temp_rand == 2) ? "Wensleydale" : + (temp_rand == 3) ? "Camembert" : + (temp_rand == 4) ? "Goat cheese" : + (temp_rand == 5) ? "Fruit cheese" : + (temp_rand == 6) ? "Mozzarella" : + (temp_rand == 7) ? "Sheep cheese" + : "Yak cheese"); break; case FOOD_SAUSAGE: mpr("That sausage was delicious!"); diff --git a/crawl-ref/source/insult.cc b/crawl-ref/source/insult.cc index 7b94c35a9d..f2fec225d3 100644 --- a/crawl-ref/source/insult.cc +++ b/crawl-ref/source/insult.cc @@ -53,15 +53,12 @@ void imp_taunt( const monsters *mons ) // XXX: Not pretty, but stops truncation... if (strlen( mon_name ) + 11 + strlen( buff ) >= 79) { - snprintf( info, INFO_SIZE, "%s shouts:", mon_name ); - mpr( info, MSGCH_TALK ); - - mpr( buff, MSGCH_TALK ); + mprf(MSGCH_TALK, "%s shouts:", mon_name ); + mprf(MSGCH_TALK, "%s", buff ); } else { - snprintf( info, INFO_SIZE, "%s shouts, \"%s\"", mon_name, buff ); - mpr( info, MSGCH_TALK ); + mprf(MSGCH_TALK, "%s shouts, \"%s\"", mon_name, buff ); } } @@ -132,15 +129,12 @@ void demon_taunt( const monsters *mons ) // XXX: Not pretty, but stops truncation... if (strlen(mon_name) + strlen(voice) + strlen(buff) + 5 >= 79) { - snprintf( info, INFO_SIZE, "%s %s:", mon_name, voice ); - mpr( info, MSGCH_TALK ); - - mpr( buff, MSGCH_TALK ); + mprf(MSGCH_TALK, "%s %s:", mon_name, voice ); + mprf(MSGCH_TALK, "%s", buff); } else { - snprintf( info, INFO_SIZE, "%s %s, \"%s\"", mon_name, voice, buff ); - mpr( info, MSGCH_TALK ); + mprf(MSGCH_TALK, "%s %s, \"%s\"", mon_name, voice, buff ); } } diff --git a/crawl-ref/source/it_use2.cc b/crawl-ref/source/it_use2.cc index 969683e7c8..2c32f6f91b 100644 --- a/crawl-ref/source/it_use2.cc +++ b/crawl-ref/source/it_use2.cc @@ -124,10 +124,8 @@ bool potion_effect( char pot_eff, int pow ) break; case POT_LEVITATION: - strcpy(info, "You feel"); - strcat(info, (!player_is_levitating()) ? " very" : " more"); - strcat(info, " buoyant."); - mpr(info); + mprf("You feel %s buoyant.", + (!player_is_levitating()) ? " very" : " more"); if (!player_is_levitating()) mpr("You gently float upwards from the floor."); @@ -144,17 +142,13 @@ bool potion_effect( char pot_eff, int pow ) case POT_STRONG_POISON: if (player_res_poison()) { - snprintf( info, INFO_SIZE, "You feel %s nauseous.", - (pot_eff == POT_POISON) ? "slightly" : "quite" ); - - mpr(info); + mprf("You feel %s nauseous.", + (pot_eff == POT_POISON) ? "slightly" : "quite" ); } else { - snprintf( info, INFO_SIZE, "That liquid tasted %s nasty...", - (pot_eff == POT_POISON) ? "very" : "extremely" ); - - mpr(info); + mprf("That liquid tasted %s nasty...", + (pot_eff == POT_POISON) ? "very" : "extremely" ); poison_player( ((pot_eff == POT_POISON) ? 1 + random2avg(5, 2) : 3 + random2avg(13, 2)) ); diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc index f738995135..1c870f648e 100644 --- a/crawl-ref/source/it_use3.cc +++ b/crawl-ref/source/it_use3.cc @@ -834,13 +834,11 @@ void tome_of_power(char sc_read_2) spell_type spell_casted = SPELL_NO_SPELL; struct bolt beam; - strcpy(info, "The book opens to a page covered in "); - char wc[30]; + char wc[40]; weird_writing( wc ); - strcat( info, wc ); - strcat( info, "." ); - mpr( info ); + + mprf("The book opens to a page covered in %s.", wc); you.turn_is_over = true; @@ -955,28 +953,21 @@ void tome_of_power(char sc_read_2) void skill_manual(char sc_read_2) { - char skname[30]; - set_ident_flags( you.inv[sc_read_2], ISFLAG_IDENT_MASK ); - strcpy(skname, skill_name(you.inv[sc_read_2].plus)); + const int skill = you.inv[sc_read_2].plus; - strcpy(info, "This is a manual of "); - strcat(info, skname); - strcat(info, "!"); - mpr(info); + const char* skname = skill_name(skill); + mprf("This is a manual of %s!", skname); you.turn_is_over = true; if (!yesno("Read it?")) return; - strcpy(info, "You read about "); - strcat(info, strlwr(skname)); - strcat(info, "."); - mpr(info); + mprf("You read about %s.", skname); - exercise( you.inv[sc_read_2].plus, 500 ); + exercise(skill, 500); if (one_chance_in(10)) { diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 8fd396f0e4..88866eec89 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -2633,11 +2633,9 @@ void zap_wand(void) mpr("Your skill with magical items lets you calculate the power of this device..."); } - snprintf( info, INFO_SIZE, "This wand has %d charge%s left.", - you.inv[item_slot].plus, - (you.inv[item_slot].plus == 1) ? "" : "s" ); - - mpr(info); + mprf("This wand has %d charge%s left.", + you.inv[item_slot].plus, + (you.inv[item_slot].plus == 1) ? "" : "s" ); set_ident_flags( you.inv[item_slot], ISFLAG_KNOW_PLUSES ); } @@ -2825,7 +2823,7 @@ bool drink_fountain(void) return true; } // end drink_fountain() -static bool affix_weapon_enchantment( void ) +static bool affix_weapon_enchantment() { const int wpn = you.equip[ EQ_WEAPON ]; bool success = true; @@ -2835,6 +2833,8 @@ static bool affix_weapon_enchantment( void ) if (wpn == -1 || !you.duration[ DUR_WEAPON_BRAND ]) return (false); + strcpy(info, you.inv[wpn].name(DESC_CAP_YOUR).c_str()); + switch (get_weapon_brand( you.inv[wpn] )) { case SPWPN_VORPAL: @@ -3409,14 +3409,14 @@ void read_scroll(void) case SCR_ENCHANT_WEAPON_III: if (you.equip[ EQ_WEAPON ] != -1) { - // Get the name before it changes. - const std::string iname = - you.inv[you.equip[EQ_WEAPON]].name(DESC_CAP_YOUR); // Successfully affixing the enchantment will print // its own message. if (!affix_weapon_enchantment()) { + const std::string iname = + you.inv[you.equip[EQ_WEAPON]].name(DESC_CAP_YOUR); + mprf("%s glows bright yellow for a while.", iname.c_str() ); enchant_weapon( ENCHANT_TO_HIT, true ); diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index e06ebe4c13..22ef3e05d7 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -519,17 +519,13 @@ static void describe_floor() { { if (grid >= DNGN_STONE_STAIRS_DOWN_I && grid <= DNGN_ROCK_STAIRS_DOWN) { - snprintf( info, INFO_SIZE, "There is a %s staircase leading down here.", - (grid == DNGN_ROCK_STAIRS_DOWN) ? "rock" : "stone" ); - - mpr(info); + mprf("There is a %s staircase leading down here.", + (grid == DNGN_ROCK_STAIRS_DOWN) ? "rock" : "stone" ); } else if (grid >= DNGN_STONE_STAIRS_UP_I && grid <= DNGN_ROCK_STAIRS_UP) { - snprintf( info, INFO_SIZE, "There is a %s staircase leading upwards here.", - (grid == DNGN_ROCK_STAIRS_UP) ? "rock" : "stone" ); - - mpr(info); + mprf("There is a %s staircase leading upwards here.", + (grid == DNGN_ROCK_STAIRS_UP) ? "rock" : "stone" ); } else { @@ -551,8 +547,8 @@ static void describe_floor() { mpr("There is a gateway to the Iron City of Dis here."); break; case DNGN_ENTER_SHOP: - snprintf( info, INFO_SIZE, "There is an entrance to %s here.", shop_name(you.x_pos, you.y_pos)); - mpr(info); + mprf("There is an entrance to %s here.", + shop_name(you.x_pos, you.y_pos)); break; case DNGN_ENTER_LABYRINTH: mpr("There is an entrance to a labyrinth here."); @@ -807,11 +803,7 @@ void item_check(char keyin) if (counter_max == 1) { - strcpy(info, "You see here "); // remember 'an'. - - strcat(info, item_show[counter_max]); - strcat(info, "."); - mpr(info); + mprf("You see here %s.", item_show[counter_max]); // remember 'an'. counter++; counter_max = 0; // to skip next part. @@ -1290,9 +1282,8 @@ void pickup() if (keyin != 'a') { - snprintf( info, INFO_SIZE, "Pick up %s? (y/n/a/*?g,/q)", - mitm[o].name(DESC_NOCAP_A).c_str() ); - mpr( info, MSGCH_PROMPT ); + mprf(MSGCH_PROMPT, "Pick up %s? (y/n/a/*?g,/q)", + mitm[o].name(DESC_NOCAP_A).c_str() ); keyin = get_ch(); } @@ -1497,10 +1488,8 @@ int move_item_to_player( int obj, int quant_got, bool quiet ) if (!quiet) { - snprintf( info, INFO_SIZE, "You pick up %d gold piece%s.", - quant_got, (quant_got > 1) ? "s" : "" ); - - mpr(info); + mprf("You pick up %d gold piece%s.", + quant_got, (quant_got > 1) ? "s" : "" ); } you.turn_is_over = true; @@ -2116,8 +2105,7 @@ void update_level( double elapsedTime ) #if DEBUG_DIAGNOSTICS int mons_total = 0; - snprintf( info, INFO_SIZE, "turns: %d", turns ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "turns: %d", turns ); #endif update_corpses( elapsedTime ); @@ -2176,12 +2164,11 @@ void update_level( double elapsedTime ) #if DEBUG_DIAGNOSTICS // probably too annoying even for DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, - "mon #%d: range %d; long %d; pos (%d,%d); targ %d(%d,%d); flags %ld", - m, range, long_time, mon->x, mon->y, - mon->foe, mon->target_x, mon->target_y, mon->flags ); - - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, + "mon #%d: range %d; long %d; " + "pos (%d,%d); targ %d(%d,%d); flags %ld", + m, range, long_time, mon->x, mon->y, + mon->foe, mon->target_x, mon->target_y, mon->flags ); #endif if (range <= 0) @@ -2243,8 +2230,7 @@ void update_level( double elapsedTime ) shift_monster( mon, mon->x, mon->y ); #if DEBUG_DIAGNOSTICS - snprintf(info, INFO_SIZE, "shifted to (%d,%d)", mon->x, mon->y); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "shifted to (%d,%d)", mon->x, mon->y); #endif continue; } @@ -2289,14 +2275,12 @@ void update_level( double elapsedTime ) shift_monster( mon, mon->x, mon->y ); #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "moved to (%d,%d)", mon->x, mon->y ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "moved to (%d,%d)", mon->x, mon->y ); #endif } #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "total monsters on level = %d", mons_total ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "total monsters on level = %d", mons_total ); #endif for (i = 0; i < MAX_CLOUDS; i++) diff --git a/crawl-ref/source/macro.cc b/crawl-ref/source/macro.cc index 17b7fa0c49..4eac355975 100644 --- a/crawl-ref/source/macro.cc +++ b/crawl-ref/source/macro.cc @@ -630,25 +630,20 @@ void macro_add_query( void ) // reference to the appropriate mapping macromap &mapref = (keymap ? Keymaps[keymc] : Macros); - snprintf( info, INFO_SIZE, "Input %s%s trigger key: ", - keymap? - (keymc == KC_DEFAULT? "default " : - keymc == KC_LEVELMAP? "level-map " : - "targeting ") : - "", - (keymap ? "keymap" : "macro") ); - - mpr( info, MSGCH_PROMPT ); + mprf(MSGCH_PROMPT, "Input %s%s trigger key: ", + keymap ? (keymc == KC_DEFAULT ? "default " : + keymc == KC_LEVELMAP ? "level-map " + : "targeting ") + : "", + (keymap ? "keymap" : "macro") ); + keyseq key = getch_mul(); cprintf( "%s" EOL, (vtostr( key )).c_str() ); // echo key to screen if (mapref[key].size() > 0) { - snprintf( info, INFO_SIZE, "Current Action: %s", - (vtostr( mapref[key] )).c_str() ); - - mpr( info, MSGCH_WARN ); + mprf(MSGCH_WARN, "Current Action: %s", vtostr(mapref[key]).c_str()); mpr( "Do you wish to (r)edefine, (c)lear, or (a)bort?", MSGCH_PROMPT ); input = getch(); diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 863dd3ea82..e1fed13fb5 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -824,11 +824,8 @@ void down_stairs( bool remove_stairs, int old_level, int force_stair ) break; default: - snprintf( info, INFO_SIZE, - "You need at least %d Runes to enter this place.", - NUMBER_OF_RUNES_NEEDED ); - - mpr(info); + mprf( "You need at least %d Runes to enter this place.", + NUMBER_OF_RUNES_NEEDED ); } return; } @@ -1195,9 +1192,7 @@ static void dart_trap( bool trap_known, int trapped, struct bolt &pbolt, if (random2(10) < 2 || (trap_known && !one_chance_in(4))) { - snprintf( info, INFO_SIZE, "You avoid triggering a%s trap.", - pbolt.name.c_str() ); - mpr(info); + mprf( "You avoid triggering a%s trap.", pbolt.name.c_str() ); return; } diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index cb35349277..0bd81b26ba 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -711,11 +711,9 @@ bool check_mons_resist_magic( const monsters *monster, int pow ) const int mrch2 = random2(100) + random2(101); #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, - "Power: %d, monster's MR: %d, target: %d, roll: %d", - pow, mrs, mrchance, mrch2 ); - - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, + "Power: %d, monster's MR: %d, target: %d, roll: %d", + pow, mrs, mrchance, mrch2 ); #endif return (mrch2 < mrchance); @@ -3381,8 +3379,7 @@ void monsters::apply_enchantment(mon_enchant me, int spd) // for debugging, we don't have this silent. simple_monster_message( this, " takes poison damage.", MSGCH_DIAGNOSTICS ); - snprintf( info, INFO_SIZE, "poison damage: %d", dam ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "poison damage: %d", dam ); #endif if (hit_points < 1) diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 95398e679c..305defc058 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -517,16 +517,14 @@ void monster_die(monsters *monster, char killer, int i, bool silent) bool created_friendly = testbits(monster->flags, MF_CREATED_FRIENDLY); - if (!silent) + if (death_message) { snprintf(info, INFO_SIZE, "You %s %s!", wounded_damaged(monster->type) ? "destroy" : "kill", ptr_monam(monster, DESC_NOCAP_THE)); - } - - if (death_message) mpr(info, MSGCH_MONSTER_DAMAGE, MDAM_DEAD); + } if (!created_friendly) { @@ -4766,10 +4764,9 @@ forget_it: if (testbits( monster->flags, MF_TAKING_STAIRS )) { #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "%s is skipping movement in order to follow.", - ptr_monam( monster, DESC_CAP_THE ) ); - - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, + "%s is skipping movement in order to follow.", + ptr_monam( monster, DESC_CAP_THE ) ); #endif mmov_x = 0; mmov_y = 0; diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc index 99b4a6a6be..f4b073af07 100644 --- a/crawl-ref/source/mstuff2.cc +++ b/crawl-ref/source/mstuff2.cc @@ -221,10 +221,9 @@ void mons_trap(struct monsters *monster) && !silenced(you.x_pos, you.y_pos)) { if (monsterNearby) - strcpy(info, "You hear a loud \"Zot\"!"); + mpr("You hear a loud \"Zot\"!"); else - strcpy(info, "You hear a distant \"Zot\"!"); - mpr(info); + mpr("You hear a distant \"Zot\"!"); } // determine trap effects upon monster, based upon @@ -405,10 +404,8 @@ void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast) int duration = 0; #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "Mon #%d casts %s (#%d)", monster_index(monster), - mons_spell_name( spell_cast ), spell_cast ); - - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "Mon #%d casts %s (#%d)", + monster_index(monster), mons_spell_name( spell_cast ), spell_cast); #endif if (spell_cast == SPELL_HELLFIRE_BURST || spell_cast == SPELL_BRAIN_FEED @@ -1331,7 +1328,7 @@ void spore_goes_pop(struct monsters *monster) if (mons_near(monster)) { viewwindow(1, false); - mpr( info ); + mpr(info); } explosion(beam); diff --git a/crawl-ref/source/mutation.cc b/crawl-ref/source/mutation.cc index b7ccb59f42..7245a2b182 100644 --- a/crawl-ref/source/mutation.cc +++ b/crawl-ref/source/mutation.cc @@ -1634,8 +1634,7 @@ int how_mutated(void) } #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "levels: %d", j ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "levels: %d", j ); #endif return (j); diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc index 36e40c5b7c..3266dfc497 100644 --- a/crawl-ref/source/newgame.cc +++ b/crawl-ref/source/newgame.cc @@ -437,7 +437,8 @@ bool new_game(void) clrscr(); char spec_buff[80]; - strncpy(spec_buff, species_name(you.species, you.experience_level), 80); + strncpy(spec_buff, + species_name(you.species, you.experience_level), 80); snprintf( info, INFO_SIZE, "You are a%s %s %s." EOL, (is_vowel( spec_buff[0] )) ? "n" : "", spec_buff, diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index 41fd58617b..c1a772b2a8 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -84,8 +84,7 @@ int check_your_resists(int hurted, int flavour) int resist; #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "checking resistance: flavour=%d", flavour ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "checking resistance: flavour=%d", flavour ); #endif if (flavour == BEAM_FIRE || flavour == BEAM_LAVA @@ -308,9 +307,7 @@ void weapon_acid( char acid_strength ) if (hand_thing == -1) { - snprintf( info, INFO_SIZE, "Your %s burn!", your_hand(true) ); - mpr( info ); - + mprf("Your %s burn!", your_hand(true) ); ouch( roll_dice( 1, acid_strength ), 0, KILLED_BY_ACID ); } else if (random2(20) <= acid_strength) @@ -518,30 +515,28 @@ static void expose_invent_to_element( beam_type flavour, int strength ) switch (target_class) { case OBJ_SCROLLS: - snprintf( info, INFO_SIZE, "%s you are carrying %s fire!", - (num_dest > 1) ? "Some of the scrolls" : "A scroll", - (num_dest > 1) ? "catch" : "catches" ); + mprf("%s you are carrying %s fire!", + (num_dest > 1) ? "Some of the scrolls" : "A scroll", + (num_dest > 1) ? "catch" : "catches" ); break; case OBJ_POTIONS: - snprintf( info, INFO_SIZE, "%s you are carrying %s and %s!", - (num_dest > 1) ? "Some of the potions" : "A potion", - (num_dest > 1) ? "freeze" : "freezes", - (num_dest > 1) ? "shatter" : "shatters" ); + mprf("%s you are carrying %s and %s!", + (num_dest > 1) ? "Some of the potions" : "A potion", + (num_dest > 1) ? "freeze" : "freezes", + (num_dest > 1) ? "shatter" : "shatters" ); break; case OBJ_FOOD: - snprintf( info, INFO_SIZE, "Some of your food is covered with spores!" ); + mprf("Some of your food is covered with spores!"); break; default: - snprintf( info, INFO_SIZE, "%s you are carrying %s destroyed!", - (num_dest > 1) ? "Some items" : "An item", - (num_dest > 1) ? "were" : "was" ); + mprf("%s you are carrying %s destroyed!", + (num_dest > 1) ? "Some items" : "An item", + (num_dest > 1) ? "were" : "was" ); break; } - - mpr( info ); // XXX: should this be in a channel? } } @@ -586,9 +581,8 @@ void lose_level(void) you.experience = exp_needed( you.experience_level + 1 ) - 1; you.experience_level--; - snprintf( info, INFO_SIZE, "You are now a level %d %s!", - you.experience_level, you.class_name ); - mpr( info, MSGCH_WARN ); + mprf(MSGCH_WARN, + "You are now a level %d %s!", you.experience_level, you.class_name); // Constant value to avoid grape jelly trick... see level_change() for // where these HPs and MPs are given back. -- bwr @@ -658,9 +652,7 @@ void drain_exp(void) you.exp_available = 0; #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "You lose %ld experience points.", - exp_drained ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "You lose %ld experience points.",exp_drained); #endif you.redraw_experience = 1; @@ -685,9 +677,8 @@ void ouch( int dam, int death_source, char death_type, const char *aux ) // assumed bug for high damage amounts if (dam > 300) { - snprintf( info, INFO_SIZE, - "Potential bug: Unexpectedly high damage = %d", dam ); - mpr( info, MSGCH_DANGER ); + mprf(MSGCH_DANGER, + "Potential bug: Unexpectedly high damage = %d", dam ); return; } @@ -755,9 +746,8 @@ void ouch( int dam, int death_source, char death_type, const char *aux ) #ifdef USE_OPTIONAL_WIZARD_DEATH #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "Damage: %d; Hit points: %d", dam, you.hp ); - mpr( info, MSGCH_DIAGNOSTICS ); -#endif // DEBUG_DIAGNOSTICS + mprf(MSGCH_DIAGNOSTICS, "Damage: %d; Hit points: %d", dam, you.hp); +#endif if (!yesno("Die?", false, 'n')) { diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 42d78f93b1..b6980b4085 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -2158,10 +2158,9 @@ bool you_resist_magic(int power) int mrch2 = random2(100) + random2(101); #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "Power: %d, player's MR: %d, target: %d, roll: %d", - ench_power, player_res_magic(), mrchance, mrch2 ); - - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, + "Power: %d, player's MR: %d, target: %d, roll: %d", + ench_power, player_res_magic(), mrchance, mrch2 ); #endif if (mrch2 < mrchance) @@ -2199,8 +2198,7 @@ void gain_exp( unsigned int exp_gained ) } #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "gain_exp: %d", exp_gained ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "gain_exp: %d", exp_gained ); #endif if (you.experience + exp_gained > 8999999) @@ -2234,10 +2232,8 @@ void level_change(void) if (you.experience_level <= you.max_level) { - snprintf( info, INFO_SIZE, "Welcome back to level %d!", - you.experience_level ); - - mpr(info, MSGCH_INTRINSIC_GAIN); + mprf(MSGCH_INTRINSIC_GAIN, + "Welcome back to level %d!", you.experience_level ); more(); // Gain back the hp and mp we lose in lose_level(). -- bwr @@ -2246,10 +2242,8 @@ void level_change(void) } else // character has gained a new level { - snprintf( info, INFO_SIZE, "You are now a level %d %s!", - you.experience_level, you.class_name ); - - mpr(info, MSGCH_INTRINSIC_GAIN); + mprf(MSGCH_INTRINSIC_GAIN, "You are now a level %d %s!", + you.experience_level, you.class_name ); more(); int brek = 0; @@ -2942,7 +2936,7 @@ void ability_increase(void) /* this is an infinite loop because it is reasonable to assume that you're not going to want to leave it prematurely. */ } // end ability_increase() -void display_char_status(void) +void display_char_status() { if (you.is_undead) mpr( "You are undead." ); @@ -3071,54 +3065,50 @@ void display_char_status(void) if (you.poisoning) { - snprintf( info, INFO_SIZE, "You are %s poisoned.", - (you.poisoning > 10) ? "extremely" : - (you.poisoning > 5) ? "very" : - (you.poisoning > 3) ? "quite" - : "mildly" ); - mpr(info); + mprf("You are %s poisoned.", + (you.poisoning > 10) ? "extremely" : + (you.poisoning > 5) ? "very" : + (you.poisoning > 3) ? "quite" + : "mildly" ); } if (you.disease) { - snprintf( info, INFO_SIZE, "You are %sdiseased.", - (you.disease > 120) ? "badly " : - (you.disease > 40) ? "" - : "mildly " ); - mpr(info); + mprf("You are %sdiseased.", + (you.disease > 120) ? "badly " : + (you.disease > 40) ? "" + : "mildly " ); } if (you.rotting || you.species == SP_GHOUL) { // I apologize in advance for the horrendous ugliness about to // transpire. Avert your eyes! - snprintf( info, INFO_SIZE, "Your flesh is rotting%s", - (you.rotting > 15) ? " before your eyes!": - (you.rotting > 8) ? " away quickly.": - (you.rotting > 4) ? " badly." - : ((you.species == SP_GHOUL && you.rotting > 0) - ? " faster than usual." : ".") ); - mpr(info); + mprf("Your flesh is rotting%s", + (you.rotting > 15) ? " before your eyes!" : + (you.rotting > 8) ? " away quickly." : + (you.rotting > 4) ? " badly." : + ((you.species == SP_GHOUL && you.rotting) ? + " faster than usual." : ".") ); } + // prints a contamination message contaminate_player( 0, true ); if (you.confusing_touch) { - snprintf( info, INFO_SIZE, "Your hands are glowing %s red.", - (you.confusing_touch > 40) ? "an extremely bright" : - (you.confusing_touch > 20) ? "bright" - : "a soft" ); - mpr(info); + mprf("Your hands are glowing %s red.", + (you.confusing_touch > 40) ? "an extremely bright" : + (you.confusing_touch > 20) ? "bright" + : "a soft" ); } if (you.sure_blade) { - snprintf( info, INFO_SIZE, "You have a %sbond with your blade.", - (you.sure_blade > 15) ? "strong " : - (you.sure_blade > 5) ? "" - : "weak " ); - mpr(info); + mprf("You have a %sbond with your blade.", + (you.sure_blade > 15) ? "strong " : + (you.sure_blade > 5) ? "" + : "weak " ); } int move_cost = (player_speed() * player_movement_speed()) / 10; @@ -3131,28 +3121,27 @@ void display_char_status(void) const bool lev = player_is_levitating(); const bool fly = (lev && you.duration[DUR_CONTROLLED_FLIGHT]); const bool swift = (you.duration[DUR_SWIFTNESS] > 0); - snprintf( info, INFO_SIZE, - "Your %s speed is %s%s%s.", - // order is important for these: - (swim) ? "swimming" : - (water) ? "wading" : - (fly) ? "flying" : - (lev) ? "levitating" - : "movement", - - (water && !swim) ? "uncertain and " : - (!water && swift) ? "aided by the wind" : "", - - (!water && swift) ? ((move_cost >= 10) ? ", but still " - : " and ") - : "", - - (move_cost < 8) ? "very quick" : - (move_cost < 10) ? "quick" : - (move_cost == 10) ? "average" : - (move_cost < 13) ? "slow" - : "very slow" ); - mpr(info); + + mprf( "Your %s speed is %s%s%s.", + // order is important for these: + (swim) ? "swimming" : + (water) ? "wading" : + (fly) ? "flying" : + (lev) ? "levitating" + : "movement", + + (water && !swim) ? "uncertain and " : + (!water && swift) ? "aided by the wind" : "", + + (!water && swift) ? ((move_cost >= 10) ? ", but still " + : " and ") + : "", + + (move_cost < 8) ? "very quick" : + (move_cost < 10) ? "quick" : + (move_cost == 10) ? "average" : + (move_cost < 13) ? "slow" + : "very slow" ); const int to_hit = calc_your_to_hit( false ) * 2; // Messages based largely on percentage chance of missing the @@ -3162,67 +3151,57 @@ void display_char_status(void) // "awkward" - need lucky hit (less than EV) // "difficult" - worse than 2 in 3 // "hard" - worse than fair chance - snprintf( info, INFO_SIZE, - "%s given your current equipment.", - (to_hit < 1) ? "You are completely incapable of fighting" : - (to_hit < 5) ? "Hitting even clumsy monsters is extremely awkward" : - (to_hit < 10) ? "Hitting average monsters is awkward" : - (to_hit < 15) ? "Hitting average monsters is difficult" : - (to_hit < 20) ? "Hitting average monsters is hard" : - (to_hit < 30) ? "Very agile monsters are a bit awkward to hit" : - (to_hit < 45) ? "Very agile monsters are a bit difficult to hit" : - (to_hit < 60) ? "Very agile monsters are a bit hard to hit" : - (to_hit < 100) ? "You feel comfortable with your ability to fight" - : "You feel confident with your ability to fight" ); - + mprf("%s given your current equipment.", + (to_hit < 1) ? "You are completely incapable of fighting" : + (to_hit < 5) ? "Hitting even clumsy monsters is extremely awkward" : + (to_hit < 10) ? "Hitting average monsters is awkward" : + (to_hit < 15) ? "Hitting average monsters is difficult" : + (to_hit < 20) ? "Hitting average monsters is hard" : + (to_hit < 30) ? "Very agile monsters are a bit awkward to hit" : + (to_hit < 45) ? "Very agile monsters are a bit difficult to hit" : + (to_hit < 60) ? "Very agile monsters are a bit hard to hit" : + (to_hit < 100) ? "You feel comfortable with your ability to fight" + : "You feel confident with your ability to fight" ); + #if DEBUG_DIAGNOSTICS - char str_pass[INFO_SIZE]; - snprintf( str_pass, INFO_SIZE, " (%d)", to_hit ); - strncat( info, str_pass, INFO_SIZE ); + mprf("To-hit: %d", to_hit); #endif - mpr(info); - // magic resistance const int mr = player_res_magic(); - snprintf(info, INFO_SIZE, "You are %s resistant to magic.", - (mr < 10) ? "not" : - (mr < 30) ? "slightly" : - (mr < 60) ? "somewhat" : - (mr < 90) ? "quite" : - (mr < 120) ? "very" : - (mr < 140) ? "extremely" : - "incredibly"); - mpr(info); + mprf("You are %s resistant to magic.", + (mr < 10) ? "not" : + (mr < 30) ? "slightly" : + (mr < 60) ? "somewhat" : + (mr < 90) ? "quite" : + (mr < 120) ? "very" : + (mr < 140) ? "extremely" + : "incredibly"); // character evaluates their ability to sneak around: const int ustealth = check_stealth(); // XXX: made these values up, probably could be better. - snprintf( info, INFO_SIZE, "You feel %sstealthy.", - (ustealth < 10) ? "extremely un" : - (ustealth < 20) ? "very un" : - (ustealth < 30) ? "un" : - (ustealth < 50) ? "fairly " : - (ustealth < 80) ? "" : - (ustealth < 120) ? "quite " : - (ustealth < 160) ? "very " : - (ustealth < 200) ? "extremely " - : "incredibly " ); + mprf("You feel %sstealthy.", + (ustealth < 10) ? "extremely un" : + (ustealth < 20) ? "very un" : + (ustealth < 30) ? "un" : + (ustealth < 50) ? "fairly " : + (ustealth < 80) ? "" : + (ustealth < 120) ? "quite " : + (ustealth < 160) ? "very " : + (ustealth < 200) ? "extremely " + : "incredibly " ); #if DEBUG_DIAGNOSTICS - snprintf( str_pass, INFO_SIZE, " (%d)", ustealth ); - strncat( info, str_pass, INFO_SIZE ); + mprf("stealth: %d", ustealth); #endif - - mpr( info ); } // end display_char_status() void redraw_skill(const char your_name[kNameLen], const char class_name[80]) { char print_it[80]; - memset( print_it, ' ', sizeof(print_it) ); snprintf( print_it, sizeof(print_it), "%s the %s", your_name, class_name ); int in_len = strlen( print_it ); @@ -4179,10 +4158,8 @@ void contaminate_player(int change, bool statusOnly) #if DEBUG_DIAGNOSTICS if (change > 0 || (change < 0 && you.magic_contamination)) { - snprintf( info, INFO_SIZE, "change: %d radiation: %d", - change, change + you.magic_contamination ); - - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "change: %d radiation: %d", + change, change + you.magic_contamination ); } #endif @@ -4216,20 +4193,18 @@ void contaminate_player(int change, bool statusOnly) { if (new_level > 3) { - strcpy(info, (new_level == 4) ? - "Your entire body has taken on an eerie glow!" : - "You are engulfed in a nimbus of crackling magics!"); + mpr( (new_level == 4) ? + "Your entire body has taken on an eerie glow!" : + "You are engulfed in a nimbus of crackling magics!"); } else { - snprintf( info, INFO_SIZE, "You are %s with residual magics%c", - (new_level == 3) ? "practically glowing" : - (new_level == 2) ? "heavily infused" - : "contaminated", - (new_level == 3) ? '!' : '.'); + mprf("You are %s with residual magics%s", + (new_level == 3) ? "practically glowing" : + (new_level == 2) ? "heavily infused" + : "contaminated", + (new_level == 3) ? "!" : "."); } - - mpr(info); } return; } @@ -4237,10 +4212,9 @@ void contaminate_player(int change, bool statusOnly) if (new_level == old_level) return; - snprintf( info, INFO_SIZE, "You feel %s contaminated with magical energies.", - (change < 0) ? "less" : "more" ); - - mpr( info, (change > 0) ? MSGCH_WARN : MSGCH_RECOVERY ); + mprf((change > 0) ? MSGCH_WARN : MSGCH_RECOVERY, + "You feel %s contaminated with magical energies.", + (change > 0) ? "more" : "less" ); } void poison_player( int amount, bool force ) @@ -4256,11 +4230,8 @@ void poison_player( int amount, bool force ) if (you.poisoning > old_value) { - snprintf( info, INFO_SIZE, "You are %spoisoned.", - (old_value > 0) ? "more " : "" ); - // XXX: which message channel for this message? - mpr( info ); + mprf("You are %spoisoned.", (old_value > 0) ? "more " : "" ); learned_something_new(TUT_YOU_POISON); } } @@ -4302,11 +4273,8 @@ void confuse_player( int amount, bool resistable ) if (you.conf > old_value) { - snprintf( info, INFO_SIZE, "You are %sconfused.", - (old_value > 0) ? "more " : "" ); - // XXX: which message channel for this message? - mpr( info ); + mprf("You are %sconfused.", (old_value > 0) ? "more " : "" ); learned_something_new(TUT_YOU_ENCHANTED); } } @@ -4453,9 +4421,8 @@ void rot_player( int amount ) { // Either this, or the actual rotting message should probably // be changed so that they're easier to tell apart. -- bwr - snprintf( info, INFO_SIZE, "You feel your flesh %s away!", - (you.rotting) ? "rotting" : "start to rot" ); - mpr( info, MSGCH_WARN ); + mprf(MSGCH_WARN, "You feel your flesh %s away!", + (you.rotting) ? "rotting" : "start to rot" ); you.rotting += amount; } diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 319d39af0f..14a403ca42 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -2588,11 +2588,7 @@ void offer_items() void god_pitch(unsigned char which_god) { - strcpy(info, "You kneel at the altar of "); - strcat(info, god_name(which_god)); - strcat(info, "."); - mpr(info); - + mprf("You kneel at the altar of %s.", god_name(which_god)); more(); // Note: using worship we could make some gods not allow followers to diff --git a/crawl-ref/source/shopping.cc b/crawl-ref/source/shopping.cc index 8092f69fde..5225109309 100644 --- a/crawl-ref/source/shopping.cc +++ b/crawl-ref/source/shopping.cc @@ -128,11 +128,11 @@ char in_a_shop( char shoppy, id_arr id ) clrscr(); int itty = 0; + ShopInfo &si = stashes.get_shop(env.shop[shoppy].x, env.shop[shoppy].y); + snprintf( info, INFO_SIZE, "Welcome to %s!", shop_name(env.shop[shoppy].x, env.shop[shoppy].y) ); - ShopInfo &si = stashes.get_shop(env.shop[shoppy].x, env.shop[shoppy].y); - shop_print(info, 20); more3(); diff --git a/crawl-ref/source/skills.cc b/crawl-ref/source/skills.cc index 239dba8259..50c3007374 100644 --- a/crawl-ref/source/skills.cc +++ b/crawl-ref/source/skills.cc @@ -388,10 +388,10 @@ static int exercise2( int exsk ) exercised and how much you spent on it. Too irritating to be a regular WIZARD feature. + #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "Exercised %s * %d for %d xp.", - skill_name(exsk), skill_inc, skill_change ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf( MSGCH_DIAGNOSTICS, "Exercised %s * %d for %d xp.", + skill_name(exsk), skill_inc, skill_change ); #endif */ @@ -403,20 +403,22 @@ static int exercise2( int exsk ) you.skills[exsk]++; take_note(Note(NOTE_GAIN_SKILL, exsk, you.skills[exsk])); - if (you.skills[exsk] == 27) { - snprintf( info, INFO_SIZE, "You have mastered %s!", - skill_name( exsk ) ); + if (you.skills[exsk] == 27) + { + mprf(MSGCH_INTRINSIC_GAIN, + "You have mastered %s!", skill_name( exsk ) ); } - else if (you.skills[exsk] == 1) { - snprintf( info, INFO_SIZE, "You have gained %s skill!", - skill_name( exsk ) ); + else if (you.skills[exsk] == 1) + { + mprf(MSGCH_INTRINSIC_GAIN, + "You have gained %s skill!", skill_name( exsk ) ); } - else { - snprintf( info, INFO_SIZE, "Your %s skill increases to level %d!", - skill_name( exsk ), you.skills[exsk] ); + else + { + mprf(MSGCH_INTRINSIC_GAIN, "Your %s skill increases to level %d!", + skill_name( exsk ), you.skills[exsk] ); } - mpr( info, MSGCH_INTRINSIC_GAIN ); learned_something_new(TUT_SKILL_RAISE); // Recalculate this skill's order for tie breaking skills diff --git a/crawl-ref/source/skills2.cc b/crawl-ref/source/skills2.cc index 948847c26f..39106b0d28 100644 --- a/crawl-ref/source/skills2.cc +++ b/crawl-ref/source/skills2.cc @@ -2352,27 +2352,21 @@ void wield_warning(bool newWeapon) if (you.strength < you.dex) { if (you.strength < 11) - snprintf( info, INFO_SIZE, "You have %strouble swinging %s.", + mprf(MSGCH_WARN, "You have %strouble swinging %s.", (you.strength < 7)?"":"a little ", wepstr); else - snprintf( info, INFO_SIZE, "You'd be more effective with " + mprf(MSGCH_WARN, "You'd be more effective with " "%s if you were stronger.", wepstr); } else { if (you.dex < 11) - { - snprintf( info, INFO_SIZE, "Wielding %s is %s awkward.", - wepstr, (you.dex < 7) ? "fairly" : "a little" ); - } + mprf(MSGCH_WARN, "Wielding %s is %s awkward.", + wepstr, (you.dex < 7) ? "fairly" : "a little" ); else - { - snprintf( info, INFO_SIZE, "You'd be more effective with " + mprf(MSGCH_WARN, "You'd be more effective with " "%s if you were nimbler.", wepstr ); - } } - - mpr( info, MSGCH_WARN ); } #endif return; @@ -2406,9 +2400,9 @@ void wield_warning(bool newWeapon) if (shoot_skill > effSkill) { - strcpy( info, "Your low throwing skill limits the effectiveness of "); - strcat( info, wepstr ); - mpr( info, MSGCH_WARN ); + mprf(MSGCH_WARN, + "Your low throwing skill limits the effectiveness of %s.", + wepstr); } #endif } diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index c4695d2c80..0a80fdde88 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -514,10 +514,7 @@ static int healing_spell( int healed ) if (heal_monster(monster, healed, false)) { - strcpy(info, "You heal "); - strcat(info, ptr_monam( monster, DESC_NOCAP_THE )); - strcat(info, "."); - mpr(info); + mprf("You heal %s.", ptr_monam( monster, DESC_NOCAP_THE )); if (monster->hit_points == monster->max_hit_points) simple_monster_message( monster, " is completely healed." ); @@ -1073,10 +1070,8 @@ void cast_ring_of_flames(int power) void cast_confusing_touch(int power) { - snprintf( info, INFO_SIZE, "Your %s begin to glow %s.", - your_hand(true), (you.confusing_touch ? "brighter" : "red") ); - - mpr( info ); + mprf("Your %s begin to glow %s.", + your_hand(true), (you.confusing_touch ? "brighter" : "red") ); you.confusing_touch += 5 + (random2(power) / 5); diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index 5bd2c3dbe0..c101b63c13 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -465,8 +465,7 @@ void cast_twisted(int power, int corps_beh, int corps_hit) } #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "Mass for abomination: %d", total_mass); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "Mass for abomination: %d", total_mass); #endif // This is what the old statement pretty much boils down to, @@ -477,8 +476,7 @@ void cast_twisted(int power, int corps_beh, int corps_hit) total_mass += roll_dice( 20, power ); #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "Mass including power bonus: %d", total_mass); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "Mass including power bonus: %d", total_mass); #endif if (total_mass < 400 + roll_dice( 2, 500 ) @@ -847,10 +845,8 @@ void cast_toxic_radiance(void) else if (player_see_invis()) { // message player re:"miss" where appropriate {dlb} - strcpy(info, "The light passes through "); - strcat(info, ptr_monam( monster, DESC_NOCAP_THE )); - strcat(info, "."); - mpr(info); + mprf("The light passes through %s.", + ptr_monam( monster, DESC_NOCAP_THE )); } } } @@ -899,10 +895,7 @@ void cast_refrigeration(int pow) if (mons_near(monster)) { - snprintf( info, INFO_SIZE, "You freeze %s.", - ptr_monam( monster, DESC_NOCAP_THE )); - - mpr(info); + mprf("You freeze %s.", ptr_monam( monster, DESC_NOCAP_THE )); hurted = roll_dice( dam_dice ); hurted = mons_adjust_flavoured( monster, beam, hurted ); @@ -959,10 +952,7 @@ void drain_life(int pow) if (mons_near(monster)) { - strcpy(info, "You draw life from "); - strcat(info, ptr_monam( monster, DESC_NOCAP_THE )); - strcat(info, "."); - mpr(info); + mprf("You draw life from %s.", ptr_monam(monster, DESC_NOCAP_THE)); hurted = 3 + random2(7) + random2(pow); @@ -1037,10 +1027,8 @@ int vampiric_drain(int pow, const dist &vmove) hurt_monster(monster, inflicted); - strcpy(info, "You feel life coursing from "); - strcat(info, ptr_monam( monster, DESC_NOCAP_THE )); - strcat(info, " into your body!"); - mpr(info); + mprf("You feel life coursing from %s into your body!", + ptr_monam( monster, DESC_NOCAP_THE )); print_wounds(monster); @@ -1091,17 +1079,13 @@ char burn_freeze(int pow, char flavour) monster = &menv[mgr]; - strcpy(info, "You "); - strcat(info, (flavour == BEAM_FIRE) ? "burn" : - (flavour == BEAM_COLD) ? "freeze" : - (flavour == BEAM_MISSILE) ? "crush" : - (flavour == BEAM_ELECTRICITY) ? "zap" - : "______"); - - strcat(info, " "); - strcat(info, ptr_monam( monster, DESC_NOCAP_THE )); - strcat(info, "."); - mpr(info); + mprf("You %s %s.", + (flavour == BEAM_FIRE) ? "burn" : + (flavour == BEAM_COLD) ? "freeze" : + (flavour == BEAM_MISSILE) ? "crush" : + (flavour == BEAM_ELECTRICITY) ? "zap" + : "______", + ptr_monam( monster, DESC_NOCAP_THE )); int hurted = roll_dice( 1, 3 + pow / 3 ); @@ -1576,10 +1560,8 @@ void summon_things( int pow ) numsc--; } - snprintf( info, INFO_SIZE, "Some Thing%s answered your call!", - (numsc + big_things > 1) ? "s" : "" ); - - mpr(info); + mprf("Some Thing%s answered your call!", + (numsc + big_things > 1) ? "s" : "" ); } return; diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index b4e741efff..5ef969ccd9 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -395,10 +395,9 @@ void simulacrum(int power) if (summoned) { - strcpy( info, (summoned == 1) ? "An icy figure forms " - : "Some icy figures form " ); - strcat( info, "before you!" ); - mpr( info ); + mprf("%s before you!", + (summoned == 1) ? "An icy figure forms " + : "Some icy figures form "); } else mpr( "You feel cold for a second." ); @@ -635,8 +634,7 @@ void you_teleport2( bool allow_control, bool new_abyss_area ) redraw_screen(); #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "Target square (%d,%d)", plox[0], plox[1] ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "Target square (%d,%d)", plox[0], plox[1] ); #endif plox[0] += random2(3) - 1; @@ -656,8 +654,8 @@ void you_teleport2( bool allow_control, bool new_abyss_area ) } #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "Scattered target square (%d,%d)", plox[0], plox[1] ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, + "Scattered target square (%d,%d)", plox[0], plox[1] ); #endif if (is_controlled) @@ -846,8 +844,7 @@ bool project_noise(void) redraw_screen(); #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "Target square (%d,%d)", plox[0], plox[1] ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "Target square (%d,%d)", plox[0], plox[1] ); #endif if (!silenced( plox[0], plox[1] )) @@ -863,14 +860,11 @@ bool project_noise(void) if (!silenced( you.x_pos, you.y_pos )) { - if (!success) - mpr("You hear a dull thud.", MSGCH_SOUND); + if (success) + mprf(MSGCH_SOUND, "You hear a %svoice call your name.", + (see_grid( plox[0], plox[1] ) ? "distant " : "") ); else - { - snprintf( info, INFO_SIZE, "You hear a %svoice call your name.", - (see_grid( plox[0], plox[1] ) ? "distant " : "") ); - mpr( info , MSGCH_SOUND ); - } + mprf(MSGCH_SOUND, "You hear a dull thud."); } } diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc index 8d89d88fbe..2c1eaad153 100644 --- a/crawl-ref/source/spells4.cc +++ b/crawl-ref/source/spells4.cc @@ -398,8 +398,8 @@ void cast_shatter(int pow) if (!sil) noisy( 30, you.x_pos, you.y_pos ); - snprintf(info, INFO_SIZE, "The dungeon %s!", (sil ? "shakes" : "rumbles")); - mpr(info, (sil? MSGCH_PLAIN : MSGCH_SOUND)); + mprf((sil ? MSGCH_PLAIN : MSGCH_SOUND), + "The dungeon %s!", (sil ? "shakes" : "rumbles")); switch (you.attribute[ATTR_TRANSFORMATION]) { @@ -602,9 +602,8 @@ void cast_detect_secret_doors(int pow) { redraw_screen(); - snprintf( info, INFO_SIZE, "You detect %s secret door%s.", - (found > 1) ? "some" : "a", (found > 1) ? "s" : "" ); - mpr( info ); + mprf("You detect %s secret door%s.", + (found > 1) ? "some" : "a", (found > 1) ? "s" : "" ); } } // end cast_detect_secret_doors() @@ -669,8 +668,7 @@ void cast_sticks_to_snakes(int pow) if (weapon == -1) { - snprintf( info, INFO_SIZE, "Your %s feel slithery!", your_hand(true)); - mpr(info); + mprf("Your %s feel slithery!", your_hand(true)); return; } @@ -762,42 +760,35 @@ void cast_sticks_to_snakes(int pow) { dec_inv_item_quantity( you.equip[EQ_WEAPON], how_many ); - snprintf( info, INFO_SIZE, "You create %s snake%s!", - how_many > 1 ? "some" : "a", how_many > 1 ? "s" : ""); + mprf("You create %s snake%s!", + how_many > 1 ? "some" : "a", how_many > 1 ? "s" : ""); } else { - snprintf( info, INFO_SIZE, "Your %s feel slithery!", your_hand(true)); + mprf("Your %s feel slithery!", your_hand(true)); } - mpr(info); - return; } // end cast_sticks_to_snakes() void cast_summon_dragon(int pow) { - int happy; // Removed the chance of multiple dragons... one should be more // than enough, and if it isn't, the player can cast again... // especially since these aren't on the Abjuration plan... they'll // last until they die (maybe that should be changed, but this is // a very high level spell so it might be okay). -- bwr - happy = (random2(pow) > 5); + const bool happy = (random2(pow) > 5); if (create_monster( MONS_DRAGON, 3, (happy ? BEH_FRIENDLY : BEH_HOSTILE), you.x_pos, you.y_pos, MHITYOU, 250 ) != -1) { - strcpy(info, "A dragon appears."); - - if (!happy) - strcat(info, " It doesn't look very happy."); + mprf("A dragon appears.%s", + happy ? "" : " It doesn't look very happy."); } else - strcpy(info, "Nothing happens."); - - mpr(info); + mprf("Nothing happens."); } // end cast_summon_dragon() void cast_conjure_ball_lightning( int pow ) @@ -1143,11 +1134,10 @@ void cast_ignite_poison(int pow) if (pcount > 0) { - snprintf( info, INFO_SIZE, "%s potion%s you are carrying explode%s!", - pcount > 1 ? "Some" : "A", - pcount > 1 ? "s" : "", - pcount > 1 ? "" : "s"); - mpr(info); + mprf("%s potion%s you are carrying explode%s!", + pcount > 1 ? "Some" : "A", + pcount > 1 ? "s" : "", + pcount > 1 ? "" : "s"); } if (wasWielding == true) @@ -1272,10 +1262,8 @@ static int discharge_monsters( int x, int y, int pow, int garbage ) if (damage) { - strcpy( info, ptr_monam( &(menv[mon]), DESC_CAP_THE ) ); - strcat( info, " is struck by lightning." ); - mpr( info ); - + mprf( "%s is struck by lightning.", + ptr_monam( &(menv[mon]), DESC_CAP_THE)); player_hurt_monster( mon, damage ); } } @@ -1308,8 +1296,7 @@ void cast_discharge( int pow ) true, pow, num_targs ); #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "Arcs: %d Damage: %d", num_targs, dam ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "Arcs: %d Damage: %d", num_targs, dam ); #endif if (dam == 0) @@ -1318,16 +1305,13 @@ void cast_discharge( int pow ) mpr("The air around you crackles with electrical energy."); else { - bool plural = coinflip(); - snprintf( info, INFO_SIZE, "%s blue arc%s ground%s harmlessly %s you.", - plural ? "Some" : "A", - plural ? "s" : "", - plural ? " themselves" : "s itself", - plural ? "around" : (coinflip() ? "beside" : - coinflip() ? "behind" : "before") - ); - - mpr(info); + const bool plural = coinflip(); + mprf("%s blue arc%s ground%s harmlessly %s you.", + plural ? "Some" : "A", + plural ? "s" : "", + plural ? " themselves" : "s itself", + plural ? "around" : (coinflip() ? "beside" : + coinflip() ? "behind" : "before")); } } } // end cast_discharge() @@ -1382,19 +1366,14 @@ static int distortion_monsters(int x, int y, int pow, int message) } else if (coinflip()) { - strcpy(info, "Space bends around "); - strcat(info, ptr_monam(defender, DESC_NOCAP_THE)); - strcat(info, "."); - mpr(info); + mprf("Space bends around %s.", + ptr_monam(defender, DESC_NOCAP_THE)); specdam += 1 + random2avg( 7, 2 ) + random2(pow) / 40; } else if (coinflip()) { - strcpy(info, "Space warps horribly around "); - strcat(info, ptr_monam( defender, DESC_NOCAP_THE )); - strcat(info, "!"); - mpr(info); - + mprf("Space warps horribly around %s!", + ptr_monam( defender, DESC_NOCAP_THE )); specdam += 3 + random2avg( 12, 2 ) + random2(pow) / 25; } else if (one_chance_in(3)) @@ -1899,10 +1878,7 @@ void cast_evaporate(int pow) if (potion == -1) { - snprintf( info, INFO_SIZE, "Wisps of steam play over your %s!", - your_hand(true) ); - - mpr(info); + mprf("Wisps of steam play over your %s!", your_hand(true) ); return; } else if (you.inv[potion].base_type != OBJ_POTIONS) @@ -2316,8 +2292,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; - snprintf( info, INFO_SIZE, "%s sways back and forth.", ptr_monam( &(menv[mon]), DESC_CAP_THE )); - mpr(info); + mprf("%s sways back and forth.", ptr_monam( &(menv[mon]), DESC_CAP_THE )); return 1; } @@ -2396,8 +2371,8 @@ void cast_fragmentation(int pow) // jmf: ripped idea from airstrike case MONS_SKELETON_LARGE: // blast of bone explode = true; - snprintf( info, INFO_SIZE, "The sk%s explodes into sharp fragments of bone!", - (menv[mon].type == MONS_FLYING_SKULL) ? "ull" : "eleton"); + mprf("The %s explodes into sharp fragments of bone!", + (menv[mon].type == MONS_FLYING_SKULL) ? "skull" : "skeleton"); blast.name = "blast of bone shards"; @@ -2485,7 +2460,7 @@ void cast_fragmentation(int pow) // jmf: ripped idea from airstrike blast.damage.num = 1; // to mark that a monster was targetted // Yes, this spell does lousy damage if the - // monster isn't susceptable. -- bwr + // monster isn't susceptible. -- bwr player_hurt_monster( mon, roll_dice( 1, 5 + pow / 25 ) ); goto do_terrain; } @@ -2655,10 +2630,9 @@ void cast_fragmentation(int pow) // jmf: ripped idea from airstrike case DNGN_PERMAROCK_WALL: case DNGN_FLOOR: explode = false; - snprintf( info, INFO_SIZE, "%s seems to be unnaturally hard.", - (grid == DNGN_PERMAROCK_WALL) ? "That wall" - : "The dungeon floor" ); - explode = false; + mprf("%s seems to be unnaturally hard.", + (grid == DNGN_PERMAROCK_WALL) ? "That wall" + : "The dungeon floor"); break; case DNGN_TRAP_III: // What are these? Should they explode? -- bwr @@ -2671,10 +2645,7 @@ void cast_fragmentation(int pow) // jmf: ripped idea from airstrike if (explode && blast.damage.num > 0) { if (what != NULL) - { - snprintf( info, INFO_SIZE, "The %s explodes!", what); - mpr(info); - } + mprf("The %s explodes!", what); explosion( blast, hole ); } @@ -2920,9 +2891,7 @@ int cast_apportation(int pow) mpr( "There are no items there." ); else if (mons_is_mimic( menv[ mon ].type )) { - snprintf( info, INFO_SIZE, "%s twitches.", - ptr_monam( &(menv[ mon ]), DESC_CAP_THE ) ); - mpr( info ); + mprf("%s twitches.", ptr_monam( &(menv[ mon ]), DESC_CAP_THE)); } else mpr( "This spell does not work on creatures." ); @@ -2964,9 +2933,8 @@ int cast_apportation(int pow) else { mpr( "Yoink!" ); - snprintf( info, INFO_SIZE, "You pull the item%s to yourself.", - (mitm[ item ].quantity > 1) ? "s" : "" ); - mpr( info ); + mprf("You pull the item%s to yourself.", + (mitm[ item ].quantity > 1) ? "s" : "" ); } done = 1; } diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc index ef29a46937..f1e40b94a6 100644 --- a/crawl-ref/source/spl-book.cc +++ b/crawl-ref/source/spl-book.cc @@ -959,10 +959,8 @@ static bool which_spellbook( int &book, int &spell ) return (false); } - snprintf( info, INFO_SIZE, "You can memorise %d more level%s of spells.", - avail_levels, (avail_levels > 1) ? "s" : "" ); - - mpr( info ); + mprf("You can memorise %d more level%s of spells.", + avail_levels, (avail_levels > 1) ? "s" : "" ); book = prompt_invent_item("Memorise from which spellbook?", MT_INVSELECT, OBJ_BOOKS ); @@ -1224,23 +1222,22 @@ bool learn_spell(void) } chance = spell_fail(specspell); - int temp_rand1 = random2(3); - int temp_rand2 = random2(4); - - snprintf(info, INFO_SIZE, "This spell is %s %s to %s.", - ((chance >= 80) ? "very" : - (chance >= 60) ? "quite" : - (chance >= 45) ? "rather" : - (chance >= 30) ? "somewhat" - : "not that"), - ((temp_rand1 == 0) ? "difficult" : - (temp_rand1 == 1) ? "tricky" : - "challenging"), - ((temp_rand2 == 0) ? "memorise" : - (temp_rand2 == 1) ? "commit to memory" : - (temp_rand2 == 2) ? "learn" : - "absorb")); - mpr(info); + const int temp_rand1 = random2(3); + const int temp_rand2 = random2(4); + + mprf("This spell is %s %s to %s.", + ((chance >= 80) ? "very" : + (chance >= 60) ? "quite" : + (chance >= 45) ? "rather" : + (chance >= 30) ? "somewhat" + : "not that"), + ((temp_rand1 == 0) ? "difficult" : + (temp_rand1 == 1) ? "tricky" + : "challenging"), + ((temp_rand2 == 0) ? "memorise" : + (temp_rand2 == 1) ? "commit to memory" : + (temp_rand2 == 2) ? "learn" + : "absorb")); snprintf(info, INFO_SIZE, "Memorise %s?", spell_title(specspell)); if ( !yesno(info, true, 0, false) ) @@ -1377,9 +1374,9 @@ int staff_spell( int staff ) spell = 'a'; // automatically selected if its the only option else { - snprintf( info, INFO_SIZE, - "Evoke which spell from the rod ([a-%c] spell [?*] list)? ", - 'a' + num_spells - 1 ); + mprf(MSGCH_PROMPT, + "Evoke which spell from the rod ([a-%c] spell [?*] list)? ", + 'a' + num_spells - 1 ); mpr( info, MSGCH_PROMPT ); spell = get_ch(); diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index f617790e4e..68d61278d0 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -117,17 +117,14 @@ static void surge_power(spell_type spell) if (enhanced) // one way or the other {dlb} { - strcpy(info, "You feel a"); - - strcat(info, (enhanced < -2) ? "n extraordinarily" : - (enhanced == -2) ? "n extremely" : - (enhanced == 2) ? " strong" : - (enhanced > 2) ? " huge" - : ""); - - strcat(info, (enhanced < 0) ? " numb sensation." - : " surge of power!"); - mpr(info); + mprf("You feel a%s %s", + (enhanced < -2) ? "n extraordinarily" : + (enhanced == -2) ? "n extremely" : + (enhanced == 2) ? " strong" : + (enhanced > 2) ? " huge" + : "", + (enhanced < 0) ? " numb sensation." + : " surge of power!"); } } // end surge_power() @@ -966,8 +963,7 @@ spret_type your_spells( spell_type spc2, int powc, bool allow_fail ) } #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "Spell #%d, power=%d", spc2, powc ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "Spell #%d, power=%d", spc2, powc ); #endif switch (spc2) @@ -1242,9 +1238,8 @@ spret_type your_spells( spell_type spc2, int powc, bool allow_fail ) break; case SPELL_DETECT_TRAPS: - strcpy(info, "You detect "); - strcat(info, (detect_traps(powc) > 0) ? "some traps!" : "nothing."); - mpr(info); + mprf("You detect %s", + (detect_traps(powc) > 0) ? "some traps!" : "nothing."); break; case SPELL_BLINK: @@ -1988,9 +1983,8 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, spec_effect = 0; #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "Sptype: %d, failure1: %d, failure2: %d", - sp_type, old_fail, spec_effect ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "Sptype: %d, failure1: %d, failure2: %d", + sp_type, old_fail, spec_effect ); #endif if (force_effect != 100) @@ -2005,9 +1999,7 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, switch (random2(10)) { case 0: - snprintf( info, INFO_SIZE, "Sparks fly from your %s!", - your_hand(true) ); - mpr(info); + mprf("Sparks fly from your %s!", your_hand(true) ); break; case 1: @@ -2015,9 +2007,7 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, break; case 2: - snprintf( info, INFO_SIZE, "Wisps of smoke drift from your %s.", - your_hand(true)); - mpr(info); + mprf("Wisps of smoke drift from your %s.", your_hand(true)); break; case 3: mpr("You feel a strange surge of energy!"); @@ -2049,10 +2039,7 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, switch (random2(2)) { case 0: - snprintf( info, INFO_SIZE, "Smoke pours from your %s!", - your_hand(true)); - mpr(info); - + mprf("Smoke pours from your %s!", your_hand(true)); big_cloud( CLOUD_GREY_SMOKE, KC_YOU, you.x_pos, you.y_pos, 20, 7 + random2(7) ); @@ -2134,9 +2121,7 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, switch (random2(10)) { case 0: - snprintf( info, INFO_SIZE, "Your %s glow momentarily.", - your_hand(true) ); - mpr(info); + mprf("Your %s glow momentarily.", your_hand(true) ); break; case 1: mpr("The air around you crackles with energy!"); @@ -2811,9 +2796,7 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, switch (random2(10)) { case 0: - snprintf( info, INFO_SIZE, "Your %s glow momentarily.", - your_hand(true)); - mpr(info); + mprf("Your %s glow momentarily.", your_hand(true)); break; case 1: mpr("The air around you crackles with energy!"); @@ -2916,17 +2899,13 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, switch (random2(10)) { case 0: - snprintf( info, INFO_SIZE, "Sparks fly from your %s!", - your_hand(true)); - mpr(info); + mprf("Sparks fly from your %s!", your_hand(true)); break; case 1: mpr("The air around you burns with energy!"); break; case 2: - snprintf( info, INFO_SIZE, "Wisps of smoke drift from your %s.", - your_hand(true)); - mpr(info); + mprf("Wisps of smoke drift from your %s.", your_hand(true)); break; case 3: mpr("You feel a strange surge of energy!"); @@ -2960,10 +2939,7 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, switch (random2(2)) { case 0: - snprintf( info, INFO_SIZE, "Smoke pours from your %s!", - your_hand(true) ); - mpr(info); - + mprf("Smoke pours from your %s!", your_hand(true) ); big_cloud( CLOUD_GREY_SMOKE + random2(3), KC_YOU, you.x_pos, you.y_pos, 20, 7 + random2(7) ); break; @@ -3069,17 +3045,14 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, mpr("A chill runs through your body."); break; case 2: - snprintf( info, INFO_SIZE, "Wisps of condensation drift from your %s.", - your_hand(true)); - mpr(info); + mprf("Wisps of condensation drift from your %s.", + your_hand(true)); break; case 3: mpr("You feel a strange surge of energy!"); break; case 4: - snprintf( info, INFO_SIZE,"Your %s feel numb with cold.", - your_hand(true)); - mpr(info); + mprf("Your %s feel numb with cold.", your_hand(true)); break; case 5: mpr("A chill runs through your body."); @@ -3165,10 +3138,7 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, expose_player_to_element(BEAM_COLD, 9); break; case 1: - snprintf( info, INFO_SIZE,"Freezing gasses pour from your %s!", - your_hand(true)); - mpr(info); - + mprf("Freezing gasses pour from your %s!", your_hand(true)); big_cloud(CLOUD_COLD, KC_YOU, you.x_pos, you.y_pos, 20, 8 + random2(4)); break; @@ -3191,9 +3161,7 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, mpr("You are showered with tiny particles of grit."); break; case 2: - snprintf( info, INFO_SIZE,"Sand pours from your %s.", - your_hand(true)); - mpr(info); + mprf("Sand pours from your %s.", your_hand(true)); break; case 3: mpr("You feel a surge of energy from the ground."); @@ -3217,12 +3185,10 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, canned_msg(MSG_NOTHING_HAPPENS); break; case 9: - strcpy(info, "Your "); - strcat(info, (you.species == SP_NAGA) ? "underbelly feels" : - (you.species == SP_CENTAUR) ? "hooves feel" - : "feet feel"); - strcat(info, " warm."); - mpr(info); + mprf("Your %s warm.", + (you.species == SP_NAGA) ? "underbelly feels" : + (you.species == SP_CENTAUR) ? "hooves feel" + : "feet feel"); break; } break; @@ -3299,9 +3265,7 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, mpr("You feel momentarily weightless."); break; case 2: - snprintf( info, INFO_SIZE, "Wisps of vapour drift from your %s.", - your_hand(true)); - mpr(info); + mprf("Wisps of vapour drift from your %s.", your_hand(true)); break; case 3: mpr("You feel a strange surge of energy!"); @@ -3310,9 +3274,8 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, mpr("You feel electric!"); break; case 5: - snprintf( info, INFO_SIZE, "Sparks of electricity dance between your %s.", - your_hand(true)); - mpr(info); + mprf("Sparks of electricity dance between your %s.", + your_hand(true)); break; case 6: mpr("You are blasted with air!"); @@ -3342,9 +3305,8 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, mpr("There is a short, sharp shower of sparks."); break; case 1: - snprintf( info, INFO_SIZE, "The wind %s around you!", - silenced(you.x_pos, you.y_pos) ? "whips" : "howls"); - mpr(info); + mprf("The wind %s around you!", + silenced(you.x_pos, you.y_pos) ? "whips" : "howls"); break; } break; @@ -3358,10 +3320,7 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, KILLED_BY_WILD_MAGIC, cause); break; case 1: - snprintf( info, INFO_SIZE, "Noxious gasses pour from your %s!", - your_hand(true)); - mpr(info); - + mprf("Noxious gasses pour from your %s!", your_hand(true)); big_cloud(CLOUD_STINK, KC_YOU, you.x_pos, you.y_pos, 20, 9 + random2(4)); break; @@ -3392,10 +3351,7 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, explosion(beam); break; case 1: - snprintf( info, INFO_SIZE, "Venomous gasses pour from your %s!", - your_hand(true)); - mpr(info); - + mprf("Venomous gasses pour from your %s!", your_hand(true)); big_cloud( CLOUD_POISON, KC_YOU, you.x_pos, you.y_pos, 20, 8 + random2(5) ); break; @@ -3417,9 +3373,8 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, mpr("You feel slightly ill."); break; case 2: - snprintf( info, INFO_SIZE, "Wisps of poison gas drift from your %s.", - your_hand(true) ); - mpr(info); + mprf("Wisps of poison gas drift from your %s.", + your_hand(true)); break; case 3: mpr("You feel a strange surge of energy!"); @@ -3463,10 +3418,7 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, break; case 1: - snprintf( info, INFO_SIZE, "Noxious gasses pour from your %s!", - your_hand(true) ); - mpr(info); - + mprf("Noxious gasses pour from your %s!", your_hand(true) ); place_cloud(CLOUD_STINK, you.x_pos, you.y_pos, 2 + random2(4), KC_YOU); break; @@ -3518,10 +3470,7 @@ bool miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail, poison_player( 10 + random2avg(19, 2) ); break; case 1: - snprintf( info, INFO_SIZE, "Venomous gasses pour from your %s!", - your_hand(true)); - mpr(info); - + mprf("Venomous gasses pour from your %s!", your_hand(true)); big_cloud(CLOUD_POISON, KC_YOU, you.x_pos, you.y_pos, 20, 7 + random2(7)); break; diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc index a7ec73eb54..f53b07a184 100644 --- a/crawl-ref/source/stuff.cc +++ b/crawl-ref/source/stuff.cc @@ -136,9 +136,8 @@ void tag_followers( void ) fmenv->flags |= MF_TAKING_STAIRS; #if DEBUG_DIAGNOSTICS - snprintf( info, INFO_SIZE, "%s is marked for following.", - ptr_monam( fmenv, DESC_CAP_THE ) ); - mpr( info, MSGCH_DIAGNOSTICS ); + mprf(MSGCH_DIAGNOSTICS, "%s is marked for following.", + ptr_monam( fmenv, DESC_CAP_THE ) ); #endif } } |