Add hidden config to disable checking for removed regions on map-updates

This commit is contained in:
Lukas Rieger (Blue) 2025-01-29 21:11:34 +01:00
parent 9d14653172
commit 526d587dc6
No known key found for this signature in database
GPG Key ID: AA33883B1BBA03E6
3 changed files with 32 additions and 26 deletions

View File

@ -80,6 +80,8 @@ public class MapConfig implements MapSettings {
private boolean enableFreeFlightView = true;
private boolean enableHires = true;
private boolean checkForRemovedRegions = true;
private String storage = "file";
private boolean ignoreMissingLightData = false;

View File

@ -133,33 +133,35 @@ private static Collection<Vector2i> getRegions(BmMap map, Vector2i center, int r
// also update regions that are present as map-tile-state files (they might have been rendered before but deleted now)
// (a little hacky as we are operating on raw tile-state files -> maybe find a better way?)
Grid tileGrid = map.getHiresModelManager().getTileGrid();
Grid cellGrid = MapTileState.GRID.multiply(tileGrid);
try (Stream<GridStorage.Cell> stream = map.getStorage().tileState().stream()) {
stream
.filter(c -> {
// filter out files that are fully UNKNOWN/NOT_GENERATED
// this avoids unnecessarily converting UNKNOWN tiles into NOT_GENERATED tiles on force-updates
try (CompressedInputStream in = c.read()) {
if (in == null) return false;
TileState[] states = TileInfoRegion.loadPalette(in.decompress());
for (TileState state : states) {
if (
state != TileState.UNKNOWN &&
state != TileState.NOT_GENERATED
) return true;
if (map.getMapSettings().isCheckForRemovedRegions()) {
Grid tileGrid = map.getHiresModelManager().getTileGrid();
Grid cellGrid = MapTileState.GRID.multiply(tileGrid);
try (Stream<GridStorage.Cell> stream = map.getStorage().tileState().stream()) {
stream
.filter(c -> {
// filter out files that are fully UNKNOWN/NOT_GENERATED
// this avoids unnecessarily converting UNKNOWN tiles into NOT_GENERATED tiles on force-updates
try (CompressedInputStream in = c.read()) {
if (in == null) return false;
TileState[] states = TileInfoRegion.loadPalette(in.decompress());
for (TileState state : states) {
if (
state != TileState.UNKNOWN &&
state != TileState.NOT_GENERATED
) return true;
}
return false;
} catch (IOException ignore) {
return true;
}
return false;
} catch (IOException ignore) {
return true;
}
})
.map(c -> new Vector2i(c.getX(), c.getZ()))
.flatMap(v -> cellGrid.getIntersecting(v, regionGrid).stream())
.filter(regionRadiusFilter)
.forEach(regions::add);
} catch (IOException ex) {
Logger.global.logError("Failed to load map tile state!", ex);
})
.map(c -> new Vector2i(c.getX(), c.getZ()))
.flatMap(v -> cellGrid.getIntersecting(v, regionGrid).stream())
.filter(regionRadiusFilter)
.forEach(regions::add);
} catch (IOException ex) {
Logger.global.logError("Failed to load map tile state!", ex);
}
}
return regions;

View File

@ -60,6 +60,8 @@ public interface MapSettings extends RenderSettings {
boolean isEnableHires();
boolean isCheckForRemovedRegions();
@Override
default boolean isSaveHiresLayer() {
return isEnableHires();