mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-30 02:23:55 -07:00
Split trice_limits.h into dedicated headers (#7025)
Some checks are pending
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 44 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 15 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Docker Image / amd64 & arm64 (push) Waiting to run
Some checks are pending
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 44 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 15 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Docker Image / amd64 & arm64 (push) Waiting to run
* Split trice_limits.h into dedicated headers * Updated docstrings
This commit is contained in:
parent
4a384f2a75
commit
18b23b19a7
43 changed files with 103 additions and 84 deletions
|
|
@ -28,8 +28,8 @@
|
|||
#include <libcockatrice/protocol/pb/command_undo_draw.pb.h>
|
||||
#include <libcockatrice/protocol/pb/context_move_card.pb.h>
|
||||
#include <libcockatrice/utility/clamped_arithmetic.h>
|
||||
#include <libcockatrice/utility/counter_limits.h>
|
||||
#include <libcockatrice/utility/expression.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/zone_names.h>
|
||||
|
||||
// milliseconds in between triggers of the move top cards until action
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
#include "abstract_card_item.h"
|
||||
|
||||
#include <libcockatrice/network/server/remote/game/server_card.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
|
||||
class CardDatabase;
|
||||
class CardDragItem;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#include <libcockatrice/protocol/pb/command_set_sideboard_plan.pb.h>
|
||||
#include <libcockatrice/protocol/pb/response_deck_download.pb.h>
|
||||
#include <libcockatrice/protocol/pending_command.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
ToggleButton::ToggleButton(QWidget *parent) : QPushButton(parent), state(false)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
#include <libcockatrice/deck_list/deck_list.h>
|
||||
#include <libcockatrice/models/database/card_database_model.h>
|
||||
#include <libcockatrice/models/database/token/token_display_model.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
DlgCreateToken::DlgCreateToken(const QStringList &_predefinedTokens, QWidget *parent)
|
||||
: QDialog(parent), predefinedTokens(_predefinedTokens)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include <QSpinBox>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/dice_limits.h>
|
||||
|
||||
DlgRollDice::DlgRollDice(QWidget *parent) : QDialog(parent)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <QInputDialog>
|
||||
#include <libcockatrice/card/relation/card_relation.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
PlayerDialogs::PlayerDialogs(PlayerGraphicsItem *_player, PlayerActions *_playerActions)
|
||||
: QObject(_player), player(_player), playerActions(_playerActions)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#include <QSplitter>
|
||||
#include <QTextEdit>
|
||||
#include <libcockatrice/card/database/card_database_manager.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
static int findRestoreIndex(const CardRef &wanted, const QComboBox *combo)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QRadioButton>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
DlgConnect::DlgConnect(QWidget *parent) : QDialog(parent)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
#include <QSpinBox>
|
||||
#include <libcockatrice/protocol/pb/serverinfo_game.pb.h>
|
||||
#include <libcockatrice/protocol/pending_command.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
void DlgCreateGame::sharedCtor()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
DlgEditAvatar::DlgEditAvatar(QWidget *parent) : QDialog(parent), image()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
DlgEditPassword::DlgEditPassword(QWidget *parent) : QDialog(parent)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#include <libcockatrice/card/database/card_database_manager.h>
|
||||
#include <libcockatrice/models/database/card_database_model.h>
|
||||
#include <libcockatrice/models/database/token/token_edit_model.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
DlgEditTokens::DlgEditTokens(QWidget *parent) : QDialog(parent), currentCard(nullptr)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#include <QGridLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
DlgEditUser::DlgEditUser(QWidget *parent, QString email, QString country, QString realName) : QDialog(parent)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
DlgForgotPasswordChallenge::DlgForgotPasswordChallenge(QWidget *parent) : QDialog(parent)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
DlgForgotPasswordRequest::DlgForgotPasswordRequest(QWidget *parent) : QDialog(parent)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
DlgForgotPasswordReset::DlgForgotPasswordReset(QWidget *parent) : QDialog(parent)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
DlgRegister::DlgRegister(QWidget *parent) : QDialog(parent)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
#include <libcockatrice/protocol/pb/response_get_games_of_user.pb.h>
|
||||
#include <libcockatrice/protocol/pb/response_get_user_info.pb.h>
|
||||
#include <libcockatrice/protocol/pending_command.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
BanDialog::BanDialog(const ServerInfo_User &info, QWidget *parent) : QDialog(parent)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <QGridLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QToolBar>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
MessagesSettingsPage::MessagesSettingsPage()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
#include <libcockatrice/protocol/pb/command_deck_upload.pb.h>
|
||||
#include <libcockatrice/protocol/pb/response.pb.h>
|
||||
#include <libcockatrice/protocol/pending_command.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
/**
|
||||
* @brief Constructs the AbstractTabDeckEditor.
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
#include <libcockatrice/protocol/pb/response_list_users.pb.h>
|
||||
#include <libcockatrice/protocol/pb/session_commands.pb.h>
|
||||
#include <libcockatrice/protocol/pending_command.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
TabAccount::TabAccount(TabSupervisor *_tabSupervisor, AbstractClient *_client, const ServerInfo_User &userInfo)
|
||||
: Tab(_tabSupervisor), client(_client)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
#include <libcockatrice/protocol/pb/event_replay_added.pb.h>
|
||||
#include <libcockatrice/protocol/pb/moderator_commands.pb.h>
|
||||
#include <libcockatrice/protocol/pending_command.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
ShutdownDialog::ShutdownDialog(QWidget *parent) : QDialog(parent)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
#include <libcockatrice/models/database/card_database_model.h>
|
||||
#include <libcockatrice/network/client/abstract/abstract_client.h>
|
||||
#include <libcockatrice/protocol/pending_command.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
|
||||
/**
|
||||
* @brief Constructs a new TabDeckEditor object.
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include <libcockatrice/protocol/pb/response_deck_download.pb.h>
|
||||
#include <libcockatrice/protocol/pb/response_deck_upload.pb.h>
|
||||
#include <libcockatrice/protocol/pending_command.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
TabDeckStorage::TabDeckStorage(TabSupervisor *_tabSupervisor,
|
||||
AbstractClient *_client,
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
#include <libcockatrice/protocol/pb/game_replay.pb.h>
|
||||
#include <libcockatrice/protocol/pb/serverinfo_player.pb.h>
|
||||
#include <libcockatrice/protocol/pb/serverinfo_user.pb.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
TabGame::TabGame(TabSupervisor *_tabSupervisor, GameReplay *_replay)
|
||||
: Tab(_tabSupervisor), sayLabel(nullptr), sayEdit(nullptr)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
#include <libcockatrice/protocol/pb/moderator_commands.pb.h>
|
||||
#include <libcockatrice/protocol/pb/response_viewlog_history.pb.h>
|
||||
#include <libcockatrice/protocol/pending_command.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
TabLog::TabLog(TabSupervisor *_tabSupervisor, AbstractClient *_client) : Tab(_tabSupervisor), client(_client)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
#include <libcockatrice/protocol/pb/serverinfo_user.pb.h>
|
||||
#include <libcockatrice/protocol/pb/session_commands.pb.h>
|
||||
#include <libcockatrice/protocol/pending_command.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
TabMessage::TabMessage(TabSupervisor *_tabSupervisor,
|
||||
AbstractClient *_client,
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
#include <libcockatrice/protocol/pb/room_commands.pb.h>
|
||||
#include <libcockatrice/protocol/pb/serverinfo_room.pb.h>
|
||||
#include <libcockatrice/protocol/pending_command.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
TabRoom::TabRoom(TabSupervisor *_tabSupervisor,
|
||||
AbstractClient *_client,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <QLineEdit>
|
||||
#include <QWidget>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
QString getTextWithMax(QWidget *parent,
|
||||
const QString &title,
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
#include <libcockatrice/protocol/pb/response.pb.h>
|
||||
#include <libcockatrice/protocol/pb/serverinfo_player.pb.h>
|
||||
#include <libcockatrice/protocol/pb/serverinfo_user.pb.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
Server_AbstractParticipant::Server_AbstractParticipant(Server_Game *_game,
|
||||
int _playerId,
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@
|
|||
#include <libcockatrice/protocol/pb/serverinfo_player.pb.h>
|
||||
#include <libcockatrice/protocol/pb/serverinfo_user.pb.h>
|
||||
#include <libcockatrice/rng/rng_abstract.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/dice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
#include <libcockatrice/utility/zone_names.h>
|
||||
#include <limits>
|
||||
#include <ranges>
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#include <libcockatrice/protocol/pb/event_set_card_counter.pb.h>
|
||||
#include <libcockatrice/protocol/pb/serverinfo_card.pb.h>
|
||||
#include <libcockatrice/utility/clamped_arithmetic.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/counter_limits.h>
|
||||
#include <limits>
|
||||
|
||||
Server_Card::Server_Card(const CardRef &cardRef, int _id, int _coord_x, int _coord_y, Server_CardZone *_zone)
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
#include <libcockatrice/protocol/pb/serverinfo_user.pb.h>
|
||||
#include <libcockatrice/rng/rng_abstract.h>
|
||||
#include <libcockatrice/utility/color.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
#include <libcockatrice/utility/zone_names.h>
|
||||
|
||||
Server_Player::Server_Player(Server_Game *_game,
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
#include <libcockatrice/protocol/pb/response_list_users.pb.h>
|
||||
#include <libcockatrice/protocol/pb/response_login.pb.h>
|
||||
#include <libcockatrice/protocol/pb/serverinfo_user.pb.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
Server_ProtocolHandler::Server_ProtocolHandler(Server *_server,
|
||||
Server_DatabaseInterface *_databaseInterface,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
#include <libcockatrice/protocol/pb/room_commands.pb.h>
|
||||
#include <libcockatrice/protocol/pb/serverinfo_chat_message.pb.h>
|
||||
#include <libcockatrice/protocol/pb/serverinfo_room.pb.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
Server_Room::Server_Room(int _id,
|
||||
int _chatHistorySize,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include <google/protobuf/descriptor.h>
|
||||
#include <google/protobuf/message.h>
|
||||
#include <google/protobuf/text_format.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
|
||||
// FastFieldValuePrinter is added in protobuf 3.4, going out of our way to add the old FieldValuePrinter is not worth it
|
||||
#if GOOGLE_PROTOBUF_VERSION > 3004000
|
||||
|
|
|
|||
|
|
@ -15,7 +15,9 @@ set(UTILITY_HEADERS
|
|||
libcockatrice/utility/levenshtein.h
|
||||
libcockatrice/utility/macros.h
|
||||
libcockatrice/utility/passwordhasher.h
|
||||
libcockatrice/utility/trice_limits.h
|
||||
libcockatrice/utility/string_limits.h
|
||||
libcockatrice/utility/dice_limits.h
|
||||
libcockatrice/utility/counter_limits.h
|
||||
libcockatrice/utility/clamped_arithmetic.h
|
||||
libcockatrice/utility/zone_names.h
|
||||
libcockatrice/utility/days_years_between.h
|
||||
|
|
|
|||
17
libcockatrice_utility/libcockatrice/utility/counter_limits.h
Normal file
17
libcockatrice_utility/libcockatrice/utility/counter_limits.h
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef COUNTER_LIMITS_H
|
||||
#define COUNTER_LIMITS_H
|
||||
|
||||
/**
|
||||
* @brief Upper bound for a bounded counter's value: [0, MAX_COUNTER_VALUE].
|
||||
*
|
||||
* Caps an individual counter's VALUE (e.g. a +1/+1 counter at 999), not how many counters
|
||||
* something holds. Applies to counters that are constrained to a non-negative display range,
|
||||
* such as card counters and commander tax. Unbounded counters (e.g. a player's life total)
|
||||
* do not use this limit and may go negative, saturating only at the int range.
|
||||
*
|
||||
* The max of 999 is a display constraint (3-digit rendering) and a reasonable gameplay limit.
|
||||
* The server enforces these bounds; the client may also check them for UX optimization.
|
||||
*/
|
||||
constexpr int MAX_COUNTER_VALUE = 999;
|
||||
|
||||
#endif // COUNTER_LIMITS_H
|
||||
15
libcockatrice_utility/libcockatrice/utility/dice_limits.h
Normal file
15
libcockatrice_utility/libcockatrice/utility/dice_limits.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef DICE_LIMITS_H
|
||||
#define DICE_LIMITS_H
|
||||
|
||||
#include <QtGlobal> // for uint
|
||||
|
||||
/** @brief Fewest sides a rollable die may have. */
|
||||
constexpr uint MINIMUM_DIE_SIDES = 2;
|
||||
/** @brief Most sides a rollable die may have. */
|
||||
constexpr uint MAXIMUM_DIE_SIDES = 1000000;
|
||||
/** @brief Fewest dice that may be rolled at once. */
|
||||
constexpr uint MINIMUM_DICE_TO_ROLL = 1;
|
||||
/** @brief Most dice that may be rolled at once. */
|
||||
constexpr uint MAXIMUM_DICE_TO_ROLL = 100;
|
||||
|
||||
#endif // DICE_LIMITS_H
|
||||
31
libcockatrice_utility/libcockatrice/utility/string_limits.h
Normal file
31
libcockatrice_utility/libcockatrice/utility/string_limits.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#ifndef STRING_LIMITS_H
|
||||
#define STRING_LIMITS_H
|
||||
|
||||
#include <QString>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
/** @brief Max size for short strings, like names and things that are generally a single phrase. */
|
||||
constexpr int MAX_NAME_LENGTH = 0xff;
|
||||
/** @brief Max size for chat messages and text contents. */
|
||||
constexpr int MAX_TEXT_LENGTH = 0xfff;
|
||||
/** @brief Max size for deck files and pictures (about 2 megabytes). */
|
||||
constexpr int MAX_FILE_LENGTH = 0x1fffff;
|
||||
|
||||
/** @brief Returns a QString from a std::string, truncated to at most MAX_NAME_LENGTH bytes. */
|
||||
inline QString nameFromStdString(const std::string &_string)
|
||||
{
|
||||
return QString::fromUtf8(_string.data(), std::min(int(_string.size()), MAX_NAME_LENGTH));
|
||||
}
|
||||
/** @brief Returns a QString from a std::string, truncated to at most MAX_TEXT_LENGTH bytes. */
|
||||
inline QString textFromStdString(const std::string &_string)
|
||||
{
|
||||
return QString::fromUtf8(_string.data(), std::min(int(_string.size()), MAX_TEXT_LENGTH));
|
||||
}
|
||||
/** @brief Returns a QString from a std::string, truncated to at most MAX_FILE_LENGTH bytes. */
|
||||
inline QString fileFromStdString(const std::string &_string)
|
||||
{
|
||||
return QString::fromUtf8(_string.data(), std::min(int(_string.size()), MAX_FILE_LENGTH));
|
||||
}
|
||||
|
||||
#endif // STRING_LIMITS_H
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
#ifndef TRICE_LIMITS_H
|
||||
#define TRICE_LIMITS_H
|
||||
|
||||
//! \todo Split trice_limits.h into focused single-purpose headers: string_limits.h,
|
||||
//! dice_limits.h, counter_limits.h.
|
||||
|
||||
#include <QString>
|
||||
|
||||
// max size for short strings, like names and things that are generally a single phrase
|
||||
constexpr int MAX_NAME_LENGTH = 0xff;
|
||||
// max size for chat messages and text contents
|
||||
constexpr int MAX_TEXT_LENGTH = 0xfff;
|
||||
// max size for deck files and pictures
|
||||
constexpr int MAX_FILE_LENGTH = 0x1fffff; // about 2 megabytes
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @brief Upper bound for a bounded counter's value: [0, MAX_COUNTER_VALUE].
|
||||
*
|
||||
* Caps an individual counter's VALUE (e.g. a +1/+1 counter at 999), not how many counters
|
||||
* something holds. Applies to counters that are constrained to a non-negative display range,
|
||||
* such as card counters and commander tax. Unbounded counters (e.g. a player's life total)
|
||||
* do not use this limit and may go negative, saturating only at the int range.
|
||||
*
|
||||
* The max of 999 is a display constraint (3-digit rendering) and a reasonable gameplay limit.
|
||||
* The server enforces these bounds; the client may also check them for UX optimization.
|
||||
*/
|
||||
constexpr int MAX_COUNTER_VALUE = 999;
|
||||
|
||||
// optimized functions to get qstrings that are at most that long
|
||||
static inline QString nameFromStdString(const std::string &_string)
|
||||
{
|
||||
return QString::fromUtf8(_string.data(), std::min(int(_string.size()), MAX_NAME_LENGTH));
|
||||
}
|
||||
static inline QString textFromStdString(const std::string &_string)
|
||||
{
|
||||
return QString::fromUtf8(_string.data(), std::min(int(_string.size()), MAX_TEXT_LENGTH));
|
||||
}
|
||||
static inline QString fileFromStdString(const std::string &_string)
|
||||
{
|
||||
return QString::fromUtf8(_string.data(), std::min(int(_string.size()), MAX_FILE_LENGTH));
|
||||
}
|
||||
|
||||
#endif // TRICE_LIMITS_H
|
||||
|
|
@ -83,7 +83,7 @@
|
|||
#include <libcockatrice/protocol/pb/serverinfo_deckstorage.pb.h>
|
||||
#include <libcockatrice/protocol/pb/serverinfo_replay.pb.h>
|
||||
#include <libcockatrice/protocol/pb/serverinfo_user.pb.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
#include <server_response_containers.h>
|
||||
#include <server_room.h>
|
||||
#include <string>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <libcockatrice/network/server/remote/game/server_card.h>
|
||||
#include <libcockatrice/protocol/pb/event_set_card_counter.pb.h>
|
||||
#include <libcockatrice/utility/card_ref.h>
|
||||
#include <libcockatrice/utility/trice_limits.h>
|
||||
#include <libcockatrice/utility/counter_limits.h>
|
||||
#include <limits>
|
||||
|
||||
TEST(ServerCardCounter, IncrementNewCounter)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue