From e889e2dff5f8593d7c752ff211d8a08274c705f0 Mon Sep 17 00:00:00 2001 From: DawnFire42 Date: Mon, 10 Aug 2026 12:21:25 -0400 Subject: [PATCH] Route tax counters by reserved ID instead of name to mirror other counters and avoid issues --- cockatrice/src/game/player/player_event_handler.cpp | 2 +- cockatrice/src/game/player/player_event_handler.h | 2 +- cockatrice/src/game_graphics/log/message_log_widget.cpp | 4 ++-- cockatrice/src/game_graphics/log/message_log_widget.h | 2 +- .../src/game_graphics/player/player_graphics_item.cpp | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cockatrice/src/game/player/player_event_handler.cpp b/cockatrice/src/game/player/player_event_handler.cpp index e30f25460..6e931e839 100644 --- a/cockatrice/src/game/player/player_event_handler.cpp +++ b/cockatrice/src/game/player/player_event_handler.cpp @@ -273,7 +273,7 @@ void PlayerEventHandler::eventSetCounter(const Event_SetCounter &event) state->setValue(event.value()); if (event.value() != oldValue) { - emit logSetCounter(player, state->getName(), event.value(), oldValue); + emit logSetCounter(player, state->getId(), state->getName(), event.value(), oldValue); } } diff --git a/cockatrice/src/game/player/player_event_handler.h b/cockatrice/src/game/player/player_event_handler.h index b7ecf8996..3d2dc7ce5 100644 --- a/cockatrice/src/game/player/player_event_handler.h +++ b/cockatrice/src/game/player/player_event_handler.h @@ -250,7 +250,7 @@ signals: void logUnattachCard(PlayerLogic *player, QString cardName); void logSetCardCounter(PlayerLogic *player, QString cardName, int counterId, int value, int oldValue); void logSetTapped(PlayerLogic *player, CardItem *card, bool tapped); - void logSetCounter(PlayerLogic *player, QString counterName, int value, int oldValue); + void logSetCounter(PlayerLogic *player, int counterId, QString counterName, int value, int oldValue); void logSetDoesntUntap(PlayerLogic *player, CardItem *card, bool doesntUntap); void logSetPT(PlayerLogic *player, CardItem *card, QString newPT); void logSetAnnotation(PlayerLogic *player, CardItem *card, QString newAnnotation); diff --git a/cockatrice/src/game_graphics/log/message_log_widget.cpp b/cockatrice/src/game_graphics/log/message_log_widget.cpp index b6f6fa9d8..d161b70f2 100644 --- a/cockatrice/src/game_graphics/log/message_log_widget.cpp +++ b/cockatrice/src/game_graphics/log/message_log_widget.cpp @@ -670,13 +670,13 @@ void MessageLogWidget::logSetCardCounter(PlayerLogic *player, QString cardName, .arg(value)); } -void MessageLogWidget::logSetCounter(PlayerLogic *player, QString counterName, int value, int oldValue) +void MessageLogWidget::logSetCounter(PlayerLogic *player, int counterId, QString counterName, int value, int oldValue) { if (counterName == "life") { soundEngine->playSound("life_change"); } - if (counterName == CounterNames::CommanderTax || counterName == CounterNames::PartnerTax) { + if (CounterIds::isTaxCounter(counterId)) { QString playerName = sanitizeHtml(player->getPlayerInfo()->getName()); QString valueStr = QString("%1").arg(value); int delta = value - oldValue; diff --git a/cockatrice/src/game_graphics/log/message_log_widget.h b/cockatrice/src/game_graphics/log/message_log_widget.h index a145d358d..7d02e3105 100644 --- a/cockatrice/src/game_graphics/log/message_log_widget.h +++ b/cockatrice/src/game_graphics/log/message_log_widget.h @@ -90,7 +90,7 @@ public slots: void logSetActivePlayer(PlayerLogic *player); void logSetAnnotation(PlayerLogic *player, CardItem *card, QString newAnnotation); void logSetCardCounter(PlayerLogic *player, QString cardName, int counterId, int value, int oldValue); - void logSetCounter(PlayerLogic *player, QString counterName, int value, int oldValue); + void logSetCounter(PlayerLogic *player, int counterId, QString counterName, int value, int oldValue); void logSetDoesntUntap(PlayerLogic *player, CardItem *card, bool doesntUntap); void logSetPT(PlayerLogic *player, CardItem *card, QString newPT); void logSetSideboardLock(PlayerLogic *player, bool locked); diff --git a/cockatrice/src/game_graphics/player/player_graphics_item.cpp b/cockatrice/src/game_graphics/player/player_graphics_item.cpp index 13ae998b1..63d5847d9 100644 --- a/cockatrice/src/game_graphics/player/player_graphics_item.cpp +++ b/cockatrice/src/game_graphics/player/player_graphics_item.cpp @@ -237,7 +237,7 @@ void PlayerGraphicsItem::onCounterAdded(CounterState *state) AbstractCounter *widget; if (state->getName() == "life") { widget = playerTarget->addCounter(state); - } else if (CounterNames::isTaxCounter(state->getName())) { + } else if (CounterIds::isTaxCounter(state->getId())) { if (!commandZoneGraphicsItem) { qWarning() << "Cannot create tax counter" << state->getName() << "- command zone not available"; return; @@ -275,7 +275,7 @@ void PlayerGraphicsItem::onCounterRemoved(int counterId) return; } setCounterMenuRegistered(widget, false); - if (commandZoneGraphicsItem && CounterNames::isTaxCounter(widget->getName())) { + if (commandZoneGraphicsItem && CounterIds::isTaxCounter(widget->getId())) { commandZoneGraphicsItem->unregisterTaxCounter(widget); } widget->delCounter(); @@ -291,7 +291,7 @@ void PlayerGraphicsItem::rearrangeCounters() qreal ySize = boundingRect().y() + 80; constexpr qreal padding = 5; for (auto *ctr : counterWidgets.values()) { - if (CounterNames::isTaxCounter(ctr->getName())) { + if (CounterIds::isTaxCounter(ctr->getId())) { continue; } if (!ctr->getShownInCounterArea()) {