mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-22 21:35:22 +00:00
Fix minimap priority for impassable terrain pathfinding 🗺️ (#4361)
## Description: Changes the minimap downscaling priority in the Go map generator from `Impassable > Water > Land` to `Water > Impassable > Land`. Tristar noticed this bug and reported it in the discord map-maker-area: Previously, any 2x2 block containing even one impassable tile would become impassable on the minimap, completely erasing narrow rivers inside or bordering impassable terrain. Since the water pathfinder runs on the minimap, this caused pathfinding failures near impassable terrain. With water taking highest priority, narrow rivers are preserved on the minimap regardless of surrounding impassable terrain, ensuring the water pathfinder can route through them correctly. ## Please complete the following: - [X] I have added screenshots for all UI updates - [X] I process any text displayed to the user through translateText() and I've added it to the en.json file - [X] I have added relevant tests to the test directory ## Please put your Discord username so you can be contacted if a bug or regression is found: FloPinguin
This commit is contained in:
@@ -256,9 +256,9 @@ func convertToWebP(thumb ThumbData) ([]byte, error) {
|
||||
|
||||
// createMiniMap downscales the terrain grid by half.
|
||||
// It maps 2x2 blocks of input tiles to a single output tile.
|
||||
// Priority: Impassable > Water > Land. If any of the 4 source tiles is
|
||||
// Impassable, the result is Impassable; else if any is Water, the result is
|
||||
// Water; otherwise the last Land tile wins.
|
||||
// Priority: Water > Impassable > Land. Water always wins so that narrow
|
||||
// rivers inside or bordering impassable terrain are preserved on the minimap
|
||||
// (the pathfinder runs on the minimap and needs accurate water bodies).
|
||||
func createMiniMap(tm [][]Terrain) [][]Terrain {
|
||||
width := len(tm)
|
||||
height := len(tm[0])
|
||||
@@ -281,7 +281,16 @@ func createMiniMap(tm [][]Terrain) [][]Terrain {
|
||||
}
|
||||
src := tm[x][y]
|
||||
dst := &miniMap[miniX][miniY]
|
||||
// Impassable wins over everything; once set, keep it.
|
||||
// Water wins over everything — narrow rivers must be preserved
|
||||
// for pathfinding accuracy.
|
||||
if dst.Type == Water {
|
||||
continue
|
||||
}
|
||||
if src.Type == Water {
|
||||
*dst = src
|
||||
continue
|
||||
}
|
||||
// Impassable wins over land; once set, keep it.
|
||||
if dst.Type == Impassable {
|
||||
continue
|
||||
}
|
||||
@@ -289,10 +298,6 @@ func createMiniMap(tm [][]Terrain) [][]Terrain {
|
||||
*dst = src
|
||||
continue
|
||||
}
|
||||
// Water wins over land; once set to water, keep it.
|
||||
if dst.Type == Water {
|
||||
continue
|
||||
}
|
||||
*dst = src
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.6 KiB |
Reference in New Issue
Block a user