mirror of
https://github.com/motajs/template.git
synced 2026-11-24 23:14:32 +08:00
refactor: ReplaySystem.route -> ReplaySystem.array,修复 disabled 标记在 setReplayArray 中清零可能导致意外记录的问题
This commit is contained in:
1 parent
3a3a6ac82d
commit
a2a8e6ec35
19 files changed
+96
-87
No files matched your search
@@ -495,6 +495,8 @@ export class CoreState implements ICoreState {
|
||||
state: ReadonlyMap<string, unknown>,
|
||||
compression: SaveCompression
|
||||
): void {
|
||||
// 需要先清空录像的禁用标记
|
||||
this.replaySystem.array.clearDisableFlag();
|
||||
for (const [key, value] of this.saveables) {
|
||||
// 使用 has 判断是否在映射中,而非值的非空判断,因为空值也有可能是存档的一部分
|
||||
if (!state.has(key)) {
|
||||
@@ -502,7 +504,11 @@ export class CoreState implements ICoreState {
|
||||
continue;
|
||||
}
|
||||
const data = state.get(key);
|
||||
// 使用禁用录像包裹所有的读档行为,避免产生意外记录
|
||||
this.replaySystem.disable();
|
||||
value.loadState(data, compression);
|
||||
this.replaySystem.revert();
|
||||
// 但 Executor 不包裹,因为它确实可能产生需要记录的行为
|
||||
const executor = this.executors.get(value);
|
||||
if (executor) {
|
||||
executor.afterLoad(value, this);
|
||||
|
||||
@@ -280,7 +280,7 @@ describe('replay commands', () => {
|
||||
replay.record(ReplayCode.Right);
|
||||
replay.record(ReplayCode.UseItem, 5);
|
||||
const sandbox = replay.createReplaySandbox({
|
||||
route: replay.route,
|
||||
route: replay.array,
|
||||
reseter: { reset: () => {} }
|
||||
}) as IManualReplaySandbox;
|
||||
sandbox.playing = true;
|
||||
|
||||
Reference in new issue
Block a user