Fix large map loading

This commit is contained in:
Treeco 2021-09-19 15:56:08 +01:00
parent 719fce1c89
commit 4ab6336d11

View File

@ -150,8 +150,13 @@ pub fn init(
.iter()
.filter(|(_, site)| site.is_settlement())
.min_by_key(|(_, site)| {
let wpos = site.center * TerrainChunk::RECT_SIZE.map(|x| x as i32);
wpos.distance_squared(spawn_point.0.xy().map(|x| x as i32))
let wpos = site
.center
.as_::<i64>()
.map2(TerrainChunk::RECT_SIZE.as_::<i64>(), |e, sz| {
e * sz + sz / 2
});
wpos.distance_squared(spawn_point.0.xy().map(|x| x as i64))
})
.map(|(id, _)| id);
#[allow(clippy::single_match)]