From fd55e0f71a7af92271a7e078c057295780cd9683 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 4 Jul 2021 11:18:23 -0700 Subject: [PATCH] SAGA2: Change abs to ABS --- engines/saga2/actor.cpp | 4 ++-- engines/saga2/audio.cpp | 4 ++-- engines/saga2/button.cpp | 4 ++-- engines/saga2/calender.cpp | 4 ++-- engines/saga2/dice.h | 4 ++-- engines/saga2/dispnode.cpp | 4 ++-- engines/saga2/gamerate.h | 4 ++-- engines/saga2/gtextbox.cpp | 8 ++++---- engines/saga2/motion.cpp | 12 ++++++------ engines/saga2/objects.cpp | 6 +++--- engines/saga2/objproto.cpp | 2 +- engines/saga2/panel.cpp | 2 +- engines/saga2/path.cpp | 28 ++++++++++++++-------------- engines/saga2/sagafunc.cpp | 8 ++++---- engines/saga2/speech.cpp | 4 ++-- engines/saga2/task.cpp | 16 ++++++++-------- engines/saga2/tcoords.h | 8 ++++---- engines/saga2/tile.cpp | 36 ++++++++++++++++++------------------ 18 files changed, 79 insertions(+), 79 deletions(-) diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp index 7807db13528..74867adba20 100644 --- a/engines/saga2/actor.cpp +++ b/engines/saga2/actor.cpp @@ -395,7 +395,7 @@ bool ActorProto::acceptDamageAction( damage = absDamage; if (dice) - for (int d = 0; d < abs(dice); d++) + for (int d = 0; d < ABS(dice); d++) damage += ((rand() % sides) + pdm + 1) * (dice > 0 ? 1 : -1); } @@ -3318,7 +3318,7 @@ int16 GetRandomBetween(int start, int end) { // Here's a more efficient way to express this. if (start == end) return start; - else return (rand() % abs(end - start)) + start; + else return (rand() % ABS(end - start)) + start; } diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp index d65a5804ea5..8c906e78a7c 100644 --- a/engines/saga2/audio.cpp +++ b/engines/saga2/audio.cpp @@ -97,9 +97,9 @@ static ATTENUATOR(volumeFromDist) { TilePoint tp(loc.x, loc.y, 0); uint32 dist = tp.quickHDistance(); if (dist < fullVolumeDist) { - return abs(maxVol); + return ABS(maxVol); } else if (dist < offVolumeDist) { - return abs((int)(maxVol * ((int)((offVolumeDist - fullVolumeDist) - (dist - fullVolumeDist))) / (offVolumeDist - fullVolumeDist))); + return ABS((int)(maxVol * ((int)((offVolumeDist - fullVolumeDist) - (dist - fullVolumeDist))) / (offVolumeDist - fullVolumeDist))); } return 0; } diff --git a/engines/saga2/button.cpp b/engines/saga2/button.cpp index de65b488714..4fdeeb038af 100644 --- a/engines/saga2/button.cpp +++ b/engines/saga2/button.cpp @@ -862,9 +862,9 @@ int16 gSlider::getSliderLenVal(void) { if (slValMin < 0 && slValMax < 0) { val = slValMax - slValMin; } else if (slValMin < 0 && slValMax >= 0) { - val = abs(slValMin) + slValMax; + val = ABS(slValMin) + slValMax; } else if (slValMin >= 0 && slValMax < 0) { - val = abs(slValMax) - slValMin; + val = ABS(slValMax) - slValMin; } else if (slValMin >= 0 && slValMax >= 0) { val = slValMax - slValMin; } diff --git a/engines/saga2/calender.cpp b/engines/saga2/calender.cpp index 3111921ddaa..2ef086f60a7 100644 --- a/engines/saga2/calender.cpp +++ b/engines/saga2/calender.cpp @@ -109,13 +109,13 @@ int CalenderTime::lightLevel(int maxLevel) { // grows to 'framesAtNoon' at noon, then shrinks // back to 0 at midnight again. solarAngle = framesAtNoon - - abs(frameInDay() - framesAtNoon); + - ABS(frameInDay() - framesAtNoon); // Just for fun, we'll make the days longer in the summer, // and shorter the winter. The calculation produces a number // which equals daysPerYear/4 in summer, and -daysperYear/4 // in winter. - season = daysPerYear / 4 - abs(dayInYear - daysPerYear / 2); + season = daysPerYear / 4 - ABS(dayInYear - daysPerYear / 2); // Convert season to an extra hour of daylight in summer, // and an extra hour of night in winter. (That's an extra diff --git a/engines/saga2/dice.h b/engines/saga2/dice.h index ef02222465a..eb18ae03d9b 100644 --- a/engines/saga2/dice.h +++ b/engines/saga2/dice.h @@ -30,13 +30,13 @@ namespace Saga2 { inline int32 RANDOM(int32 minV, int32 maxV) { - return (maxV - minV + 1) ? g_vm->_rnd->getRandomNumber(abs(maxV - minV)) + minV : 0; + return (maxV - minV + 1) ? g_vm->_rnd->getRandomNumber(ABS(maxV - minV)) + minV : 0; } inline int32 diceRoll(int dice, int sides, int perDieMod, int base) { int32 rv = base; if (dice) - for (int i = 0; i < abs(dice); i++) + for (int i = 0; i < ABS(dice); i++) rv += (RANDOM(1, sides) + perDieMod * (dice > 0 ? 1 : -1)); return rv; } diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp index b70380b2e0d..5d5b4d018d9 100644 --- a/engines/saga2/dispnode.cpp +++ b/engines/saga2/dispnode.cpp @@ -206,8 +206,8 @@ void DisplayNodeList::buildObjects(bool fromScratch) { int16 dist; // Compute distance from object to screen center. - dist = abs(viewCenter.u - objLoc.u) - + abs(viewCenter.v - objLoc.v); + dist = ABS(viewCenter.u - objLoc.u) + + ABS(viewCenter.v - objLoc.v); // Determine if the object is beyond the screen threshold if ((dist >= loadDist diff --git a/engines/saga2/gamerate.h b/engines/saga2/gamerate.h index aed8390302a..a8a033fd001 100644 --- a/engines/saga2/gamerate.h +++ b/engines/saga2/gamerate.h @@ -131,8 +131,8 @@ class frameSmoother: public frameCounter { // get variance totals for (uint i = 0; i < historySize; i++) { - dif1Sec[i / int(desiredFPS)] += abs(ksHistory(i) - avg1Sec[i / int(desiredFPS)]); - dif5Sec += abs(ksHistory(i) - avg5Sec); + dif1Sec[i / int(desiredFPS)] += ABS(ksHistory(i) - avg1Sec[i / int(desiredFPS)]); + dif5Sec += ABS(ksHistory(i) - avg5Sec); } // get average variances diff --git a/engines/saga2/gtextbox.cpp b/engines/saga2/gtextbox.cpp index 39bb62fe00c..75d578bd0a5 100644 --- a/engines/saga2/gtextbox.cpp +++ b/engines/saga2/gtextbox.cpp @@ -265,7 +265,7 @@ gTextBox::~gTextBox() { */ bool gTextBox::insertText(char *newText, int length) { int16 selStart = MIN(cursorPos, anchorPos), - selWidth = abs(cursorPos - anchorPos), + selWidth = ABS(cursorPos - anchorPos), selEnd = selStart + selWidth; if (length == -1) length = strlen(newText); @@ -429,7 +429,7 @@ void gTextBox::scroll(int8 req) { indexReq = clamp(0, indexReq, numEditLines); visIndex = (indexReq - (visBase - linesPerPage)); - if (abs(oldIndex - indexReq) < 2) { + if (ABS(oldIndex - indexReq) < 2) { if (visIndex < 0) { visBase--; visIndex++; @@ -640,7 +640,7 @@ void gTextBox::pointerRelease(gPanelMessage &msg) { bool gTextBox::keyStroke(gPanelMessage &msg) { gPort &port = window.windowPort; int16 selStart = MIN(cursorPos, anchorPos), - selWidth = abs(cursorPos - anchorPos); + selWidth = ABS(cursorPos - anchorPos); uint8 key = msg.key; // Process the various keystrokes... @@ -839,7 +839,7 @@ char *gTextBox::getLine(int8 stringIndex) { //----------------------------------------------------------------------- char *gTextBox::selectedText(int &length) { - length = abs(cursorPos - anchorPos); + length = ABS(cursorPos - anchorPos); return fieldStrings[index] + MIN(cursorPos, anchorPos); } diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp index 2ecb791818c..ae9359dd13a 100644 --- a/engines/saga2/motion.cpp +++ b/engines/saga2/motion.cpp @@ -274,7 +274,7 @@ bool unstickObject(GameObject *obj) { // Set new radius to maximum of abs of the 3 coords, minus 1 // (Because we want solution to converge faster) - newRadius = MAX(MAX(abs(dx), abs(dy)), abs(dz)) - 1; + newRadius = MAX(MAX(ABS(dx), ABS(dy)), ABS(dz)) - 1; if (newRadius < radius) { radius = newRadius; @@ -2178,7 +2178,7 @@ void MotionTask::ballisticAction(void) { // Make Up For Rounding Errors In ThrowTo if (uFrac) { - uErrorTerm += abs(uFrac); + uErrorTerm += ABS(uFrac); if (uErrorTerm >= steps) { uErrorTerm -= steps; @@ -2190,7 +2190,7 @@ void MotionTask::ballisticAction(void) { } if (vFrac) { - vErrorTerm += abs(vFrac); + vErrorTerm += ABS(vFrac); if (vErrorTerm >= steps) { vErrorTerm -= steps; @@ -2434,7 +2434,7 @@ bool MotionTask::nextWayPoint(void) { // use dumb pathfinding until the pathfinder finishes it's task. if ((finalTarget - object->_data.location).quickHDistance() > 0 - || abs(finalTarget.z - object->_data.location.z) > kMaxStepHeight) { + || ABS(finalTarget.z - object->_data.location.z) > kMaxStepHeight) { // If no pathfind in progress if ((flags & pathFind) && !(flags & finalPath) @@ -2585,7 +2585,7 @@ void MotionTask::walkAction(void) { // If we're not already there, then proceed towards // the target. - if (targetDist > 0 || abs(targetVector.z) > kMaxStepHeight) + if (targetDist > 0 || ABS(targetVector.z) > kMaxStepHeight) break; } @@ -2645,7 +2645,7 @@ void MotionTask::walkAction(void) { if (moveTaskDone || moveTaskWaiting) { movementDirection = a->currentFacing; - } else if (targetDist == 0 && abs(targetVector.z) > kMaxStepHeight) { + } else if (targetDist == 0 && ABS(targetVector.z) > kMaxStepHeight) { if (pathFindTask) { movementDirection = a->currentFacing; moveTaskWaiting = true; diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp index 68d7b15ebb0..7c26cfa0a94 100644 --- a/engines/saga2/objects.cpp +++ b/engines/saga2/objects.cpp @@ -1710,7 +1710,7 @@ bool GameObject::inRange(const TilePoint &tp, uint16 range) { TilePoint vector = tp - loc; return vector.quickHDistance() <= range - && abs(vector.z) <= range; + && ABS(vector.z) <= range; } //----------------------------------------------------------------------- @@ -3527,8 +3527,8 @@ ObjectID RingObjectIterator::next(GameObject **obj) { int16 DispRegionObjectIterator::computeDist(const TilePoint &tp) { // Compute distance from object to screen center. // REM: remember to add in Z there somewhere. - return abs(getCenter().u - tp.u) - + abs(getCenter().v - tp.v); + return ABS(getCenter().u - tp.u) + + ABS(getCenter().v - tp.v); } /* ======================================================================= * diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp index 14c118ad1fa..6f49a1c2a19 100644 --- a/engines/saga2/objproto.cpp +++ b/engines/saga2/objproto.cpp @@ -619,7 +619,7 @@ bool ProtoObj::acceptHealing( assert(dObj != Nothing); damage = absDamage; if (dice) - for (int d = 0; d < abs(dice); d++) + for (int d = 0; d < ABS(dice); d++) damage += (g_vm->_rnd->getRandomNumber(sides - 1) + pdm + 1) * (dice > 0 ? 1 : -1); return acceptHealingAction(dObj, enactor, damage); diff --git a/engines/saga2/panel.cpp b/engines/saga2/panel.cpp index 27b4a4576c3..22430f81381 100644 --- a/engines/saga2/panel.cpp +++ b/engines/saga2/panel.cpp @@ -930,7 +930,7 @@ void gToolBase::handleMouse(Common::Event &event, uint32 time) { || _curMouseState.right > 1) { Point16 diff = lastClickPos - _curMouseState.pos; - if (abs(diff.x) + abs(diff.y) < 6) + if (ABS(diff.x) + ABS(diff.y) < 6) msg.doubleClick = 1; } diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp index 214548ec1da..2201e392b67 100644 --- a/engines/saga2/path.cpp +++ b/engines/saga2/path.cpp @@ -1571,14 +1571,14 @@ big_break: // If the height difference is too great skip this tile // position - if (abs(quantizedCoords.z - startingCoords.z) > kMaxStepHeight) + if (ABS(quantizedCoords.z - startingCoords.z) > kMaxStepHeight) continue; // Compute initial cost based upon the distance from the // starting location offsetVector = quantizedCoords - startingCoords; dist = offsetVector.quickHDistance(); - zDist = abs(offsetVector.z); + zDist = ABS(offsetVector.z); cost = dist + zDist; // Push this point @@ -1625,7 +1625,7 @@ void PathRequest::finish(void) { if (cell->direction != dirInvalid) { if (cell->direction != prevDir - || abs(cell->height - prevHeight) > kMaxStepHeight) { + || ABS(cell->height - prevHeight) > kMaxStepHeight) { if (res <= tempResult) break; coords.u = @@ -1854,7 +1854,7 @@ PathResult PathRequest::findPath(void) { &testPlatform); // Determine if elevation change is too great - if (abs(testPt.z - prevZ) <= kMaxStepHeight) + if (ABS(testPt.z - prevZ) <= kMaxStepHeight) prevZ = testPt.z; else goto big_continue; @@ -2105,8 +2105,8 @@ bool DestinationPathRequest::setCenter( // Determine the target vector in order to calculate distance. targetDelta = (targetCoords - centerPt); dist = targetDelta.quickHDistance(); - zDist = abs(targetDelta.z); - platDiff = abs(centerPlatform - targetPlatform); + zDist = ABS(targetDelta.z); + platDiff = ABS(centerPlatform - targetPlatform); centerCost = dist + zDist * (platDiff + 1); // Determine if this location is closer than any location we have @@ -2179,8 +2179,8 @@ int16 DestinationPathRequest::evaluateMove( // order to calculate the distance. targetDelta = targetCoords - testPt; dist = targetDelta.quickHDistance(); - zDist = abs(targetDelta.z); - platDiff = abs(testPlatform - targetPlatform); + zDist = ABS(targetDelta.z); + platDiff = ABS(testPlatform - targetPlatform); return (dist + zDist * (platDiff + 1) - centerCost) >> 2; } @@ -2229,7 +2229,7 @@ bool WanderPathRequest::setCenter( // Determine the movement vector in order to calculate distance. movementDelta = (startingCoords - centerPt); dist = movementDelta.quickHDistance(); - zDist = abs(movementDelta.z); + zDist = ABS(movementDelta.z); centerCost = dist + zDist; // Determine if this location is farther than any location we have @@ -2276,7 +2276,7 @@ int16 WanderPathRequest::evaluateMove(const TilePoint &testPt, uint8) { // order to calculate the distance. movementDelta = startingCoords - testPt; dist = movementDelta.quickHDistance(); - zDist = abs(movementDelta.z) >> 1; + zDist = ABS(movementDelta.z) >> 1; return (centerCost - (dist + zDist)) >> 1; } @@ -2540,7 +2540,7 @@ TilePoint selectNearbySite( distFromCenter = quickDistance( Point32(qi.u - searchCenter, qi.v - searchCenter)); -// max( abs( qi.u - searchCenter ), abs( qi.v - searchCenter ) ); +// max( ABS( qi.u - searchCenter ), ABS( qi.v - searchCenter ) ); // Calculate the "goodness" of this cell -- is it in the // middle of the band between min and max? @@ -2781,14 +2781,14 @@ bool checkPath( // If the height difference is too great skip this tile // position - if (abs(quantizedCoords.z - startingCoords.z) > kMaxStepHeight) + if (ABS(quantizedCoords.z - startingCoords.z) > kMaxStepHeight) continue; // Compute initial cost based upon the distance from the // starting location offsetVector = quantizedCoords - startingCoords; dist = offsetVector.quickHDistance(); - zDist = abs(offsetVector.z); + zDist = ABS(offsetVector.z); cost = dist + zDist; // Push this point @@ -2908,7 +2908,7 @@ bool checkPath( // If the resulting height is significantly different // from the destination height, assume we're on a // different level and return false. - return abs(testPt.z - destCoords.z) <= kMaxStepHeight; + return ABS(testPt.z - destCoords.z) <= kMaxStepHeight; } diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp index de60e26670a..68eea60f19f 100644 --- a/engines/saga2/sagafunc.cpp +++ b/engines/saga2/sagafunc.cpp @@ -3619,15 +3619,15 @@ int16 scriptSwapRegions(int16 *args) { region1.min.u = args[1]; region1.min.v = args[2]; region1.min.z = -128; - region1.max.u = args[1] + abs(args[6]); - region1.max.v = args[2] + abs(args[7]); + region1.max.u = args[1] + ABS(args[6]); + region1.max.v = args[2] + ABS(args[7]); region1.max.z = 127; region2.min.u = args[4]; region2.min.v = args[5]; region2.min.z = -128; - region2.max.u = args[4] + abs(args[6]); - region2.max.v = args[5] + abs(args[7]); + region2.max.u = args[4] + ABS(args[6]); + region2.max.v = args[5] + ABS(args[7]); region2.max.z = 127; // Count how many objects are in each region diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp index 92e23323c49..267a7fecd7d 100644 --- a/engines/saga2/speech.cpp +++ b/engines/saga2/speech.cpp @@ -897,8 +897,8 @@ bool isVisible(GameObject *obj) { TileToScreenCoords(viewCenter, vp); - distanceX = abs(vp.x - p.x); - distanceY = abs(vp.y - p.y); + distanceX = ABS(vp.x - p.x); + distanceY = ABS(vp.y - p.y); if ((distanceY >= loadDistY) || (distanceX >= loadDistX)) diff --git a/engines/saga2/task.cpp b/engines/saga2/task.cpp index 3129df2937f..6523ff97d40 100644 --- a/engines/saga2/task.cpp +++ b/engines/saga2/task.cpp @@ -81,7 +81,7 @@ TilePoint computeRepulsionVector( repulsorDist; repulsorDist = repulsorVectorArray[i].quickHDistance() - + abs(repulsorVectorArray[i].z); + + ABS(repulsorVectorArray[i].z); repulsorWeight = repulsorDist != 0 ? 64 * 64 / (repulsorDist * repulsorDist) @@ -1347,7 +1347,7 @@ TaskResult GotoTask::update(void) { != (immediateDest.u >> kTileUVShift) || (motionTarget.v >> kTileUVShift) != (immediateDest.v >> kTileUVShift) - || abs(motionTarget.z - immediateDest.z) > 16 + || ABS(motionTarget.z - immediateDest.z) > 16 || runState != prevRunState) actorMotion->changeTarget( immediateDest, @@ -1478,7 +1478,7 @@ bool GotoLocationTask::run(void) { return runThreshold != maxuint8 ? (targetLoc - actorLoc).quickHDistance() > runThreshold - || abs(targetLoc.z - actorLoc.z) > runThreshold + || ABS(targetLoc.z - actorLoc.z) > runThreshold : false; } @@ -1677,7 +1677,7 @@ bool GotoObjectTargetTask::lineOfSight(void) { // sight if the target has moved beyond a certain range from // the last location it was tested at. if ((targetLoc - lastTestedLoc).quickHDistance() > 25 - || abs(targetLoc.z - lastTestedLoc.z) > 25) { + || ABS(targetLoc.z - lastTestedLoc.z) > 25) { if (a->canSenseSpecificObject( info, maxSenseRange, @@ -4014,11 +4014,11 @@ bool BandTask::targetHasChanged(GotoTask *gotoTarget) { int16 slop; slop = ((currentTarget - actorLoc).quickHDistance() - + abs(currentTarget.z - actorLoc.z)) + + ABS(currentTarget.z - actorLoc.z)) / 2; if ((currentTarget - oldTarget).quickHDistance() - + abs(currentTarget.z - oldTarget.z) + + ABS(currentTarget.z - oldTarget.z) > slop) gotoLocation->changeTarget(currentTarget); @@ -4043,7 +4043,7 @@ bool BandTask::atTarget(void) { TilePoint actorLoc = stack->getActor()->getLocation(); if ((actorLoc - currentTarget).quickHDistance() > 6 - || abs(actorLoc.z - currentTarget.z) > kMaxStepHeight) { + || ABS(actorLoc.z - currentTarget.z) > kMaxStepHeight) { if (attend != NULL) { attend->abortTask(); delete attend; @@ -4380,7 +4380,7 @@ TaskResult FollowPatrolRouteTask::handleFollowPatrolRoute(void) { == (currentWayPoint.u >> kTileUVShift) && (actorLoc.v >> kTileUVShift) == (currentWayPoint.v >> kTileUVShift) - && abs(actorLoc.z - currentWayPoint.z) <= kMaxStepHeight) { + && ABS(actorLoc.z - currentWayPoint.z) <= kMaxStepHeight) { // Delete the gotoWayPoint task if (gotoWayPoint != NULL) { gotoWayPoint->abortTask(); diff --git a/engines/saga2/tcoords.h b/engines/saga2/tcoords.h index d33892bc99b..668fea8a7ed 100644 --- a/engines/saga2/tcoords.h +++ b/engines/saga2/tcoords.h @@ -174,8 +174,8 @@ struct TilePoint { void operator-= (TilePoint a) { u -= a.u; v -= a.v; z -= a.z; } int16 quickHDistance(void) { - int16 au = (int16)abs(u), - av = (int16)abs(v); + int16 au = (int16)ABS(u), + av = (int16)ABS(v); if (au > av) return (int16)(au + (av >> 1)); @@ -264,8 +264,8 @@ public: void operator-= (TilePoint32 a) { u -= a.u; v -= a.v; z -= a.z; } int32 quickHDistance( void ) { - int32 au = abs( u ), - av = abs( v ); + int32 au = ABS( u ), + av = ABS( v ); if (au > av) return au + (av >> 1); else return av + (au >> 1); diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp index e13becc3ae1..e3e14a4cf84 100644 --- a/engines/saga2/tile.cpp +++ b/engines/saga2/tile.cpp @@ -3667,7 +3667,7 @@ SurfaceType pointOnTile(TileInfo *ti, // Compute the mask which represents the subtile sMask = calcSubTileMask(subTile.u, subTile.v); - yBound = abs(subTileRel.x >> 1); + yBound = ABS(subTileRel.x >> 1); while (subTileRel.y >= 0 && subTile.u < 4 @@ -3812,7 +3812,7 @@ SurfaceType pointOnTile(TileInfo *ti, sMask <<= kSubTileMaskUShift + kSubTileMaskVShift; subTileRel.y -= kSubTileDY * 2; } - yBound = abs(subTileRel.x >> 1); + yBound = ABS(subTileRel.x >> 1); if (subTile.u >= 4 || subTile.v >= 4) { // No subtile was found, so lets move the pointer. @@ -3826,10 +3826,10 @@ SurfaceType pointOnTile(TileInfo *ti, subTileRel.x = relPos.x - ((subTile.u - subTile.v) << kSubTileDXShift); subTileRel.y = ti->attrs.terrainHeight + kSubTileDY * 2 - - abs(subTileRel.x >> 1) - 1; + ABS(subTileRel.x >> 1) - 1; sMask = calcSubTileMask(subTile.u, subTile.v); - yBound = abs(subTileRel.x >> 1); + yBound = ABS(subTileRel.x >> 1); } else { // If there were no raised subtiles checked, move the // pointer laterally to the nearest raised subtile. @@ -3899,7 +3899,7 @@ testLeft: if (raisedCol == -4) break; // compute the number of subtiles in column - int8 subsInCol = 4 - abs(raisedCol); + int8 subsInCol = 4 - ABS(raisedCol); relPos.x = (raisedCol << kSubTileDXShift) + subTileRel.x; if (raisedCol > 0) { @@ -3925,7 +3925,7 @@ testLeft: // column subTileRel.y = relPos.y - ((subTile.u + subTile.v) * kSubTileDY) - h; sMask = calcSubTileMask(subTile.u, subTile.v); - yBound = abs(subTileRel.x >> 1); + yBound = ABS(subTileRel.x >> 1); } } } @@ -4122,7 +4122,7 @@ StaticTilePoint pickTile(Point32 pos, mt = curMap->lookupMeta(mCoords); // While we are less than the pick altitude - while (relPos.y < zMax + kTileDX + kMaxStepHeight - abs(relPos.x >> 1)) { + while (relPos.y < zMax + kTileDX + kMaxStepHeight - ABS(relPos.x >> 1)) { // If there is a metatile on this spot if (mt != nullptr) { // Iterate through all platforms @@ -4155,7 +4155,7 @@ StaticTilePoint pickTile(Point32 pos, // Reject the tile if mouse position is below lower tile // boundary - if ((relPos.y - sti.surfaceHeight) < abs(relPos.x >> 1)) + if ((relPos.y - sti.surfaceHeight) < ABS(relPos.x >> 1)) continue; if (ti->attrs.height > 0) { @@ -4525,8 +4525,8 @@ void updateMainDisplay(void) { viewDiff = trackPos - lastViewLoc; lastViewLoc = trackPos; - if (abs(viewDiff.u) > 8 * kPlatformWidth * kTileUVSize - || abs(viewDiff.v) > 8 * kPlatformWidth * kTileUVSize) + if (ABS(viewDiff.u) > 8 * kPlatformWidth * kTileUVSize + || ABS(viewDiff.v) > 8 * kPlatformWidth * kTileUVSize) freeAllTileBanks(); // Add current coordinates to map if they have mapping @@ -4693,25 +4693,25 @@ void markMetaAsVisited(const TilePoint &pt) { * ===================================================================== */ int16 quickDistance(const Point16 &p) { - int16 ax = abs(p.x), - ay = abs(p.y); + int16 ax = ABS(p.x), + ay = ABS(p.y); if (ax > ay) return ax + (ay >> 1); else return ay + (ax >> 1); } int32 quickDistance(const Point32 &p) { - int32 ax = abs(p.x), - ay = abs(p.y); + int32 ax = ABS(p.x), + ay = ABS(p.y); if (ax > ay) return ax + (ay >> 1); else return ay + (ax >> 1); } int16 TilePoint::magnitude(void) { - int16 au = abs(u), - av = abs(v), - az = abs(z); + int16 au = ABS(u), + av = ABS(v), + az = ABS(z); if (az > au && az > av) return az + ((au + av) >> 1); if (au > av) return au + ((az + av) >> 1); @@ -4763,7 +4763,7 @@ uint16 lineDist( else dist = lineFar; - return abs(dist); + return ABS(dist); } } // end of namespace Saga2