[Scummvm-git-logs] scummvm master -> efdd2bdf2781e44dd8971bb64573a1bcaa6842c6

tag2015 noreply at scummvm.org
Sat Jun 3 11:17:09 UTC 2023


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
efdd2bdf27 AGS: Engine: fixed possible vector idx error in start_character_turning()


Commit: efdd2bdf2781e44dd8971bb64573a1bcaa6842c6
    https://github.com/scummvm/scummvm/commit/efdd2bdf2781e44dd8971bb64573a1bcaa6842c6
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-06-03T13:13:49+02:00

Commit Message:
AGS: Engine: fixed possible vector idx error in start_character_turning()

This replaces the previous commit, to keep in sync with upstream.
>From upstream fca247a28fe2d0609cdbd71ab734929c1c451f1c

Changed paths:
    engines/ags/engine/ac/character.cpp


diff --git a/engines/ags/engine/ac/character.cpp b/engines/ags/engine/ac/character.cpp
index 66dd33f8743..84f0713a864 100644
--- a/engines/ags/engine/ac/character.cpp
+++ b/engines/ags/engine/ac/character.cpp
@@ -1703,6 +1703,7 @@ void start_character_turning(CharacterInfo *chinf, int useloop, int no_diagonal)
 		no_diagonal = 0;
 
 	for (ii = fromidx; ii != toidx; ii -= go_anticlock) {
+		// Wrap the loop order into range [0-7]
 		if (ii < 0)
 			ii = 7;
 		if (ii >= 8)
@@ -1710,15 +1711,12 @@ void start_character_turning(CharacterInfo *chinf, int useloop, int no_diagonal)
 		if (ii == toidx)
 			break;
 		if ((turnlooporder[ii] >= 4) && (no_diagonal > 0))
-			continue;
-		// Upstream does not do this check
-		// The value of turnlooporder should be checked before addressing the
-		// loops vector, to avoid going OOB and triggering an assertion
-		if (((uint)turnlooporder[ii] < _GP(views)[chinf->view].loops.size()) &&
-			(_GP(views)[chinf->view].loops[turnlooporder[ii]].numFrames < 1))
-			continue;
-		if (turnlooporder[ii] < _GP(views)[chinf->view].numLoops)
-			chinf->walking += TURNING_AROUND;
+			continue; // there are no diagonal loops
+		if (turnlooporder[ii] >= _GP(views)[chinf->view].numLoops)
+			continue; // no such loop
+		if (_GP(views)[chinf->view].loops[turnlooporder[ii]].numFrames < 1)
+			continue; // no frames in such loop
+		chinf->walking += TURNING_AROUND;
 	}
 
 }




More information about the Scummvm-git-logs mailing list