record and replay lockpick/bash commands

This commit is contained in:
2024-08-26 22:05:47 -05:00
committed by Celtic Minstrel
parent 28d9af4f25
commit 3bcfbc9f34
3 changed files with 39 additions and 2 deletions

View File

@@ -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<std::string,std::string> 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 {

View File

@@ -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

View File

@@ -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