Skip to content

Commit

Permalink
PARALLACTION: Correct Previous Commit to Coding Conventions.
Browse files Browse the repository at this point in the history
  • Loading branch information
digitall committed Aug 24, 2011
1 parent 5a0680a commit d13a927
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions engines/parallaction/walk.cpp
Expand Up @@ -54,56 +54,56 @@ WalkFrames _char24WalkFrames_NS = {
{ 2, 2, 4, 4 }
};

static int get_path_width() {
static int getPathWidth() {
if (!_vm->_gfx->_backgroundInfo->_path) {
warning("get_path_width() _path is NULL!");
warning("getPathWidth() _path is NULL!");
return 0;
} else
return _vm->_gfx->_backgroundInfo->_path->w;
}

static int get_path_height() {
static int getPathHeight() {
if (!_vm->_gfx->_backgroundInfo->_path) {
warning("get_path_height() _path is NULL!");
warning("getPathHeight() _path is NULL!");
return 0;
} else
return _vm->_gfx->_backgroundInfo->_path->h;
}

static bool is_path_clear(uint16 x, uint16 y) {
static bool isPathClear(uint16 x, uint16 y) {
if (!_vm->_gfx->_backgroundInfo->_path) {
warning("is_path_clear() _path is NULL!");
warning("isPathClear() _path is NULL!");
return false;
} else
return (_vm->_gfx->_backgroundInfo->_path->getValue(x, y) ? true : false);
}

// adjusts position towards nearest walkable point
void PathWalker_NS::correctPathPoint(Common::Point &to) {
if (is_path_clear(to.x, to.y)) return;
if (isPathClear(to.x, to.y)) return;

int maxX = get_path_width();
int maxY = get_path_height();
int maxX = getPathWidth();
int maxY = getPathHeight();

int16 right = to.x;
int16 left = to.x;
do {
right++;
} while ((right < maxX) && !is_path_clear(right, to.y));
} while ((right < maxX) && !isPathClear(right, to.y));
do {
left--;
} while ((left > 0) && !is_path_clear(left, to.y));
} while ((left > 0) && !isPathClear(left, to.y));
right = (right == maxX) ? 1000 : right - to.x;
left = (left == 0) ? 1000 : to.x - left;

int16 top = to.y;
int16 bottom = to.y;
do {
top--;
} while ((top > 0) && !is_path_clear(to.x, top));
} while ((top > 0) && !isPathClear(to.x, top));
do {
bottom++;
} while ((bottom < maxY) && !is_path_clear(to.x, bottom));
} while ((bottom < maxY) && !isPathClear(to.x, bottom));
top = (top == 0) ? 1000 : to.y - top;
bottom = (bottom == maxY) ? 1000 : bottom - to.y;

