record and replay repeating spellcast

This commit is contained in:
2024-08-26 21:05:50 -05:00
committed by Celtic Minstrel
parent 532a1e3236
commit 34cae14279
2 changed files with 24 additions and 2 deletions

View File

@@ -251,9 +251,17 @@ bool prime_time() {
void handle_spellcast(eSkill which_type, bool& did_something, bool& need_redraw, bool& need_reprint, bool record) {
if(record && recording){
std::map<std::string,std::string> info;
std::ostringstream sstr;
sstr << which_type;
record_action("handle_spellcast", sstr.str());
info["which_type"] = sstr.str();
sstr.str("");
sstr << std::boolalpha << spell_forced;
info["spell_forced"] = sstr.str();
record_action("handle_spellcast", info);
}
short store_sp[6];
extern short spec_target_fail;

View File

@@ -429,10 +429,24 @@ static void replay_next_action() {
eSpell spell_picked = static_cast<eSpell>(std::stoi(next_action.GetText()));
handle_menu_spell(spell_picked);
}else if(t == "handle_spellcast"){
std::istringstream sstr(next_action.GetText());
auto info = info_from_action(next_action);
std::istringstream sstr(info["which_type"]);
eSkill which_type;
sstr >> which_type;
// Incredibly, this code isn't working despite being used as a pattern elsewhere:
// sstr.str(info["spell_forced"]);
// sstr >> std::boolalpha >> spell_forced;
// But this code is:
if(info["spell_forced"] == "true"){
spell_forced = true;
}else{
spell_forced = false;
}
// If I'm making an obvious error I just can't see it.
handle_spellcast(which_type, did_something, need_redraw, need_reprint);
}else if(t == "handle_target_space"){
location destination = location_from_action(next_action);