A state-driven bug scenario: baseline snapshot + ordered per-frame inputs. 更多...
#include <ScenarioRecorder.h>
Public 成员函数 | |
| ScenarioRecorder (const ScenarioRecorder &)=delete | |
| ScenarioRecorder & | operator= (const ScenarioRecorder &)=delete |
| bool | begin (HSQUIRRELVM vm, std::string *err=nullptr) |
| Start recording: capture the baseline snapshot and observe the event queue. | |
| void | markFrame () |
| Begin a new frame bucket; no-op unless recording. | |
| bool | end (const std::string &path, std::string *err=nullptr) |
| Stop recording and persist the scenario to a JSON file. | |
| void | cancel () |
| Abort recording and restore the previous event observer. | |
| bool | recording () const |
| True while a scenario is being recorded. | |
| bool | beginReplay (HSQUIRRELVM vm, const std::string &path, std::string *err=nullptr) |
| Load a scenario and restore its baseline snapshot onto the VM. | |
| bool | stageFrame () |
| Re-push the next recorded frame's events into the event queue. | |
| bool | replaying () const |
| True while a replay is in progress with frames remaining. | |
| int | framesRemaining () const |
| Number of frames remaining to stage. | |
| void | setErrorInfo (const std::string &report, const std::string &site) |
| Called by DevTool when a script error is dumped during recording. | |
| void | onEventConsumed (const eve::platform_event::Message &msg) |
| Invoked by the event poll observer for every consumed message. | |
| void | detachObserver () |
| Ensure the event observer is detached (restore previous); safe to call repeatedly. | |
| const std::string & | baseline () const |
| Baseline. | |
| const std::vector< ScenarioFrame > & | frames () const |
| Frames. | |
| const std::string & | errorReport () const |
| Error report. | |
| const std::string & | errorSite () const |
| Error site. | |
静态 Public 成员函数 | |
| static ScenarioRecorder & | instance () |
| Instance. | |
| static bool | save (const std::string &baseline, const std::vector< ScenarioFrame > &frames, const std::string &errorReport, const std::string &errorSite, const std::string &path, std::string *err=nullptr) |
| Persist a scenario to a JSON file (used for both record and replay paths). | |
| static bool | load (const std::string &path, std::string *baseline, std::vector< ScenarioFrame > *frames, std::string *errorReport, std::string *errorSite, std::string *err=nullptr) |
| Load a scenario from a JSON file into the given outputs. | |
详细描述
A state-driven bug scenario: baseline snapshot + ordered per-frame inputs.
The engine treats itself as stateless (recoverable game state lives in script variables), so restoring the baseline snapshot and re-injecting the recorded per-frame input/event stream reproduces the original run deterministically (given deterministic game logic and RNG seeds).
Record: begin() captures the baseline, an observer on the event module records every consumed message per frame (markFrame()), end() persists the scenario to a JSON file alongside the error report.
Replay: beginReplay() restores the baseline, then each stageFrame() re-pushes one recorded frame's events into the event queue; the caller advances one game frame between calls and watches for the error to reproduce.
在文件 ScenarioRecorder.h 第 47 行定义.
构造及析构函数说明
◆ ScenarioRecorder()
|
delete |
成员函数说明
◆ baseline()
|
inline |
Baseline.
在文件 ScenarioRecorder.h 第 100 行定义.
◆ begin()
| bool eve::dev::ScenarioRecorder::begin | ( | HSQUIRRELVM | vm, |
| std::string * | err = nullptr |
||
| ) |
Start recording: capture the baseline snapshot and observe the event queue.
- 返回
- false when the VM is null or the baseline capture fails.
在文件 ScenarioRecorder.cpp 第 36 行定义.
引用了 cancel(), eve::dev::Snapshot::capture(), eve::dev::Snapshot::instance() , 以及 vm.
被这些函数引用 eve::dev::DevTool::exposeScriptApi().
◆ beginReplay()
| bool eve::dev::ScenarioRecorder::beginReplay | ( | HSQUIRRELVM | vm, |
| const std::string & | path, | ||
| std::string * | err = nullptr |
||
| ) |
Load a scenario and restore its baseline snapshot onto the VM.
- 返回
- false when the file is invalid or restore fails.
在文件 ScenarioRecorder.cpp 第 114 行定义.
◆ cancel()
| void eve::dev::ScenarioRecorder::cancel | ( | ) |
Abort recording and restore the previous event observer.
在文件 ScenarioRecorder.cpp 第 74 行定义.
引用了 detachObserver().
被这些函数引用 begin(), eve::dev::DevTool::detach() , 以及 eve::dev::DevTool::exposeScriptApi().
◆ detachObserver()
| void eve::dev::ScenarioRecorder::detachObserver | ( | ) |
Ensure the event observer is detached (restore previous); safe to call repeatedly.
在文件 ScenarioRecorder.cpp 第 29 行定义.
◆ end()
| bool eve::dev::ScenarioRecorder::end | ( | const std::string & | path, |
| std::string * | err = nullptr |
||
| ) |
Stop recording and persist the scenario to a JSON file.
- 参数
-
path Destination file (e.g. "scenario_boss.json").
- 返回
- false when not recording or the file cannot be written.
在文件 ScenarioRecorder.cpp 第 62 行定义.
引用了 detachObserver(), ok, path , 以及 save().
◆ errorReport()
|
inline |
◆ errorSite()
|
inline |
Error site.
在文件 ScenarioRecorder.h 第 106 行定义.
◆ frames()
|
inline |
Frames.
在文件 ScenarioRecorder.h 第 102 行定义.
◆ framesRemaining()
|
inline |
Number of frames remaining to stage.
在文件 ScenarioRecorder.h 第 88 行定义.
被这些函数引用 eve::dev::DevTool::exposeScriptApi().
◆ instance()
|
static |
Instance.
在文件 ScenarioRecorder.cpp 第 16 行定义.
被这些函数引用 eve::dev::DevTool::detach(), eve::dev::DevTool::exposeScriptApi() , 以及 eve::dev::DevTool::notifyError().
◆ load()
|
static |
Load a scenario from a JSON file into the given outputs.
在文件 ScenarioRecorder.cpp 第 194 行定义.
引用了 eve::dev::ScenarioEvent::args, f, eve::dev::ScenarioFrame::frame, eve::dev::ScenarioEvent::name, path , 以及 root.
◆ markFrame()
| void eve::dev::ScenarioRecorder::markFrame | ( | ) |
Begin a new frame bucket; no-op unless recording.
在文件 ScenarioRecorder.cpp 第 55 行定义.
被这些函数引用 eve::dev::DevTool::exposeScriptApi().
◆ onEventConsumed()
| void eve::dev::ScenarioRecorder::onEventConsumed | ( | const eve::platform_event::Message & | msg | ) |
Invoked by the event poll observer for every consumed message.
在文件 ScenarioRecorder.cpp 第 93 行定义.
引用了 a, eve::dev::ScenarioEvent::args, eve::platform_event::Message::args, eve::platform_event::Variant::Int, eve::dev::ScenarioEvent::name, eve::platform_event::Message::name, eve::platform_event::Variant::Nil , 以及 eve::platform_event::Variant::String.
◆ operator=()
|
delete |
◆ recording()
|
inline |
True while a scenario is being recorded.
在文件 ScenarioRecorder.h 第 72 行定义.
被这些函数引用 eve::dev::DevTool::exposeScriptApi().
◆ replaying()
|
inline |
True while a replay is in progress with frames remaining.
在文件 ScenarioRecorder.h 第 86 行定义.
◆ save()
|
static |
◆ setErrorInfo()
| void eve::dev::ScenarioRecorder::setErrorInfo | ( | const std::string & | report, |
| const std::string & | site | ||
| ) |
Called by DevTool when a script error is dumped during recording.
在文件 ScenarioRecorder.cpp 第 87 行定义.
被这些函数引用 eve::dev::DevTool::notifyError().
◆ stageFrame()
| bool eve::dev::ScenarioRecorder::stageFrame | ( | ) |
Re-push the next recorded frame's events into the event queue.
- 返回
- false when replay is exhausted (all frames staged) or not replaying.
在文件 ScenarioRecorder.cpp 第 136 行定义.
引用了 a, eve::dev::ScenarioFrame::events , 以及 eve::platform_event::Variant::makeString().
被这些函数引用 eve::dev::DevTool::exposeScriptApi().
该类的文档由以下文件生成:
- src/engine/devtools/ScenarioRecorder.h
- src/engine/devtools/ScenarioRecorder.cpp