mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed floating sprites in towns, clippy fixes
This commit is contained in:
parent
50a85853e3
commit
e3cab272c3
@ -47,14 +47,11 @@ impl<T> Lottery<T> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
assets,
|
||||
comp::inventory::item::{lottery::Lottery, Item},
|
||||
};
|
||||
use super::*;
|
||||
use crate::{assets, comp::Item};
|
||||
#[test]
|
||||
fn test_loot_table() {
|
||||
let test = assets::load_expect::<Lottery<_>>("common.loot_table");
|
||||
let test = test;
|
||||
let test = assets::load_expect::<Lottery<String>>("common.loot_table");
|
||||
|
||||
for (_, item) in test.iter() {
|
||||
assert!(
|
||||
|
@ -209,7 +209,7 @@ fn handle_make_block(
|
||||
} else {
|
||||
server.notify_client(
|
||||
client,
|
||||
ChatType::CommandError.server_msg(String::from(action.help_string())),
|
||||
ChatType::CommandError.server_msg(action.help_string()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -41,15 +41,12 @@ impl Animation for BetaAnimation {
|
||||
.sqrt())
|
||||
* ((anim_time as f32 * lab as f32 * 14.0).sin());
|
||||
|
||||
match active_tool_kind {
|
||||
//TODO: Inventory
|
||||
Some(ToolKind::Axe(_))
|
||||
| Some(ToolKind::Hammer(_))
|
||||
| Some(ToolKind::Sword(_))
|
||||
| Some(ToolKind::Dagger(_)) => {
|
||||
if let Some(
|
||||
ToolKind::Axe(_) | ToolKind::Hammer(_) | ToolKind::Sword(_) | ToolKind::Dagger(_),
|
||||
) = active_tool_kind
|
||||
{
|
||||
//INTENTION: SWORD
|
||||
next.head.offset =
|
||||
Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
|
||||
next.head.offset = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
|
||||
next.head.ori = Quaternion::rotation_z(slow * -0.18)
|
||||
* Quaternion::rotation_x(-0.1 + slow * -0.28)
|
||||
* Quaternion::rotation_y(0.2 + slow * 0.18);
|
||||
@ -89,17 +86,15 @@ impl Animation for BetaAnimation {
|
||||
footquick * -9.5,
|
||||
skeleton_attr.foot.2,
|
||||
);
|
||||
next.l_foot.ori = Quaternion::rotation_x(footquick * 0.3)
|
||||
* Quaternion::rotation_y(footquick * -0.6);
|
||||
next.l_foot.ori =
|
||||
Quaternion::rotation_x(footquick * 0.3) * Quaternion::rotation_y(footquick * -0.6);
|
||||
|
||||
next.r_foot.offset =
|
||||
Vec3::new(skeleton_attr.foot.0, footquick * 9.5, skeleton_attr.foot.2);
|
||||
next.r_foot.ori = Quaternion::rotation_x(footquick * -0.3)
|
||||
* Quaternion::rotation_y(footquick * 0.2);
|
||||
next.r_foot.ori =
|
||||
Quaternion::rotation_x(footquick * -0.3) * Quaternion::rotation_y(footquick * 0.2);
|
||||
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
|
||||
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
|
||||
next.l_shoulder.offset = Vec3::new(
|
||||
|
@ -38,12 +38,10 @@ impl Animation for SpinAnimation {
|
||||
let spin = (anim_time as f32 * 2.8 * lab as f32).sin();
|
||||
let spinhalf = (anim_time as f32 * 1.4 * lab as f32).sin();
|
||||
|
||||
match active_tool_kind {
|
||||
//TODO: Inventory
|
||||
Some(ToolKind::Axe(_))
|
||||
| Some(ToolKind::Hammer(_))
|
||||
| Some(ToolKind::Sword(_))
|
||||
| Some(ToolKind::Dagger(_)) => {
|
||||
if let Some(
|
||||
ToolKind::Axe(_) | ToolKind::Hammer(_) | ToolKind::Sword(_) | ToolKind::Dagger(_),
|
||||
) = active_tool_kind
|
||||
{
|
||||
//INTENTION: SWORD
|
||||
next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5);
|
||||
next.l_hand.ori = Quaternion::rotation_x(1.27);
|
||||
@ -88,10 +86,8 @@ impl Animation for SpinAnimation {
|
||||
* Quaternion::rotation_x(0.0)
|
||||
* Quaternion::rotation_y(0.0);
|
||||
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
|
||||
},
|
||||
|
||||
_ => {},
|
||||
}
|
||||
|
||||
next.l_foot.offset = Vec3::new(-skeleton_attr.foot.0, foot * 1.0, skeleton_attr.foot.2);
|
||||
next.l_foot.ori = Quaternion::rotation_x(foot * -1.2);
|
||||
next.l_foot.scale = Vec3::one();
|
||||
|
@ -1,3 +1,4 @@
|
||||
#![feature(or_patterns)]
|
||||
#[cfg(all(feature = "be-dyn-lib", feature = "use-dyn-lib"))]
|
||||
compile_error!("Can't use both \"be-dyn-lib\" and \"use-dyn-lib\" features at once");
|
||||
|
||||
|
@ -85,7 +85,7 @@ fn maps_idle() {
|
||||
on_ceiling: false,
|
||||
on_wall: None,
|
||||
touch_entity: None,
|
||||
in_fluid: false,
|
||||
in_fluid: None,
|
||||
},
|
||||
&PreviousEntityState {
|
||||
event: SfxEvent::Idle,
|
||||
@ -107,7 +107,7 @@ fn maps_run_with_sufficient_velocity() {
|
||||
on_ceiling: false,
|
||||
on_wall: None,
|
||||
touch_entity: None,
|
||||
in_fluid: false,
|
||||
in_fluid: None,
|
||||
},
|
||||
&PreviousEntityState {
|
||||
event: SfxEvent::Idle,
|
||||
@ -129,7 +129,7 @@ fn does_not_map_run_with_insufficient_velocity() {
|
||||
on_ceiling: false,
|
||||
on_wall: None,
|
||||
touch_entity: None,
|
||||
in_fluid: false,
|
||||
in_fluid: None,
|
||||
},
|
||||
&PreviousEntityState {
|
||||
event: SfxEvent::Idle,
|
||||
@ -151,7 +151,7 @@ fn does_not_map_run_with_sufficient_velocity_but_not_on_ground() {
|
||||
on_ceiling: false,
|
||||
on_wall: None,
|
||||
touch_entity: None,
|
||||
in_fluid: false,
|
||||
in_fluid: None,
|
||||
},
|
||||
&PreviousEntityState {
|
||||
event: SfxEvent::Idle,
|
||||
@ -176,7 +176,7 @@ fn maps_roll() {
|
||||
on_ceiling: false,
|
||||
on_wall: None,
|
||||
touch_entity: None,
|
||||
in_fluid: false,
|
||||
in_fluid: None,
|
||||
},
|
||||
&PreviousEntityState {
|
||||
event: SfxEvent::Run,
|
||||
@ -198,7 +198,7 @@ fn maps_land_on_ground_to_run() {
|
||||
on_ceiling: false,
|
||||
on_wall: None,
|
||||
touch_entity: None,
|
||||
in_fluid: false,
|
||||
in_fluid: None,
|
||||
},
|
||||
&PreviousEntityState {
|
||||
event: SfxEvent::Idle,
|
||||
@ -220,7 +220,7 @@ fn maps_glider_open() {
|
||||
on_ceiling: false,
|
||||
on_wall: None,
|
||||
touch_entity: None,
|
||||
in_fluid: false,
|
||||
in_fluid: None,
|
||||
},
|
||||
&PreviousEntityState {
|
||||
event: SfxEvent::Jump,
|
||||
@ -242,7 +242,7 @@ fn maps_glide() {
|
||||
on_ceiling: false,
|
||||
on_wall: None,
|
||||
touch_entity: None,
|
||||
in_fluid: false,
|
||||
in_fluid: None,
|
||||
},
|
||||
&PreviousEntityState {
|
||||
event: SfxEvent::Glide,
|
||||
@ -264,7 +264,7 @@ fn maps_glider_close_when_closing_mid_flight() {
|
||||
on_ceiling: false,
|
||||
on_wall: None,
|
||||
touch_entity: None,
|
||||
in_fluid: false,
|
||||
in_fluid: None,
|
||||
},
|
||||
&PreviousEntityState {
|
||||
event: SfxEvent::Glide,
|
||||
@ -287,7 +287,7 @@ fn maps_glider_close_when_landing() {
|
||||
on_ceiling: false,
|
||||
on_wall: None,
|
||||
touch_entity: None,
|
||||
in_fluid: false,
|
||||
in_fluid: None,
|
||||
},
|
||||
&PreviousEntityState {
|
||||
event: SfxEvent::Glide,
|
||||
@ -308,7 +308,7 @@ fn maps_quadrupeds_running() {
|
||||
on_ceiling: false,
|
||||
on_wall: None,
|
||||
touch_entity: None,
|
||||
in_fluid: false,
|
||||
in_fluid: None,
|
||||
},
|
||||
Vec3::new(0.5, 0.8, 0.0),
|
||||
);
|
||||
|
@ -28,7 +28,7 @@ fn main() {
|
||||
let pos = focus + Vec2::new(i as i32, j as i32) * scale;
|
||||
|
||||
let (alt, place) = sampler
|
||||
.get(pos)
|
||||
.get((pos, world.index()))
|
||||
.map(|sample| {
|
||||
(
|
||||
sample.alt.sub(64.0).add(gain).mul(0.7).max(0.0).min(255.0) as u8,
|
||||
|
@ -85,7 +85,7 @@ fn main() {
|
||||
lakes,
|
||||
oceans,
|
||||
quads,
|
||||
} = config.generate(sampler, |pos, (r, g, b, a)| {
|
||||
} = config.generate(sampler, world.index(), |pos, (r, g, b, a)| {
|
||||
let i = pos.x;
|
||||
let j = pos.y;
|
||||
buf[j * W + i] = u32::from_le_bytes([b, g, r, a]);
|
||||
@ -104,7 +104,7 @@ fn main() {
|
||||
..config
|
||||
};
|
||||
let mut buf = vec![0u8; 4 * len];
|
||||
config.generate(sampler, |pos, (r, g, b, a)| {
|
||||
config.generate(sampler, world.index(), |pos, (r, g, b, a)| {
|
||||
let i = pos.x;
|
||||
let j = pos.y;
|
||||
(&mut buf[(j * x + i) * 4..]).write(&[r, g, b, a]).unwrap();
|
||||
|
@ -48,10 +48,7 @@ impl<'a> BlockGen<'a> {
|
||||
close_cliffs.iter().fold(
|
||||
0.0f32,
|
||||
|max_height, (cliff_pos, seed)| match Self::sample_column(
|
||||
column_gen,
|
||||
cache,
|
||||
*cliff_pos,
|
||||
index,
|
||||
column_gen, cache, *cliff_pos, index,
|
||||
) {
|
||||
Some(cliff_sample) if cliff_sample.is_cliffs && cliff_sample.spawn_rate > 0.5 => {
|
||||
let cliff_pos3d = Vec3::from(*cliff_pos);
|
||||
@ -314,10 +311,10 @@ impl<'a> BlockGen<'a> {
|
||||
|
||||
// Some(Block::new(
|
||||
// if on_cliff && (height * 1271.0).fract() < 0.015 {
|
||||
// treasures[(height * 731.3) as usize % treasures.len()]
|
||||
// } else if (height * 1271.0).fract() < 0.1 {
|
||||
// flowers[(height * 0.2) as usize % flowers.len()]
|
||||
// } else {
|
||||
// treasures[(height * 731.3) as usize %
|
||||
// treasures.len()] } else if (height *
|
||||
// 1271.0).fract() < 0.1 { flowers[(height *
|
||||
// 0.2) as usize % flowers.len()] } else {
|
||||
// grasses[(height * 103.3) as usize % grasses.len()]
|
||||
// },
|
||||
// Rgb::broadcast(0),
|
||||
@ -343,10 +340,10 @@ impl<'a> BlockGen<'a> {
|
||||
|
||||
// Some(Block::new(
|
||||
// if (height * 1271.0).fract() < 0.5 {
|
||||
// large_cacti[(height * 0.2) as usize % large_cacti.len()]
|
||||
// } else {
|
||||
// small_cacti[(height * 0.3) as usize % small_cacti.len()]
|
||||
// },
|
||||
// large_cacti[(height * 0.2) as usize %
|
||||
// large_cacti.len()] } else {
|
||||
// small_cacti[(height * 0.3) as usize %
|
||||
// small_cacti.len()] },
|
||||
// Rgb::broadcast(0),
|
||||
// ))
|
||||
} else {
|
||||
|
@ -715,9 +715,7 @@ fn find_site_loc(
|
||||
loc = ctx.sim.get(test_loc).and_then(|c| {
|
||||
Some(
|
||||
c.downhill?
|
||||
.map2(TerrainChunkSize::RECT_SIZE, |e, sz: u32| {
|
||||
e / (sz as i32)
|
||||
}),
|
||||
.map2(TerrainChunkSize::RECT_SIZE, |e, sz: u32| e / (sz as i32)),
|
||||
)
|
||||
});
|
||||
}
|
||||
|
@ -614,7 +614,7 @@ where
|
||||
.unwrap_or_else(|| {
|
||||
max_border_river
|
||||
.river_kind
|
||||
.and_then(|river_kind| {
|
||||
.map(|river_kind| {
|
||||
match river_kind {
|
||||
RiverKind::Ocean => {
|
||||
let (
|
||||
@ -648,7 +648,7 @@ where
|
||||
let river_dist = wposf.distance(river_pos);
|
||||
let _river_height_factor =
|
||||
river_dist / (river_width * 0.5);
|
||||
return Some((
|
||||
return (
|
||||
true,
|
||||
Some((river_dist - river_width * 0.5) as f32),
|
||||
alt_for_river
|
||||
@ -656,10 +656,10 @@ where
|
||||
lake_water_alt - river_gouge,
|
||||
alt_for_river.max(lake_water_alt),
|
||||
0.0,
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
Some((
|
||||
(
|
||||
river_scale_factor <= 1.0,
|
||||
Some(
|
||||
(wposf.distance(river_pos) - river_width * 0.5)
|
||||
@ -669,7 +669,7 @@ where
|
||||
downhill_water_alt,
|
||||
alt_for_river,
|
||||
river_scale_factor as f32,
|
||||
))
|
||||
)
|
||||
},
|
||||
RiverKind::Lake { .. } => {
|
||||
let lake_dist = (max_border_river_pos.map(|e| e as f64)
|
||||
@ -691,7 +691,7 @@ where
|
||||
|| in_bounds
|
||||
{
|
||||
let gouge_factor = 0.0;
|
||||
return Some((
|
||||
return (
|
||||
in_bounds
|
||||
|| downhill_water_alt
|
||||
.max(river_chunk.water_alt)
|
||||
@ -703,16 +703,16 @@ where
|
||||
alt_for_river,
|
||||
river_scale_factor as f32
|
||||
* (1.0 - gouge_factor),
|
||||
));
|
||||
);
|
||||
} else {
|
||||
return Some((
|
||||
return (
|
||||
false,
|
||||
Some(lake_dist as f32),
|
||||
alt_for_river,
|
||||
downhill_water_alt,
|
||||
alt_for_river,
|
||||
river_scale_factor as f32,
|
||||
));
|
||||
);
|
||||
};
|
||||
|
||||
let lake_dist = dist.y;
|
||||
@ -724,7 +724,7 @@ where
|
||||
river_t as f32,
|
||||
);
|
||||
if dist == Vec2::zero() {
|
||||
return Some((
|
||||
return (
|
||||
true,
|
||||
Some(lake_dist as f32),
|
||||
alt_for_river
|
||||
@ -732,7 +732,7 @@ where
|
||||
lake_water_alt - river_gouge,
|
||||
alt_for_river.max(lake_water_alt),
|
||||
0.0,
|
||||
));
|
||||
);
|
||||
}
|
||||
if lake_dist <= TerrainChunkSize::RECT_SIZE.x as f64 * 1.0
|
||||
|| in_bounds
|
||||
@ -745,7 +745,7 @@ where
|
||||
let in_bounds_ = lake_dist
|
||||
<= TerrainChunkSize::RECT_SIZE.x as f64 * 0.5;
|
||||
if gouge_factor == 1.0 {
|
||||
return Some((
|
||||
return (
|
||||
true,
|
||||
Some(lake_dist as f32),
|
||||
alt.min(lake_water_alt - 1.0 - river_gouge),
|
||||
@ -753,9 +753,9 @@ where
|
||||
- river_gouge,
|
||||
alt.max(lake_water_alt),
|
||||
0.0,
|
||||
));
|
||||
);
|
||||
} else {
|
||||
return Some((
|
||||
return (
|
||||
true,
|
||||
None,
|
||||
alt_for_river,
|
||||
@ -767,17 +767,17 @@ where
|
||||
alt_for_river,
|
||||
river_scale_factor as f32
|
||||
* (1.0 - gouge_factor),
|
||||
));
|
||||
);
|
||||
}
|
||||
}
|
||||
Some((
|
||||
(
|
||||
river_scale_factor <= 1.0,
|
||||
Some(lake_dist as f32),
|
||||
alt_for_river,
|
||||
downhill_water_alt,
|
||||
alt_for_river,
|
||||
river_scale_factor as f32,
|
||||
))
|
||||
)
|
||||
},
|
||||
RiverKind::River { .. } => {
|
||||
let (_, _, river_width, (_, (river_pos, _), _)) =
|
||||
@ -785,14 +785,14 @@ where
|
||||
let river_dist = wposf.distance(river_pos);
|
||||
|
||||
// FIXME: Make water altitude accurate.
|
||||
Some((
|
||||
(
|
||||
river_scale_factor <= 1.0,
|
||||
Some((river_dist - river_width * 0.5) as f32),
|
||||
alt_for_river,
|
||||
downhill_water_alt,
|
||||
alt_for_river,
|
||||
river_scale_factor as f32,
|
||||
))
|
||||
)
|
||||
},
|
||||
}
|
||||
})
|
||||
|
@ -404,7 +404,7 @@ impl Floor {
|
||||
if area.contains_point(stair_rcenter.xy()) {
|
||||
let offs = Vec2::new(rng.gen_range(-1.0, 1.0), rng.gen_range(-1.0, 1.0))
|
||||
.try_normalized()
|
||||
.unwrap_or(Vec2::unit_y())
|
||||
.unwrap_or_else(Vec2::unit_y)
|
||||
* FLOOR_SIZE.x as f32
|
||||
/ 2.0
|
||||
- 8.0;
|
||||
|
@ -12,6 +12,8 @@ pub trait Archetype {
|
||||
fn generate<R: Rng>(rng: &mut R) -> (Self, Skeleton<Self::Attr>)
|
||||
where
|
||||
Self: Sized;
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn draw(
|
||||
&self,
|
||||
pos: Vec3<i32>,
|
||||
|
@ -232,7 +232,7 @@ impl Settlement {
|
||||
for _ in 0..PATH_COUNT {
|
||||
dir = (Vec2::new(rng.gen::<f32>() - 0.5, rng.gen::<f32>() - 0.5) * 2.0 - dir)
|
||||
.try_normalized()
|
||||
.unwrap_or(Vec2::zero());
|
||||
.unwrap_or_else(Vec2::zero);
|
||||
let origin = dir.map(|e| (e * 100.0) as i32);
|
||||
let origin = self
|
||||
.land
|
||||
@ -662,7 +662,7 @@ impl Settlement {
|
||||
}
|
||||
}
|
||||
|
||||
Some(Rgb::new(100, 105, 75).map2(Rgb::iota(), |e: u8, i: i32| {
|
||||
Some(Rgb::new(100, 95, 65).map2(Rgb::iota(), |e: u8, i: i32| {
|
||||
e.saturating_add(
|
||||
(self.noise.get(Vec3::new(wpos2d.x, wpos2d.y, i * 5)) % 1)
|
||||
as u8,
|
||||
@ -746,9 +746,9 @@ impl Settlement {
|
||||
|
||||
for z in -8 - diff..4 + diff {
|
||||
let pos = Vec3::new(offs.x, offs.y, surface_z + z);
|
||||
let block = vol.get(pos).ok().copied().unwrap_or(Block::empty());
|
||||
let block = vol.get(pos).ok().copied().unwrap_or_else(Block::empty);
|
||||
|
||||
if block.is_empty() {
|
||||
if block.kind() == BlockKind::Air {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -24,17 +24,17 @@ impl Sampler<'static> for RandomField {
|
||||
let mut a = self.seed;
|
||||
a = (a ^ 61) ^ (a >> 16);
|
||||
a = a.wrapping_add(a << 3);
|
||||
a = a ^ pos.x;
|
||||
a = a ^ (a >> 4);
|
||||
a ^= pos.x;
|
||||
a ^= a >> 4;
|
||||
a = a.wrapping_mul(0x27d4eb2d);
|
||||
a = a ^ (a >> 15);
|
||||
a = a ^ pos.y;
|
||||
a ^= a >> 15;
|
||||
a ^= pos.y;
|
||||
a = (a ^ 61) ^ (a >> 16);
|
||||
a = a.wrapping_add(a << 3);
|
||||
a = a ^ (a >> 4);
|
||||
a = a ^ pos.z;
|
||||
a ^= a >> 4;
|
||||
a ^= pos.z;
|
||||
a = a.wrapping_mul(0x27d4eb2d);
|
||||
a = a ^ (a >> 15);
|
||||
a ^= a >> 15;
|
||||
a
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user