[Scummvm-git-logs] scummvm master -> 5b8fd81f72641f05e53acf2013455b9d596183bc

Strangerke noreply at scummvm.org
Mon Mar 21 22:17:22 UTC 2022


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:
5b8fd81f72 CHEWY: Add a parameter to get_mov_vector to avoid depending on out of bond accesses


Commit: 5b8fd81f72641f05e53acf2013455b9d596183bc
    https://github.com/scummvm/scummvm/commit/5b8fd81f72641f05e53acf2013455b9d596183bc
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2022-03-21T23:16:40+01:00

Commit Message:
CHEWY: Add a parameter to get_mov_vector to avoid depending on out of bond accesses

Changed paths:
    engines/chewy/main.cpp
    engines/chewy/movclass.cpp
    engines/chewy/movclass.h
    engines/chewy/sprite.cpp


diff --git a/engines/chewy/main.cpp b/engines/chewy/main.cpp
index 677108f09fa..768d27f5d3e 100644
--- a/engines/chewy/main.cpp
+++ b/engines/chewy/main.cpp
@@ -556,7 +556,7 @@ void setupScreen(SetupScreenMode mode) {
 						_G(spieler_mi)[P_CHEWY].XyzStart[1] = _G(spieler_vector)[P_CHEWY].Xypos[1];
 						_G(spieler_mi)[P_CHEWY].XyzEnd[0] = _G(gpkt).Dx - _G(spieler_mi)[P_CHEWY].HotX;
 						_G(spieler_mi)[P_CHEWY].XyzEnd[1] = _G(gpkt).Dy - _G(spieler_mi)[P_CHEWY].HotY;
-						_G(mov)->get_mov_vector((int16 *)_G(spieler_mi)[P_CHEWY].XyzStart, _G(spieler_mi)[P_CHEWY].Vorschub, &_G(spieler_vector)[P_CHEWY]);
+						_G(mov)->get_mov_vector((int16 *)_G(spieler_mi)[P_CHEWY].XyzStart, (int16 *)_G(spieler_mi)[P_CHEWY].XyzEnd, _G(spieler_mi)[P_CHEWY].Vorschub, &_G(spieler_vector)[P_CHEWY]);
 						get_phase(&_G(spieler_vector)[P_CHEWY], &_G(spieler_mi)[P_CHEWY]);
 						_G(spieler_vector)[P_CHEWY]._delayCount = 0;
 						_G(auto_p_nr) = P_CHEWY;
@@ -1202,7 +1202,7 @@ bool autoMove(int16 movNr, int16 playerNum) {
 			_G(spieler_mi)[playerNum].XyzStart[1] = _G(spieler_vector)[playerNum].Xypos[1];
 			_G(spieler_mi)[playerNum].XyzEnd[0] = _G(gpkt).Dx - _G(spieler_mi)[playerNum].HotX;
 			_G(spieler_mi)[playerNum].XyzEnd[1] = _G(gpkt).Dy - _G(spieler_mi)[playerNum].HotY;
-			_G(mov)->get_mov_vector((int16 *)_G(spieler_mi)[playerNum].XyzStart,
+			_G(mov)->get_mov_vector((int16 *)_G(spieler_mi)[playerNum].XyzStart, (int16 *)_G(spieler_mi)[playerNum].XyzEnd,
 				_G(spieler_mi)[playerNum].Vorschub, &_G(spieler_vector)[playerNum]);
 			get_phase(&_G(spieler_vector)[playerNum], &_G(spieler_mi)[playerNum]);
 			_G(spieler_vector)[playerNum]._delayCount = 0;
@@ -1227,7 +1227,7 @@ bool autoMove(int16 movNr, int16 playerNum) {
 				_G(spieler_mi)[playerNum].XyzStart[1] = _G(spieler_vector)[playerNum].Xypos[1];
 				_G(spieler_mi)[playerNum].XyzEnd[0] = _G(gpkt).Dx - _G(spieler_mi)[playerNum].HotX;
 				_G(spieler_mi)[playerNum].XyzEnd[1] = _G(gpkt).Dy - _G(spieler_mi)[playerNum].HotY;
-				_G(mov)->get_mov_vector((int16 *)_G(spieler_mi)[playerNum].XyzStart, _G(spieler_mi)[playerNum].Vorschub, &_G(spieler_vector)[playerNum]);
+				_G(mov)->get_mov_vector((int16 *)_G(spieler_mi)[playerNum].XyzStart, (int16 *)_G(spieler_mi)[playerNum].XyzEnd, _G(spieler_mi)[playerNum].Vorschub, &_G(spieler_vector)[playerNum]);
 				get_phase(&_G(spieler_vector)[playerNum], &_G(spieler_mi)[playerNum]);
 				while (!endLoopFl) {
 					if (_G(in)->getSwitchCode() == Common::KEYCODE_ESCAPE || key == Common::KEYCODE_ESCAPE) {
@@ -1270,7 +1270,7 @@ void goAutoXy(int16 x, int16 y, int16 personNum, int16 mode) {
 		_G(spieler_mi)[personNum].XyzStart[1] = _G(spieler_vector)[personNum].Xypos[1];
 		_G(spieler_mi)[personNum].XyzEnd[0] = x;
 		_G(spieler_mi)[personNum].XyzEnd[1] = y;
-		_G(mov)->get_mov_vector((int16 *)_G(spieler_mi)[personNum].XyzStart,
+		_G(mov)->get_mov_vector((int16 *)_G(spieler_mi)[personNum].XyzStart, (int16 *)_G(spieler_mi)[personNum].XyzEnd,
 			_G(spieler_mi)[personNum].Vorschub, &_G(spieler_vector)[personNum]);
 
 		if (_G(spieler_vector)[personNum].Count)
@@ -1881,7 +1881,7 @@ void calc_auto_go() {
 		_G(spieler_mi)[_G(auto_p_nr)].XyzStart[1] = _G(spieler_vector)[_G(auto_p_nr)].Xypos[1];
 		_G(spieler_mi)[_G(auto_p_nr)].XyzEnd[0] -= x_offset;
 		_G(spieler_mi)[_G(auto_p_nr)].XyzEnd[1] -= y_offset;
-		_G(mov)->get_mov_vector((int16 *)_G(spieler_mi)[_G(auto_p_nr)].XyzStart, _G(spieler_mi)[_G(auto_p_nr)].Vorschub, &_G(spieler_vector)[_G(auto_p_nr)])
+		_G(mov)->get_mov_vector((int16 *)_G(spieler_mi)[_G(auto_p_nr)].XyzStart, (int16 *)_G(spieler_mi)[_G(auto_p_nr)].XyzEnd, _G(spieler_mi)[_G(auto_p_nr)].Vorschub, &_G(spieler_vector)[_G(auto_p_nr)])
 		;
 		get_phase(&_G(spieler_vector)[_G(auto_p_nr)], &_G(spieler_mi)[_G(auto_p_nr)]);
 	}
diff --git a/engines/chewy/movclass.cpp b/engines/chewy/movclass.cpp
index cb7b8899e3f..01f68110316 100644
--- a/engines/chewy/movclass.cpp
+++ b/engines/chewy/movclass.cpp
@@ -287,7 +287,7 @@ short MovClass::calc_go(int16 src_feld, int16 *dst_feld) {
 	get_feld_xy(*dst_feld, &mi.XyzEnd[0], &mi.XyzEnd[1]);
 	mi.XyzStart[0] = om.Xypos[0];
 	mi.XyzStart[1] = om.Xypos[1];
-	get_mov_vector(mi.XyzStart, mi.Vorschub, &om);
+	get_mov_vector(mi.XyzStart, mi.XyzEnd, mi.Vorschub, &om);
 	bool endFl = false;
 	int16 mov_ok = 0;
 	int16 steps = 0;
@@ -369,7 +369,7 @@ short MovClass::calc_go(int16 src_feld, int16 *dst_feld) {
 					new_vector = false;
 					mi.XyzStart[0] = om.Xypos[0];
 					mi.XyzStart[1] = om.Xypos[1];
-					get_mov_vector(mi.XyzStart, mi.Vorschub, &om);
+					get_mov_vector(mi.XyzStart, mi.XyzEnd, mi.Vorschub, &om);
 				}
 				if (om.Count == 0) {
 
@@ -386,7 +386,7 @@ short MovClass::calc_go(int16 src_feld, int16 *dst_feld) {
 				om.Xypos[2] += tmpz;
 				mi.XyzStart[0] = om.Xypos[0];
 				mi.XyzStart[1] = om.Xypos[1];
-				get_mov_vector(mi.XyzStart, mi.Vorschub, &om);
+				get_mov_vector(mi.XyzStart, mi.XyzEnd, mi.Vorschub, &om);
 				if (mov_ok == MOV_X) {
 					if (om.Xyvo[0] != 0)
 						new_vector = true;
@@ -661,14 +661,14 @@ void MovClass::get_feld_xy(int16 fnr, int16 *x, int16 *y) {
 	*y <<= 3;
 }
 
-void MovClass::get_mov_vector(int16 *xyz, int16 vorschub, ObjMov *om) {
+void MovClass::get_mov_vector(int16 *startXyz, int16 *endXyz, int16 vorschub, ObjMov *om) {
 	if (vorschub > 0) {
-		int16 x = xyz[0];
-		int16 y = xyz[1];
-		int16 z = xyz[2];
-		int16 x1 = xyz[3];
-		int16 y1 = xyz[4];
-		int16 z1 = xyz[5];
+		int16 x = startXyz[0];
+		int16 y = startXyz[1];
+		int16 z = startXyz[2];
+		int16 x1 = endXyz[0];
+		int16 y1 = endXyz[1];
+		int16 z1 = endXyz[2];
 		om->Xypos[0] = x;
 		om->Xypos[1] = y;
 		om->Xypos[2] = z;
@@ -746,17 +746,17 @@ void MovClass::get_mov_vector(int16 *xyz, int16 vorschub, ObjMov *om) {
 		om->Xyna[2][1] = tmp - (om->Xyvo[2] * 1000);
 		om->Xyna[2][0] = 0;
 		if (!om->Count) {
-			xyz[0] = xyz[3];
-			xyz[1] = xyz[4];
-			om->Xypos[0] = xyz[3];
-			om->Xypos[1] = xyz[4];
+			startXyz[0] = endXyz[0];
+			startXyz[1] = endXyz[1];
+			om->Xypos[0] = endXyz[0];
+			om->Xypos[1] = endXyz[1];
 		}
 	} else {
 		om->Count = 0;
 
-		om->Xypos[0] = xyz[0];
-		om->Xypos[1] = xyz[1];
-		om->Xypos[2] = xyz[2];
+		om->Xypos[0] = startXyz[0];
+		om->Xypos[1] = startXyz[1];
+		om->Xypos[2] = startXyz[2];
 		om->Xyvo[0] = 0;
 		om->Xyvo[1] = 0;
 		om->Xyvo[2] = 0;
diff --git a/engines/chewy/movclass.h b/engines/chewy/movclass.h
index 43e34ea273b..588bec5ce64 100644
--- a/engines/chewy/movclass.h
+++ b/engines/chewy/movclass.h
@@ -116,7 +116,7 @@ public:
 	void stop_auto_go();
 	void continue_auto_go();
 	bool auto_go_status();
-	void get_mov_vector(int16 *xyz, int16 vorschub, ObjMov *om);
+	void get_mov_vector(int16 *startXyz, int16 *endXyz, int16 vorschub, ObjMov *om);
 
 private:
 	void calc_xy();
diff --git a/engines/chewy/sprite.cpp b/engines/chewy/sprite.cpp
index 4305215e72e..6d1a0c17475 100644
--- a/engines/chewy/sprite.cpp
+++ b/engines/chewy/sprite.cpp
@@ -664,7 +664,7 @@ void new_auto_line(int16 nr) {
 				_G(auto_mov_obj)[nr].XyzEnd[0] = _G(mov_line)[nr][_G(auto_mov_vector)[nr].StNr - 1].EndXyz[0];
 				_G(auto_mov_obj)[nr].XyzEnd[1] = _G(mov_line)[nr][_G(auto_mov_vector)[nr].StNr - 1].EndXyz[1];
 				_G(auto_mov_obj)[nr].XyzEnd[2] = _G(mov_line)[nr][_G(auto_mov_vector)[nr].StNr - 1].EndXyz[2];
-				_G(mov)->get_mov_vector((int16 *)_G(auto_mov_obj)[nr].XyzStart,
+				_G(mov)->get_mov_vector((int16 *)_G(auto_mov_obj)[nr].XyzStart, (int16 *)_G(auto_mov_obj)[nr].XyzEnd, 
 				                     _G(auto_mov_obj)[nr].Vorschub, &_G(auto_mov_vector)[nr]);
 			}
 		} else {
@@ -814,7 +814,7 @@ void mov_objekt(ObjMov *om, MovInfo *mi) {
 								om->Xypos[2] += tmpz;
 								mi->XyzStart[0] = om->Xypos[0];
 								mi->XyzStart[1] = om->Xypos[1];
-								_G(mov)->get_mov_vector(mi->XyzStart, mi->Vorschub, om);
+								_G(mov)->get_mov_vector(mi->XyzStart, mi->XyzEnd, mi->Vorschub, om);
 								if (om->Xyvo[1] != 0) {
 									_G(new_vector) = true;
 									swap_if_l(&om->Xyvo[1], &om->Xyvo[0]);
@@ -851,7 +851,7 @@ void mov_objekt(ObjMov *om, MovInfo *mi) {
 							om->Xypos[2] += tmpz;
 							mi->XyzStart[0] = om->Xypos[0];
 							mi->XyzStart[1] = om->Xypos[1];
-							_G(mov)->get_mov_vector(mi->XyzStart, mi->Vorschub, om);
+							_G(mov)->get_mov_vector(mi->XyzStart, mi->XyzEnd, mi->Vorschub, om);
 							if (om->Xyvo[0] != 0) {
 								_G(new_vector) = true;
 								swap_if_l(&om->Xyvo[0], &om->Xyvo[1]);
@@ -876,7 +876,7 @@ void mov_objekt(ObjMov *om, MovInfo *mi) {
 						_G(new_vector) = false;
 						mi->XyzStart[0] = om->Xypos[0];
 						mi->XyzStart[1] = om->Xypos[1];
-						_G(mov)->get_mov_vector(mi->XyzStart, mi->Vorschub, om);
+						_G(mov)->get_mov_vector(mi->XyzStart, mi->XyzEnd, mi->Vorschub, om);
 					}
 					if (om->Count == 0 && !_G(flags).NoEndPosMovObj) {
 						mi->XyzStart[0] = mi->XyzEnd[0];
@@ -1036,7 +1036,7 @@ void zoom_mov_anpass(ObjMov *om, MovInfo *mi) {
 				mi->Vorschub = 2;
 		}
 		if (tmp_vorschub != mi->Vorschub && om->Count) {
-			_G(mov)->get_mov_vector((int16 *)mi->XyzStart, mi->Vorschub, om);
+			_G(mov)->get_mov_vector((int16 *)mi->XyzStart, (int16 *)mi->XyzEnd, mi->Vorschub, om);
 			get_phase(om, mi);
 		}
 	}




More information about the Scummvm-git-logs mailing list