diff options
author | Torbjörn Andersson | 2003-12-19 14:16:31 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2003-12-19 14:16:31 +0000 |
commit | 34433d87bbf378430ad6ea523787616c748a7d43 (patch) | |
tree | 305948902a5f7fa1e96d6ebd84cf668aa9e1794c | |
parent | b179e8f6ec6d24f6b46a1b9e14e46ad777374d94 (diff) | |
download | scummvm-rg350-34433d87bbf378430ad6ea523787616c748a7d43.tar.gz scummvm-rg350-34433d87bbf378430ad6ea523787616c748a7d43.tar.bz2 scummvm-rg350-34433d87bbf378430ad6ea523787616c748a7d43.zip |
Changed abs() to ABS(), and changed a sorting function to use SWAP()
svn-id: r11761
-rw-r--r-- | sword1/logic.cpp | 2 | ||||
-rw-r--r-- | sword1/router.cpp | 18 | ||||
-rw-r--r-- | sword1/screen.cpp | 21 |
3 files changed, 19 insertions, 22 deletions
diff --git a/sword1/logic.cpp b/sword1/logic.cpp index 508413417f..c569847c3a 100644 --- a/sword1/logic.cpp +++ b/sword1/logic.cpp @@ -1431,7 +1431,7 @@ int SwordLogic::fnIsFacing(BsObject *cpt, int32 id, int32 targetId, int32 b, int int32 lookDir = whatTarget(x, y, cpt->o_xcoord, cpt->o_ycoord); lookDir -= dir; - lookDir = abs(lookDir); + lookDir = ABS(lookDir); if (lookDir > 4) lookDir = 8 - lookDir; diff --git a/sword1/router.cpp b/sword1/router.cpp index e575c9575c..4ba29a4921 100644 --- a/sword1/router.cpp +++ b/sword1/router.cpp @@ -704,7 +704,7 @@ int32 SwordRouter::SlidyPath() stepY = stepY * scale; stepX = stepX >> 19;// quarter a step minimum stepY = stepY >> 19; - if ((abs(deltaX)>=abs(stepX)) && (abs(deltaY)>=abs(stepY))) + if ((ABS(deltaX)>=ABS(stepX)) && (ABS(deltaY)>=ABS(stepY))) { modularPath[slidy].x = smoothPath[smooth].x; modularPath[slidy].y = smoothPath[smooth].y; @@ -936,7 +936,7 @@ void SwordRouter::SlidyWalkAnimator(WalkData *walkAnim) lastErrorY = modularPath[p].y - walkAnim[stepCount-7].y; if (stepX==0) { - if (3*abs(lastErrorY) < abs(errorY)) //the last stop was closest + if (3*ABS(lastErrorY) < ABS(errorY)) //the last stop was closest { stepCount -= framesPerStep; if (left == 0) @@ -947,7 +947,7 @@ void SwordRouter::SlidyWalkAnimator(WalkData *walkAnim) } else { - if (3*abs(lastErrorX) < abs(errorX)) //the last stop was closest + if (3*ABS(lastErrorX) < ABS(errorX)) //the last stop was closest { stepCount -= framesPerStep; if (left == 0) @@ -1187,7 +1187,7 @@ int32 SwordRouter::SolidPath() stepY = stepY * scale; stepX = stepX >> 16; stepY = stepY >> 16; - if ((abs(deltaX)>=abs(stepX)) && (abs(deltaY)>=abs(stepY))) + if ((ABS(deltaX)>=ABS(stepX)) && (ABS(deltaY)>=ABS(stepY))) { modularPath[solid].x = smoothPath[smooth].x; modularPath[solid].y = smoothPath[smooth].y; @@ -1677,13 +1677,13 @@ int32 SwordRouter::Scan(int32 level) x2 = node[k].x; y2 = node[k].y; - if (abs(x2-x1)>(4.5*abs(y2-y1))) + if (ABS(x2-x1)>(4.5*ABS(y2-y1))) { - distance = (8*abs(x2-x1)+18*abs(y2-y1))/(54*8)+1; + distance = (8*ABS(x2-x1)+18*ABS(y2-y1))/(54*8)+1; } else { - distance = (6*abs(x2-x1)+36*abs(y2-y1))/(36*14)+1; + distance = (6*ABS(x2-x1)+36*ABS(y2-y1))/(36*14)+1; } if ((distance + node[i].dist < node[nnodes].dist) && (distance + node[i].dist < node[k].dist)) @@ -2629,9 +2629,9 @@ int whatTarget(int32 startX, int32 startY, int32 destX, int32 destY) { int signY = (deltaY > 0); int slope; - if ( (abs(deltaY) * DIAGONALX ) < (abs(deltaX) * DIAGONALY / 2)) + if ( (ABS(deltaY) * DIAGONALX ) < (ABS(deltaX) * DIAGONALY / 2)) slope = 0;// its flat - else if ( (abs(deltaY) * DIAGONALX / 2) > (abs(deltaX) * DIAGONALY ) ) + else if ( (ABS(deltaY) * DIAGONALX / 2) > (ABS(deltaX) * DIAGONALY ) ) slope = 2;// its vertical else slope = 1;// its diagonal diff --git a/sword1/screen.cpp b/sword1/screen.cpp index 69f9e247ac..19543c1c6a 100644 --- a/sword1/screen.cpp +++ b/sword1/screen.cpp @@ -288,13 +288,10 @@ void SwordScreen::spritesAndParallax(void) { for (uint8 cnt = 0; cnt < _backLength; cnt++) processImage(_backList[cnt]); - SortSpr temp; for (uint8 cnt = 0; cnt < _sortLength - 1; cnt++) for (uint8 sCnt = 0; sCnt < _sortLength - 1; sCnt++) if (_sortList[sCnt].y > _sortList[sCnt + 1].y) { - temp = _sortList[sCnt]; - _sortList[sCnt] = _sortList[sCnt + 1]; - _sortList[sCnt + 1] = temp; + SWAP(_sortList[sCnt], _sortList[sCnt + 1]); } for (uint8 cnt = 0; cnt < _sortLength; cnt++) processImage(_sortList[cnt].id); @@ -748,8 +745,8 @@ void SwordScreen::hline(uint16 x1, uint16 x2, uint16 y) { void SwordScreen::bsubline_1(uint16 x1, uint16 y1, uint16 x2, uint16 y2) { int x, y, ddx, ddy, e; - ddx = abs(x2 - x1); - ddy = abs(y2 - y1) << 1; + ddx = ABS(x2 - x1); + ddy = ABS(y2 - y1) << 1; e = ddx - ddy; ddx <<= 1; @@ -772,8 +769,8 @@ void SwordScreen::bsubline_1(uint16 x1, uint16 y1, uint16 x2, uint16 y2) { void SwordScreen::bsubline_2(uint16 x1, uint16 y1, uint16 x2, uint16 y2) { int x, y, ddx, ddy, e; - ddx = abs(x2 - x1) << 1; - ddy = abs(y2 - y1); + ddx = ABS(x2 - x1) << 1; + ddy = ABS(y2 - y1); e = ddy - ddx; ddy <<= 1; @@ -796,8 +793,8 @@ void SwordScreen::bsubline_2(uint16 x1, uint16 y1, uint16 x2, uint16 y2) { void SwordScreen::bsubline_3(uint16 x1, uint16 y1, uint16 x2, uint16 y2) { int x, y, ddx, ddy, e; - ddx = abs(x1 - x2) << 1; - ddy = abs(y2 - y1); + ddx = ABS(x1 - x2) << 1; + ddy = ABS(y2 - y1); e = ddy - ddx; ddy <<= 1; @@ -820,8 +817,8 @@ void SwordScreen::bsubline_3(uint16 x1, uint16 y1, uint16 x2, uint16 y2) { void SwordScreen::bsubline_4(uint16 x1, uint16 y1, uint16 x2, uint16 y2) { int x, y, ddx, ddy, e; - ddy = abs(y2 - y1) << 1; - ddx = abs(x1 - x2); + ddy = ABS(y2 - y1) << 1; + ddx = ABS(x1 - x2); e = ddx - ddy; ddx <<= 1; |