From 3bcfbc9f34518f13d5a436778c1757555b969411 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Mon, 26 Aug 2024 22:05:47 -0500 Subject: [PATCH] record and replay lockpick/bash commands --- src/game/boe.actions.cpp | 21 +++++++++++++++++++-- src/game/boe.actions.hpp | 2 ++ src/game/boe.main.cpp | 18 ++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/game/boe.actions.cpp b/src/game/boe.actions.cpp index ad7a7701..19f27511 100644 --- a/src/game/boe.actions.cpp +++ b/src/game/boe.actions.cpp @@ -780,7 +780,12 @@ static void handle_use_space(location destination, bool& did_something, bool& ne put_item_screen(stat_window); } -static void handle_bash_pick_select(bool& need_reprint, bool isBash) { +void handle_bash_pick_select(bool& need_reprint, bool isBash) { + if(recording){ + std::ostringstream sstr; + sstr << std::boolalpha << isBash; + record_action("handle_bash_pick_select", sstr.str()); + } if(overall_mode == MODE_BASH_TOWN || overall_mode == MODE_PICK_TOWN) { add_string_to_buf(" Cancelled."); overall_mode = MODE_TOWN; @@ -791,7 +796,19 @@ static void handle_bash_pick_select(bool& need_reprint, bool isBash) { need_reprint = true; } -static void handle_bash_pick(location destination, bool& did_something, bool& need_redraw, bool isBash) { +void handle_bash_pick(location destination, bool& did_something, bool& need_redraw, bool isBash) { + if(recording){ + std::map info; + std::ostringstream sstr; + sstr << destination; + info["destination"] = sstr.str(); + + sstr.str(""); + sstr << std::boolalpha << isBash; + info["isBash"] = sstr.str(); + + record_action("handle_bash_pick", info); + } if(!adjacent(destination,univ.party.town_loc)) add_string_to_buf(" Must be adjacent."); else { diff --git a/src/game/boe.actions.hpp b/src/game/boe.actions.hpp index 829c8ac1..1c72fa52 100644 --- a/src/game/boe.actions.hpp +++ b/src/game/boe.actions.hpp @@ -65,5 +65,7 @@ void handle_rest(bool& need_redraw, bool& need_reprint); void handle_spellcast(eSkill which_type, bool& did_something, bool& need_redraw, bool& need_reprint, bool record = true); void handle_target_space(location destination, bool& did_something, bool& need_redraw, bool& need_reprint); void handle_pause(bool& did_something, bool& need_redraw); +void handle_bash_pick_select(bool& need_reprint, bool isBash); +void handle_bash_pick(location destination, bool& did_something, bool& need_redraw, bool isBash); #endif diff --git a/src/game/boe.main.cpp b/src/game/boe.main.cpp index 168e1283..ee8bab2d 100644 --- a/src/game/boe.main.cpp +++ b/src/game/boe.main.cpp @@ -457,6 +457,24 @@ static void replay_next_action() { spell_cast_hit_return(); }else if(t == "handle_pause"){ handle_pause(did_something, need_redraw); + }else if(t == "handle_bash_pick_select"){ + std::istringstream sstr(next_action.GetText()); + bool isBash; + sstr >> std::boolalpha >> isBash; + handle_bash_pick_select(need_reprint, isBash); + }else if(t == "handle_bash_pick"){ + auto info = info_from_action(next_action); + + std::istringstream sstr(info["destination"]); + location destination; + sstr >> destination; + + sstr.str(info["isBash"]); + sstr.seekg(0); + bool isBash; + sstr >> std::boolalpha >> isBash; + + handle_bash_pick(destination, did_something, need_redraw, isBash); } // TODO some of these actions shouldn't call advance_time(). They should return