From e69c096f94477379da68defdf4d464790e80569b Mon Sep 17 00:00:00 2001 From: Dydzio Date: Mon, 1 Apr 2024 15:13:18 +0200 Subject: [PATCH] Move dimension door FoW limit check to lib --- client/adventureMap/AdventureMapInterface.cpp | 12 ++---------- lib/CGameInfoCallback.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/client/adventureMap/AdventureMapInterface.cpp b/client/adventureMap/AdventureMapInterface.cpp index 44ab9afaa..059a5a75e 100644 --- a/client/adventureMap/AdventureMapInterface.cpp +++ b/client/adventureMap/AdventureMapInterface.cpp @@ -533,11 +533,7 @@ void AdventureMapInterface::onTileLeftClicked(const int3 &targetPosition) performSpellcasting(targetPosition); break; case SpellID::DIMENSION_DOOR: - bool allowOnlyToUncoveredTiles = VLC->settings()->getBoolean(EGameSettings::DIMENSION_DOOR_ONLY_TO_UNCOVERED_TILES); - - const TerrainTile * targetTile = allowOnlyToUncoveredTiles - ? LOCPLINT->cb->getTile(targetPosition, false) - : LOCPLINT->cb->getTileForDimensionDoor(targetPosition, LOCPLINT->localState->getCurrentHero()); + const TerrainTile * targetTile = LOCPLINT->cb->getTileForDimensionDoor(targetPosition, LOCPLINT->localState->getCurrentHero()); if(targetTile && targetTile->isClear(heroTile)) performSpellcasting(targetPosition); @@ -668,11 +664,7 @@ void AdventureMapInterface::onTileHovered(const int3 &targetPosition) } case SpellID::DIMENSION_DOOR: { - bool allowOnlyToUncoveredTiles = VLC->settings()->getBoolean(EGameSettings::DIMENSION_DOOR_ONLY_TO_UNCOVERED_TILES); - - const TerrainTile * t = allowOnlyToUncoveredTiles - ? LOCPLINT->cb->getTile(targetPosition, false) - : LOCPLINT->cb->getTileForDimensionDoor(targetPosition, LOCPLINT->localState->getCurrentHero()); + const TerrainTile * t = LOCPLINT->cb->getTileForDimensionDoor(targetPosition, LOCPLINT->localState->getCurrentHero()); if(t && t->isClear(LOCPLINT->cb->getTile(heroPosition))/* && isInScreenRange(hpos, mapPos)*/) CCS->curh->set(Cursor::Map::TELEPORT); //TODO: something wrong with beyond east spell range border cursor on arrogance after TP-ing near underground portal on previous day diff --git a/lib/CGameInfoCallback.cpp b/lib/CGameInfoCallback.cpp index a8c8770a8..6ea9eb6a0 100644 --- a/lib/CGameInfoCallback.cpp +++ b/lib/CGameInfoCallback.cpp @@ -514,7 +514,12 @@ const TerrainTile * CGameInfoCallback::getTileForDimensionDoor(int3 tile, const { auto outputTile = getTile(tile, false); - if(outputTile == nullptr) + if(outputTile != nullptr) + return outputTile; + + bool allowOnlyToUncoveredTiles = VLC->settings()->getBoolean(EGameSettings::DIMENSION_DOOR_ONLY_TO_UNCOVERED_TILES); + + if(!allowOnlyToUncoveredTiles) { if(castingHero->canCastThisSpell(static_cast(SpellID::DIMENSION_DOOR).toSpell()) && isInScreenRange(castingHero->pos, tile)) //TODO: check if > 0 casts left