• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ attack and magic wall bug

Solution
wow, yeah looks like it's broke and the commit doesn't fix it either.
Here's canarys code, not ideal but looks like it works on TFS 1.4.2, give it a test.

src\map.cpp replace checkSightLine
C++:
bool Map::checkSightLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t z) const
{
    if (x0 == x1 && y0==y1) {
        return true;
    }

    Position start(x0,y0,z);
    Position destination(x1,y1,z);

    const int8_t mx = start.x < destination.x ? 1 : start.x == destination.x ? 0
        : -1;
    const int8_t my = start.y < destination.y ? 1 : start.y == destination.y ? 0
        : -1;

    int32_t A = Position::getOffsetY(destination, start);
    int32_t B = Position::getOffsetX(start, destination);
    int32_t C = -(A *...
with this commit only 1 side of the bug is fixed, the east side and I can hit spells and waves passing through walls
 
wow, yeah looks like it's broke and the commit doesn't fix it either.
Here's canarys code, not ideal but looks like it works on TFS 1.4.2, give it a test.

src\map.cpp replace checkSightLine
C++:
bool Map::checkSightLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t z) const
{
    if (x0 == x1 && y0==y1) {
        return true;
    }

    Position start(x0,y0,z);
    Position destination(x1,y1,z);

    const int8_t mx = start.x < destination.x ? 1 : start.x == destination.x ? 0
        : -1;
    const int8_t my = start.y < destination.y ? 1 : start.y == destination.y ? 0
        : -1;

    int32_t A = Position::getOffsetY(destination, start);
    int32_t B = Position::getOffsetX(start, destination);
    int32_t C = -(A * destination.x + B * destination.y);

    while (start.x != destination.x || start.y != destination.y) {
        int32_t move_hor = std::abs(A * (start.x + mx) + B * (start.y) + C);
        int32_t move_ver = std::abs(A * (start.x) + B * (start.y + my) + C);
        int32_t move_cross = std::abs(A * (start.x + mx) + B * (start.y + my) + C);

        if (start.y != destination.y && (start.x == destination.x || move_hor > move_ver || move_hor > move_cross)) {
            start.y += my;
        }

        if (start.x != destination.x && (start.y == destination.y || move_ver > move_hor || move_ver > move_cross)) {
            start.x += mx;
        }

        if (!g_game.map.isTileClear(start.x, start.y, start.z)) {
            return false;
        }
    }

    return true;
}

Change Map::isSightClear
Code:
bool sightClear = checkSightLine(fromPos.x, fromPos.y, toPos.x, toPos.y, fromPos.z);
new:
Code:
bool sightClear = checkSightLine(fromPos.x, fromPos.y, toPos.x, toPos.y, fromPos.z) || checkSightLine(toPos.x, toPos.y, fromPos.x, fromPos.y, fromPos.z);
 
Solution
Back
Top