From ebe2c494aa4c92f2ed64f94c1ef6df05e63deafd Mon Sep 17 00:00:00 2001 From: ebbit1q Date: Wed, 2 Jun 2021 03:52:20 +0200 Subject: [PATCH] remove the stop dump zone command from the protocol (#4326) the stop dump zone command was implemented as a courtesy to other players in order to take into account when they would stop looking at unknown information however, this can be abused, a malicious client can send this command whenever they would like cockatrice is not a physical tabletop nor does it aim to be, if you can take a screenshot of your deck and then close the view, you are not cheating as you have been given this information in order to prevent anyone from abusing this we should remove the command from the protocol, this means servers will ignore this message and clients will get a little invalid command reply in their debug log the extension id will remain reserved shuffling your deck will always invalidate any card view looking at those cards if players wish to signal that they stopped looking at their deck for whatever reason they should just use the chat instead, optionally using one of the chat macros --- cockatrice/src/messagelogwidget.cpp | 8 ------ cockatrice/src/messagelogwidget.h | 1 - cockatrice/src/player.cpp | 17 ------------- cockatrice/src/player.h | 3 --- cockatrice/src/zoneviewwidget.cpp | 7 ------ common/pb/CMakeLists.txt | 2 -- common/pb/command_stop_dump_zone.proto | 9 ------- common/pb/event_stop_dump_zone.proto | 10 -------- common/pb/game_commands.proto | 2 +- common/pb/game_event.proto | 2 +- common/server_player.cpp | 35 -------------------------- common/server_player.h | 3 --- webclient/src/websocket/ProtoFiles.tsx | 4 +-- 13 files changed, 3 insertions(+), 100 deletions(-) delete mode 100644 common/pb/command_stop_dump_zone.proto delete mode 100644 common/pb/event_stop_dump_zone.proto diff --git a/cockatrice/src/messagelogwidget.cpp b/cockatrice/src/messagelogwidget.cpp index 22f4e8bd..1b9b610f 100644 --- a/cockatrice/src/messagelogwidget.cpp +++ b/cockatrice/src/messagelogwidget.cpp @@ -757,13 +757,6 @@ void MessageLogWidget::logSpectatorSay(QString spectatorName, appendMessage(std::move(message), {}, spectatorName, spectatorUserLevel, userPrivLevel, false); } -void MessageLogWidget::logStopDumpZone(Player *player, CardZone *zone) -{ - appendHtmlServerMessage(tr("%1 stops looking at %2.") - .arg(sanitizeHtml(player->getName())) - .arg(zone->getTranslatedName(zone->getPlayer() == player, CaseLookAtZone))); -} - void MessageLogWidget::logUnattachCard(Player *player, QString cardName) { appendHtmlServerMessage( @@ -824,7 +817,6 @@ void MessageLogWidget::connectToPlayer(Player *player) SLOT(logAttachCard(Player *, QString, Player *, QString))); connect(player, SIGNAL(logUnattachCard(Player *, QString)), this, SLOT(logUnattachCard(Player *, QString))); connect(player, SIGNAL(logDumpZone(Player *, CardZone *, int)), this, SLOT(logDumpZone(Player *, CardZone *, int))); - connect(player, SIGNAL(logStopDumpZone(Player *, CardZone *)), this, SLOT(logStopDumpZone(Player *, CardZone *))); connect(player, SIGNAL(logDrawCards(Player *, int)), this, SLOT(logDrawCards(Player *, int))); connect(player, SIGNAL(logUndoDraw(Player *, QString)), this, SLOT(logUndoDraw(Player *, QString))); connect(player, SIGNAL(logRevealCards(Player *, CardZone *, int, QString, Player *, bool, int)), this, diff --git a/cockatrice/src/messagelogwidget.h b/cockatrice/src/messagelogwidget.h index 645c54f4..7769e098 100644 --- a/cockatrice/src/messagelogwidget.h +++ b/cockatrice/src/messagelogwidget.h @@ -93,7 +93,6 @@ public slots: void logShuffle(Player *player, CardZone *zone, int start, int end); void logSpectatorSay(QString spectatorName, UserLevelFlags spectatorUserLevel, QString userPrivLevel, QString message); - void logStopDumpZone(Player *player, CardZone *zone); void logUnattachCard(Player *player, QString cardName); void logUndoDraw(Player *player, QString cardName); void setContextJudgeName(QString player); diff --git a/cockatrice/src/player.cpp b/cockatrice/src/player.cpp index d80afc52..80354fe7 100644 --- a/cockatrice/src/player.cpp +++ b/cockatrice/src/player.cpp @@ -49,7 +49,6 @@ #include "pb/event_set_card_counter.pb.h" #include "pb/event_set_counter.pb.h" #include "pb/event_shuffle.pb.h" -#include "pb/event_stop_dump_zone.pb.h" #include "pb/serverinfo_player.pb.h" #include "pb/serverinfo_user.pb.h" #include "pb/serverinfo_zone.pb.h" @@ -1984,19 +1983,6 @@ void Player::eventDumpZone(const Event_DumpZone &event) emit logDumpZone(this, zone, event.number_cards()); } -void Player::eventStopDumpZone(const Event_StopDumpZone &event) -{ - Player *zoneOwner = game->getPlayers().value(event.zone_owner_id(), 0); - if (!zoneOwner) { - return; - } - CardZone *zone = zoneOwner->getZones().value(QString::fromStdString(event.zone_name()), 0); - if (!zone) { - return; - } - emit logStopDumpZone(this, zone); -} - void Player::eventMoveCard(const Event_MoveCard &event, const GameEventContext &context) { Player *startPlayer = game->getPlayers().value(event.start_player_id()); @@ -2314,9 +2300,6 @@ void Player::processGameEvent(GameEvent::GameEventType type, const GameEvent &ev case GameEvent::DUMP_ZONE: eventDumpZone(event.GetExtension(Event_DumpZone::ext)); break; - case GameEvent::STOP_DUMP_ZONE: - eventStopDumpZone(event.GetExtension(Event_StopDumpZone::ext)); - break; case GameEvent::MOVE_CARD: eventMoveCard(event.GetExtension(Event_MoveCard::ext), context); break; diff --git a/cockatrice/src/player.h b/cockatrice/src/player.h index 81f95fba..363fbe6c 100644 --- a/cockatrice/src/player.h +++ b/cockatrice/src/player.h @@ -47,7 +47,6 @@ class Event_SetCardAttr; class Event_SetCardCounter; class Event_SetCounter; class Event_Shuffle; -class Event_StopDumpZone; class GameCommand; class GameEvent; class GameEventContext; @@ -135,7 +134,6 @@ signals: void logSetPT(Player *player, CardItem *card, QString newPT); void logSetAnnotation(Player *player, CardItem *card, QString newAnnotation); void logDumpZone(Player *player, CardZone *zone, int numberCards); - void logStopDumpZone(Player *player, CardZone *zone); void logRevealCards(Player *player, CardZone *zone, int cardId, @@ -312,7 +310,6 @@ private: void eventSetCounter(const Event_SetCounter &event); void eventDelCounter(const Event_DelCounter &event); void eventDumpZone(const Event_DumpZone &event); - void eventStopDumpZone(const Event_StopDumpZone &event); void eventMoveCard(const Event_MoveCard &event, const GameEventContext &context); void eventFlipCard(const Event_FlipCard &event); void eventDestroyCard(const Event_DestroyCard &event); diff --git a/cockatrice/src/zoneviewwidget.cpp b/cockatrice/src/zoneviewwidget.cpp index ffda0eaf..87348cba 100644 --- a/cockatrice/src/zoneviewwidget.cpp +++ b/cockatrice/src/zoneviewwidget.cpp @@ -3,7 +3,6 @@ #include "carditem.h" #include "gamescene.h" #include "pb/command_shuffle.pb.h" -#include "pb/command_stop_dump_zone.pb.h" #include "player.h" #include "settingscache.h" #include "zoneviewzone.h" @@ -200,12 +199,6 @@ void ZoneViewWidget::handleScrollBarChange(int value) void ZoneViewWidget::closeEvent(QCloseEvent *event) { disconnect(zone, SIGNAL(beingDeleted()), this, 0); - if (zone->getNumberCards() != -2) { - Command_StopDumpZone cmd; - cmd.set_player_id(player->getId()); - cmd.set_zone_name(zone->getName().toStdString()); - player->sendGameCommand(cmd); - } if (shuffleCheckBox.isChecked()) player->sendGameCommand(Command_Shuffle()); emit closePressed(this); diff --git a/common/pb/CMakeLists.txt b/common/pb/CMakeLists.txt index 5467303f..ea1855d8 100644 --- a/common/pb/CMakeLists.txt +++ b/common/pb/CMakeLists.txt @@ -48,7 +48,6 @@ SET(PROTO_FILES command_set_sideboard_lock.proto command_shuffle.proto commands.proto - command_stop_dump_zone.proto command_undo_draw.proto context_concede.proto context_connection_state_changed.proto @@ -102,7 +101,6 @@ SET(PROTO_FILES event_set_card_counter.proto event_set_counter.proto event_shuffle.proto - event_stop_dump_zone.proto event_user_joined.proto event_user_left.proto event_user_message.proto diff --git a/common/pb/command_stop_dump_zone.proto b/common/pb/command_stop_dump_zone.proto deleted file mode 100644 index 1896c9dc..00000000 --- a/common/pb/command_stop_dump_zone.proto +++ /dev/null @@ -1,9 +0,0 @@ -syntax = "proto2"; -import "game_commands.proto"; -message Command_StopDumpZone { - extend GameCommand { - optional Command_StopDumpZone ext = 1025; - } - optional sint32 player_id = 1; - optional string zone_name = 2; -} diff --git a/common/pb/event_stop_dump_zone.proto b/common/pb/event_stop_dump_zone.proto deleted file mode 100644 index 3e8f1693..00000000 --- a/common/pb/event_stop_dump_zone.proto +++ /dev/null @@ -1,10 +0,0 @@ -syntax = "proto2"; -import "game_event.proto"; - -message Event_StopDumpZone { - extend GameEvent { - optional Event_StopDumpZone ext = 2019; - } - optional sint32 zone_owner_id = 1; - optional string zone_name = 2; -} diff --git a/common/pb/game_commands.proto b/common/pb/game_commands.proto index 76f7b200..3a36cd21 100644 --- a/common/pb/game_commands.proto +++ b/common/pb/game_commands.proto @@ -26,7 +26,7 @@ message GameCommand { NEXT_TURN = 1022; SET_ACTIVE_PHASE = 1023; DUMP_ZONE = 1024; - STOP_DUMP_ZONE = 1025; + STOP_DUMP_ZONE = 1025; // deprecated REVEAL_CARDS = 1026; MOVE_CARD = 1027; SET_SIDEBOARD_PLAN = 1028; diff --git a/common/pb/game_event.proto b/common/pb/game_event.proto index 0d7c2d9c..45644e2c 100644 --- a/common/pb/game_event.proto +++ b/common/pb/game_event.proto @@ -28,7 +28,7 @@ message GameEvent { SET_ACTIVE_PLAYER = 2016; SET_ACTIVE_PHASE = 2017; DUMP_ZONE = 2018; - STOP_DUMP_ZONE = 2019; + STOP_DUMP_ZONE = 2019; // deprecated CHANGE_ZONE_PROPERTIES = 2020; REVERSE_TURN = 2021; } diff --git a/common/server_player.cpp b/common/server_player.cpp index 78667866..db9f1fa1 100644 --- a/common/server_player.cpp +++ b/common/server_player.cpp @@ -34,7 +34,6 @@ #include "pb/command_set_sideboard_lock.pb.h" #include "pb/command_set_sideboard_plan.pb.h" #include "pb/command_shuffle.pb.h" -#include "pb/command_stop_dump_zone.pb.h" #include "pb/command_undo_draw.pb.h" #include "pb/context_concede.pb.h" #include "pb/context_connection_state_changed.pb.h" @@ -65,7 +64,6 @@ #include "pb/event_set_card_counter.pb.h" #include "pb/event_set_counter.pb.h" #include "pb/event_shuffle.pb.h" -#include "pb/event_stop_dump_zone.pb.h" #include "pb/response.pb.h" #include "pb/response_deck_download.pb.h" #include "pb/response_dump_zone.pb.h" @@ -1830,36 +1828,6 @@ Server_Player::cmdDumpZone(const Command_DumpZone &cmd, ResponseContainer &rc, G return Response::RespOk; } -Response::ResponseCode -Server_Player::cmdStopDumpZone(const Command_StopDumpZone &cmd, ResponseContainer & /*rc*/, GameEventStorage &ges) -{ - if (!game->getGameStarted()) { - return Response::RespGameNotStarted; - } - if (conceded) { - return Response::RespContextError; - } - - Server_Player *otherPlayer = game->getPlayers().value(cmd.player_id()); - if (!otherPlayer) { - return Response::RespNameNotFound; - } - Server_CardZone *zone = otherPlayer->getZones().value(QString::fromStdString(cmd.zone_name())); - if (!zone) { - return Response::RespNameNotFound; - } - - if (zone->getType() == ServerInfo_Zone::HiddenZone) { - zone->setCardsBeingLookedAt(0); - - Event_StopDumpZone event; - event.set_zone_owner_id(cmd.player_id()); - event.set_zone_name(zone->getName().toStdString()); - ges.enqueueGameEvent(event, playerId); - } - return Response::RespOk; -} - Response::ResponseCode Server_Player::cmdRevealCards(const Command_RevealCards &cmd, ResponseContainer & /*rc*/, GameEventStorage &ges) { @@ -2115,9 +2083,6 @@ Server_Player::processGameCommand(const GameCommand &command, ResponseContainer case GameCommand::DUMP_ZONE: return cmdDumpZone(command.GetExtension(Command_DumpZone::ext), rc, ges); break; - case GameCommand::STOP_DUMP_ZONE: - return cmdStopDumpZone(command.GetExtension(Command_StopDumpZone::ext), rc, ges); - break; case GameCommand::REVEAL_CARDS: return cmdRevealCards(command.GetExtension(Command_RevealCards::ext), rc, ges); break; diff --git a/common/server_player.h b/common/server_player.h index 69e885aa..379bbc60 100644 --- a/common/server_player.h +++ b/common/server_player.h @@ -55,7 +55,6 @@ class Command_DelCounter; class Command_NextTurn; class Command_SetActivePhase; class Command_DumpZone; -class Command_StopDumpZone; class Command_RevealCards; class Command_ReverseTurn; class Command_MoveCard; @@ -226,8 +225,6 @@ public: Response::ResponseCode cmdSetActivePhase(const Command_SetActivePhase &cmd, ResponseContainer &rc, GameEventStorage &ges); Response::ResponseCode cmdDumpZone(const Command_DumpZone &cmd, ResponseContainer &rc, GameEventStorage &ges); - Response::ResponseCode - cmdStopDumpZone(const Command_StopDumpZone &cmd, ResponseContainer &rc, GameEventStorage &ges); Response::ResponseCode cmdRevealCards(const Command_RevealCards &cmd, ResponseContainer &rc, GameEventStorage &ges); Response::ResponseCode cmdReverseTurn(const Command_ReverseTurn & /*cmd*/, ResponseContainer & /*rc*/, GameEventStorage &ges); diff --git a/webclient/src/websocket/ProtoFiles.tsx b/webclient/src/websocket/ProtoFiles.tsx index 7556754a..5d711cb7 100644 --- a/webclient/src/websocket/ProtoFiles.tsx +++ b/webclient/src/websocket/ProtoFiles.tsx @@ -42,7 +42,6 @@ const ProtoFiles = [ "command_set_sideboard_lock.proto", "command_set_sideboard_plan.proto", "command_shuffle.proto", - "command_stop_dump_zone.proto", "command_undo_draw.proto", "commands.proto", "context_concede.proto", @@ -97,7 +96,6 @@ const ProtoFiles = [ "event_set_card_counter.proto", "event_set_counter.proto", "event_shuffle.proto", - "event_stop_dump_zone.proto", "event_user_joined.proto", "event_user_left.proto", "event_user_message.proto", @@ -154,4 +152,4 @@ const ProtoFiles = [ "session_event.proto", ]; -export default ProtoFiles; \ No newline at end of file +export default ProtoFiles;