From 4eb425cc914246fcd213403f4aee31b4794b7d85 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Wed, 15 Jan 2025 15:04:44 -0600 Subject: [PATCH] record and replay the burma shave easter egg --- src/game/boe.actions.cpp | 30 ++++++++++++++++++++++-------- src/game/boe.actions.hpp | 1 + src/game/boe.main.cpp | 2 ++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/game/boe.actions.cpp b/src/game/boe.actions.cpp index 6fe74e71..0913bbe1 100644 --- a/src/game/boe.actions.cpp +++ b/src/game/boe.actions.cpp @@ -2226,6 +2226,24 @@ void cancel_item_target(bool& did_something, bool& need_redraw, bool& need_repri did_something = need_redraw = need_reprint = true; } +// I'm finally adding the easter egg to the replay system +// because it allows forcing the text buffer into a specific state +// which I'm debugging. +std::vector easter_egg_messages = { + "If Valorim ...", + "You want to save ...", + "Back up your save files ...", + "Burma Shave." +}; + +void easter_egg(int idx) { + if(recording){ + record_action("easter_egg", boost::lexical_cast(idx)); + } + add_string_to_buf(easter_egg_messages[idx]); + print_buf(); +} + bool handle_keystroke(const sf::Event& event, cFramerateLimiter& fps_limiter){ bool are_done = false; location pass_point; // TODO: This isn't needed @@ -2381,20 +2399,16 @@ bool handle_keystroke(const sf::Event& event, cFramerateLimiter& fps_limiter){ switch(chr) { case '&': - add_string_to_buf("If Valorim ..."); - print_buf(); + easter_egg(0); break; case '*': - add_string_to_buf("You want to save ..."); - print_buf(); + easter_egg(1); break; case '(': - add_string_to_buf("Back up your save files ..."); - print_buf(); + easter_egg(2); break; case ')': - add_string_to_buf("Burma Shave."); - print_buf(); + easter_egg(3); break; case '?': diff --git a/src/game/boe.actions.hpp b/src/game/boe.actions.hpp index 4921abff..c81587a8 100644 --- a/src/game/boe.actions.hpp +++ b/src/game/boe.actions.hpp @@ -102,5 +102,6 @@ void show_item_info(short item_hit); void close_map(bool record = false); void cancel_item_target(bool& did_something, bool& need_redraw, bool& need_reprint); void update_item_stats_area(bool& need_reprint); +void easter_egg(int idx); #endif diff --git a/src/game/boe.main.cpp b/src/game/boe.main.cpp index e0b47108..033a7468 100644 --- a/src/game/boe.main.cpp +++ b/src/game/boe.main.cpp @@ -640,6 +640,8 @@ void replay_action(Element& action) { return; }else if(t == "cancel_item_target"){ cancel_item_target(did_something, need_redraw, need_reprint); + }else if(t == "easter_egg"){ + easter_egg(boost::lexical_cast(action.GetText())); }else if(t == "advance_time"){ // This is bad regardless of strictness, because visual changes may have occurred which won't get redrawn/reprinted throw std::string { "Replay system internal error! advance_time() was supposed to be called by the last action, but wasn't: " } + _last_action_type;