[Scummvm-git-logs] scummvm master -> 4185def5e7753450a58b0f40d960fd1ef3f68b27

aquadran noreply at scummvm.org
Sat Sep 13 14:13:46 UTC 2025


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

Summary:
4185def5e7 WINTERMUTE: Use ABS/MAX where applicable


Commit: 4185def5e7753450a58b0f40d960fd1ef3f68b27
    https://github.com/scummvm/scummvm/commit/4185def5e7753450a58b0f40d960fd1ef3f68b27
Author: Paweł Kołodziejski (aquadran at gmail.com)
Date: 2025-09-13T16:13:41+02:00

Commit Message:
WINTERMUTE: Use ABS/MAX where applicable

Changed paths:
    engines/wintermute/ad/ad_actor.cpp
    engines/wintermute/ad/ad_scene.cpp
    engines/wintermute/base/base_game.cpp
    engines/wintermute/base/scriptables/script_ext_file.cpp
    engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp


diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp
index bab01072d07..fe9ad476641 100644
--- a/engines/wintermute/ad/ad_actor.cpp
+++ b/engines/wintermute/ad/ad_actor.cpp
@@ -488,11 +488,11 @@ void AdActor::turnTo(TDirection dir) {
 	delta2 = dir + NUM_DIRECTIONS - _dir;
 	delta3 = dir - NUM_DIRECTIONS - _dir;
 
-	delta1 = (abs(delta1) <= abs(delta2)) ? delta1 : delta2;
-	delta = (abs(delta1) <= abs(delta3)) ? delta1 : delta3;
+	delta1 = (ABS(delta1) <= ABS(delta2)) ? delta1 : delta2;
+	delta = (ABS(delta1) <= ABS(delta3)) ? delta1 : delta3;
 
 	// already there?
-	if (abs(delta) < 2) {
+	if (ABS(delta) < 2) {
 		_dir = dir;
 		_targetDir = dir;
 		_state = _nextState;
@@ -906,8 +906,8 @@ void AdActor::getNextStep() {
 
 
 	int maxStepX, maxStepY;
-	maxStepX = abs(_currentSprite->_moveX);
-	maxStepY = abs(_currentSprite->_moveY);
+	maxStepX = ABS(_currentSprite->_moveX);
+	maxStepY = ABS(_currentSprite->_moveY);
 
 	maxStepX = MAX(maxStepX, maxStepY);
 	maxStepX = MAX(maxStepX, 1);
@@ -958,7 +958,7 @@ void AdActor::getNextStep() {
 
 //////////////////////////////////////////////////////////////////////////
 void AdActor::initLine(const BasePoint &startPt, const BasePoint &endPt) {
-	_pFCount = MAX((abs(endPt.x - startPt.x)), (abs(endPt.y - startPt.y)));
+	_pFCount = MAX((ABS(endPt.x - startPt.x)), (ABS(endPt.y - startPt.y)));
 
 	_pFStepX = (double)(endPt.x - startPt.x) / _pFCount;
 	_pFStepY = (double)(endPt.y - startPt.y) / _pFCount;
diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp
index a16d8e679c3..2ce47f8d639 100644
--- a/engines/wintermute/ad/ad_scene.cpp
+++ b/engines/wintermute/ad/ad_scene.cpp
@@ -254,7 +254,7 @@ bool AdScene::getPath(BasePoint source, BasePoint target, AdPath *path, BaseObje
 			for (int xxx = startX - tolerance; xxx <= startX + tolerance; xxx++) {
 				for (int yyy = startY - tolerance; yyy <= startY + tolerance; yyy++) {
 					if (isWalkableAt(xxx, yyy, true, requester)) {
-						int distance = abs(xxx - source.x) + abs(yyy - source.y);
+						int distance = ABS(xxx - source.x) + ABS(yyy - source.y);
 						if (distance < bestDistance) {
 							startX = xxx;
 							startY = yyy;
@@ -468,8 +468,8 @@ int AdScene::getPointsDist(BasePoint p1, BasePoint p2, BaseObject *requester) {
 	x2 = p2.x;
 	y2 = p2.y;
 
-	xLength = abs(x2 - x1);
-	yLength = abs(y2 - y1);
+	xLength = ABS(x2 - x1);
+	yLength = ABS(y2 - y1);
 
 	if (xLength > yLength) {
 		if (x1 > x2) {
@@ -1573,10 +1573,10 @@ void AdScene::scrollTo(int offsetX, int offsetY) {
 
 
 	if (_game->_mainObject && _game->_mainObject->_is3D) {
-		if (abs(origOffsetLeft - _targetOffsetLeft) < 5) {
+		if (ABS(origOffsetLeft - _targetOffsetLeft) < 5) {
 			_targetOffsetLeft = origOffsetLeft;
 		}
-		if (abs(origOffsetTop - _targetOffsetTop) < 5) {
+		if (ABS(origOffsetTop - _targetOffsetTop) < 5) {
 			_targetOffsetTop = origOffsetTop;
 		}
 		//_targetOffsetTop = 0;
@@ -3131,8 +3131,8 @@ bool AdScene::correctTargetPoint2(int32 startX, int32 startY, int32 *targetX, in
 	x2 = startX;
 	y2 = startY;
 
-	xLength = abs(x2 - x1);
-	yLength = abs(y2 - y1);
+	xLength = ABS(x2 - x1);
+	yLength = ABS(y2 - y1);
 
 	if (xLength > yLength) {
 
@@ -3221,7 +3221,7 @@ bool AdScene::correctTargetPoint(int32 startX, int32 startY, int32 *argX, int32
 	int offsetX = INT_MAX_VALUE, offsetY = INT_MAX_VALUE;
 
 	if (foundLeft && foundRight) {
-		if (abs(lengthLeft) < abs(lengthRight)) {
+		if (ABS(lengthLeft) < ABS(lengthRight)) {
 			offsetX = lengthLeft;
 		} else {
 			offsetX = lengthRight;
@@ -3233,7 +3233,7 @@ bool AdScene::correctTargetPoint(int32 startX, int32 startY, int32 *argX, int32
 	}
 
 	if (foundUp && foundDown) {
-		if (abs(lengthUp) < abs(lengthDown)) {
+		if (ABS(lengthUp) < ABS(lengthDown)) {
 			offsetY = lengthUp;
 		} else {
 			offsetY = lengthDown;
@@ -3244,7 +3244,7 @@ bool AdScene::correctTargetPoint(int32 startX, int32 startY, int32 *argX, int32
 		offsetY = lengthDown;
 	}
 
-	if (abs(offsetX) < abs(offsetY)) {
+	if (ABS(offsetX) < ABS(offsetY)) {
 		*argX = *argX + offsetX;
 	} else {
 		*argY = *argY + offsetY;
diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp
index 298e93bd0c0..8068a7f216c 100644
--- a/engines/wintermute/base/base_game.cpp
+++ b/engines/wintermute/base/base_game.cpp
@@ -5716,8 +5716,8 @@ bool BaseGame::isDoubleClick(int32 buttonIndex) {
 	Common::Point32 pos;
 	BasePlatform::getCursorPos(&pos);
 
-	int moveX = abs(pos.x - _lastClick[buttonIndex].posX);
-	int moveY = abs(pos.y - _lastClick[buttonIndex].posY);
+	int moveX = ABS(pos.x - _lastClick[buttonIndex].posX);
+	int moveY = ABS(pos.y - _lastClick[buttonIndex].posY);
 
 
 	if (_lastClick[buttonIndex].time == 0 || g_system->getMillis() - _lastClick[buttonIndex].time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) {
diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp
index c80bf59724c..1a3e729bdcf 100644
--- a/engines/wintermute/base/scriptables/script_ext_file.cpp
+++ b/engines/wintermute/base/scriptables/script_ext_file.cpp
@@ -699,7 +699,7 @@ bool SXFile::scSetProperty(const char *name, ScValue *value) {
 	//////////////////////////////////////////////////////////////////////////
 	if (strcmp(name, "Length")==0) {
 	    int origLength = _length;
-	    _length = max(value->getInt(0), 0);
+	    _length = MAX(value->getInt(0), 0);
 
 	    char propName[20];
 	    if (_length < OrigLength) {
diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp
index 6e8a1bc0f39..36bd31ef384 100644
--- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp
+++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp
@@ -478,7 +478,7 @@ bool SXMemBuffer::scSetProperty(const char *name, ScValue *value) {
 	//////////////////////////////////////////////////////////////////////////
 	if (strcmp(name, "Length")==0) {
 	    int origLength = _length;
-	    _length = max(value->getInt(0), 0);
+	    _length = MAX(value->getInt(0), 0);
 
 	    char propName[20];
 	    if (_length < origLength) {




More information about the Scummvm-git-logs mailing list