From 9fb91309b60ac65171e71d4dfeaba28cece2c7c0 Mon Sep 17 00:00:00 2001 From: Rodrigo Alfonso Date: Thu, 30 Jan 2025 06:28:41 -0300 Subject: [PATCH] playerCount() cannot be greater than LINK_UNIVERSAL_MAX_PLAYERS --- lib/LinkUniversal.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/LinkUniversal.hpp b/lib/LinkUniversal.hpp index a539d55..954d270 100644 --- a/lib/LinkUniversal.hpp +++ b/lib/LinkUniversal.hpp @@ -197,8 +197,9 @@ class LinkUniversal { * @brief Returns the number of connected players (`1~5`). */ [[nodiscard]] u8 playerCount() { - return mode == Mode::LINK_CABLE ? linkCable.playerCount() - : linkWireless.playerCount(); + return Link::_min(mode == Mode::LINK_CABLE ? linkCable.playerCount() + : linkWireless.playerCount(), + LINK_UNIVERSAL_MAX_PLAYERS); } /**