Selaa lähdekoodia

Move dimension door FoW limit check to lib

Dydzio 1 vuosi sitten
vanhempi
sitoutus
e69c096f94
2 muutettua tiedostoa jossa 8 lisäystä ja 11 poistoa
  1. 2 10
      client/adventureMap/AdventureMapInterface.cpp
  2. 6 1
      lib/CGameInfoCallback.cpp

+ 2 - 10
client/adventureMap/AdventureMapInterface.cpp

@@ -533,11 +533,7 @@ void AdventureMapInterface::onTileLeftClicked(const int3 &targetPosition)
 				performSpellcasting(targetPosition);
 				performSpellcasting(targetPosition);
 			break;
 			break;
 		case SpellID::DIMENSION_DOOR:
 		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))
 			if(targetTile && targetTile->isClear(heroTile))
 				performSpellcasting(targetPosition);
 				performSpellcasting(targetPosition);
@@ -668,11 +664,7 @@ void AdventureMapInterface::onTileHovered(const int3 &targetPosition)
 			}
 			}
 		case SpellID::DIMENSION_DOOR:
 		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)*/)
 				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
 					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

+ 6 - 1
lib/CGameInfoCallback.cpp

@@ -514,7 +514,12 @@ const TerrainTile * CGameInfoCallback::getTileForDimensionDoor(int3 tile, const
 {
 {
     auto outputTile = getTile(tile, false);
     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>(SpellID::DIMENSION_DOOR).toSpell())
         if(castingHero->canCastThisSpell(static_cast<SpellID>(SpellID::DIMENSION_DOOR).toSpell())
             && isInScreenRange(castingHero->pos, tile)) //TODO: check if > 0 casts left
             && isInScreenRange(castingHero->pos, tile)) //TODO: check if > 0 casts left