mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 14:00:54 +00:00
remove single pixel lakes
This commit is contained in:
+15
-15
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -60,6 +60,7 @@ export async function loadTerrainMap(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
removeSmallLakes(terrain)
|
||||
const shorelineWaters = processShore(terrain)
|
||||
processDistToLand(shorelineWaters, terrain)
|
||||
processOcean(terrain)
|
||||
@@ -235,6 +236,28 @@ function processOcean(map: Terrain[][]) {
|
||||
}
|
||||
}
|
||||
|
||||
function removeSmallLakes(map: Terrain[][]) {
|
||||
console.log(`removing lakes ${map.length}, ${map[0].length}`)
|
||||
|
||||
for (let x = 0; x < map.length; x++) {
|
||||
for (let y = 0; y < map[0].length; y++) {
|
||||
if (map[x][y].type != TerrainType.Water) {
|
||||
continue
|
||||
}
|
||||
let allLand = true
|
||||
for (const neighbor of neighbors(x, y, map)) {
|
||||
if (neighbor.type != TerrainType.Land) {
|
||||
allLand = false
|
||||
}
|
||||
}
|
||||
if (allLand) {
|
||||
map[x][y].type = TerrainType.Land
|
||||
map[x][y].magnitude = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function logBinaryAsBits(data: Uint8Array, length: number = 8) {
|
||||
const bits = Array.from(data.slice(0, length))
|
||||
.map(b => b.toString(2).padStart(8, '0'))
|
||||
|
||||
Reference in New Issue
Block a user