From 6ed3b1139939bae95783f7c1a9a3cddd26693df2 Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Tue, 27 Jan 2015 14:05:42 -0500 Subject: [PATCH] Fix text wrap in transcript to work with pixel width of text instead of character width Also, remove all (or at least most) of the extraneous spaces from the end of transcript messages. --- src/boe.actions.cpp | 134 ++++++++++++++++++++-------------------- src/boe.combat.cpp | 81 ++++++++++++------------ src/boe.fileio.cpp | 2 +- src/boe.items.cpp | 11 ++-- src/boe.main.cpp | 4 +- src/boe.party.cpp | 76 +++++++++++------------ src/boe.specials.cpp | 61 +++++++++--------- src/boe.text.cpp | 134 ++++++++++++++++++++++------------------ src/boe.town.cpp | 20 +++--- src/boe.townspec.cpp | 24 +++---- src/tools/graphtool.cpp | 4 +- src/tools/graphtool.hpp | 2 +- 12 files changed, 280 insertions(+), 273 deletions(-) diff --git a/src/boe.actions.cpp b/src/boe.actions.cpp index 3e23b665..d070e687 100644 --- a/src/boe.actions.cpp +++ b/src/boe.actions.cpp @@ -295,7 +295,7 @@ static void handle_spellcast(eSkill which_type, bool& did_something, bool& need_ if(store_sp[i] != univ.party[i].cur_sp) did_something = true; } else if(overall_mode == MODE_TOWN_TARGET) { - add_string_to_buf(" Cancelled. "); + add_string_to_buf(" Cancelled."); overall_mode = MODE_TOWN; need_redraw = true; need_reprint = true; @@ -311,7 +311,7 @@ static void handle_spellcast(eSkill which_type, bool& did_something, bool& need_ spell_forced = false; redraw_terrain(); } else if(overall_mode == MODE_SPELL_TARGET || overall_mode == MODE_FANCY_TARGET) { - add_string_to_buf(" Cancelled. "); + add_string_to_buf(" Cancelled."); overall_mode = MODE_COMBAT; center = univ.party[current_pc].combat_pos; pause(10); @@ -326,19 +326,19 @@ static void handle_rest(bool& need_redraw, bool& need_reprint) { int i = 0; ter_num_t ter = univ.out[univ.party.p_loc.x][univ.party.p_loc.y]; if(univ.party.in_boat >= 0) - add_string_to_buf("Rest: Not in boat. "); + add_string_to_buf("Rest: Not in boat."); else if(someone_poisoned()) - add_string_to_buf("Rest: Someone poisoned. "); + add_string_to_buf("Rest: Someone poisoned."); else if(univ.party.food <= 12) - add_string_to_buf("Rest: Not enough food. "); + add_string_to_buf("Rest: Not enough food."); else if(nearest_monster() <= 3) - add_string_to_buf("Rest: Monster too close. "); + add_string_to_buf("Rest: Monster too close."); else if(univ.scenario.ter_types[ter].special == eTerSpec::DAMAGING || univ.scenario.ter_types[ter].special == eTerSpec::DANGEROUS) add_string_to_buf("Rest: It's dangerous here."); else if(flying()) - add_string_to_buf("Rest: Not while flying. "); + add_string_to_buf("Rest: Not while flying."); else { - add_string_to_buf("Resting... "); + add_string_to_buf("Resting..."); print_buf(); play_sound(-20); draw_rest_screen(); @@ -362,7 +362,7 @@ static void handle_rest(bool& need_redraw, bool& need_reprint) { } if(i == 50) { do_rest(1200, get_ran(5,1,10), 50); - add_string_to_buf(" Rest successful. "); + add_string_to_buf(" Rest successful."); put_pc_screen(); pause(25); } @@ -373,9 +373,9 @@ static void handle_rest(bool& need_redraw, bool& need_reprint) { static void handle_pause(bool& did_something, bool& need_redraw) { if(overall_mode == MODE_COMBAT) { char_stand_ready(); - add_string_to_buf("Stand ready. "); + add_string_to_buf("Stand ready."); if(univ.party[current_pc].status[eStatus::WEBS] > 0) { - add_string_to_buf("You clean webs. "); + add_string_to_buf("You clean webs."); move_to_zero(univ.party[current_pc].status[eStatus::WEBS]); move_to_zero(univ.party[current_pc].status[eStatus::WEBS]); put_pc_screen(); @@ -416,11 +416,11 @@ static void handle_look(location destination, bool& need_redraw, bool& need_repr // TODO: I'm not sure what this check was for or if it would be needed for anything anymore. // if(can_see(cur_loc,destination) >= 4 || (overall_mode != MODE_LOOK_OUTDOORS && loc_off_world(destination))) if(overall_mode != MODE_LOOK_COMBAT && party_can_see(destination) == 6) - add_string_to_buf(" Can't see space. "); + add_string_to_buf(" Can't see space."); else if(overall_mode == MODE_LOOK_COMBAT && can_see_light(univ.party[current_pc].combat_pos,destination,sight_obscurity) >= 4) - add_string_to_buf(" Can't see space. "); + add_string_to_buf(" Can't see space."); else { - add_string_to_buf("You see... "); + add_string_to_buf("You see..."); ter_num_t ter_looked_at = do_look(destination); if(overall_mode == MODE_LOOK_TOWN || overall_mode == MODE_LOOK_COMBAT) if(adjacent(univ.town.p_loc,destination)) @@ -437,7 +437,7 @@ static void handle_look(location destination, bool& need_redraw, bool& need_repr need_reprint = true; if(adjacent(univ.town->sign_locs[k],univ.town.p_loc)) do_sign(univ.town.num,k,ter_looked_at); - else add_string_to_buf(" Too far away to read sign. "); + else add_string_to_buf(" Too far away to read sign."); } } } else if(overall_mode == MODE_LOOK_OUTDOORS) { @@ -446,7 +446,7 @@ static void handle_look(location destination, bool& need_redraw, bool& need_repr need_reprint = true; if(adjacent(univ.out->sign_locs[k],univ.party.loc_in_sec)) do_sign(200 + get_outdoor_num(),k,ter_looked_at); - else add_string_to_buf(" Too far away to read sign. "); + else add_string_to_buf(" Too far away to read sign."); } } } @@ -522,7 +522,7 @@ static void handle_move(location destination, bool& did_something, bool& need_re static void handle_talk(location destination, bool& did_something, bool& need_redraw, bool& need_reprint) { if(can_see_light(center,destination,sight_obscurity) >= 4 || loc_off_world(destination)) { - add_string_to_buf(" Can't see space "); + add_string_to_buf(" Can't see space."); need_reprint = true; } else { for(int i = 0; i < univ.town.monst.size(); i++) { @@ -530,7 +530,7 @@ static void handle_talk(location destination, bool& did_something, bool& need_re did_something = true; need_redraw = true; if(univ.town.monst[i].attitude % 2 == 1) { - add_string_to_buf(" Creature is hostile. "); + add_string_to_buf(" Creature is hostile."); } else if(univ.town.monst[i].summoned > 0 || univ.town.monst[i].personality < 0) { short small_talk = 1; if(!univ.town.monst[i].summoned) @@ -609,7 +609,7 @@ static void handle_drop_item(location destination, bool& need_redraw) { static void handle_use_space(location destination, bool& did_something, bool& need_redraw) { if(!adjacent(destination,univ.town.p_loc)) - add_string_to_buf(" Must be adjacent. "); + add_string_to_buf(" Must be adjacent."); else did_something = use_space(destination); overall_mode = MODE_TOWN; need_redraw = true; @@ -619,11 +619,11 @@ static void handle_use_space(location destination, bool& did_something, bool& ne static void handle_bash_pick(location destination, bool& did_something, bool& need_redraw, bool isBash) { if(!adjacent(destination,univ.town.p_loc)) - add_string_to_buf(" Must be adjacent. "); + add_string_to_buf(" Must be adjacent."); else { short pc = char_select_pc(0, isBash ? "Who will bash?" : "Who will pick the lock?"); if(pc == 6) { - add_string_to_buf(" Cancelled"); + add_string_to_buf(" Cancelled."); overall_mode = MODE_TOWN; need_redraw = true; return; @@ -686,8 +686,7 @@ static void handle_switch_pc_items(short which_pc, bool& need_redraw) { static void handle_equip_item(short item_hit, bool& need_redraw) { if(overall_mode == MODE_USE_TOWN) { // TODO: Uh, this looks wrong somehow. - add_string_to_buf("Note: Clicking 'U' button by item"); - add_string_to_buf(" uses the item."); + add_string_to_buf("Note: Clicking 'U' button by item uses the item.", 2); use_item(stat_window, item_hit); overall_mode = MODE_TOWN; take_ap(3); @@ -790,7 +789,7 @@ static void handle_town_wait(bool& need_redraw, bool& need_reprint) { if(party_sees_a_monst()) add_string_to_buf("Long wait: Monster in sight."); else { - add_string_to_buf("Long wait... "); + add_string_to_buf("Long wait..."); print_buf(); play_sound(-20); draw_rest_screen(); @@ -828,12 +827,12 @@ static void handle_combat_switch(bool& did_something, bool& need_redraw, bool& n if(overall_mode == MODE_TOWN) { if(univ.party.in_boat >= 0) { need_reprint = true; - add_string_to_buf("Combat: Not while in boat. "); + add_string_to_buf("Combat: Not while in boat."); } else if(univ.party.in_horse >= 0) { need_reprint = true; - add_string_to_buf("Combat: Not while on horseback. "); + add_string_to_buf("Combat: Not while on horseback."); } else { - add_string_to_buf("Combat! "); + add_string_to_buf("Combat!"); play_sound(18); need_reprint = true; start_town_combat(univ.party.direction); @@ -847,12 +846,12 @@ static void handle_combat_switch(bool& did_something, bool& need_redraw, bool& n if(hit_end_c_button()) { end_town_mode(0,univ.town.p_loc); play_sound(93); - add_string_to_buf("End combat. "); + add_string_to_buf("End combat."); handle_wandering_specials(0,1); menu_activate(); put_pc_screen(); set_stat_window(current_pc); - } else add_string_to_buf("Can't end combat yet. "); + } else add_string_to_buf("Can't end combat yet."); } else { univ.party.direction = end_town_combat(); center = univ.town.p_loc; @@ -874,7 +873,7 @@ static void handle_missile(bool& need_redraw, bool& need_reprint) { need_reprint = true; redraw_terrain(); } else if(overall_mode == MODE_FIRING || overall_mode == MODE_THROWING) { - add_string_to_buf(" Cancelled. "); + add_string_to_buf(" Cancelled."); center = univ.party[current_pc].combat_pos; pause(10); need_redraw = true; @@ -885,7 +884,7 @@ static void handle_missile(bool& need_redraw, bool& need_reprint) { static void handle_get_items(bool& did_something, bool& need_redraw, bool& need_reprint) { int j = 0; if(univ.party.in_boat >= 0) - add_string_to_buf("Get: Not while in boat. "); + add_string_to_buf("Get: Not while in boat."); if(overall_mode == MODE_TOWN) j = get_item(univ.town.p_loc,6,false); else { @@ -1040,21 +1039,20 @@ bool handle_action(sf::Event event) { if(overall_mode == MODE_OUTDOORS) overall_mode = MODE_LOOK_OUTDOORS; if(overall_mode == MODE_TOWN) overall_mode = MODE_LOOK_TOWN; if(overall_mode == MODE_COMBAT) overall_mode = MODE_LOOK_COMBAT; - add_string_to_buf("Look: Select a space. You can also "); - add_string_to_buf(" right click to look."); + add_string_to_buf("Look: Select a space. You can also right click to look.", 2); need_redraw = true; break; case 3: if(overall_mode == MODE_COMBAT) { - add_string_to_buf("Parry. "); + add_string_to_buf("Parry."); char_parry(); did_something = true; need_reprint = true; need_redraw = true; } else if(overall_mode == MODE_TOWN) { overall_mode = MODE_TALK_TOWN; - add_string_to_buf("Talk: Select someone "); + add_string_to_buf("Talk: Select someone."); need_reprint = true; } else if(overall_mode == MODE_OUTDOORS) handle_rest(need_redraw, need_reprint); @@ -1109,10 +1107,10 @@ bool handle_action(sf::Event event) { case 8: if(overall_mode == MODE_COMBAT) { if(combat_active_pc == 6) { - add_string_to_buf("This PC now active. "); + add_string_to_buf("This PC now active."); combat_active_pc = current_pc; } else { - add_string_to_buf("All PC's now active. "); + add_string_to_buf("All PC's now active."); current_pc = combat_active_pc; combat_active_pc = 6; } @@ -1438,7 +1436,7 @@ void handle_monster_actions(bool& need_redraw, bool& need_reprint) { end_combat(); if(which_combat_type == 0) { end_town_mode(0,univ.party.p_loc); - add_string_to_buf("Fled the combat. "); + add_string_to_buf("Fled the combat."); handle_wandering_specials(0,2); } } else { @@ -1550,7 +1548,7 @@ void initiate_outdoor_combat(short i) { // Is combat too easy? if((univ.party.get_level() > ((out_enc_lev_tot(i) * 5) / 3) ) && (out_enc_lev_tot(i) < 200) && (univ.party.out_c[i].what_monst.cant_flee % 10 != 1)) { - add_string_to_buf("Combat: Monsters fled! "); + add_string_to_buf("Combat: Monsters fled!"); univ.party.out_c[i].exists = false; return; } @@ -1875,7 +1873,7 @@ bool handle_keystroke(sf::Event& event){ } // kill_monst(&univ.town.monst[i],6); draw_terrain(); - add_string_to_buf("Debug: Kill things. "); + add_string_to_buf("Debug: Kill things."); print_buf(); break; @@ -1930,11 +1928,11 @@ bool handle_keystroke(sf::Event& event){ case 'R': if(!in_scen_debug) break; if(univ.party.in_boat >= 0) { - add_string_to_buf(" Not while in boat. "); + add_string_to_buf(" Not while in boat."); break; } if(univ.party.in_horse >= 0) { - add_string_to_buf(" Not while on horse. "); + add_string_to_buf(" Not while on horse."); break; } force_town_enter(univ.scenario.which_town_start,univ.scenario.where_start); @@ -1968,7 +1966,7 @@ bool handle_keystroke(sf::Event& event){ case 'W': if(!in_scen_debug) break; refresh_store_items(); - add_string_to_buf("Debug: Refreshed jobs/shops. "); + add_string_to_buf("Debug: Refreshed jobs/shops."); print_buf(); break; @@ -2155,8 +2153,7 @@ void post_load() { //mode; // 0 - normal 1 - save as void do_save(short mode) { if(overall_mode > MODE_TOWN && overall_mode != MODE_STARTUP) { - add_string_to_buf("Save: Only while outdoors, or in "); - add_string_to_buf(" town and not looking/casting. "); + add_string_to_buf("Save: Only while outdoors, or in town and not looking/casting.", 2); print_buf(); return; } @@ -2269,15 +2266,15 @@ void increase_age() { // Party spell effects if(univ.party.status[ePartyStatus::STEALTH] == 1) { - add_string_to_buf("Your footsteps grow louder. "); + add_string_to_buf("Your footsteps grow louder."); } move_to_zero(univ.party.status[ePartyStatus::STEALTH]); if(univ.party.status[ePartyStatus::DETECT_LIFE] == 1) { - add_string_to_buf("You stop detecting monsters. "); + add_string_to_buf("You stop detecting monsters."); } move_to_zero(univ.party.status[ePartyStatus::DETECT_LIFE]); if(univ.party.status[ePartyStatus::FIREWALK] == 1) { - add_string_to_buf("Your feet stop glowing. "); + add_string_to_buf("Your feet stop glowing."); } move_to_zero(univ.party.status[ePartyStatus::FIREWALK]); @@ -2285,12 +2282,12 @@ void increase_age() { add_string_to_buf("You are starting to descend."); if(univ.party.status[ePartyStatus::FLIGHT] == 1) { if(blocksMove(univ.scenario.ter_types[univ.out[univ.party.p_loc.x][univ.party.p_loc.y]].blockage)) { - add_string_to_buf(" You plummet to your deaths. "); + add_string_to_buf(" You plummet to your deaths."); slay_party(eMainStatus::DEAD); print_buf(); pause(150); } - else add_string_to_buf(" You land safely. "); + else add_string_to_buf(" You land safely."); } move_to_zero(univ.party.status[ePartyStatus::FLIGHT]); @@ -2366,7 +2363,7 @@ void increase_age() { how_many_short++; how_many_short = take_food (how_many_short,false); if(how_many_short > 0) { - add_string_to_buf("Starving! "); + add_string_to_buf("Starving!"); play_sound(66); r1 = get_ran(3,1,6); hit_party(r1,eDamageType::UNBLOCKABLE); @@ -2376,7 +2373,7 @@ void increase_age() { } else { play_sound(6); - add_string_to_buf("You eat. "); + add_string_to_buf("You eat."); } update_stat = true; } @@ -2529,7 +2526,7 @@ void switch_pc(short which) { current_switch = 6; } else { - add_string_to_buf("Switch: Switch with who? "); + add_string_to_buf("Switch: Switch with who?"); current_switch = which; } } @@ -2539,10 +2536,10 @@ void drop_pc(short which) { choice = cChoiceDlog("delete-pc-confirm",{"yes","no"}).show(); if(choice == "no") { - add_string_to_buf("Delete PC: Cancelled. "); + add_string_to_buf("Delete PC: Cancelled."); return; } - add_string_to_buf("Delete PC: OK. "); + add_string_to_buf("Delete PC: OK."); kill_pc(which,eMainStatus::ABSENT); for(short i = which; i < 5; i++) univ.party.swap_pcs(i, i + 1); @@ -2705,7 +2702,7 @@ static void run_waterfalls(short mode){ // mode 0 - town, 1 - outdoors } eDirection dir; while((dir = find_waterfall(x,y,mode)) != DIR_HERE){ - add_string_to_buf(" Waterfall! "); + add_string_to_buf(" Waterfall!"); if(mode == 0){ x += 2 * dir_x_dif[dir]; y += 2 * dir_y_dif[dir]; @@ -2726,6 +2723,7 @@ static void run_waterfalls(short mode){ // mode 0 - town, 1 - outdoors if(wilderness_lore_present(coord_to_ter(x - dir_x_dif[dir], y - dir_y_dif[dir]) > 0) && get_ran(1,0,1) == 0) add_string_to_buf(" (No supplies lost.)"); else if(univ.party.food > 1800){ + // TODO: Shouldn't this check n instead of univ.party.food? add_string_to_buf(" (Many supplies lost.)"); univ.party.food -= 50; } @@ -2841,7 +2839,7 @@ bool outd_move_party(location destination,bool forced) { if(cChoiceDlog("boat-bridge",{"under","land"}).show() == "under") forced = true; else { - add_string_to_buf("You leave the boat. "); + add_string_to_buf("You leave the boat."); univ.party.in_boat = -1; } } @@ -2853,11 +2851,11 @@ bool outd_move_party(location destination,bool forced) { std::string dir_str = dir_string[univ.party.direction]; if(((boat_num = out_boat_there(real_dest)) < 30) && (univ.party.in_boat < 0) && (univ.party.in_horse < 0)) { if(flying()) { - add_string_to_buf("You land first. "); + add_string_to_buf("You land first."); univ.party.status[ePartyStatus::FLIGHT] = 0; } give_help(61,0); - add_string_to_buf("Move: You board the boat. "); + add_string_to_buf("Move: You board the boat."); univ.party.in_boat = boat_num; univ.party.p_loc = real_dest; @@ -2878,7 +2876,7 @@ bool outd_move_party(location destination,bool forced) { } give_help(60,0); - add_string_to_buf("Move: You mount the horses. "); + add_string_to_buf("Move: You mount the horses."); play_sound(84); univ.party.in_horse = horse_num; @@ -2909,7 +2907,7 @@ bool outd_move_party(location destination,bool forced) { // TODO: But I though you automatically landed when entering? if(flying() && univ.scenario.ter_types[ter].special == eTerSpec::TOWN_ENTRANCE) { - add_string_to_buf("Moved: You have to land first. "); + add_string_to_buf("Moved: You have to land first."); return false; } @@ -2989,7 +2987,7 @@ bool town_move_party(location destination,short forced) { // If to bridge, exit if heading diagonal, keep going if heading horiz or vert && (!univ.scenario.ter_types[ter].boat_over || ((destination.x != univ.town.p_loc.x) && (destination.y != univ.town.p_loc.y)))) { - add_string_to_buf("You leave the boat. "); + add_string_to_buf("You leave the boat."); univ.party.in_boat = -1; } else if((destination.x != univ.town.p_loc.x) && (destination.y != univ.town.p_loc.y)) @@ -2999,13 +2997,13 @@ bool town_move_party(location destination,short forced) { if(cChoiceDlog("boat-bridge",{"under","land"}).show() == "under") forced = true; else if(!is_blocked(destination)) { - add_string_to_buf("You leave the boat. "); + add_string_to_buf("You leave the boat."); univ.party.in_boat = -1; } } // boat in destination else if(town_boat_there(destination) < 30) { - add_string_to_buf(" Boat there already. "); + add_string_to_buf(" Boat there already."); return false; } // water or lava @@ -3017,11 +3015,11 @@ bool town_move_party(location destination,short forced) { std::string dir_str = dir_string[univ.party.direction]; if(((boat_there = town_boat_there(destination)) < 30) && (univ.party.in_boat < 0)) { if(univ.party.boats[boat_there].property) { - add_string_to_buf(" Not your boat. "); + add_string_to_buf(" Not your boat."); return false; } give_help(61,0); - add_string_to_buf("Move: You board the boat. "); + add_string_to_buf("Move: You board the boat."); univ.party.in_boat = boat_there; univ.town.p_loc = destination; @@ -3031,11 +3029,11 @@ bool town_move_party(location destination,short forced) { } else if(((horse_there = town_horse_there(destination)) < 30) && (univ.party.in_horse < 0)) { if(univ.party.horses[horse_there].property) { - add_string_to_buf(" Not your horses. "); + add_string_to_buf(" Not your horses."); return false; } give_help(60,0); - add_string_to_buf("Move: You mount the horses. "); + add_string_to_buf("Move: You mount the horses."); play_sound(84); univ.party.in_horse = horse_there; diff --git a/src/boe.combat.cpp b/src/boe.combat.cpp index 3ca2b678..b45b6f54 100644 --- a/src/boe.combat.cpp +++ b/src/boe.combat.cpp @@ -593,7 +593,7 @@ void pc_attack(short who_att,iLiving* target) { if(store_hp - target->get_health() > 0) { if(target->is_shielded()) { int how_much = target->get_shared_dmg(store_hp - target->get_health()); - add_string_to_buf(" Shares damage! "); + add_string_to_buf(" Shares damage!"); damage_pc(who_att, how_much, eDamageType::MAGIC,eRace::UNKNOWN,0); } } @@ -878,11 +878,11 @@ void place_target(location target) { if(num_targets_left > 0) { if(loc_off_act_area(target)) { - add_string_to_buf(" Space not in town. "); + add_string_to_buf(" Space not in town."); return; } if(can_see_light(univ.party[current_pc].combat_pos,target,sight_obscurity) > 4) { - add_string_to_buf(" Can't see target. "); + add_string_to_buf(" Can't see target."); return; } if(dist(univ.party[current_pc].combat_pos,target) > (*spell_being_cast).range) { @@ -890,7 +890,7 @@ void place_target(location target) { return; } if(sight_obscurity(target.x,target.y) == 5 && spell_being_cast != eSpell::DISPEL_BARRIER) { - add_string_to_buf(" Target space obstructed. "); + add_string_to_buf(" Target space obstructed."); return; } if(univ.town.is_antimagic(target.x,target.y)) { @@ -1002,15 +1002,15 @@ void do_combat_cast(location target) { } if((adjust = can_see_light(caster.combat_pos,target,sight_obscurity)) > 4) { - add_string_to_buf(" Can't see target. "); + add_string_to_buf(" Can't see target."); } else if(loc_off_act_area(target)) { - add_string_to_buf(" Space not in town. "); + add_string_to_buf(" Space not in town."); } else if(dist(caster.combat_pos,target) > (*spell_being_cast).range) add_string_to_buf(" Target out of range."); else if(sight_obscurity(target.x,target.y) == 5 && spell_being_cast != eSpell::DISPEL_BARRIER) - add_string_to_buf(" Target space obstructed. "); + add_string_to_buf(" Target space obstructed."); else if(univ.town.is_antimagic(target.x,target.y)) add_string_to_buf(" Target in antimagic field."); else { @@ -1066,7 +1066,7 @@ void do_combat_cast(location target) { hit_space(target,r1,eDamageType::FIRE,true,true); univ.town.set_fire_barr(target.x,target.y,true); if(univ.town.is_fire_barr(target.x,target.y)) - add_string_to_buf(" You create the barrier. "); + add_string_to_buf(" You create the barrier."); else add_string_to_buf(" Failed."); break; case eSpell::BARRIER_FORCE: @@ -1075,7 +1075,7 @@ void do_combat_cast(location target) { hit_space(target,r1,eDamageType::FIRE,true,true); univ.town.set_force_barr(target.x,target.y,true); if(univ.town.is_force_barr(target.x,target.y)) - add_string_to_buf(" You create the barrier. "); + add_string_to_buf(" You create the barrier."); else add_string_to_buf(" Failed."); break; @@ -1233,7 +1233,7 @@ void do_combat_cast(location target) { default: if(!(victim = univ.target_there(target, TARG_MONST))) - add_string_to_buf(" Nobody there "); + add_string_to_buf(" Nobody there."); else { cCreature* cur_monst = dynamic_cast(victim); if(cur_monst->attitude % 2 != 1 && spell_being_cast != eSpell::SCRY_MONSTER && spell_being_cast != eSpell::CAPTURE_SOUL) @@ -1375,14 +1375,14 @@ void do_combat_cast(location target) { case eSpell::TURN_UNDEAD: case eSpell::DISPEL_UNDEAD: if(cur_monst->m_type != eRace::UNDEAD) { - add_string_to_buf(" Not undead. "); + add_string_to_buf(" Not undead."); store_m_type = -1; break; } store_m_type = 8; r1 = get_ran(1,0,90); if(r1 > hit_chance[minmax(0,19,bonus * 2 + level * 4 - (cur_monst->level / 2) + 3)]) - add_string_to_buf(" Monster resisted. "); + add_string_to_buf(" Monster resisted."); else { r1 = get_ran((spell_being_cast == eSpell::TURN_UNDEAD) ? 2 : 6, 1, 14); @@ -1393,13 +1393,13 @@ void do_combat_cast(location target) { case eSpell::RAVAGE_SPIRIT: if(cur_monst->m_type != eRace::DEMON) { - add_string_to_buf(" Not a demon. "); + add_string_to_buf(" Not a demon."); store_m_type = -1; break; } r1 = get_ran(1,1,100); if(r1 > hit_chance[minmax(0,19,level * 4 - cur_monst->level + 10)]) - add_string_to_buf(" Demon resisted. "); + add_string_to_buf(" Demon resisted."); else { r1 = get_ran(8 + bonus * 2, 1, 11); //if(PSD[4][0] == 3) // anama @@ -1484,7 +1484,7 @@ void load_missile() { if(thrown < 24) { missile_inv_slot = thrown; ammo_inv_slot = thrown; - add_string_to_buf("Throw: Select a target. "); + add_string_to_buf("Throw: Select a target."); add_string_to_buf(" (Hit 's' to cancel.)"); overall_mode = MODE_THROWING; current_spell_range = 8; @@ -1495,19 +1495,19 @@ void load_missile() { else current_pat = single; } else if(((bolts < 24) && (bow < 24)) || ((arrow < 24) && (crossbow < 24))) { - add_string_to_buf("Fire: Wrong ammunition. "); + add_string_to_buf("Fire: Wrong ammunition."); } else if((arrow == 24) && (bow < 24)) { - add_string_to_buf("Fire: Equip some arrows. "); + add_string_to_buf("Fire: Equip some arrows."); } else if(crossbow == 24 && bolts < 24) { - add_string_to_buf("Fire: Equip some bolts. "); + add_string_to_buf("Fire: Equip some bolts."); } else if((arrow < 24) && (bow < 24)) { missile_inv_slot = bow; ammo_inv_slot = arrow; overall_mode = MODE_FIRING; - add_string_to_buf("Fire: Select a target. "); + add_string_to_buf("Fire: Select a target."); add_string_to_buf(" (Hit 's' to cancel.)"); current_spell_range = 12; if(univ.party[current_pc].items[arrow].ability == eItemAbil::DISTANCE_MISSILE) @@ -1520,7 +1520,7 @@ void load_missile() { missile_inv_slot = crossbow; ammo_inv_slot = bolts; overall_mode = MODE_FIRING; - add_string_to_buf("Fire: Select a target. "); + add_string_to_buf("Fire: Select a target."); add_string_to_buf(" (Hit 's' to cancel.)"); current_spell_range = 12; if(univ.party[current_pc].items[bolts].ability == eItemAbil::DISTANCE_MISSILE) @@ -1533,7 +1533,7 @@ void load_missile() { missile_inv_slot = no_ammo; ammo_inv_slot = no_ammo; overall_mode = MODE_FIRING; - add_string_to_buf("Fire: Select a target. "); + add_string_to_buf("Fire: Select a target."); add_string_to_buf(" (Hit 's' to cancel.)"); current_spell_range = 12; if(univ.party[current_pc].items[no_ammo].ability == eItemAbil::DISTANCE_MISSILE) @@ -1542,7 +1542,7 @@ void load_missile() { current_pat = radius2; else current_pat = single; } - else add_string_to_buf("Fire: Equip a missile. "); + else add_string_to_buf("Fire: Equip a missile."); } void fire_missile(location target) { @@ -1609,13 +1609,13 @@ void fire_missile(location target) { if(dist(missile_firer.combat_pos,target) > range) add_string_to_buf(" Out of range."); else if(can_see_light(missile_firer.combat_pos,target,sight_obscurity) >= 5) - add_string_to_buf(" Can't see target. "); + add_string_to_buf(" Can't see target."); else { // First, some missiles do special things if(exploding) { take_ap((overall_mode == MODE_FIRING) ? 3 : 2); univ.party[current_pc].void_sanctuary(); // TODO: Is this right? - add_string_to_buf(" The arrow explodes! "); + add_string_to_buf(" The arrow explodes!"); if(PSD[SDF_GAME_SPEED] == 0) pause(dist(missile_firer.combat_pos,target)); else @@ -1760,8 +1760,7 @@ bool combat_next_step() { set_pc_moves(); if((combat_active_pc < 6) && (univ.party[combat_active_pc].ap == 0)){ combat_active_pc = 6; - ASB("The active character is unable to act!"); - ASB("The whole party is now active."); + ASB("The active character is unable to act! The whole party is now active.", 2); } to_return = true; // Safety valve @@ -2438,7 +2437,7 @@ void do_monster_turn() { if(cur_monst->active != 0) { // Take care of monster effects if(cur_monst->status[eStatus::ACID] > 0) { // Acid if(!printed_acid) { - add_string_to_buf("Acid: "); + add_string_to_buf("Acid:"); printed_acid = true; } r1 = get_ran(cur_monst->status[eStatus::ACID],1,6); @@ -2458,7 +2457,7 @@ void do_monster_turn() { if(cur_monst->status[eStatus::POISON] > 0) { // Poison if(!printed_poison) { - add_string_to_buf("Poisoned monsters: "); + add_string_to_buf("Poisoned monsters:"); printed_poison = true; } r1 = get_ran(cur_monst->status[eStatus::POISON],1,6); @@ -2467,7 +2466,7 @@ void do_monster_turn() { } if(cur_monst->status[eStatus::DISEASE] > 0) { // Disease if(!printed_disease) { - add_string_to_buf("Diseased monsters: "); + add_string_to_buf("Diseased monsters:"); printed_disease = true; } k = get_ran(1,1,5); @@ -2529,7 +2528,7 @@ void monster_attack(short who_att,iLiving* target) { if(target->status[eStatus::INVISIBLE] > 0) { r1 = get_ran(1,1,100); if(r1 > hit_chance[attacker->level / 2]) { - add_string_to_buf(" Can't find target! "); + add_string_to_buf(" Can't find target!"); } return; } @@ -2600,7 +2599,7 @@ void monster_attack(short who_att,iLiving* target) { if(target->is_shielded()) { int dmg = attacker->get_shared_dmg(store_hp - target->get_health()); - add_string_to_buf(" Shares damage! "); + add_string_to_buf(" Shares damage!"); int who_hit = pc_target != nullptr ? 6 : 7; damage_monst(who_att, who_hit, dmg, eDamageType::MAGIC,0); } @@ -4228,7 +4227,7 @@ void do_poison() { if(univ.party[i].status[eStatus::POISON] > 0) some_poison = true; if(some_poison) { - add_string_to_buf("Poison: "); + add_string_to_buf("Poison:"); for(i = 0; i < 6; i++) if(univ.party[i].main_status == eMainStatus::ALIVE) if(univ.party[i].status[eStatus::POISON] > 0) { @@ -4258,7 +4257,7 @@ void handle_disease() { disease = true; if(disease) { - add_string_to_buf("Disease: "); + add_string_to_buf("Disease:"); for(i = 0; i < 6; i++) if(univ.party[i].main_status == eMainStatus::ALIVE) if(univ.party[i].status[eStatus::DISEASE] > 0) { @@ -4303,7 +4302,7 @@ void handle_acid() { some_acid = true; if(some_acid) { - add_string_to_buf("Acid: "); + add_string_to_buf("Acid:"); for(i = 0; i < 6; i++) if(univ.party[i].main_status == eMainStatus::ALIVE) if(univ.party[i].status[eStatus::ACID] > 0) { @@ -4392,11 +4391,11 @@ bool combat_cast_mage_spell() { } store_sp = univ.party[current_pc].cur_sp; if(univ.party[current_pc].cur_sp == 0) - add_string_to_buf("Cast: No spell points. "); + add_string_to_buf("Cast: No spell points."); else if(univ.party[current_pc].skill(eSkill::MAGE_SPELLS) == 0) - add_string_to_buf("Cast: No mage skill. "); + add_string_to_buf("Cast: No mage skill."); else if(get_encumberance(current_pc) > 1) { - add_string_to_buf("Cast: Too encumbered. "); + add_string_to_buf("Cast: Too encumbered."); take_ap(6); give_help(40,0); return true; @@ -4418,7 +4417,7 @@ bool combat_cast_mage_spell() { return false; get_monst = univ.scenario.scen_monsters[store_sum_monst]; if(store_sp < get_monst.level) { - add_string_to_buf("Cast: Not enough spell points. "); + add_string_to_buf("Cast: Not enough spell points."); return false; } store_sum_monst_cost = get_monst.level; @@ -4602,10 +4601,10 @@ bool combat_cast_priest_spell() { store_sp = univ.party[current_pc].cur_sp; if(univ.party[current_pc].cur_sp == 0) { - add_string_to_buf("Cast: No spell points. "); + add_string_to_buf("Cast: No spell points."); return false; } else if(univ.party[current_pc].skill(eSkill::PRIEST_SPELLS) == 0) { - add_string_to_buf("Cast: No priest skill. "); + add_string_to_buf("Cast: No priest skill."); return false; } @@ -4614,7 +4613,7 @@ bool combat_cast_priest_spell() { combat_posing_monster = current_working_monster = current_pc; if(univ.party[current_pc].cur_sp == 0) - add_string_to_buf("Cast: No spell points. "); + add_string_to_buf("Cast: No spell points."); else if(spell_num != eSpell::NONE) { print_spell_cast(spell_num,eSkill::PRIEST_SPELLS); if((*spell_num).refer == REFER_YES) { diff --git a/src/boe.fileio.cpp b/src/boe.fileio.cpp index cc6b0078..6966d62d 100644 --- a/src/boe.fileio.cpp +++ b/src/boe.fileio.cpp @@ -143,7 +143,7 @@ void finish_load_party(){ last_load_file = file_to_load.filename().string(); store_file_reply = file_to_load; - add_string_to_buf("Load: Game loaded. "); + add_string_to_buf("Load: Game loaded."); // Set sounds, map saving, and speed if(((play_sounds) && (PSD[SDF_NO_SOUNDS] == 1)) || diff --git a/src/boe.items.cpp b/src/boe.items.cpp index b8001508..7263e42a 100644 --- a/src/boe.items.cpp +++ b/src/boe.items.cpp @@ -110,12 +110,12 @@ void equip_item(short pc_num,short item_num) { // unequip if(univ.party[pc_num].equip[item_num]) { if(univ.party[pc_num].equip[item_num] && univ.party[pc_num].items[item_num].cursed) - add_string_to_buf("Equip: Item is cursed. "); + add_string_to_buf("Equip: Item is cursed."); else { univ.party[pc_num].equip[item_num] = false; add_string_to_buf("Equip: Unequipped"); if(univ.party[pc_num].weap_poisoned == item_num && univ.party[pc_num].status[eStatus::POISONED_WEAPON] > 0) { - add_string_to_buf(" Poison lost. "); + add_string_to_buf(" Poison lost."); univ.party[pc_num].status[eStatus::POISONED_WEAPON] = 0; } } @@ -138,8 +138,7 @@ void equip_item(short pc_num,short item_num) { if(equip_item_type > 0) { for(i = 0; i < 24; i++) if((univ.party[pc_num].equip[i]) && (excluding_types[univ.party[pc_num].items[i].variety] == equip_item_type)) { - add_string_to_buf("Equip: You have something of"); - add_string_to_buf(" this type equipped."); + add_string_to_buf("Equip: You have something of this type equipped.", 2); return; } } @@ -174,7 +173,7 @@ void drop_item(short pc_num,short item_num,location where_drop) { item_store = univ.party[pc_num].items[item_num]; if(univ.party[pc_num].equip[item_num] && univ.party[pc_num].items[item_num].cursed) - add_string_to_buf("Drop: Item is cursed. "); + add_string_to_buf("Drop: Item is cursed."); else switch(overall_mode) { case MODE_OUTDOORS: choice = cChoiceDlog("drop-item-confirm",{"okay","cancel"}).show(); @@ -247,7 +246,7 @@ void give_thing(short pc_num, short item_num) { bool take_given_item = true; if(univ.party[pc_num].equip[item_num] && univ.party[pc_num].items[item_num].cursed) - add_string_to_buf("Give: Item is cursed. "); + add_string_to_buf("Give: Item is cursed."); else { item_store = univ.party[pc_num].items[item_num]; who_to = char_select_pc(3,"Give item to who?"); diff --git a/src/boe.main.cpp b/src/boe.main.cpp index cd456de3..3f178694 100644 --- a/src/boe.main.cpp +++ b/src/boe.main.cpp @@ -474,9 +474,7 @@ void handle_menu_choice(eMenu item_hit) { give_help(56,0); create_pc(6,NULL); } else { - add_string_to_buf("Add PC: You cannot add new"); - add_string_to_buf(" characters in this town."); - add_string_to_buf(" Try in the town you started in."); + add_string_to_buf("Add PC: You cannot add new characters in this town. Try in the town you started in.", 2); } print_buf(); put_pc_screen(); diff --git a/src/boe.party.cpp b/src/boe.party.cpp index d8204d92..fedb164a 100644 --- a/src/boe.party.cpp +++ b/src/boe.party.cpp @@ -678,22 +678,22 @@ bool poison_weapon( short pc_num, short how_much,short safe) { i = 30; } if(weap == 24) { - add_string_to_buf(" No weapon equipped. "); + add_string_to_buf(" No weapon equipped."); return false; } else { p_level = how_much; - add_string_to_buf(" You poison your weapon. "); + add_string_to_buf(" You poison your weapon."); r1 = get_ran(1,1,100); // Nimble? if(univ.party[pc_num].traits[eTrait::NIMBLE]) r1 -= 6; if((r1 > p_chance[univ.party[pc_num].skill(eSkill::POISON)]) && (safe == 0)) { - add_string_to_buf(" Poison put on badly. "); + add_string_to_buf(" Poison put on badly."); p_level = p_level / 2; r1 = get_ran(1,1,100); if(r1 > p_chance[univ.party[pc_num].skill(eSkill::POISON)] + 10) { - add_string_to_buf(" You nick yourself. "); + add_string_to_buf(" You nick yourself."); univ.party[pc_num].status[eStatus::POISON] += p_level; } } @@ -927,9 +927,9 @@ void do_mage_spell(short pc_num,eSpell spell_num,bool freebie) { case eSpell::MAGIC_MAP: item = univ.party[pc_num].has_abil(eItemAbil::SAPPHIRE); if(item == 24 && !freebie) - add_string_to_buf(" You need a sapphire. "); + add_string_to_buf(" You need a sapphire."); else if(univ.town->defy_scrying || univ.town->defy_mapping) - add_string_to_buf(" The spell fails. "); + add_string_to_buf(" The spell fails."); else { if(freebie) add_string_to_buf(" You have a vision."); else { @@ -937,8 +937,7 @@ void do_mage_spell(short pc_num,eSpell spell_num,bool freebie) { if(stat_window == pc_num) put_item_screen(stat_window,1); univ.party[pc_num].cur_sp -= (*spell_num).cost; - add_string_to_buf(" As the sapphire dissolves, "); - add_string_to_buf(" you have a vision. "); + add_string_to_buf(" As the sapphire dissolves, you have a vision.", 2); } for(i = 0; i < 64; i++) for(j = 0; j < 64; j++) @@ -966,17 +965,17 @@ void do_mage_spell(short pc_num,eSpell spell_num,bool freebie) { case eSpell::FLIGHT: if(univ.party.status[ePartyStatus::FLIGHT] > 0) { - add_string_to_buf(" Not while already flying. "); + add_string_to_buf(" Not while already flying."); return; } if(univ.party.in_boat >= 0) - add_string_to_buf(" Leave boat first. "); + add_string_to_buf(" Leave boat first."); else if(univ.party.in_horse >= 0) //// - add_string_to_buf(" Leave horse first. "); + add_string_to_buf(" Leave horse first."); else { if(!freebie) univ.party[pc_num].cur_sp -= (*spell_num).cost; - add_string_to_buf(" You start flying! "); + add_string_to_buf(" You start flying!"); univ.party.status[ePartyStatus::FLIGHT] = 3; } break; @@ -1048,7 +1047,7 @@ void do_priest_spell(short pc_num,eSpell spell_num,bool freebie) { break; case eSpell::RITUAL_SANCTIFY: - add_string_to_buf(" Sanctify which space? "); + add_string_to_buf(" Sanctify which space?"); start_town_targeting(spell_num,pc_num,freebie); break; @@ -1096,7 +1095,7 @@ void do_priest_spell(short pc_num,eSpell spell_num,bool freebie) { break; case eSpell::MOVE_MOUNTAINS: case eSpell::MOVE_MOUNTAINS_MASS: - add_string_to_buf(" Destroy what? "); + add_string_to_buf(" Destroy what?"); start_town_targeting(spell_num,pc_num,freebie, spell_num == eSpell::MOVE_MOUNTAINS ? PAT_SINGLE : PAT_SQ); break; @@ -1105,21 +1104,21 @@ void do_priest_spell(short pc_num,eSpell spell_num,bool freebie) { break; case eSpell::DETECT_LIFE: - add_string_to_buf(" Monsters now on map. "); + add_string_to_buf(" Monsters now on map."); univ.party.status[ePartyStatus::DETECT_LIFE] += 6 + get_ran(1,0,6); clear_map(); if(!freebie) univ.party[pc_num].cur_sp -= (*spell_num).cost; break; case eSpell::FIREWALK: - add_string_to_buf(" You are now firewalking. "); + add_string_to_buf(" You are now firewalking."); univ.party.status[ePartyStatus::FIREWALK] += univ.party[pc_num].level / 12 + 2; if(!freebie) univ.party[pc_num].cur_sp -= (*spell_num).cost; break; case eSpell::SHATTER: - add_string_to_buf(" You send out a burst of energy. "); + add_string_to_buf(" You send out a burst of energy."); if(!freebie) univ.party[pc_num].cur_sp -= (*spell_num).cost; for(loc.x = where.x - 1;loc.x < where.x + 2; loc.x++) @@ -1130,15 +1129,15 @@ void do_priest_spell(short pc_num,eSpell spell_num,bool freebie) { case eSpell::WORD_RECALL: if(overall_mode > MODE_OUTDOORS) { - add_string_to_buf(" Can only cast outdoors. "); + add_string_to_buf(" Can only cast outdoors."); return; } if(univ.party.in_boat >= 0) { - add_string_to_buf(" Not while in boat. "); + add_string_to_buf(" Not while in boat."); return; } if(univ.party.in_horse >= 0) {//// - add_string_to_buf(" Not while on horseback. "); + add_string_to_buf(" Not while on horseback."); return; } if(!freebie) @@ -1422,7 +1421,7 @@ void cast_town_spell(location where) { return; // The special node intercepted and cancelled regular spell behaviour. if(adjust > 4) - add_string_to_buf(" Can't see target. "); + add_string_to_buf(" Can't see target."); else switch(town_spell) { case eSpell::NONE: // Not a spell but a special node targeting run_special(eSpecCtx::TARGET, 2, spell_caster, where, &r1, &adjust, &store); @@ -1442,12 +1441,12 @@ void cast_town_spell(location where) { break; case eSpell::DISPEL_FIELD: case eSpell::DISPEL_SPHERE: case eSpell::DISPEL_SQUARE: - add_string_to_buf(" You attempt to dispel. "); + add_string_to_buf(" You attempt to dispel."); place_spell_pattern(current_pat,where,FIELD_DISPEL,7); break; case eSpell::MOVE_MOUNTAINS: case eSpell::MOVE_MOUNTAINS_MASS: - add_string_to_buf(" You blast the area. "); + add_string_to_buf(" You blast the area."); place_spell_pattern(current_pat, where, FIELD_SMASH, 7); update_explored(univ.town.p_loc); break; @@ -1458,7 +1457,7 @@ void cast_town_spell(location where) { } univ.town.set_fire_barr(where.x,where.y,true); if(univ.town.is_fire_barr(where.x,where.y)) - add_string_to_buf(" You create the barrier. "); + add_string_to_buf(" You create the barrier."); else add_string_to_buf(" Failed."); break; case eSpell::BARRIER_FORCE: @@ -1468,18 +1467,18 @@ void cast_town_spell(location where) { } univ.town.set_force_barr(where.x,where.y,true); if(univ.town.is_force_barr(where.x,where.y)) - add_string_to_buf(" You create the barrier. "); + add_string_to_buf(" You create the barrier."); else add_string_to_buf(" Failed."); break; case eSpell::QUICKFIRE: univ.town.set_quickfire(where.x,where.y,true); if(univ.town.is_quickfire(where.x,where.y)) - add_string_to_buf(" You create quickfire. "); + add_string_to_buf(" You create quickfire."); else add_string_to_buf(" Failed."); break; case eSpell::ANTIMAGIC: - add_string_to_buf(" You create an antimagic cloud. "); + add_string_to_buf(" You create an antimagic cloud."); for(loc.x = 0; loc.x < univ.town->max_dim(); loc.x++) for(loc.y = 0; loc.y < univ.town->max_dim(); loc.y++) if(dist(where,loc) <= 2 && can_see(where,loc,sight_obscurity) < 5 && @@ -1501,16 +1500,16 @@ void cast_town_spell(location where) { r1 += univ.scenario.ter_types[ter].flag2.u * 7; } if(r1 < (135 - combat_percent[min(19,univ.party[who_cast].level)])) { - add_string_to_buf(" Door unlocked. "); + add_string_to_buf(" Door unlocked."); play_sound(9); univ.town->terrain(where.x,where.y) = univ.scenario.ter_types[ter].flag1.u; } else { play_sound(41); - add_string_to_buf(" Didn't work. "); + add_string_to_buf(" Didn't work."); } }else - add_string_to_buf(" Wrong terrain type. "); + add_string_to_buf(" Wrong terrain type."); break; case eSpell::DISPEL_BARRIER: @@ -1519,7 +1518,7 @@ void cast_town_spell(location where) { if(univ.town.is_fire_barr(where.x,where.y)) r1 -= 8; if(r1 < (120 - combat_percent[min(19,univ.party[who_cast].level)])) { - add_string_to_buf(" Barrier broken. "); + add_string_to_buf(" Barrier broken."); univ.town.set_fire_barr(where.x,where.y,false); univ.town.set_force_barr(where.x,where.y,false); @@ -1529,7 +1528,7 @@ void cast_town_spell(location where) { else { store = get_ran(1,0,1); play_sound(41); - add_string_to_buf(" Didn't work. "); + add_string_to_buf(" Didn't work."); } } else if(univ.town.is_force_cage(where.x,where.y)) { add_string_to_buf(" Cage broken."); @@ -2297,7 +2296,7 @@ void do_alchemy() { r1 = get_ran(1,1,100); if(r1 < fail_chance[univ.party[pc_num].skill(eSkill::ALCHEMY) - alch_difficulty[which_p]]) { - add_string_to_buf("Alchemy: Failed. "); + add_string_to_buf("Alchemy: Failed."); r1 = get_ran(1,0,1); play_sound(41 ); } @@ -2309,11 +2308,10 @@ void do_alchemy() { store_i.charges++; store_i.graphic_num += get_ran(1,0,2); if(!univ.party[pc_num].give_item(store_i,false)) { - ASB("No room in inventory."); - ASB(" Potion placed on floor."); + add_string_to_buf("No room in inventory. Potion placed on floor.", 2); place_item(store_i,univ.town.p_loc,true); } - else add_string_to_buf("Alchemy: Successful. "); + else add_string_to_buf("Alchemy: Successful."); } put_item_screen(stat_window,0); } @@ -2656,7 +2654,7 @@ bool damage_pc(short which_pc,short how_much,eDamageType damage_type,eRace type_ univ.party[which_pc].cur_health = 0; else // Check if PC can die if(how_much > 25) { - add_string_to_buf(" " + univ.party[which_pc].name + " is obliterated. "); + add_string_to_buf(" " + univ.party[which_pc].name + " is obliterated."); kill_pc(which_pc, eMainStatus::DUST); } else { @@ -2709,7 +2707,7 @@ void kill_pc(short which_pc,eMainStatus type) { int luck = univ.party[which_pc].skill(eSkill::LUCK); if(!no_save && type != eMainStatus::ABSENT && luck > 0 && get_ran(1,1,100) < hit_chance[luck]) { - add_string_to_buf(" But you luck out! "); + add_string_to_buf(" But you luck out!"); univ.party[which_pc].cur_health = 0; } else if(i == 24 || type == eMainStatus::ABSENT) { @@ -2738,7 +2736,7 @@ void kill_pc(short which_pc,eMainStatus type) { univ.party[which_pc].ap = 0; } else { - add_string_to_buf(" Life saved! "); + add_string_to_buf(" Life saved!"); univ.party[which_pc].take_item(i); univ.party[which_pc].heal(200); } diff --git a/src/boe.specials.cpp b/src/boe.specials.cpp index f16ed5ee..2d8e2a77 100644 --- a/src/boe.specials.cpp +++ b/src/boe.specials.cpp @@ -186,7 +186,7 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc, if((mode == eSpecCtx::TOWN_MOVE || (mode == eSpecCtx::COMBAT_MOVE && which_combat_type == 1)) && (univ.town.is_special(where_check.x,where_check.y))) { if(univ.town.is_force_barr(where_check.x,where_check.y)) { - add_string_to_buf(" Magic barrier! "); + add_string_to_buf(" Magic barrier!"); return false; } if(univ.town.is_force_cage(where_check.x,where_check.y)) { @@ -228,7 +228,7 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc, check_fields(where_check,mode,which_pc); if(univ.town.is_web(where_check.x,where_check.y)) { - add_string_to_buf(" Webs! "); + add_string_to_buf(" Webs!"); if(mode != eSpecCtx::COMBAT_MOVE) { for(i = 0; i < 6; i++) { r1 = get_ran(1,2,3); @@ -240,11 +240,11 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc, univ.town.set_web(where_check.x,where_check.y,false); } if(univ.town.is_force_barr(where_check.x,where_check.y)) { - add_string_to_buf(" Magic barrier! "); + add_string_to_buf(" Magic barrier!"); can_enter = false; } if(univ.town.is_force_cage(where_check.x,where_check.y)) { - add_string_to_buf(" Force cage! "); + add_string_to_buf(" Force cage!"); can_enter = false; } if(univ.town.is_crate(where_check.x,where_check.y)) { @@ -475,19 +475,19 @@ void check_fields(location where_check,eSpecCtx mode,cPlayer& which_pc) { if(is_out()) return; if(univ.town.is_fire_wall(where_check.x,where_check.y)) { - add_string_to_buf(" Fire wall! "); + add_string_to_buf(" Fire wall!"); r1 = get_ran(1,1,6) + 1; if(mode == eSpecCtx::COMBAT_MOVE) damage_pc(i_pc,r1,eDamageType::FIRE,eRace::UNKNOWN,0); } if(univ.town.is_force_wall(where_check.x,where_check.y)) { - add_string_to_buf(" Force wall! "); + add_string_to_buf(" Force wall!"); r1 = get_ran(2,1,6); if(mode == eSpecCtx::COMBAT_MOVE) damage_pc(i_pc,r1,eDamageType::MAGIC,eRace::UNKNOWN,0); } if(univ.town.is_ice_wall(where_check.x,where_check.y)) { - add_string_to_buf(" Ice wall! "); + add_string_to_buf(" Ice wall!"); r1 = get_ran(2,1,6); if(mode == eSpecCtx::COMBAT_MOVE) damage_pc(i_pc,r1,eDamageType::COLD,eRace::UNKNOWN,0); @@ -495,28 +495,28 @@ void check_fields(location where_check,eSpecCtx mode,cPlayer& which_pc) { boom_space(univ.party.p_loc,overall_mode,4,r1,7); } if(univ.town.is_blade_wall(where_check.x,where_check.y)) { - add_string_to_buf(" Blade wall! "); + add_string_to_buf(" Blade wall!"); r1 = get_ran(4,1,8); if(mode == eSpecCtx::COMBAT_MOVE) damage_pc(i_pc,r1,eDamageType::WEAPON,eRace::UNKNOWN,0); } if(univ.town.is_quickfire(where_check.x,where_check.y)) { - add_string_to_buf(" Quickfire! "); + add_string_to_buf(" Quickfire!"); r1 = get_ran(2,1,8); if(mode == eSpecCtx::COMBAT_MOVE) damage_pc(i_pc,r1,eDamageType::FIRE,eRace::UNKNOWN,0); } if(univ.town.is_scloud(where_check.x,where_check.y)) { - add_string_to_buf(" Stinking cloud! "); + add_string_to_buf(" Stinking cloud!"); univ.party[current_pc].curse(get_ran(1,2,3)); } if(univ.town.is_sleep_cloud(where_check.x,where_check.y)) { - add_string_to_buf(" Sleep cloud! "); + add_string_to_buf(" Sleep cloud!"); univ.party[current_pc].sleep(eStatus::ASLEEP,3,0); put_pc_screen(); } if(univ.town.is_fire_barr(where_check.x,where_check.y)) { - add_string_to_buf(" Magic barrier! "); + add_string_to_buf(" Magic barrier!"); r1 = get_ran(2,1,10); if(is_town()) fast_bang = 1; if(mode == eSpecCtx::COMBAT_MOVE) @@ -590,31 +590,31 @@ void use_item(short pc,short item) { user_loc = univ.party[current_pc].combat_pos; if(item_use_code == 0) { - add_string_to_buf("Use: Can't use this item. "); + add_string_to_buf("Use: Can't use this item."); take_charge = false; } if(univ.party[pc].traits[eTrait::MAGICALLY_INEPT] && !inept_ok){ - add_string_to_buf("Use: Can't - magically inept. "); + add_string_to_buf("Use: Can't - magically inept."); take_charge = false; } // 0 - can't use 1 - combat only 2 - town only 3 - town & combat only 4 - everywhere 5 - outdoor if(take_charge) { if(overall_mode == MODE_OUTDOORS && item_use_code < 4) { - add_string_to_buf("Use: Not while outdoors. "); + add_string_to_buf("Use: Not while outdoors."); take_charge = false; } // TODO: Almost all of these look wrong! if((overall_mode == MODE_TOWN) && (item_use_code == 1)) { - add_string_to_buf("Use: Not while in town. "); + add_string_to_buf("Use: Not while in town."); take_charge = false; } if((overall_mode == MODE_COMBAT) && (item_use_code == 2)) { - add_string_to_buf("Use: Not in combat. "); + add_string_to_buf("Use: Not in combat."); take_charge = false; } if((overall_mode != MODE_OUTDOORS) && (item_use_code == 5)){ - add_string_to_buf("Use: Only outdoors. "); + add_string_to_buf("Use: Only outdoors."); take_charge = false; } } @@ -967,13 +967,13 @@ void use_item(short pc,short item) { case ePartyStatus::DETECT_LIFE: ASB(" You detect life."); break; case ePartyStatus::FLIGHT: if(univ.party.status[ePartyStatus::FLIGHT] > 0) { - add_string_to_buf(" Not while already flying. "); + add_string_to_buf(" Not while already flying."); take_charge = false; } else if(univ.party.in_boat >= 0) { - add_string_to_buf(" Leave boat first. "); + add_string_to_buf(" Leave boat first."); take_charge = false; } else if(univ.party.in_horse >= 0) { - add_string_to_buf(" Leave horse first. "); + add_string_to_buf(" Leave horse first."); take_charge = false; } else ASB(" You rise into the air!"); break; @@ -1192,7 +1192,7 @@ bool adj_town_look(location where) { if(where == univ.town->special_locs[i]) { if(get_blockage(univ.town->terrain(where.x,where.y)) > 0) { // tell party you find something, if looking at a space they can't step in - add_string_to_buf(" Search: You find something! "); + add_string_to_buf(" Search: You find something!"); } run_special(eSpecCtx::TOWN_LOOK,2,univ.town->spec_id[i],where,&s1,&s2,&s3); @@ -1207,11 +1207,10 @@ bool adj_town_look(location where) { get_item(where,6,true); }else if(univ.scenario.ter_types[terrain].special == eTerSpec::CHANGE_WHEN_USED || univ.scenario.ter_types[terrain].special == eTerSpec::CALL_SPECIAL_WHEN_USED) { - add_string_to_buf(" (Use this space to do something"); - add_string_to_buf(" with it.)"); + add_string_to_buf(" (Use this space to do something with it.)", 2); }else{ if(!got_special) - add_string_to_buf(" Search: You don't find anything. "); + add_string_to_buf(" Search: You don't find anything."); return false; } return false; @@ -1483,7 +1482,7 @@ bool damage_monst(short which_m, short who_hit, short how_much, eDamageType dam_ if((victim->attitude % 2 != 1) && (who_hit < 7) && ((processing_fields && !monsters_going) || (processing_fields && !PSD[SDF_HOSTILES_PRESENT]))) { - add_string_to_buf("Damaged an innocent. "); + add_string_to_buf("Damaged an innocent."); victim->attitude = 1; make_town_hostile(); } @@ -2035,9 +2034,9 @@ void general_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, get_strs(str1,str2, cur_spec_type,cur_node.m1 + mess_adj[cur_spec_type], cur_node.m2 + mess_adj[cur_spec_type]); if(cur_node.m1 >= 0) - ASB(str1.c_str(), 4); + add_string_to_buf(str1, 4); if(cur_node.m2 >= 0) - ASB(str2.c_str(), 4); + add_string_to_buf(str2, 4); break; case eSpecType::FLIP_SDF: setsd(cur_node.sd1,cur_node.sd2, @@ -2871,9 +2870,9 @@ void affect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, case eSpecType::AFFECT_PARTY_STATUS: if(spec.ex2a < 0 || spec.ex2a > 3) break; if(spec.ex2a == 1 && univ.party.in_boat >= 0) - add_string_to_buf(" Can't fly when on a boat. "); - else if(spec.ex2a == 1 && univ.party.in_horse >= 0)//// - add_string_to_buf(" Can't fly when on a horse. "); + add_string_to_buf(" Can't fly when on a boat."); + else if(spec.ex2a == 1 && univ.party.in_horse >= 0) + add_string_to_buf(" Can't fly when on a horse."); r1 = univ.party.status[ePartyStatus(spec.ex2a)]; r1 = minmax(0,250,r1 + spec.ex1a); univ.party.status[ePartyStatus::STEALTH] = r1; diff --git a/src/boe.text.cpp b/src/boe.text.cpp index 6eac42b4..e9d972d0 100644 --- a/src/boe.text.cpp +++ b/src/boe.text.cpp @@ -680,62 +680,62 @@ short do_look(location space) { } if(out_boat_there(space) < 30) - add_string_to_buf(" Boat "); + add_string_to_buf(" Boat"); if(out_horse_there(space) < 30) - add_string_to_buf(" Horse "); + add_string_to_buf(" Horse"); } if((overall_mode == MODE_LOOK_TOWN) || (overall_mode == MODE_LOOK_COMBAT)) { if(town_boat_there(space) < 30) - add_string_to_buf(" Boat "); + add_string_to_buf(" Boat"); if(town_horse_there(space) < 30) - add_string_to_buf(" Horse "); + add_string_to_buf(" Horse"); if(univ.town.is_web(space.x,space.y)) - add_string_to_buf(" Web "); + add_string_to_buf(" Web"); if(univ.town.is_crate(space.x,space.y)) - add_string_to_buf(" Crate "); + add_string_to_buf(" Crate"); if(univ.town.is_barrel(space.x,space.y)) - add_string_to_buf(" Barrel "); + add_string_to_buf(" Barrel"); if(univ.town.is_block(space.x,space.y)) - add_string_to_buf(" Stone Block "); + add_string_to_buf(" Stone Block"); if(univ.town.is_fire_barr(space.x,space.y)) - add_string_to_buf(" Magic Barrier "); + add_string_to_buf(" Magic Barrier"); if(univ.town.is_force_barr(space.x,space.y)) - add_string_to_buf(" Magic Barrier "); + add_string_to_buf(" Magic Barrier"); if(univ.town.is_quickfire(space.x,space.y)) - add_string_to_buf(" Quickfire "); + add_string_to_buf(" Quickfire"); if(univ.town.is_fire_wall(space.x,space.y)) - add_string_to_buf(" Wall of Fire "); + add_string_to_buf(" Wall of Fire"); if(univ.town.is_force_wall(space.x,space.y)) - add_string_to_buf(" Wall of Force "); + add_string_to_buf(" Wall of Force"); if(univ.town.is_antimagic(space.x,space.y)) - add_string_to_buf(" Antimagic Field "); + add_string_to_buf(" Antimagic Field"); if(univ.town.is_scloud(space.x,space.y)) - add_string_to_buf(" Stinking Cloud "); + add_string_to_buf(" Stinking Cloud"); if(univ.town.is_ice_wall(space.x,space.y)) - add_string_to_buf(" Ice Wall "); + add_string_to_buf(" Ice Wall"); if(univ.town.is_blade_wall(space.x,space.y)) - add_string_to_buf(" Blade Wall "); + add_string_to_buf(" Blade Wall"); if(univ.town.is_force_cage(space.x,space.y)) - add_string_to_buf(" Force Cage "); + add_string_to_buf(" Force Cage"); if(univ.town.is_sm_blood(space.x,space.y)) - add_string_to_buf(" Blood stain "); + add_string_to_buf(" Blood stain"); if(univ.town.is_med_blood(space.x,space.y)) - add_string_to_buf(" Blood stain "); + add_string_to_buf(" Blood stain"); if(univ.town.is_lg_blood(space.x,space.y)) - add_string_to_buf(" Blood stain "); + add_string_to_buf(" Blood stain"); if(univ.town.is_sm_slime(space.x,space.y)) - add_string_to_buf(" Smears of slime "); + add_string_to_buf(" Smears of slime"); if(univ.town.is_lg_slime(space.x,space.y)) - add_string_to_buf(" Smears of slime "); + add_string_to_buf(" Smears of slime"); if(univ.town.is_ash(space.x,space.y)) - add_string_to_buf(" Ashes "); + add_string_to_buf(" Ashes"); if(univ.town.is_bones(space.x,space.y)) - add_string_to_buf(" Bones "); + add_string_to_buf(" Bones"); if(univ.town.is_rubble(space.x,space.y)) - add_string_to_buf(" Rubble "); + add_string_to_buf(" Rubble"); for(i = 0; i < univ.town.items.size(); i++) { if(univ.town.items[i].variety != eItemType::NO_ITEM && space == univ.town.items[i].item_loc @@ -765,7 +765,7 @@ short do_look(location space) { } if(!is_lit) { - add_string_to_buf(" Dark "); + add_string_to_buf(" Dark"); return 0; } @@ -815,19 +815,19 @@ void notify_out_combat_began(cOutdoors::cWandering encounter,short *nums) { short i; std::string msg; - add_string_to_buf((char *) "COMBAT! "); + add_string_to_buf("COMBAT!"); for(i = 0; i < 6; i++) if(encounter.monst[i] != 0) { msg = get_m_name(encounter.monst[i]); std::ostringstream sout; - sout << " " << nums[i] << " x " << msg << " "; + sout << " " << nums[i] << " x " << msg; msg = sout.str(); - add_string_to_buf((char *) msg.c_str()); + add_string_to_buf(msg); } if(encounter.monst[6] != 0) { - msg = " " + get_m_name(encounter.monst[6]) + " "; - add_string_to_buf((char *) msg.c_str()); + msg = " " + get_m_name(encounter.monst[6]); + add_string_to_buf(msg); } } @@ -880,41 +880,41 @@ void cCreature::spell_note(int which_mess) { std::string msg = m_name; switch(which_mess) { case 1: - msg = " " + msg + " scared. "; + msg = " " + msg + " scared."; break; case 2: - msg = " " + msg + " slowed. "; + msg = " " + msg + " slowed."; break; case 3: - msg = " " + msg + " weakened. "; + msg = " " + msg + " weakened."; break; case 4: - msg = " " + msg + " poisoned. "; + msg = " " + msg + " poisoned."; break; case 5: - msg = " " + msg + " cursed. "; + msg = " " + msg + " cursed."; break; case 6: - msg = " " + msg + " ravaged. "; + msg = " " + msg + " ravaged."; break; case 7: - msg = " " + msg + " undamaged. "; + msg = " " + msg + " undamaged."; break; case 8: - msg = " " + msg + " is stoned. "; + msg = " " + msg + " is stoned."; break; case 9: msg = " Gazes at " + msg + '.'; break; case 10: - msg = " " + msg + " resists. "; + msg = " " + msg + " resists."; break; case 11: msg = " Drains " + msg + '.'; @@ -935,31 +935,31 @@ void cCreature::spell_note(int which_mess) { msg = " Hits " + msg + '.'; break; case 17: - msg = " " + msg + " disappears. "; + msg = " " + msg + " disappears."; break; case 18: msg = " Misses " + msg + '.'; break; case 19: - msg = " " + msg + " is webbed. "; + msg = " " + msg + " is webbed."; break; case 20: - msg = " " + msg + " chokes. "; + msg = " " + msg + " chokes."; break; case 21: - msg = " " + msg + " summoned. "; + msg = " " + msg + " summoned."; break; case 22: - msg = " " + msg + " is dumbfounded. "; + msg = " " + msg + " is dumbfounded."; break; case 23: - msg = " " + msg + " is charmed. "; + msg = " " + msg + " is charmed."; break; case 24: - msg = " " + msg + " is recorded. "; + msg = " " + msg + " is recorded."; break; case 25: - msg = " " + msg + " is diseased. "; + msg = " " + msg + " is diseased."; break; case 26: msg = " " + msg + " is an avatar!"; @@ -968,22 +968,22 @@ void cCreature::spell_note(int which_mess) { msg = " " + msg + " splits!"; break; case 28: - msg = " " + msg + " falls asleep. "; + msg = " " + msg + " falls asleep."; break; case 29: - msg = " " + msg + " wakes up. "; + msg = " " + msg + " wakes up."; break; case 30: - msg = " " + msg + " paralyzed. "; + msg = " " + msg + " paralyzed."; break; case 31: - msg = " " + msg + " covered with acid. "; + msg = " " + msg + " covered with acid."; break; case 32: msg = " Fires spines at " + msg + '.'; break; case 33: - msg = " " + msg + " summons aid. "; + msg = " " + msg + " summons aid."; break; case 34: msg = " " + msg + " is cured."; @@ -1063,6 +1063,8 @@ void cCreature::spell_note(int which_mess) { case 59: msg = " Spits at " + msg + '.'; break; + default: + msg += ": Unknown action " + std::to_string(which_mess); } if(which_mess > 0) @@ -1119,6 +1121,15 @@ void add_string_to_buf(std::string str) { } void add_string_to_buf(std::string str, unsigned short indent) { + static bool inited; + static size_t width; + static TextStyle buf_style; + if(!inited) { + inited = true; + buf_style.font = FONT_PLAIN; + buf_style.pointSize = 12; + width = text_area_gworld.getSize().x - 5; + } if(overall_mode == MODE_STARTUP) return; @@ -1126,20 +1137,25 @@ void add_string_to_buf(std::string str, unsigned short indent) { if(str.find_last_not_of(' ') == std::string::npos) return; - // TODO: Base this on pixel length instead of character length - if(indent && str.find_last_not_of(' ') > 48) { + if(indent && string_length(str.substr(0,str.find_last_not_of(' ')), buf_style) >= width) { if(indent > 20) indent = 20; size_t split = str.find_last_of(' ', 49); + while(string_length(str.substr(0,split), buf_style) >= width) + split = str.find_last_of(' ', split - 1); add_string_to_buf(str.substr(0,split)); str = str.substr(split); - size_t wrap_w = 48 - indent; - while(str.find_last_not_of(' ') > wrap_w) { - std::string wrap(indent, ' '); + std::string space(indent, ' '); + size_t wrap_w = width - string_length(space, buf_style); + while(string_length(str.substr(0,str.find_last_not_of(' ')), buf_style) > wrap_w) { + std::string wrap = space; split = str.find_last_of(' ', 49 - indent); + while(string_length(str.substr(0,split), buf_style) >= wrap_w) + split = str.find_last_of(' ', split - 1); wrap += str.substr(0,split); str = str.substr(split); add_string_to_buf(wrap); } + add_string_to_buf(space + str); return; } diff --git a/src/boe.town.cpp b/src/boe.town.cpp index d2b79ced..f185a91c 100644 --- a/src/boe.town.cpp +++ b/src/boe.town.cpp @@ -1099,7 +1099,7 @@ void dump_gold(short print_mes) { univ.party.gold = 30000; if(print_mes == 1) { put_pc_screen(); - add_string_to_buf("Excess gold dropped. "); + add_string_to_buf("Excess gold dropped."); print_buf(); } } @@ -1107,7 +1107,7 @@ void dump_gold(short print_mes) { univ.party.food = 25000; if(print_mes == 1) { put_pc_screen(); - add_string_to_buf("Excess food dropped. "); + add_string_to_buf("Excess food dropped."); print_buf(); } } @@ -1124,7 +1124,7 @@ void pick_lock(location where,short pc_num) { terrain = univ.town->terrain(where.x,where.y); which_item = univ.party[pc_num].has_abil_equip(eItemAbil::LOCKPICKS); if(which_item == 24) { - add_string_to_buf(" Need lockpick equipped. "); + add_string_to_buf(" Need lockpick equipped."); return; } @@ -1144,14 +1144,14 @@ void pick_lock(location where,short pc_num) { r1 = r1 - 12; if(univ.scenario.ter_types[terrain].special != eTerSpec::UNLOCKABLE) { - add_string_to_buf(" Wrong terrain type. "); + add_string_to_buf(" Wrong terrain type."); return; } unlock_adjust = univ.scenario.ter_types[terrain].flag2.u; if((unlock_adjust >= 5) || (r1 > (unlock_adjust * 15 + 30))) { - add_string_to_buf(" Didn't work. "); + add_string_to_buf(" Didn't work."); if(will_break) { - add_string_to_buf(" Pick breaks. "); + add_string_to_buf(" Pick breaks."); univ.party[pc_num].remove_charge(which_item); if(stat_window == pc_num) put_item_screen(stat_window,1); @@ -1159,7 +1159,7 @@ void pick_lock(location where,short pc_num) { play_sound(41); } else { - add_string_to_buf(" Door unlocked. "); + add_string_to_buf(" Door unlocked."); play_sound(9); univ.town->terrain(where.x,where.y) = univ.scenario.ter_types[terrain].flag1.u; } @@ -1173,17 +1173,17 @@ void bash_door(location where,short pc_num) { r1 = get_ran(1,1,100) - 15 * univ.party[pc_num].stat_adj(eSkill::STRENGTH) + univ.town.difficulty * 4; if(univ.scenario.ter_types[terrain].special != eTerSpec::UNLOCKABLE) { - add_string_to_buf(" Wrong terrain type. "); + add_string_to_buf(" Wrong terrain type."); return; } unlock_adjust = univ.scenario.ter_types[terrain].flag2.u; if(unlock_adjust >= 5 || r1 > (unlock_adjust * 15 + 40) || univ.scenario.ter_types[terrain].flag3.u != 1) { - add_string_to_buf(" Didn't work. "); + add_string_to_buf(" Didn't work."); damage_pc(pc_num,get_ran(1,1,4),eDamageType::UNBLOCKABLE,eRace::UNKNOWN,0); } else { - add_string_to_buf(" Lock breaks. "); + add_string_to_buf(" Lock breaks."); play_sound(9); univ.town->terrain(where.x,where.y) = univ.scenario.ter_types[terrain].flag1.u; } diff --git a/src/boe.townspec.cpp b/src/boe.townspec.cpp index fc1cf20c..a390927f 100644 --- a/src/boe.townspec.cpp +++ b/src/boe.townspec.cpp @@ -64,30 +64,30 @@ bool run_trap(short pc_num,eTrapType trap_type,short trap_level,short diff) { if(r1 < trap_odds[skill]) { - add_string_to_buf(" Trap disarmed. "); + add_string_to_buf(" Trap disarmed."); return true; } - else add_string_to_buf(" Disarm failed. "); + else add_string_to_buf(" Disarm failed."); } switch(trap_type) { case TRAP_BLADE: for(i = 0; i < num_hits; i++) { - add_string_to_buf(" A knife flies out! "); + add_string_to_buf(" A knife flies out!"); r1 = get_ran(2 + univ.town.difficulty / 14,1,10); damage_pc(pc_num,r1,eDamageType::WEAPON,eRace::UNKNOWN,0); } break; case TRAP_DART: - add_string_to_buf(" A dart flies out. "); + add_string_to_buf(" A dart flies out."); r1 = 3 + univ.town.difficulty / 14; r1 = r1 + trap_level * 2; disarmer.poison(r1); break; case TRAP_GAS: - add_string_to_buf(" Poison gas pours out. "); + add_string_to_buf(" Poison gas pours out."); r1 = 2 + univ.town.difficulty / 14; r1 = r1 + trap_level * 2; univ.party.poison(r1); @@ -95,43 +95,43 @@ bool run_trap(short pc_num,eTrapType trap_type,short trap_level,short diff) { case TRAP_EXPLOSION: for(i = 0; i < num_hits; i++) { - add_string_to_buf(" There is an explosion. "); + add_string_to_buf(" There is an explosion."); r1 = get_ran(3 + univ.town.difficulty / 13,1,8); hit_party(r1,eDamageType::FIRE); } break; case TRAP_SLEEP_RAY: - add_string_to_buf(" A purple ray flies out. "); + add_string_to_buf(" A purple ray flies out."); r1 = 200 + univ.town.difficulty * 100; r1 = r1 + trap_level * 400; // TODO: It says sleep ray but is actually paralysis ray? disarmer.sleep(eStatus::PARALYZED, r1, 50); break; case TRAP_DRAIN_XP: - add_string_to_buf(" You feel weak. "); + add_string_to_buf(" You feel weak."); r1 = 40; r1 = r1 + trap_level * 30; disarmer.experience = max(0,disarmer.experience - r1); break; case TRAP_ALERT: - add_string_to_buf(" An alarm goes off!!! "); + add_string_to_buf(" An alarm goes off!!!"); make_town_hostile(); break; case TRAP_FLAMES: - add_string_to_buf(" Flames shoot from the walls. "); + add_string_to_buf(" Flames shoot from the walls."); r1 = get_ran(10 + trap_level * 5,1,8); hit_party(r1,eDamageType::FIRE); break; case TRAP_DUMBFOUND: - add_string_to_buf(" You feel disoriented. "); + add_string_to_buf(" You feel disoriented."); univ.party.dumbfound(2 + trap_level * 2); break; case TRAP_DISEASE: - add_string_to_buf(" You prick your finger. "); + add_string_to_buf(" You prick your finger."); r1 = 3 + univ.town.difficulty / 14; r1 = r1 + trap_level * 2; disarmer.disease(r1); diff --git a/src/tools/graphtool.cpp b/src/tools/graphtool.cpp index 11e5326c..bace53c9 100644 --- a/src/tools/graphtool.cpp +++ b/src/tools/graphtool.cpp @@ -387,8 +387,8 @@ void win_draw_string(sf::RenderTarget& dest_window,rectangle dest_rect,std::stri } } -short string_length(std::string str, TextStyle style, short* height){ - short total_width = 0; +size_t string_length(std::string str, TextStyle style, short* height){ + size_t total_width = 0; sf::Text text; style.applyTo(text); diff --git a/src/tools/graphtool.hpp b/src/tools/graphtool.hpp index 7b12c9ec..90a23219 100644 --- a/src/tools/graphtool.hpp +++ b/src/tools/graphtool.hpp @@ -112,7 +112,7 @@ void rect_draw_some_item(const sf::Texture& src_gworld,rectangle src_rect,const std::vector draw_string_hilite(sf::RenderTarget& dest_window,rectangle dest_rect,std::string str,TextStyle style,std::vector hilites,sf::Color hiliteClr); std::vector draw_string_sel(sf::RenderTarget& dest_window,rectangle dest_rect,std::string str,TextStyle style,std::vector hilites,sf::Color hiliteClr); void win_draw_string(sf::RenderTarget& dest_window,rectangle dest_rect,std::string str,eTextMode mode,TextStyle style, location offset = {0,0}); -short string_length(std::string str, TextStyle style, short* height = nullptr); +size_t string_length(std::string str, TextStyle style, short* height = nullptr); rectangle calc_rect(short i, short j); void setActiveRenderTarget(sf::RenderTarget& where); void flushTessels(sf::Texture& alteredImg);