Permalink
Browse files

optimize some stuff

  • Loading branch information...
Warboy1982 committed Mar 17, 2018
1 parent 330c218 commit ea9ac466221f8b4f8974d2db1c42dc4ad6126564
Showing with 15 additions and 12 deletions.
  1. +15 −12 src/Battlescape/TileEngine.cpp
@@ -1599,34 +1599,37 @@ int TileEngine::verticalBlockage(Tile *startTile, Tile *endTile, ItemDamageType
if (direction < 0) // down
{
block += blockage(_save->getTile(Position(x, y, z)), O_FLOOR, type);
block += blockage(startTile, O_FLOOR, type);
if (!skipObject)
block += blockage(_save->getTile(Position(x, y, z)), O_OBJECT, type, Pathfinding::DIR_DOWN);
block += blockage(startTile, O_OBJECT, type, Pathfinding::DIR_DOWN);
if (x != endTile->getPosition().x || y != endTile->getPosition().y)
{
x = endTile->getPosition().x;
y = endTile->getPosition().y;
int z = startTile->getPosition().z;
block += horizontalBlockage(startTile, _save->getTile(Position(x, y, z)), type, skipObject);
block += blockage(_save->getTile(Position(x, y, z)), O_FLOOR, type);
// z remains same as startTile
Tile *currTile = _save->getTile(Position(x, y, z));
block += horizontalBlockage(startTile, currTile, type, skipObject);
block += blockage(currTile, O_FLOOR, type);
if (!skipObject)
block += blockage(_save->getTile(Position(x, y, z)), O_OBJECT, type, Pathfinding::DIR_DOWN);
block += blockage(currTile, O_OBJECT, type, Pathfinding::DIR_DOWN);
}
}
else if (direction > 0) // up
{
block += blockage(_save->getTile(Position(x, y, z+1)), O_FLOOR, type);
z += 1;
Tile *currTile = _save->getTile(Position(x, y, z));
block += blockage(currTile, O_FLOOR, type);
if (!skipObject)
block += blockage(_save->getTile(Position(x, y, z+1)), O_OBJECT, type, Pathfinding::DIR_UP);
block += blockage(currTile, O_OBJECT, type, Pathfinding::DIR_UP);
if (x != endTile->getPosition().x || y != endTile->getPosition().y)
{
x = endTile->getPosition().x;
y = endTile->getPosition().y;
int z = startTile->getPosition().z+1;
block += horizontalBlockage(startTile, _save->getTile(Position(x, y, z)), type, skipObject);
block += blockage(_save->getTile(Position(x, y, z)), O_FLOOR, type);
currTile = _save->getTile(Position(x, y, z));
block += horizontalBlockage(startTile, currTile, type, skipObject);
block += blockage(currTile, O_FLOOR, type);
if (!skipObject)
block += blockage(_save->getTile(Position(x, y, z)), O_OBJECT, type, Pathfinding::DIR_UP);
block += blockage(currTile, O_OBJECT, type, Pathfinding::DIR_UP);
}
}

0 comments on commit ea9ac46

Please sign in to comment.