From 16180306ad0bbcdb6590f7afa05a872efe88e4bf Mon Sep 17 00:00:00 2001 From: Goober5000 Date: Sat, 16 Sep 2023 02:03:02 -0400 Subject: [PATCH] fix random selection of message candidates The `Random::next(low, high)` function returns a value in [low, high]. This location should use the single-argument version, `Random::next(int modulus)`, which returns a value in [0, modulus-1]. --- code/mission/missionmessage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/mission/missionmessage.cpp b/code/mission/missionmessage.cpp index 3fdfd7f6c70..ccdc2379db5 100644 --- a/code/mission/missionmessage.cpp +++ b/code/mission/missionmessage.cpp @@ -1979,7 +1979,7 @@ int pick_persona(ship* shipp) { if (count == 1) { return candidates[0]; } else if (count > 1) { - return candidates[Random::next(0, count)]; + return candidates[Random::next(count)]; } else if (persona_type & PERSONA_FLAG_SUPPORT) { // Species without a support persona (e.g. the UEF) historically used the // first support persona; retain that behavior