From 8751f0605d242066e677ffa17f85af120064f3c9 Mon Sep 17 00:00:00 2001 From: BruebachL <44814898+BruebachL@users.noreply.github.com> Date: Fri, 22 May 2026 10:25:13 +0200 Subject: [PATCH] [Game][Arrows] Don't request deletion on inbound arrow deletion signal again but react to it locally (#6927) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [Game][Arrows] Deleting arrows has no acknowledgement command so we have to delete locally as well. Took 22 minutes * Fix properly. Took 15 minutes --------- Co-authored-by: Lukas BrĂ¼bach --- cockatrice/src/game/game_scene.cpp | 8 ++++++++ cockatrice/src/game/game_scene.h | 1 + cockatrice/src/game/player/player_event_handler.cpp | 2 +- cockatrice/src/game/player/player_logic.h | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cockatrice/src/game/game_scene.cpp b/cockatrice/src/game/game_scene.cpp index 71b9caa4b..e70069ee3 100644 --- a/cockatrice/src/game/game_scene.cpp +++ b/cockatrice/src/game/game_scene.cpp @@ -93,6 +93,7 @@ void GameScene::addPlayer(PlayerLogic *player) rearrange(); }); + connect(player, &PlayerLogic::arrowDeleted, this, &GameScene::onArrowDeleted); connect(player, &PlayerLogic::arrowCreateRequested, this, &GameScene::onArrowCreateRequested); connect(player, &PlayerLogic::arrowDeleteRequested, this, &GameScene::onArrowDeleteRequested); connect(player, &PlayerLogic::arrowsCleared, this, @@ -404,6 +405,13 @@ void GameScene::onArrowCreateRequested(const ArrowData &data) connect(arrow, &QObject::destroyed, this, [this, id = data.id]() { arrowRegistry.remove(id); }); } +void GameScene::onArrowDeleted(int arrowId) +{ + if (arrowRegistry.contains(arrowId)) { + arrowRegistry.take(arrowId)->delArrow(); + } +} + void GameScene::onArrowDeleteRequested(int arrowId) { if (arrowRegistry.contains(arrowId)) { diff --git a/cockatrice/src/game/game_scene.h b/cockatrice/src/game/game_scene.h index 5e0e6b7c9..235ce6550 100644 --- a/cockatrice/src/game/game_scene.h +++ b/cockatrice/src/game/game_scene.h @@ -202,6 +202,7 @@ public slots: QTransform getViewportTransform() const; void onArrowCreateRequested(const ArrowData &data); + void onArrowDeleted(int arrowId); void onArrowDeleteRequested(int arrowId); void onCardZoneChanged(CardItem *card, bool sameZone); void clearArrowsForPlayer(int playerId); diff --git a/cockatrice/src/game/player/player_event_handler.cpp b/cockatrice/src/game/player/player_event_handler.cpp index 24030057b..3a7d0345b 100644 --- a/cockatrice/src/game/player/player_event_handler.cpp +++ b/cockatrice/src/game/player/player_event_handler.cpp @@ -128,7 +128,7 @@ void PlayerEventHandler::eventCreateArrow(const Event_CreateArrow &event) void PlayerEventHandler::eventDeleteArrow(const Event_DeleteArrow &event) { - emit player->arrowDeleteRequested(event.arrow_id()); + emit player->arrowDeleted(event.arrow_id()); } void PlayerEventHandler::eventCreateToken(const Event_CreateToken &event) diff --git a/cockatrice/src/game/player/player_logic.h b/cockatrice/src/game/player/player_logic.h index 5f58ca265..20d7597b4 100644 --- a/cockatrice/src/game/player/player_logic.h +++ b/cockatrice/src/game/player/player_logic.h @@ -80,6 +80,7 @@ signals: void resetTopCardMenuActions(); void arrowCreateRequested(ArrowData data); void arrowDeleteRequested(int arrowId); + void arrowDeleted(int arrowId); void arrowsCleared(); // fires on clear() and processPlayerInfo public slots: