Fix issues loading larger maps

This commit is contained in:
Treeco 2021-03-27 12:37:16 +00:00
parent 6bc0f76bf8
commit f3284b7d90
2 changed files with 4 additions and 4 deletions

View File

@ -251,13 +251,13 @@ impl Civs {
.into_iter()
.for_each(|posi| {
let chpos = uniform_idx_as_vec2(ctx.sim.map_size_lg(), posi);
let wpos = chpos * TerrainChunkSize::RECT_SIZE.map(|e| e as i32);
let wpos = chpos.map(|e| e as i64) * TerrainChunkSize::RECT_SIZE.map(|e| e as i64);
let closest_site = (*sites)
.iter_mut()
.filter(|s| !matches!(s.1.kind, crate::site::SiteKind::Dungeon(_)))
.min_by_key(|(_id, s)| s.get_origin().distance_squared(wpos));
.min_by_key(|(_id, s)| s.get_origin().map(|e| e as i64).distance_squared(wpos));
if let Some((_id, s)) = closest_site {
let distance_squared = s.get_origin().distance_squared(wpos);
let distance_squared = s.get_origin().map(|e| e as i64).distance_squared(wpos);
s.economy
.add_chunk(ctx.sim.get(chpos).unwrap(), distance_squared);
}

View File

@ -279,7 +279,7 @@ impl Economy {
// info!("resources {:?}", self.stocks);
}
pub fn add_chunk(&mut self, ch: &SimChunk, distance_squared: i32) {
pub fn add_chunk(&mut self, ch: &SimChunk, distance_squared: i64) {
let biome = ch.get_biome();
// we don't scale by pi, although that would be correct
let distance_bin = (distance_squared >> 16).min(64) as usize;