mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-13 13:02:28 +00:00
ChessEngine: Handle the UCI quit command
This commit is contained in:
parent
13dbc69c23
commit
c2b9376409
Notes:
sideshowbarker
2024-07-17 01:51:00 +09:00
Author: https://github.com/tcl3
Commit: c2b9376409
Pull-request: https://github.com/SerenityOS/serenity/pull/18140
Issue: https://github.com/SerenityOS/serenity/issues/17427
Reviewed-by: https://github.com/LucasChollet
Reviewed-by: https://github.com/petelliott
3 changed files with 13 additions and 0 deletions
|
@ -62,3 +62,9 @@ void ChessEngine::handle_go(GoCommand const& command)
|
||||||
|
|
||||||
m_last_tree = move(best_node);
|
m_last_tree = move(best_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChessEngine::handle_quit()
|
||||||
|
{
|
||||||
|
if (on_quit)
|
||||||
|
on_quit(ESUCCESS);
|
||||||
|
}
|
||||||
|
|
|
@ -18,6 +18,9 @@ public:
|
||||||
virtual void handle_uci() override;
|
virtual void handle_uci() override;
|
||||||
virtual void handle_position(Chess::UCI::PositionCommand const&) override;
|
virtual void handle_position(Chess::UCI::PositionCommand const&) override;
|
||||||
virtual void handle_go(Chess::UCI::GoCommand const&) override;
|
virtual void handle_go(Chess::UCI::GoCommand const&) override;
|
||||||
|
virtual void handle_quit() override;
|
||||||
|
|
||||||
|
Function<void(int)> on_quit;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ChessEngine() = default;
|
ChessEngine() = default;
|
||||||
|
|
|
@ -17,5 +17,9 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
||||||
TRY(Core::System::unveil(nullptr, nullptr));
|
TRY(Core::System::unveil(nullptr, nullptr));
|
||||||
|
|
||||||
auto engine = TRY(ChessEngine::try_create(Core::DeprecatedFile::standard_input(), Core::DeprecatedFile::standard_output()));
|
auto engine = TRY(ChessEngine::try_create(Core::DeprecatedFile::standard_input(), Core::DeprecatedFile::standard_output()));
|
||||||
|
engine->on_quit = [&](auto status_code) {
|
||||||
|
loop.quit(status_code);
|
||||||
|
};
|
||||||
|
|
||||||
return loop.exec();
|
return loop.exec();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue