Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
dump_zone_range.h File Reference
#include <QtGlobal>
#include <utility>
Include dependency graph for dump_zone_range.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

std::pair< qsizetype, qsizetype > dumpZoneCardRange (qsizetype cardCount, int numberCards, bool isReversed)
 Resolve a client's zone dump request against a zone's real card count.

Function Documentation

◆ dumpZoneCardRange()

std::pair< qsizetype, qsizetype > dumpZoneCardRange ( qsizetype cardCount,
int numberCards,
bool isReversed )

Resolve a client's zone dump request against a zone's real card count.

number_cards arrives from the client unvalidated. -1 means "the whole zone", which is the convention the client uses when sizing its own view of one. Every other negative value, and every value larger than the zone, has to be brought into range rather than used as an index: with a reversed request the zone offset is cardCount - numberCards, which runs off the front of the list when the request exceeds the zone and off the back when numberCards is -1.

Kept in its own translation unit so it can be exercised without the rest of server_abstract_player.cpp, which refers to the RNG global that only the servatrice binary defines.

Parameters
cardCountnumber of cards the zone actually holds
numberCardsthe requested count, -1 for the whole zone
isReversedtake the trailing cards instead of the leading ones
Returns
the half-open index range [begin, end) into the zone's card list, always contained in [0, cardCount)
Here is the call graph for this function:
Here is the caller graph for this function: