From b86af518709310d8ac8f04b14484b2d879561ef7 Mon Sep 17 00:00:00 2001 From: Franck Dary <franck.dary@lis-lab.fr> Date: Wed, 10 Nov 2021 15:49:28 +0100 Subject: [PATCH] Corrected bug where wordIndex would overflow --- reading_machine/src/Config.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/reading_machine/src/Config.cpp b/reading_machine/src/Config.cpp index 019d17d..99a7d34 100644 --- a/reading_machine/src/Config.cpp +++ b/reading_machine/src/Config.cpp @@ -448,15 +448,15 @@ bool Config::moveWordIndex(int relativeMovement) dir = -1; int movementDone = 0; - if (isMultiwordPredicted(wordIndex)) + if (isMultiwordPredicted(wordIndex) and (dir >= 0 or wordIndex > 0)) wordIndex += dir; while (movementDone != relativeMovement) { - if (isMultiwordPredicted(wordIndex)) + if (isMultiwordPredicted(wordIndex) and (dir >= 0 or wordIndex > 0)) wordIndex += dir; wordIndex += dir; movementDone += dir; - if (isMultiwordPredicted(wordIndex)) + if (isMultiwordPredicted(wordIndex) and (dir >= 0 or wordIndex > 0)) wordIndex += dir; } @@ -468,7 +468,7 @@ void Config::moveWordIndexRelaxed(int relativeMovement) int dir = 1; if (relativeMovement < 0) dir = -1; - if (isMultiwordPredicted(wordIndex)) + if (isMultiwordPredicted(wordIndex) and (dir >= 0 or wordIndex > 0)) wordIndex += dir; for (int i = 0; i < abs(relativeMovement); i++) if (!moveWordIndex(dir)) -- GitLab