From 69dc4829976d84477af8689629a01344bf541498 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Sat, 31 Aug 2024 14:25:22 -0500 Subject: [PATCH] record and replay using special items --- src/game/boe.actions.cpp | 3 +-- src/game/boe.main.cpp | 3 +++ src/game/boe.specials.cpp | 8 +++++++- src/game/boe.specials.hpp | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/game/boe.actions.cpp b/src/game/boe.actions.cpp index 26fd3d9a..a8a7e8b1 100644 --- a/src/game/boe.actions.cpp +++ b/src/game/boe.actions.cpp @@ -1574,8 +1574,7 @@ bool handle_action(const sf::Event& event, cFramerateLimiter& fps_limiter) { break; case ITEMBTN_DROP: if(stat_window == ITEM_WIN_SPECIAL) { - use_spec_item(spec_item_array[item_hit]); - need_redraw = true; + use_spec_item(spec_item_array[item_hit], need_redraw); } else handle_drop_item(item_hit, need_redraw); break; case ITEMBTN_INFO: diff --git a/src/game/boe.main.cpp b/src/game/boe.main.cpp index cb818ad5..ef2a21fa 100644 --- a/src/game/boe.main.cpp +++ b/src/game/boe.main.cpp @@ -29,6 +29,7 @@ #include "boe.main.hpp" #include "boe.consts.hpp" #include "boe.ui.hpp" +#include "boe.specials.hpp" #include "tools/winutil.hpp" #include "sounds.hpp" #include "gfx/render_image.hpp" @@ -547,6 +548,8 @@ static void replay_next_action() { std::shared_ptr sbar = std::dynamic_pointer_cast(event_listeners[name]); sbar->setPosition(newPos); + }else if(t == "use_spec_item"){ + use_spec_item(boost::lexical_cast(next_action.GetText()), need_redraw); }else{ std::ostringstream sstr; sstr << "Couldn't replay action: " << next_action; diff --git a/src/game/boe.specials.cpp b/src/game/boe.specials.cpp index 3ff5aa7b..b5c41456 100644 --- a/src/game/boe.specials.cpp +++ b/src/game/boe.specials.cpp @@ -31,6 +31,8 @@ #include #include "spell.hpp" #include "boe.menus.hpp" +#include "replay.hpp" +#include extern sf::RenderWindow mainPtr; extern eGameMode overall_mode; @@ -567,8 +569,12 @@ void check_fields(location where_check,eSpecCtx mode,cPlayer& which_pc) { put_pc_screen(); } -void use_spec_item(short item) { +void use_spec_item(short item, bool& need_redraw) { + if(recording){ + record_action("use_spec_item", boost::lexical_cast(item)); + } run_special(eSpecCtx::USE_SPEC_ITEM, eSpecCtxType::SCEN, univ.scenario.special_items[item].special, univ.party.get_loc()); + need_redraw = true; } diff --git a/src/game/boe.specials.hpp b/src/game/boe.specials.hpp index 730d6a1a..b3a3c09b 100644 --- a/src/game/boe.specials.hpp +++ b/src/game/boe.specials.hpp @@ -4,7 +4,7 @@ bool handle_wandering_specials(short mode); bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc,bool *forced); void check_fields(location where_check,eSpecCtx mode,cPlayer& which_pc); -void use_spec_item(short item); +void use_spec_item(short item, bool& need_redraw); void use_item(short pc,short item); bool use_space(location where); bool adj_town_look(location where);