From 9dfc9e7287b80c48deb37c93ccb4e86ffe24e569 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Wed, 26 Feb 2025 12:10:41 -0600 Subject: [PATCH] DRY a frequently used buffer string --- src/game/boe.actions.cpp | 18 +++++++++--------- src/game/boe.town.cpp | 2 +- src/global.hpp | 2 ++ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/game/boe.actions.cpp b/src/game/boe.actions.cpp index 7b679f5c..b8dce4ee 100644 --- a/src/game/boe.actions.cpp +++ b/src/game/boe.actions.cpp @@ -881,7 +881,7 @@ void handle_switch_pc(short which_pc, bool& need_redraw, bool& need_reprint) { cPlayer& pc = univ.party[which_pc]; if(!prime_time() && overall_mode != MODE_SHOPPING && overall_mode != MODE_TALKING && overall_mode != MODE_ITEM_TARGET) - add_string_to_buf("Set active: Finish what you're doing first."); + add_string_to_buf("Set active: " + FINISH_FIRST); else if(is_combat()) { if(univ.debug_mode && pc.ap <= 0){ pc.ap = 4; @@ -912,7 +912,7 @@ void handle_switch_pc_items(short which_pc, bool& need_redraw) { cPlayer& pc = univ.party[which_pc]; if(!prime_time() && overall_mode != MODE_TALKING && overall_mode != MODE_SHOPPING) - add_string_to_buf("Set active: Finish what you're doing first."); + add_string_to_buf("Set active: " + FINISH_FIRST); else { if(!is_combat()) { if(pc.main_status != eMainStatus::ALIVE && (overall_mode != MODE_SHOPPING || active_shop.getType() != eShopType::ALLOW_DEAD)) @@ -950,7 +950,7 @@ void handle_equip_item(short item_hit, bool& need_redraw) { } else if(stat_screen_mode > MODE_SHOP) { // TODO: For some reason, the game didn't do anything at all in this case. // I'm not sure why; maybe it intended to forward to the sell button? - } else add_string_to_buf("Equip: Finish what you're doing first."); + } else add_string_to_buf("Equip: " + FINISH_FIRST); } void handle_use_item(short item_hit, bool& did_something, bool& need_redraw) { @@ -959,7 +959,7 @@ void handle_use_item(short item_hit, bool& did_something, bool& need_redraw) { } if(!prime_time()) { - add_string_to_buf("Use item: Finish what you're doing first."); + add_string_to_buf("Use item: " + FINISH_FIRST); return; } use_item(stat_window, item_hit); @@ -975,7 +975,7 @@ void handle_give_item(short item_hit, bool& did_something, bool& need_redraw) { } if(!prime_time()) { - add_string_to_buf("Give item: Finish what you're doing first."); + add_string_to_buf("Give item: " + FINISH_FIRST); return; } give_thing(stat_window, item_hit); @@ -993,7 +993,7 @@ void handle_drop_item(short item_hit, bool& need_redraw) { add_string_to_buf("Drop item: Cancelled"); overall_mode = is_town() ? MODE_TOWN : MODE_COMBAT; } else if(!prime_time()) - add_string_to_buf("Drop item: Finish what you're doing first."); + add_string_to_buf("Drop item: " + FINISH_FIRST); else if(is_out()) drop_item(stat_window,item_hit,univ.party.out_loc); else { @@ -1349,7 +1349,7 @@ void handle_trade_places(int which_pc, bool& need_reprint) { record_action("handle_trade_places", boost::lexical_cast(which_pc)); } if(!prime_time()) - add_string_to_buf("Trade places: Finish what you're doing first."); + add_string_to_buf("Trade places: " + FINISH_FIRST); else if(is_combat()) add_string_to_buf("Trade places: Can't do this in combat."); else { @@ -1868,7 +1868,7 @@ void handle_menu_spell(eSpell spell_picked) { eSkill spell_type = (*spell_picked).type; if(!prime_time()) { - ASB("Finish what you're doing first."); + ASB("Cast: " + FINISH_FIRST); print_buf(); return; } @@ -3287,7 +3287,7 @@ void handle_drop_pc() { record_action("handle_drop_pc", ""); } if(!prime_time()) { - ASB("Finish what you're doing first."); + ASB("Delete PC: " + FINISH_FIRST); print_buf(); }else if(is_combat()){ add_string_to_buf("Delete PC: Not in combat."); diff --git a/src/game/boe.town.cpp b/src/game/boe.town.cpp index a9dd989b..822c6bf4 100644 --- a/src/game/boe.town.cpp +++ b/src/game/boe.town.cpp @@ -1545,7 +1545,7 @@ void display_map() { } if(!prime_time()) { - ASB("Finish what you're doing first."); + ASB("Map: " + FINISH_FIRST); print_buf(); return; } diff --git a/src/global.hpp b/src/global.hpp index 440cd38a..8a06f3c6 100644 --- a/src/global.hpp +++ b/src/global.hpp @@ -53,4 +53,6 @@ inline void LOG(std::string line) { #define LOG_VALUE(x) std::cout << #x << ": " << (x) << std::endl; +const std::string FINISH_FIRST = "Finish what you're doing first."; + #endif