[Scummvm-git-logs] scummvm master -> 15d7f29f5a9bb4f2e375fce35867337a4fff7069

Strangerke noreply at scummvm.org
Wed Jan 15 08:04:31 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:
15d7f29f5a GOT: Fix 2 PVS-Studio issues (V1037) in move_patterns, refactor movement_forty (fixes a PVS-Studio V1048)


Commit: 15d7f29f5a9bb4f2e375fce35867337a4fff7069
    https://github.com/scummvm/scummvm/commit/15d7f29f5a9bb4f2e375fce35867337a4fff7069
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-15T09:04:24+01:00

Commit Message:
GOT: Fix 2 PVS-Studio issues (V1037) in move_patterns, refactor movement_forty (fixes a PVS-Studio V1048)

Changed paths:
    engines/got/game/move_patterns.cpp


diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index 77626bc3dd7..ef1081340b8 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -1444,52 +1444,47 @@ int movement_nine(ACTOR *actr) {
 
 // Vert straight (random length) change
 int movement_ten(ACTOR *actr) {
-	int d = actr->last_dir;
+	int lastDir = actr->last_dir;
 	int x1 = actr->x;
 	int y1 = actr->y;
 
-	int f = 0;
+	bool setRandomDirFl = false;
 	if (actr->counter) {
 		if (actr->pass_value != 1)
 			actr->counter--;
-		switch (d) {
+		switch (lastDir) {
 		case 0:
-			y1 -= 2;
-			if (!check_move2(x1, y1, actr))
-				f = 1;
-			break;
-		case 1:
-			y1 += 2;
-			if (!check_move2(x1, y1, actr))
-				f = 1;
-			break;
 		case 2:
 			y1 -= 2;
 			if (!check_move2(x1, y1, actr))
-				f = 1;
+				setRandomDirFl = true;
 			break;
+		case 1:
 		case 3:
 			y1 += 2;
 			if (!check_move2(x1, y1, actr))
-				f = 1;
+				setRandomDirFl = true;
+			break;
+
+		default:
 			break;
 		}
 	} else
-		f = 1;
+		setRandomDirFl = true;
 
-	if (f == 1) {
+	if (setRandomDirFl) {
 		actr->counter = g_events->getRandomNumber(10, 99);
-		d = g_events->getRandomNumber(1);
+		lastDir = g_events->getRandomNumber(1);
 	}
 
-	if (d > 1)
-		d -= 2;
+	if (lastDir > 1)
+		lastDir -= 2;
 
 	next_frame(actr);
-	actr->last_dir = d;
+	actr->last_dir = lastDir;
 	if (actr->directions == 1)
 		return 0;
-	return d;
+	return lastDir;
 }
 
 // Horz only (bats)
@@ -2102,7 +2097,6 @@ void set_thor_vars() {
 	_G(thor_y1) = _G(thor)->y + 8;
 
 	_G(thor_real_y1) = _G(thor)->y;
-
 	_G(thor_x2) = (_G(thor)->x + 12);
 	_G(thor_y2) = _G(thor)->y + 15;
 }
@@ -2476,8 +2470,7 @@ int movement_forty(ACTOR *actr) {
 		thor_damaged(actr);
 	}
 	int a = 5 + (actr->pass_value * 4);
-	int x1 = actr->x;
-	int x2 = _G(actor[a + 1]).x;
+	const int x1 = actr->x;
 	int d = actr->last_dir;
 
 	int f = 1;
@@ -2488,24 +2481,14 @@ int movement_forty(ACTOR *actr) {
 			_G(actor[a - 2]).x -= 2;
 			_G(actor[a + 1]).x -= 2;
 		} else
-			f = 0;
-		if (!f)
 			d = 3;
-	} else {
-		if (bgtile(_G(actor[a + 1]).x + 14, _G(actor[a + 1]).y) >= TILE_SOLID) {
-			_G(actor[a]).x += 2;
-			_G(actor[a - 1]).x += 2;
-			_G(actor[a - 2]).x += 2;
-			_G(actor[a + 1]).x += 2;
-		} else
-			f = 0;
-		if (!f)
-			d = 2;
-	}
-	if (!f) {
-		actr->x = x1;
-		_G(actor[a + 1]).x = x2;
-	}
+	} else if (bgtile(_G(actor[a + 1]).x + 14, _G(actor[a + 1]).y) >= TILE_SOLID) {
+		_G(actor[a]).x += 2;
+		_G(actor[a - 1]).x += 2;
+		_G(actor[a - 2]).x += 2;
+		_G(actor[a + 1]).x += 2;
+	} else
+		d = 2;
 
 	if (actr->next == 3 && !actr->num_shots && actr->frame_count == actr->frame_speed) {
 		actor_always_shoots(actr, 1);




More information about the Scummvm-git-logs mailing list