route the win-path restart through ResetCommand

The Restart button on the Win dialog called Simulation::reset() directly,
while the escape-menu and Game Over restarts enqueue a ResetCommand. That
bypassed the command chokepoint every sim mutation is supposed to flow
through (docs/replay_design.md), so a post-win restart was never recorded
into the replay stream, and it had UI code calling a sim mutator directly.

Mirror the Game Over path instead. The manual resetForNewGame() call goes
away with it: GameWorldView::onFrame already resets the view when it drains
a Reset command.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GH8ZMRY3vhxxXcaUxBqxkk
This commit is contained in:
2026-08-02 21:31:27 +02:00
parent 0eb9c97e5d
commit 75f306f650

View File

@@ -419,10 +419,12 @@ void MainWindow::handleEvent(std::shared_ptr<const WinEvent> /*event*/)
{ {
return; return;
} }
// Unlike the other two restart paths this one resets the simulation // Restart is a command boundary; the view resets when the drain applies it.
// directly instead of enqueueing a ResetCommand; kept as-is. std::shared_ptr<ResetCommand> command = std::make_shared<ResetCommand>();
m_sim->reset(std::move(*newConfig)); command->config = std::make_shared<GameConfig>(std::move(*newConfig));
m_gameWorldView->resetForNewGame(); command->seed = std::random_device{}();
EventManager::getInstance()->sendEventImmediately(
std::make_shared<CommandRequestedEvent>(command));
} }
else else
{ {