mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix issues loading larger maps
This commit is contained in:
parent
a75db4b436
commit
0186cf8398
@ -251,13 +251,13 @@ impl Civs {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.for_each(|posi| {
|
.for_each(|posi| {
|
||||||
let chpos = uniform_idx_as_vec2(ctx.sim.map_size_lg(), 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)
|
let closest_site = (*sites)
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.filter(|s| !matches!(s.1.kind, crate::site::SiteKind::Dungeon(_)))
|
.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 {
|
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
|
s.economy
|
||||||
.add_chunk(ctx.sim.get(chpos).unwrap(), distance_squared);
|
.add_chunk(ctx.sim.get(chpos).unwrap(), distance_squared);
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ impl Economy {
|
|||||||
// info!("resources {:?}", self.stocks);
|
// 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();
|
let biome = ch.get_biome();
|
||||||
// we don't scale by pi, although that would be correct
|
// we don't scale by pi, although that would be correct
|
||||||
let distance_bin = (distance_squared >> 16).min(64) as usize;
|
let distance_bin = (distance_squared >> 16).min(64) as usize;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user