Expand Down Expand Up @@ -225,10 +225,10 @@ uint16 PathWalker_NS::walkFunc1(const Common::Point &to, Common::Point& node) {

while (foot != arg) {

if (foot.x < to.x && is_path_clear(foot.x + 1, foot.y)) foot.x++;
if (foot.x > to.x && is_path_clear(foot.x - 1, foot.y)) foot.x--;
if (foot.y < to.y && is_path_clear(foot.x, foot.y + 1)) foot.y++;
if (foot.y > to.y && is_path_clear(foot.x, foot.y - 1)) foot.y--;
if (foot.x < to.x && isPathClear(foot.x + 1, foot.y)) foot.x++;
if (foot.x > to.x && isPathClear(foot.x - 1, foot.y)) foot.x--;
if (foot.y < to.y && isPathClear(foot.x, foot.y + 1)) foot.y++;
if (foot.y > to.y && isPathClear(foot.x, foot.y - 1)) foot.y--;

if (foot == v8 && foot != arg) {
// foot couldn't move and still away from target
Expand All @@ -237,10 +237,10 @@ uint16 PathWalker_NS::walkFunc1(const Common::Point &to, Common::Point& node) {

while (foot != arg) {

if (foot.x < to.x && !is_path_clear(foot.x + 1, foot.y)) foot.x++;
if (foot.x > to.x && !is_path_clear(foot.x - 1, foot.y)) foot.x--;
if (foot.y < to.y && !is_path_clear(foot.x, foot.y + 1)) foot.y++;
if (foot.y > to.y && !is_path_clear(foot.x, foot.y - 1)) foot.y--;
if (foot.x < to.x && !isPathClear(foot.x + 1, foot.y)) foot.x++;
if (foot.x > to.x && !isPathClear(foot.x - 1, foot.y)) foot.x--;
if (foot.y < to.y && !isPathClear(foot.x, foot.y + 1)) foot.y++;
if (foot.y > to.y && !isPathClear(foot.x, foot.y - 1)) foot.y--;

if (foot == v8 && foot != arg)
return 0;
Expand All @@ -260,19 +260,19 @@ uint16 PathWalker_NS::walkFunc1(const Common::Point &to, Common::Point& node) {
}

void PathWalker_NS::clipMove(Common::Point& pos, const Common::Point& to) {
if ((pos.x < to.x) && (pos.x < get_path_width()) && is_path_clear(pos.x + 2, pos.y)) {
if ((pos.x < to.x) && (pos.x < getPathWidth()) && isPathClear(pos.x + 2, pos.y)) {
pos.x = (pos.x + 2 < to.x) ? pos.x + 2 : to.x;
}

if ((pos.x > to.x) && (pos.x > 0) && is_path_clear(pos.x - 2, pos.y)) {
if ((pos.x > to.x) && (pos.x > 0) && isPathClear(pos.x - 2, pos.y)) {
pos.x = (pos.x - 2 > to.x) ? pos.x - 2 : to.x;
}

if ((pos.y < to.y) && (pos.y < get_path_height()) && is_path_clear(pos.x, pos.y + 2)) {
if ((pos.y < to.y) && (pos.y < getPathHeight()) && isPathClear(pos.x, pos.y + 2)) {
pos.y = (pos.y + 2 <= to.y) ? pos.y + 2 : to.y;
}

if ((pos.y > to.y) && (pos.y > 0) && is_path_clear(pos.x, pos.y - 2)) {
if ((pos.y > to.y) && (pos.y > 0) && isPathClear(pos.x, pos.y - 2)) {
pos.y = (pos.y - 2 >= to.y) ? pos.y - 2 : to.y;
}
}
Expand Down Expand Up @@ -390,10 +390,10 @@ bool PathWalker_BR::directPathExists(const Common::Point &from, const Common::Po
Common::Point p(copy);

while (p != to) {
if (p.x < to.x && is_path_clear(p.x + 1, p.y)) p.x++;
if (p.x > to.x && is_path_clear(p.x - 1, p.y)) p.x--;
if (p.y < to.y && is_path_clear(p.x, p.y + 1)) p.y++;
if (p.y > to.y && is_path_clear(p.x, p.y - 1)) p.y--;
if (p.x < to.x && isPathClear(p.x + 1, p.y)) p.x++;
if (p.x > to.x && isPathClear(p.x - 1, p.y)) p.x--;
if (p.y < to.y && isPathClear(p.x, p.y + 1)) p.y++;
if (p.y > to.y && isPathClear(p.x, p.y - 1)) p.y--;

if (p == copy && p != to)
return false;
Expand Down Expand Up @@ -642,7 +642,7 @@ void PathWalker_BR::doWalk(State &s) {
assert (!s._walkPath.empty());
Common::Point p(*s._walkPath.begin());

if (s._startFoot.y < p.y && (s._startFoot.y + yStep) < maxY && is_path_clear(s._startFoot.x, s._startFoot.y + yStep)) {
if (s._startFoot.y < p.y && (s._startFoot.y + yStep) < maxY && isPathClear(s._startFoot.x, s._startFoot.y + yStep)) {
if (yStep + s._startFoot.y <= p.y) {
s._stillWalkingTowardsNode = true;
delta.y = yStep;
Expand All @@ -653,7 +653,7 @@ void PathWalker_BR::doWalk(State &s) {
}
s._dirFrame = 9;
} else
if (s._startFoot.y > p.y && (s._startFoot.y - yStep) > minY && is_path_clear(s._startFoot.x, s._startFoot.y - yStep)) {
if (s._startFoot.y > p.y && (s._startFoot.y - yStep) > minY && isPathClear(s._startFoot.x, s._startFoot.y - yStep)) {
if (s._startFoot.y - yStep >= p.y) {
s._stillWalkingTowardsNode = true;
delta.y = yStep;
Expand All @@ -665,7 +665,7 @@ void PathWalker_BR::doWalk(State &s) {
s._dirFrame = 0;
}

if (s._startFoot.x < p.x && (s._startFoot.x + xStep) < maxX && is_path_clear(s._startFoot.x + xStep, s._startFoot.y)) {
if (s._startFoot.x < p.x && (s._startFoot.x + xStep) < maxX && isPathClear(s._startFoot.x + xStep, s._startFoot.y)) {
if (s._startFoot.x + xStep <= p.x) {
s._stillWalkingTowardsNode = true;
delta.x = xStep;
Expand All @@ -678,7 +678,7 @@ void PathWalker_BR::doWalk(State &s) {
s._dirFrame = 18; // right
}
} else
if (s._startFoot.x > p.x && (s._startFoot.x - xStep) > minX && is_path_clear(s._startFoot.x - xStep, s._startFoot.y)) {
if (s._startFoot.x > p.x && (s._startFoot.x - xStep) > minX && isPathClear(s._startFoot.x - xStep, s._startFoot.y)) {
if (s._startFoot.x - xStep >= p.x) {
s._stillWalkingTowardsNode = true;
delta.x = xStep;
Expand Down

0 comments on commit d13a927

Please sign in to comment.