Refine command zone counters and unify counter clamp arithmetic

- Route value updates through the virtual setValue() so
      CommanderTaxCounter's tooltip tracks the live value instead of
      freezing at its initial value
    - Reject deletion of reserved tax counters in cmdDelCounter; they are
      server-managed and must persist for the game
    - Register aMoveToCommandZone and aViewCommandZone as bindable
      shortcuts, matching their sibling move/view zone actions
    - Extract overflow-safe clamped addition into addClamped(), shared by
      Server_Card and Server_Counter instead of duplicated
    - Update stale comments: the clip-container note (now used by
      CommandZone) and CommandZone's layout docs (defer to
      SelectZone::layoutCardsVertically)
This commit is contained in:
DawnFire42 2026-06-16 12:49:10 -04:00
parent 754b31cc29
commit 240ca7029f
No known key found for this signature in database
GPG key ID: 24BB855EE2911B33
8 changed files with 37 additions and 22 deletions

View file

@ -2,6 +2,8 @@
#define TRICE_LIMITS_H
#include <QString>
#include <QtGlobal>
#include <cstdint>
// max size for short strings, like names and things that are generally a single phrase
constexpr int MAX_NAME_LENGTH = 0xff;
@ -21,6 +23,18 @@ constexpr uint MAXIMUM_DICE_TO_ROLL = 100;
// Server enforces these bounds; client may also check for UX optimization.
constexpr int MAX_COUNTER_VALUE = 999;
/**
* @brief Overflow-safe clamped addition: returns value + delta bounded to [minValue, maxValue].
*
* Uses a 64-bit intermediate so the addition itself cannot overflow int. Shared by the
* counter arithmetic in Server_Card and Server_Counter so both stay in sync.
*/
inline int addClamped(int value, int delta, int minValue, int maxValue)
{
const auto result = static_cast<int64_t>(value) + static_cast<int64_t>(delta);
return static_cast<int>(qBound(static_cast<int64_t>(minValue), result, static_cast<int64_t>(maxValue)));
}
// optimized functions to get qstrings that are at most that long
static inline QString nameFromStdString(const std::string &_string)
{