Index: source/simulation2/components/CCmpRangeManager.cpp =================================================================== --- source/simulation2/components/CCmpRangeManager.cpp +++ source/simulation2/components/CCmpRangeManager.cpp @@ -1584,6 +1584,8 @@ LosVisibility ComputeLosVisibility(CEntityHandle ent, player_id_t player) const { + PROFILE2("ComputeLosVisibility"); + // Entities not with positions in the world are never visible if (ent.GetId() == INVALID_ENTITY) return LosVisibility::HIDDEN; @@ -1627,7 +1629,6 @@ } // Else, default behavior - if (los.IsVisible(i, j)) { if (cmpMirage) @@ -1636,7 +1637,28 @@ return LosVisibility::VISIBLE; } - if (!los.IsExplored(i, j)) + i = (pos.X / (int)TERRAIN_TILE_SIZE).ToInt_RoundToZero(); + j = (pos.Y / (int)TERRAIN_TILE_SIZE).ToInt_RoundToZero(); + + bool explored = los.IsExplored(i, j); + for (int ii = -it->second.size; ii <= (int)it->second.size + 1; ++ii) + for (int jj = -it->second.size; jj <= (int)it->second.size + 1; ++jj) + { + if (ii*ii + jj*jj > (int)((it->second.size+1) * (it->second.size+1))) + continue; + + if (los.IsVisible(i+ii, j+jj)) + { + if (cmpMirage) + return LosVisibility::HIDDEN; + + return LosVisibility::VISIBLE; + } + if (!explored && los.IsExplored(i+ii, j+jj)) + explored = true; + } + + if (!explored) return LosVisibility::HIDDEN; // Invisible if the 'retain in fog' flag is not set, and in a non-visible explored region