diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 121235c22..731c55369 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -48,6 +48,7 @@ set(cockatrice_SOURCES src/dlg_load_remote_deck.cpp src/dlg_manage_sets.cpp src/dlg_register.cpp + src/dlg_roll_dice.cpp src/dlg_settings.cpp src/dlg_tip_of_the_day.cpp src/dlg_update.cpp diff --git a/cockatrice/src/dlg_connect.cpp b/cockatrice/src/dlg_connect.cpp index eff0371a8..3a2fbc0d5 100644 --- a/cockatrice/src/dlg_connect.cpp +++ b/cockatrice/src/dlg_connect.cpp @@ -1,7 +1,7 @@ #include "dlg_connect.h" #include "settingscache.h" -#include "stringsizes.h" +#include "trice_limits.h" #include "userconnection_information.h" #include diff --git a/cockatrice/src/dlg_create_token.cpp b/cockatrice/src/dlg_create_token.cpp index 3a7c86de8..6aedf2cc3 100644 --- a/cockatrice/src/dlg_create_token.cpp +++ b/cockatrice/src/dlg_create_token.cpp @@ -5,7 +5,7 @@ #include "decklist.h" #include "main.h" #include "settingscache.h" -#include "stringsizes.h" +#include "trice_limits.h" #include #include diff --git a/cockatrice/src/dlg_creategame.cpp b/cockatrice/src/dlg_creategame.cpp index a659a5157..7dbada5d2 100644 --- a/cockatrice/src/dlg_creategame.cpp +++ b/cockatrice/src/dlg_creategame.cpp @@ -3,8 +3,8 @@ #include "pb/serverinfo_game.pb.h" #include "pending_command.h" #include "settingscache.h" -#include "stringsizes.h" #include "tab_room.h" +#include "trice_limits.h" #include #include diff --git a/cockatrice/src/dlg_edit_avatar.cpp b/cockatrice/src/dlg_edit_avatar.cpp index 9c73348eb..da85da525 100644 --- a/cockatrice/src/dlg_edit_avatar.cpp +++ b/cockatrice/src/dlg_edit_avatar.cpp @@ -1,6 +1,6 @@ #include "dlg_edit_avatar.h" -#include "stringsizes.h" +#include "trice_limits.h" #include #include diff --git a/cockatrice/src/dlg_edit_password.cpp b/cockatrice/src/dlg_edit_password.cpp index c942c0c91..95787ad37 100644 --- a/cockatrice/src/dlg_edit_password.cpp +++ b/cockatrice/src/dlg_edit_password.cpp @@ -1,7 +1,7 @@ #include "dlg_edit_password.h" #include "settingscache.h" -#include "stringsizes.h" +#include "trice_limits.h" #include #include diff --git a/cockatrice/src/dlg_edit_tokens.cpp b/cockatrice/src/dlg_edit_tokens.cpp index 9e724b977..6bf048e1c 100644 --- a/cockatrice/src/dlg_edit_tokens.cpp +++ b/cockatrice/src/dlg_edit_tokens.cpp @@ -4,7 +4,7 @@ #include "carddatabasemodel.h" #include "gettextwithmax.h" #include "main.h" -#include "stringsizes.h" +#include "trice_limits.h" #include #include diff --git a/cockatrice/src/dlg_edit_user.cpp b/cockatrice/src/dlg_edit_user.cpp index 819d03527..dbe91e31c 100644 --- a/cockatrice/src/dlg_edit_user.cpp +++ b/cockatrice/src/dlg_edit_user.cpp @@ -1,7 +1,7 @@ #include "dlg_edit_user.h" #include "settingscache.h" -#include "stringsizes.h" +#include "trice_limits.h" #include #include diff --git a/cockatrice/src/dlg_forgotpasswordchallenge.cpp b/cockatrice/src/dlg_forgotpasswordchallenge.cpp index 8de5afaec..75412b591 100644 --- a/cockatrice/src/dlg_forgotpasswordchallenge.cpp +++ b/cockatrice/src/dlg_forgotpasswordchallenge.cpp @@ -1,7 +1,7 @@ #include "dlg_forgotpasswordchallenge.h" #include "settingscache.h" -#include "stringsizes.h" +#include "trice_limits.h" #include #include diff --git a/cockatrice/src/dlg_forgotpasswordrequest.cpp b/cockatrice/src/dlg_forgotpasswordrequest.cpp index c92b28d31..9849f236d 100644 --- a/cockatrice/src/dlg_forgotpasswordrequest.cpp +++ b/cockatrice/src/dlg_forgotpasswordrequest.cpp @@ -1,7 +1,7 @@ #include "dlg_forgotpasswordrequest.h" #include "settingscache.h" -#include "stringsizes.h" +#include "trice_limits.h" #include #include diff --git a/cockatrice/src/dlg_forgotpasswordreset.cpp b/cockatrice/src/dlg_forgotpasswordreset.cpp index 9669a21e8..79ef053c5 100644 --- a/cockatrice/src/dlg_forgotpasswordreset.cpp +++ b/cockatrice/src/dlg_forgotpasswordreset.cpp @@ -1,7 +1,7 @@ #include "dlg_forgotpasswordreset.h" #include "settingscache.h" -#include "stringsizes.h" +#include "trice_limits.h" #include #include diff --git a/cockatrice/src/dlg_register.cpp b/cockatrice/src/dlg_register.cpp index 0136ce70e..51c2d4dae 100644 --- a/cockatrice/src/dlg_register.cpp +++ b/cockatrice/src/dlg_register.cpp @@ -2,7 +2,7 @@ #include "pb/serverinfo_user.pb.h" #include "settingscache.h" -#include "stringsizes.h" +#include "trice_limits.h" #include #include diff --git a/cockatrice/src/dlg_roll_dice.cpp b/cockatrice/src/dlg_roll_dice.cpp new file mode 100644 index 000000000..7a1a2bb9b --- /dev/null +++ b/cockatrice/src/dlg_roll_dice.cpp @@ -0,0 +1,52 @@ +#include "dlg_roll_dice.h" + +#include "trice_limits.h" + +#include +#include +#include +#include +#include + +DlgRollDice::DlgRollDice(QWidget *parent) : QDialog(parent) +{ + numberOfSidesLabel = new QLabel(tr("Number of sides:")); + numberOfSidesEdit = new QSpinBox(this); + numberOfSidesEdit->setValue(DEFAULT_NUMBER_SIDES_DIE); + numberOfSidesEdit->setRange(MINIMUM_DIE_SIDES, MAXIMUM_DIE_SIDES); + numberOfSidesEdit->setFocus(); + numberOfSidesLabel->setBuddy(numberOfSidesEdit); + + numberOfDiceLabel = new QLabel(tr("Number of dice:")); + numberOfDiceEdit = new QSpinBox(this); + numberOfDiceEdit->setValue(DEFAULT_NUMBER_DICE_TO_ROLL); + numberOfDiceEdit->setRange(MINIMUM_DICE_TO_ROLL, MAXIMUM_DICE_TO_ROLL); + numberOfDiceLabel->setBuddy(numberOfDiceEdit); + + auto *grid = new QGridLayout; + grid->addWidget(numberOfSidesLabel, 0, 0); + grid->addWidget(numberOfSidesEdit, 0, 1); + grid->addWidget(numberOfDiceLabel, 1, 0); + grid->addWidget(numberOfDiceEdit, 1, 1); + + buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + + auto *mainLayout = new QVBoxLayout; + mainLayout->addItem(grid); + mainLayout->addWidget(buttonBox); + + setLayout(mainLayout); + setWindowTitle(tr("Roll Dice")); +} + +uint DlgRollDice::getDieSideCount() const +{ + return numberOfSidesEdit->text().toUInt(); +} + +uint DlgRollDice::getDiceToRollCount() const +{ + return numberOfDiceEdit->text().toUInt(); +} diff --git a/cockatrice/src/dlg_roll_dice.h b/cockatrice/src/dlg_roll_dice.h new file mode 100644 index 000000000..2bd77749f --- /dev/null +++ b/cockatrice/src/dlg_roll_dice.h @@ -0,0 +1,26 @@ +#ifndef DLG_ROLL_DICE_H +#define DLG_ROLL_DICE_H + +#include +#include +#include +#include + +class DlgRollDice : public QDialog +{ + Q_OBJECT + + static constexpr uint DEFAULT_NUMBER_SIDES_DIE = 20; + static constexpr uint DEFAULT_NUMBER_DICE_TO_ROLL = 1; + + QLabel *numberOfSidesLabel, *numberOfDiceLabel; + QSpinBox *numberOfSidesEdit, *numberOfDiceEdit; + QDialogButtonBox *buttonBox; + +public: + explicit DlgRollDice(QWidget *parent = nullptr); + [[nodiscard]] uint getDieSideCount() const; + [[nodiscard]] uint getDiceToRollCount() const; +}; + +#endif // DLG_ROLL_DICE_H diff --git a/cockatrice/src/gettextwithmax.h b/cockatrice/src/gettextwithmax.h index 84e00a7e9..b6a9304ed 100644 --- a/cockatrice/src/gettextwithmax.h +++ b/cockatrice/src/gettextwithmax.h @@ -2,7 +2,7 @@ #ifndef GETTEXTWITHMAX_H #define GETTEXTWITHMAX_H -#include "stringsizes.h" +#include "trice_limits.h" #include diff --git a/cockatrice/src/messagelogwidget.cpp b/cockatrice/src/messagelogwidget.cpp index 7d630b062..e32158880 100644 --- a/cockatrice/src/messagelogwidget.cpp +++ b/cockatrice/src/messagelogwidget.cpp @@ -558,18 +558,39 @@ void MessageLogWidget::logReverseTurn(Player *player, bool reversed) .arg(reversed ? tr("reversed") : tr("normal"))); } -void MessageLogWidget::logRollDie(Player *player, int sides, int roll) +void MessageLogWidget::logRollDie(Player *player, int sides, const QList &rolls) { - if (sides == 2) { - QString coinOptions[2] = {tr("Heads") + " (1)", tr("Tails") + " (2)"}; - appendHtmlServerMessage(tr("%1 flipped a coin. It landed as %2.") - .arg(sanitizeHtml(player->getName())) - .arg("" + coinOptions[roll - 1] + "")); + if (rolls.length() == 1) { + const auto roll = rolls.at(0); + if (sides == 2) { + QString coinOptions[2] = {tr("Heads") + " (1)", tr("Tails") + " (2)"}; + appendHtmlServerMessage(tr("%1 flipped a coin. It landed as %2.") + .arg(sanitizeHtml(player->getName())) + .arg("" + coinOptions[roll - 1] + "")); + } else { + appendHtmlServerMessage(tr("%1 rolls a %2 with a %3-sided die.") + .arg(sanitizeHtml(player->getName())) + .arg("" + QString::number(roll) + "") + .arg("" + QString::number(sides) + "")); + } } else { - appendHtmlServerMessage(tr("%1 rolls a %2 with a %3-sided die.") - .arg(sanitizeHtml(player->getName())) - .arg("" + QString::number(roll) + "") - .arg("" + QString::number(sides) + "")); + if (sides == 2) { + appendHtmlServerMessage(tr("%1 flips %2 coins. There are %3 heads and %4 tails.") + .arg(sanitizeHtml(player->getName())) + .arg("" + QString::number(rolls.length()) + "") + .arg("" + QString::number(rolls.count(1)) + "") + .arg("" + QString::number(rolls.count(2)) + "")); + } else { + QStringList rollsStrings; + for (const auto &roll : rolls) { + rollsStrings.append(QString::number(roll)); + } + appendHtmlServerMessage(tr("%1 rolls a %2-sided dice %3 times: %4.") + .arg(sanitizeHtml(player->getName())) + .arg("" + QString::number(sides) + "") + .arg("" + QString::number(rolls.length()) + "") + .arg("" + rollsStrings.join(", ") + "")); + } } soundEngine->playSound("roll_dice"); } @@ -796,7 +817,8 @@ void MessageLogWidget::connectToPlayer(Player *player) connect(player, SIGNAL(logSay(Player *, QString)), this, SLOT(logSay(Player *, QString))); connect(player, &Player::logShuffle, this, &MessageLogWidget::logShuffle); - connect(player, SIGNAL(logRollDie(Player *, int, int)), this, SLOT(logRollDie(Player *, int, int))); + connect(player, SIGNAL(logRollDie(Player *, int, const QList &)), this, + SLOT(logRollDie(Player *, int, const QList &))); connect(player, SIGNAL(logCreateArrow(Player *, Player *, QString, Player *, QString, bool)), this, SLOT(logCreateArrow(Player *, Player *, QString, Player *, QString, bool))); connect(player, SIGNAL(logCreateToken(Player *, QString, QString)), this, diff --git a/cockatrice/src/messagelogwidget.h b/cockatrice/src/messagelogwidget.h index 6e2e75b5b..9ad1808e0 100644 --- a/cockatrice/src/messagelogwidget.h +++ b/cockatrice/src/messagelogwidget.h @@ -79,7 +79,7 @@ public slots: bool faceDown, int amount); void logReverseTurn(Player *player, bool reversed); - void logRollDie(Player *player, int sides, int roll); + void logRollDie(Player *player, int sides, const QList &rolls); void logSay(Player *player, QString message); void logSetActivePhase(int phase); void logSetActivePlayer(Player *player); diff --git a/cockatrice/src/player.cpp b/cockatrice/src/player.cpp index 1d0b60998..6e9e12843 100644 --- a/cockatrice/src/player.cpp +++ b/cockatrice/src/player.cpp @@ -9,6 +9,7 @@ #include "counter_general.h" #include "deck_loader.h" #include "dlg_create_token.h" +#include "dlg_roll_dice.h" #include "gamescene.h" #include "gettextwithmax.h" #include "handcounter.h" @@ -57,10 +58,10 @@ #include "playertarget.h" #include "settingscache.h" #include "stackzone.h" -#include "stringsizes.h" #include "tab_game.h" #include "tablezone.h" #include "thememanager.h" +#include "trice_limits.h" #include "zoneviewwidget.h" #include "zoneviewzone.h" @@ -1601,15 +1602,15 @@ void Player::actUntapAll() void Player::actRollDie() { - bool ok; - int sides = QInputDialog::getInt(game, tr("Roll die"), tr("Number of sides:"), defaultNumberDieRoll, minDieRoll, - maxDieRoll, 1, &ok); - if (ok) { - defaultNumberDieRoll = sides; - Command_RollDie cmd; - cmd.set_sides(static_cast(sides)); - sendGameCommand(cmd); + DlgRollDice dlg(game); + if (!dlg.exec()) { + return; } + + Command_RollDie cmd; + cmd.set_sides(dlg.getDieSideCount()); + cmd.set_count(dlg.getDiceToRollCount()); + sendGameCommand(cmd); } void Player::actCreateToken() @@ -1962,7 +1963,21 @@ void Player::eventShuffle(const Event_Shuffle &event) void Player::eventRollDie(const Event_RollDie &event) { - emit logRollDie(this, event.sides(), event.value()); + if (event.value()) { + // Backwards compatibility for old clients + emit logRollDie(this, static_cast(event.sides()), {event.value()}); + } else { +#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) + QList rolls(event.values().begin(), event.values().end()); +#else + QList rolls; + for (const auto &value : event.values()) { + rolls.append(value); + } +#endif + std::sort(rolls.begin(), rolls.end()); + emit logRollDie(this, static_cast(event.sides()), rolls); + } } void Player::eventCreateArrow(const Event_CreateArrow &event) diff --git a/cockatrice/src/player.h b/cockatrice/src/player.h index 646644a16..fafa1ee4d 100644 --- a/cockatrice/src/player.h +++ b/cockatrice/src/player.h @@ -114,7 +114,7 @@ signals: // Log events void logSay(Player *player, QString message); void logShuffle(Player *player, CardZone *zone, int start, int end); - void logRollDie(Player *player, int sides, int roll); + void logRollDie(Player *player, int sides, const QList &rolls); void logCreateArrow(Player *player, Player *startPlayer, QString startCard, @@ -259,8 +259,6 @@ private: int defaultNumberTopCardsToPlaceBelow = 1; int defaultNumberBottomCards = 1; int defaultNumberDieRoll = 20; - static constexpr int minDieRoll = 2; - static constexpr int maxDieRoll = 1000000; QString lastTokenName, lastTokenColor, lastTokenPT, lastTokenAnnotation; bool lastTokenDestroy; int lastTokenTableRow; diff --git a/cockatrice/src/tab_account.cpp b/cockatrice/src/tab_account.cpp index c845ebb29..f289f7da0 100644 --- a/cockatrice/src/tab_account.cpp +++ b/cockatrice/src/tab_account.cpp @@ -10,7 +10,7 @@ #include "pb/session_commands.pb.h" #include "pending_command.h" #include "soundengine.h" -#include "stringsizes.h" +#include "trice_limits.h" #include "userinfobox.h" #include "userlist.h" diff --git a/cockatrice/src/tab_admin.cpp b/cockatrice/src/tab_admin.cpp index 010bdfefb..5610fa542 100644 --- a/cockatrice/src/tab_admin.cpp +++ b/cockatrice/src/tab_admin.cpp @@ -2,7 +2,7 @@ #include "abstractclient.h" #include "pb/admin_commands.pb.h" -#include "stringsizes.h" +#include "trice_limits.h" #include #include diff --git a/cockatrice/src/tab_deck_editor.cpp b/cockatrice/src/tab_deck_editor.cpp index 5f7c66d80..ab859cae9 100644 --- a/cockatrice/src/tab_deck_editor.cpp +++ b/cockatrice/src/tab_deck_editor.cpp @@ -15,9 +15,9 @@ #include "pictureloader.h" #include "pixmapgenerator.h" #include "settingscache.h" -#include "stringsizes.h" #include "tab_supervisor.h" #include "tappedout_interface.h" +#include "trice_limits.h" #include #include diff --git a/cockatrice/src/tab_game.cpp b/cockatrice/src/tab_game.cpp index 29bd1b1c7..aa2b59922 100644 --- a/cockatrice/src/tab_game.cpp +++ b/cockatrice/src/tab_game.cpp @@ -52,8 +52,8 @@ #include "playerlistwidget.h" #include "replay_timeline_widget.h" #include "settingscache.h" -#include "stringsizes.h" #include "tab_supervisor.h" +#include "trice_limits.h" #include "window_main.h" #include "zoneviewwidget.h" #include "zoneviewzone.h" diff --git a/cockatrice/src/tab_logs.cpp b/cockatrice/src/tab_logs.cpp index da0589efd..dd4ee9c50 100644 --- a/cockatrice/src/tab_logs.cpp +++ b/cockatrice/src/tab_logs.cpp @@ -6,7 +6,7 @@ #include "pb/moderator_commands.pb.h" #include "pb/response_viewlog_history.pb.h" #include "pending_command.h" -#include "stringsizes.h" +#include "trice_limits.h" #include #include diff --git a/cockatrice/src/tab_message.cpp b/cockatrice/src/tab_message.cpp index 5c09adbb6..8c7dac2b5 100644 --- a/cockatrice/src/tab_message.cpp +++ b/cockatrice/src/tab_message.cpp @@ -10,7 +10,7 @@ #include "pending_command.h" #include "settingscache.h" #include "soundengine.h" -#include "stringsizes.h" +#include "trice_limits.h" #include #include diff --git a/cockatrice/src/tab_room.cpp b/cockatrice/src/tab_room.cpp index 4efbcc10c..fc260d175 100644 --- a/cockatrice/src/tab_room.cpp +++ b/cockatrice/src/tab_room.cpp @@ -15,9 +15,9 @@ #include "pb/serverinfo_room.pb.h" #include "pending_command.h" #include "settingscache.h" -#include "stringsizes.h" #include "tab_account.h" #include "tab_supervisor.h" +#include "trice_limits.h" #include "userlist.h" #include diff --git a/cockatrice/src/userlist.cpp b/cockatrice/src/userlist.cpp index dc93a1f63..deaff2aca 100644 --- a/cockatrice/src/userlist.cpp +++ b/cockatrice/src/userlist.cpp @@ -8,9 +8,9 @@ #include "pb/session_commands.pb.h" #include "pending_command.h" #include "pixmapgenerator.h" -#include "stringsizes.h" #include "tab_account.h" #include "tab_supervisor.h" +#include "trice_limits.h" #include "user_context_menu.h" #include diff --git a/common/debug_pb_message.cpp b/common/debug_pb_message.cpp index 8c6569c77..dda672689 100644 --- a/common/debug_pb_message.cpp +++ b/common/debug_pb_message.cpp @@ -1,6 +1,6 @@ #include "debug_pb_message.h" -#include "stringsizes.h" +#include "trice_limits.h" #include #include diff --git a/common/pb/command_roll_die.proto b/common/pb/command_roll_die.proto index 0d0c48075..6639241e1 100644 --- a/common/pb/command_roll_die.proto +++ b/common/pb/command_roll_die.proto @@ -5,4 +5,5 @@ message Command_RollDie { optional Command_RollDie ext = 1005; } optional uint32 sides = 1; + optional uint32 count = 2; } diff --git a/common/pb/event_roll_die.proto b/common/pb/event_roll_die.proto index 4d99f2be5..26014f218 100644 --- a/common/pb/event_roll_die.proto +++ b/common/pb/event_roll_die.proto @@ -7,4 +7,5 @@ message Event_RollDie { } optional uint32 sides = 1; optional uint32 value = 2; + repeated uint32 values = 3; } diff --git a/common/server_player.cpp b/common/server_player.cpp index d2a3ec594..d1a20acc9 100644 --- a/common/server_player.cpp +++ b/common/server_player.cpp @@ -79,7 +79,7 @@ #include "server_database_interface.h" #include "server_game.h" #include "server_room.h" -#include "stringsizes.h" +#include "trice_limits.h" #include #include @@ -1060,7 +1060,7 @@ Server_Player::cmdMulligan(const Command_Mulligan &cmd, ResponseContainer & /*rc } Response::ResponseCode -Server_Player::cmdRollDie(const Command_RollDie &cmd, ResponseContainer & /*rc*/, GameEventStorage &ges) +Server_Player::cmdRollDie(const Command_RollDie &cmd, ResponseContainer & /*rc*/, GameEventStorage &ges) const { if (spectator) { return Response::RespFunctionNotAllowed; @@ -1069,9 +1069,15 @@ Server_Player::cmdRollDie(const Command_RollDie &cmd, ResponseContainer & /*rc*/ return Response::RespContextError; } + const auto validatedSides = static_cast(std::min(std::max(cmd.sides(), MINIMUM_DIE_SIDES), MAXIMUM_DIE_SIDES)); + const auto validatedDiceToRoll = + static_cast(std::min(std::max(cmd.count(), MINIMUM_DICE_TO_ROLL), MAXIMUM_DICE_TO_ROLL)); + Event_RollDie event; - event.set_sides(cmd.sides()); - event.set_value(rng->rand(1, cmd.sides())); + event.set_sides(validatedSides); + for (auto i = 0; i < validatedDiceToRoll; ++i) { + event.add_values(rng->rand(1, validatedSides)); + } ges.enqueueGameEvent(event, playerId); return Response::RespOk; diff --git a/common/server_player.h b/common/server_player.h index 27257d06f..e6b91f5e5 100644 --- a/common/server_player.h +++ b/common/server_player.h @@ -203,7 +203,7 @@ public: Response::ResponseCode cmdGameSay(const Command_GameSay &cmd, ResponseContainer &rc, GameEventStorage &ges); Response::ResponseCode cmdShuffle(const Command_Shuffle &cmd, ResponseContainer &rc, GameEventStorage &ges); Response::ResponseCode cmdMulligan(const Command_Mulligan &cmd, ResponseContainer &rc, GameEventStorage &ges); - Response::ResponseCode cmdRollDie(const Command_RollDie &cmd, ResponseContainer &rc, GameEventStorage &ges); + Response::ResponseCode cmdRollDie(const Command_RollDie &cmd, ResponseContainer &rc, GameEventStorage &ges) const; Response::ResponseCode cmdDrawCards(const Command_DrawCards &cmd, ResponseContainer &rc, GameEventStorage &ges); Response::ResponseCode cmdUndoDraw(const Command_UndoDraw &cmd, ResponseContainer &rc, GameEventStorage &ges); Response::ResponseCode cmdMoveCard(const Command_MoveCard &cmd, ResponseContainer &rc, GameEventStorage &ges); diff --git a/common/server_protocolhandler.cpp b/common/server_protocolhandler.cpp index 8e4d58f48..74ab45e90 100644 --- a/common/server_protocolhandler.cpp +++ b/common/server_protocolhandler.cpp @@ -21,7 +21,7 @@ #include "server_game.h" #include "server_player.h" #include "server_room.h" -#include "stringsizes.h" +#include "trice_limits.h" #include #include diff --git a/common/server_room.cpp b/common/server_room.cpp index 4cd5f3a01..77f720cb5 100644 --- a/common/server_room.cpp +++ b/common/server_room.cpp @@ -11,7 +11,7 @@ #include "pb/serverinfo_room.pb.h" #include "server_game.h" #include "server_protocolhandler.h" -#include "stringsizes.h" +#include "trice_limits.h" #include #include diff --git a/common/stringsizes.h b/common/trice_limits.h similarity index 79% rename from common/stringsizes.h rename to common/trice_limits.h index d8015ccf0..072045b10 100644 --- a/common/stringsizes.h +++ b/common/trice_limits.h @@ -1,6 +1,5 @@ -// max sizes of strings used in the protocol -#ifndef STRINGSIZES_H -#define STRINGSIZES_H +#ifndef TRICE_LIMITS_H +#define TRICE_LIMITS_H #include @@ -11,6 +10,11 @@ constexpr int MAX_TEXT_LENGTH = 0xfff; // max size for deck files and pictures constexpr int MAX_FILE_LENGTH = 0xfffff; // about a megabyte +constexpr uint MINIMUM_DIE_SIDES = 2; +constexpr uint MAXIMUM_DIE_SIDES = 1000000; +constexpr uint MINIMUM_DICE_TO_ROLL = 1; +constexpr uint MAXIMUM_DICE_TO_ROLL = 100; + // optimized functions to get qstrings that are at most that long static inline QString nameFromStdString(const std::string &_string) { @@ -25,4 +29,4 @@ static inline QString fileFromStdString(const std::string &_string) return QString::fromUtf8(_string.data(), std::min(int(_string.size()), MAX_FILE_LENGTH)); } -#endif // STRINGSIZES_H +#endif // TRICE_LIMITS_H diff --git a/servatrice/src/serversocketinterface.cpp b/servatrice/src/serversocketinterface.cpp index a77055f37..4e1d45696 100644 --- a/servatrice/src/serversocketinterface.cpp +++ b/servatrice/src/serversocketinterface.cpp @@ -65,7 +65,7 @@ #include "server_response_containers.h" #include "server_room.h" #include "settingscache.h" -#include "stringsizes.h" +#include "trice_limits.h" #include "version_string.h" #include