mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 09:20:47 +00:00
fix minimap priority: water > impassable > land for pathfinding accuracy
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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user