mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Address review on !3888
This commit is contained in:
parent
4becb2c616
commit
ddf9e0eaab
@ -55,11 +55,7 @@ pub struct Civs {
|
||||
/// (3) we have 8-byte keys (for which FxHash is fastest).
|
||||
pub track_map: DHashMap<Id<Site>, DHashMap<Id<Site>, Id<Track>>>,
|
||||
|
||||
pub bridges: hashbrown::HashMap<
|
||||
Vec2<i32>,
|
||||
(Vec2<i32>, Id<Site>),
|
||||
std::hash::BuildHasherDefault<fxhash::FxHasher64>,
|
||||
>,
|
||||
pub bridges: DHashMap<Vec2<i32>, (Vec2<i32>, Id<Site>)>,
|
||||
|
||||
pub sites: Store<Site>,
|
||||
pub caves: Store<CaveInfo>,
|
||||
@ -1372,11 +1368,7 @@ fn walk_in_all_dirs(
|
||||
) -> [Option<(Vec2<i32>, f32)>; 8] {
|
||||
let mut potential = [None; 8];
|
||||
|
||||
let mut adjacents = [a; 8];
|
||||
NEIGHBORS
|
||||
.iter()
|
||||
.zip(&mut adjacents)
|
||||
.for_each(|(&dir, adj)| *adj += dir);
|
||||
let adjacents = NEIGHBORS.map(|dir| a + dir);
|
||||
|
||||
let Some(a_chunk) = sim.get(a) else { return potential };
|
||||
let mut chunks = [None; 8];
|
||||
@ -1432,15 +1424,10 @@ fn walk_in_all_dirs(
|
||||
/// Return true if a position is suitable for walking on
|
||||
fn loc_suitable_for_walking(sim: &WorldSim, loc: Vec2<i32>) -> bool {
|
||||
if sim.get(loc).is_some() {
|
||||
!NEIGHBORS
|
||||
.iter()
|
||||
.map(|n| {
|
||||
sim.get(loc + *n)
|
||||
.map_or(false, |chunk| chunk.river.near_water())
|
||||
})
|
||||
.fold(false, |any_near_water, near_water| {
|
||||
any_near_water | near_water
|
||||
})
|
||||
NEIGHBORS.iter().all(|n| {
|
||||
sim.get(loc + *n)
|
||||
.map_or(false, |chunk| !chunk.river.near_water())
|
||||
})
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
@ -23,13 +23,13 @@ pub use self::{
|
||||
|
||||
pub use common::grid::Grid;
|
||||
|
||||
use fxhash::FxHasher32;
|
||||
use fxhash::{FxHasher32, FxHasher64};
|
||||
use hashbrown::{HashMap, HashSet};
|
||||
use std::hash::BuildHasherDefault;
|
||||
use vek::*;
|
||||
|
||||
// Deterministic HashMap and HashSet
|
||||
pub type DHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FxHasher32>>;
|
||||
pub type DHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FxHasher64>>;
|
||||
pub type DHashSet<T> = HashSet<T, BuildHasherDefault<FxHasher32>>;
|
||||
|
||||
pub fn attempt<T>(max_iters: usize, mut f: impl FnMut() -> Option<T>) -> Option<T> {
|
||||
|
Loading…
Reference in New Issue
Block a user