From 25b7adba9febadd4c531953f773b29bc543a43ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Sun, 24 May 2026 21:18:50 +0200 Subject: [PATCH] Observe "not found" response Took 18 minutes Took 4 seconds --- cockatrice/src/game/game_event_handler.cpp | 15 ++++++++++++++- cockatrice/src/game/game_event_handler.h | 2 ++ .../src/interface/widgets/tabs/tab_game.cpp | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/cockatrice/src/game/game_event_handler.cpp b/cockatrice/src/game/game_event_handler.cpp index b338deaea..cff80a1ec 100644 --- a/cockatrice/src/game/game_event_handler.cpp +++ b/cockatrice/src/game/game_event_handler.cpp @@ -217,7 +217,20 @@ void GameEventHandler::handleArrowDeletion(int arrowId) { Command_DeleteArrow cmd; cmd.set_arrow_id(arrowId); - sendGameCommand(cmd); + + auto preparedCommand = prepareGameCommand(cmd); + + connect(preparedCommand, &PendingCommand::finished, this, + [arrowId, this](const Response &response) { handleArrowDeletionFinished(response, arrowId); }); + + sendGameCommand(preparedCommand); +} + +void GameEventHandler::handleArrowDeletionFinished(const Response &response, int arrowId) +{ + if (response.response_code() == Response::RespNameNotFound) { + emit arrowDeleted(arrowId); + } } void GameEventHandler::eventSpectatorSay(const Event_GameSay &event, diff --git a/cockatrice/src/game/game_event_handler.h b/cockatrice/src/game/game_event_handler.h index 7587ab46d..bc4812aa4 100644 --- a/cockatrice/src/game/game_event_handler.h +++ b/cockatrice/src/game/game_event_handler.h @@ -61,6 +61,7 @@ public: void handleGameLeft(); void handleChatMessageSent(const QString &chatMessage); void handleArrowDeletion(int arrowId); + void handleArrowDeletionFinished(const Response &response, int arrowId); void eventSpectatorSay(const Event_GameSay &event, int eventPlayerId, const GameEventContext &context); void eventSpectatorLeave(const Event_Leave &event, int eventPlayerId, const GameEventContext &context); @@ -112,6 +113,7 @@ signals: void containerProcessingStarted(GameEventContext context); void setContextJudgeName(QString judgeName); void containerProcessingDone(); + void arrowDeleted(int arrowId); void logSpectatorSay(ServerInfo_User userInfo, QString message); void logSpectatorLeave(QString name, QString reason); void logGameStart(); diff --git a/cockatrice/src/interface/widgets/tabs/tab_game.cpp b/cockatrice/src/interface/widgets/tabs/tab_game.cpp index 6b7b3539c..dd5df72a1 100644 --- a/cockatrice/src/interface/widgets/tabs/tab_game.cpp +++ b/cockatrice/src/interface/widgets/tabs/tab_game.cpp @@ -1147,6 +1147,7 @@ void TabGame::createPlayAreaWidget(bool bReplay) connect(game->getPlayerManager(), &PlayerManager::playerCountChanged, scene, &GameScene::rearrange); connect(scene, &GameScene::requestArrowDeletion, game->getGameEventHandler(), &GameEventHandler::handleArrowDeletion); + connect(game->getGameEventHandler(), &GameEventHandler::arrowDeleted, scene, &GameScene::onArrowDeleted); gameView = new GameView(scene); auto gamePlayAreaVBox = new QVBoxLayout;