Cylinder* Tile::__queryDestination(int32_t& index, const Thing* thing, Item** destItem, uint32_t& flags) { Tile* destTile = NULL; *destItem = NULL; if(floorChangeDown()){ int dx = getTilePosition().x; int dy = getTilePosition().y; int dz = getTilePosition().z + 1; Tile* downTile = g_game.getTile(dx, dy, dz); if(downTile){ if(downTile->floorChange(NORTH)) dy += 1; if(downTile->floorChange(SOUTH)) dy -= 1; if(downTile->floorChange(EAST)) dx -= 1; if(downTile->floorChange(WEST)) dx += 1; destTile = g_game.getTile(dx, dy, dz); } } else if(floorChange()){ int dx = getTilePosition().x; int dy = getTilePosition().y; int dz = getTilePosition().z - 1; if(floorChange(NORTH)) dy -= 1; if(floorChange(SOUTH)) dy += 1; if(floorChange(EAST)) dx += 1; if(floorChange(WEST)) dx -= 1; destTile = g_game.getTile(dx, dy, dz); } if(destTile == NULL){ destTile = this; } else{ flags |= FLAG_NOLIMIT; //Will ignore that there is blocking items/creatures } if(destTile){ Thing* destThing = destTile->getTopDownItem(); if(destThing) *destItem = destThing->getItem(); } return destTile; }
Tile* Tile::queryDestination(int32_t&, const Thing&, Item** destItem, uint32_t& flags) { Tile* destTile = nullptr; *destItem = nullptr; if (floorChangeDown()) { uint16_t dx = tilePos.x; uint16_t dy = tilePos.y; uint8_t dz = tilePos.z + 1; Tile* southDownTile = g_game.map.getTile(dx, dy - 1, dz); if (southDownTile && southDownTile->floorChange(DIRECTION_SOUTH_ALT)) { dy -= 2; destTile = g_game.map.getTile(dx, dy, dz); } else { Tile* eastDownTile = g_game.map.getTile(dx - 1, dy, dz); if (eastDownTile && eastDownTile->floorChange(DIRECTION_EAST_ALT)) { dx -= 2; destTile = g_game.map.getTile(dx, dy, dz); } else { Tile* downTile = g_game.map.getTile(dx, dy, dz); if (downTile) { if (downTile->floorChange(DIRECTION_NORTH)) { ++dy; } if (downTile->floorChange(DIRECTION_SOUTH)) { --dy; } if (downTile->floorChange(DIRECTION_SOUTH_ALT)) { dy -= 2; } if (downTile->floorChange(DIRECTION_EAST)) { --dx; } if (downTile->floorChange(DIRECTION_EAST_ALT)) { dx -= 2; } if (downTile->floorChange(DIRECTION_WEST)) { ++dx; } destTile = g_game.map.getTile(dx, dy, dz); } } } } else if (floorChange()) { uint16_t dx = tilePos.x; uint16_t dy = tilePos.y; uint8_t dz = tilePos.z - 1; if (floorChange(DIRECTION_NORTH)) { --dy; } if (floorChange(DIRECTION_SOUTH)) { ++dy; } if (floorChange(DIRECTION_EAST)) { ++dx; } if (floorChange(DIRECTION_WEST)) { --dx; } if (floorChange(DIRECTION_SOUTH_ALT)) { dy += 2; } if (floorChange(DIRECTION_EAST_ALT)) { dx += 2; } destTile = g_game.map.getTile(dx, dy, dz); } if (destTile == nullptr) { destTile = this; } else { flags |= FLAG_NOLIMIT; //Will ignore that there is blocking items/creatures } if (destTile) { Thing* destThing = destTile->getTopDownItem(); if (destThing) { *destItem = destThing->getItem(); } } return destTile; }