[Scummvm-git-logs] scummvm master -> 98be5c5489640de849a7cda754edc54af59a5576

Strangerke noreply at scummvm.org
Mon Jan 13 23:13:25 UTC 2025


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:
98be5c5489 GOT: Fix Cppcheck issue - Unsigned checked against negative values


Commit: 98be5c5489640de849a7cda754edc54af59a5576
    https://github.com/scummvm/scummvm/commit/98be5c5489640de849a7cda754edc54af59a5576
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-14T00:13:19+01:00

Commit Message:
GOT: Fix Cppcheck issue - Unsigned checked against negative values

Changed paths:
    engines/got/game/boss3.cpp
    engines/got/game/move.cpp


diff --git a/engines/got/game/boss3.cpp b/engines/got/game/boss3.cpp
index 20d4d43062f..a6c2cd7bf10 100644
--- a/engines/got/game/boss3.cpp
+++ b/engines/got/game/boss3.cpp
@@ -72,7 +72,8 @@ static void set_boss(ACTOR *actr) {
 // Boss - Loki-2
 static int boss_movement_one(ACTOR *actr) {
 	int rx, ry, i, numPods = 0;
-
+	int fcount;
+	
 	actr->num_moves = 2;
 	pod_speed = 2;
 
@@ -104,15 +105,17 @@ static int boss_movement_one(ACTOR *actr) {
 	}
 	if (actr->i6) {
 		// Fade out
-		actr->frame_count--;
-		if (actr->frame_count <= 0) {
+		fcount = actr->frame_count - 1;
+		if (fcount <= 0) {
 			actr->next++;
 			if (actr->next > 2) {
 				actr->i6 = 0;
 				actr->temp3 = 160;
 			}
 			actr->frame_count = 3;
-		}
+		} else
+			actr->frame_count = fcount;
+		
 		goto done1;
 	}
 	if (actr->temp3 > 1) {
@@ -144,8 +147,8 @@ static int boss_movement_one(ACTOR *actr) {
 
 	if (actr->temp4) {
 		// Fade in
-		actr->frame_count--;
-		if (actr->frame_count <= 0) {
+		fcount = actr->frame_count - 1;
+		if (fcount <= 0) {
 			actr->next--;
 			if (actr->next > 254) {
 				actr->next = 0;
@@ -159,7 +162,9 @@ static int boss_movement_one(ACTOR *actr) {
 			}
 
 			actr->frame_count = 3;
-		}
+		} else
+			actr->frame_count = fcount;
+		
 		goto done1;
 	}
 
@@ -192,13 +197,15 @@ static int boss_movement_one(ACTOR *actr) {
 	}
 
 done:
-	actr->frame_count--;
-	if (actr->frame_count <= 0) {
+	fcount = actr->frame_count - 1;
+	if (fcount <= 0) {
 		actr->next++;
 		if (actr->next > 2)
 			actr->next = 0;
 		actr->frame_count = LFC;
-	}
+	} else
+		actr->frame_count = fcount;
+	
 done1:
 	set_boss(actr);
 	return actr->dir;
diff --git a/engines/got/game/move.cpp b/engines/got/game/move.cpp
index 060ac8e58a7..aff6c6117fe 100644
--- a/engines/got/game/move.cpp
+++ b/engines/got/game/move.cpp
@@ -31,16 +31,17 @@
 namespace Got {
 
 void next_frame(ACTOR *actr) {
-	actr->frame_count--;
+	const int fcount = actr->frame_count - 1;
 
-	if (actr->frame_count <= 0) {
+	if (fcount <= 0) {
 		actr->next++;
 
 		if (actr->next > 3)
 			actr->next = 0;
 
 		actr->frame_count = actr->frame_speed;
-	}
+	} else
+		actr->frame_count = fcount;
 }
 
 bool point_within(int x, int y, int x1, int y1, int x2, int y2) {
@@ -339,8 +340,8 @@ void move_actor(ACTOR *actr) {
 		}
 	}
 
-	actr->speed_count--;
-	if (actr->speed_count <= 0) {
+	const int scount = actr->speed_count -1;
+	if (scount <= 0) {
 		if (!actr->move_counter)
 			actr->speed_count = actr->speed;
 		else
@@ -369,7 +370,8 @@ void move_actor(ACTOR *actr) {
 			_G(actor[2]).last_y[0] = _G(actor[2]).y;
 			_G(actor[2]).last_y[1] = _G(actor[2]).y;
 		}
-	}
+	} else
+		actr->speed_count = scount;
 
 	actr->x &= 0xfffe;
 }




More information about the Scummvm-git-logs mailing list