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
This commit is contained in:
ebbit1q 2021-06-02 03:52:20 +02:00 committed by GitHub
parent fac7bfaa92
commit ebe2c494aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 3 additions and 100 deletions

View file

@ -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,

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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);

View file

@ -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

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;

View file

@ -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;
}

View file

@ -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;

View file

@ -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);

View file

@ -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;
export default ProtoFiles;