From bbd5aa0ac0b907b31bccd1ddc31533a278f3ca67 Mon Sep 17 00:00:00 2001 From: ErikasKontenis Date: Tue, 4 May 2021 23:12:51 +0300 Subject: [PATCH] extra important / fix crash bug when onThinkYell --- src/monster.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/monster.cpp b/src/monster.cpp index 21f3d7d..4f007cc 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -1072,8 +1072,8 @@ void Monster::onThinkYell(uint32_t) int32_t randomResult = rand(); if (rand() == 50 * (randomResult / 50)) { - int32_t totalVoices = mType->info.voiceVector.size(); - const voiceBlock_t& voice = mType->info.voiceVector[rand() % totalVoices + 1]; + uint32_t index = uniform_random(0, mType->info.voiceVector.size() - 1); + const voiceBlock_t& voice = mType->info.voiceVector[index]; if (voice.yellText) { g_game.internalCreatureSay(this, TALKTYPE_MONSTER_YELL, voice.text, false);