Merge pull request #559 from iceiix/rust1.53

Update to Rust 1.53.0
This commit is contained in:
iceiix 2021-06-18 19:47:29 -07:00 committed by GitHub
commit 72f5fdf619
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 163 additions and 163 deletions

View File

@ -11,7 +11,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
# TODO: refactor toolchain version
toolchain: 1.49.0
toolchain: 1.53.0
components: clippy, rustfmt
default: true
- name: Install dependencies
@ -49,7 +49,7 @@ jobs:
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.49.0
toolchain: 1.53.0
components: clippy, rustfmt
default: true
- name: Build binary
@ -83,7 +83,7 @@ jobs:
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.49.0
toolchain: 1.53.0
components: clippy, rustfmt
default: true
- name: Build binary
@ -128,7 +128,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
# TODO: refactor toolchain version
toolchain: 1.49.0
toolchain: 1.53.0
components: clippy, rustfmt
default: true
- name: Install wasm-pack

View File

@ -3,6 +3,7 @@ name = "stevenarella"
version = "0.0.1"
authors = [ "Thinkofdeath <thinkofdeath@spigotmc.org>", "iceiix <ice_ix@protonmail.ch>" ]
edition = "2018"
resolver = "2"
description = "Multi-protocol multi-platform Minecraft-compatible client"
repository = "https://github.com/iceiix/stevenarella"
license = "MIT/Apache-2.0"
@ -19,6 +20,7 @@ crate-type = ["cdylib", "rlib"]
path = "src/main.rs"
[profile.dev]
split-debuginfo = "unpacked"
# Steven runs horrendously slow with no optimizations, and often freezes.
# However, building with full -O3 optimizations takes too long for a debug build.
# Use an -O1 optimization level strikes a good compromise between build and program performance.

View File

@ -67,7 +67,7 @@ from [GitHub Actions](https://actions-badge.atrox.dev/iceiix/stevenarella/goto?r
## Dependencies
Requires Rust stable version 1.49.0 or newer.
Requires Rust stable version 1.53.0 or newer.
**Debian/Ubuntu**

View File

@ -5883,47 +5883,53 @@ mod tests {
}
fn can_burn<W: WorldAccess>(world: &W, pos: Position) -> bool {
matches!(world.get_block(pos), Block::Planks { .. }
| Block::DoubleWoodenSlab { .. }
| Block::WoodenSlab { .. }
| Block::FenceGate { .. }
| Block::SpruceFenceGate { .. }
| Block::BirchFenceGate { .. }
| Block::JungleFenceGate { .. }
| Block::DarkOakFenceGate { .. }
| Block::AcaciaFenceGate { .. }
| Block::Fence { .. }
| Block::SpruceFence { .. }
| Block::BirchFence { .. }
| Block::JungleFence { .. }
| Block::DarkOakFence { .. }
| Block::AcaciaFence { .. }
| Block::OakStairs { .. }
| Block::BirchStairs { .. }
| Block::SpruceStairs { .. }
| Block::JungleStairs { .. }
| Block::AcaciaStairs { .. }
| Block::DarkOakStairs { .. }
| Block::Log { .. }
| Block::Log2 { .. }
| Block::Leaves { .. }
| Block::Leaves2 { .. }
| Block::BookShelf { .. }
| Block::TNT { .. }
| Block::TallGrass { .. }
| Block::DoublePlant { .. }
| Block::YellowFlower { .. }
| Block::RedFlower { .. }
| Block::DeadBush { .. }
| Block::Wool { .. }
| Block::Vine { .. }
| Block::CoalBlock { .. }
| Block::HayBlock { .. }
| Block::Carpet { .. })
matches!(
world.get_block(pos),
Block::Planks { .. }
| Block::DoubleWoodenSlab { .. }
| Block::WoodenSlab { .. }
| Block::FenceGate { .. }
| Block::SpruceFenceGate { .. }
| Block::BirchFenceGate { .. }
| Block::JungleFenceGate { .. }
| Block::DarkOakFenceGate { .. }
| Block::AcaciaFenceGate { .. }
| Block::Fence { .. }
| Block::SpruceFence { .. }
| Block::BirchFence { .. }
| Block::JungleFence { .. }
| Block::DarkOakFence { .. }
| Block::AcaciaFence { .. }
| Block::OakStairs { .. }
| Block::BirchStairs { .. }
| Block::SpruceStairs { .. }
| Block::JungleStairs { .. }
| Block::AcaciaStairs { .. }
| Block::DarkOakStairs { .. }
| Block::Log { .. }
| Block::Log2 { .. }
| Block::Leaves { .. }
| Block::Leaves2 { .. }
| Block::BookShelf { .. }
| Block::TNT { .. }
| Block::TallGrass { .. }
| Block::DoublePlant { .. }
| Block::YellowFlower { .. }
| Block::RedFlower { .. }
| Block::DeadBush { .. }
| Block::Wool { .. }
| Block::Vine { .. }
| Block::CoalBlock { .. }
| Block::HayBlock { .. }
| Block::Carpet { .. }
)
}
fn is_snowy<W: WorldAccess>(world: &W, pos: Position) -> bool {
matches!(world.get_block(pos.shift(Direction::Up)), Block::Snow { .. } | Block::SnowLayer { .. })
matches!(
world.get_block(pos.shift(Direction::Up)),
Block::Snow { .. } | Block::SnowLayer { .. }
)
}
fn can_connect_sides<F: Fn(Block) -> bool, W: WorldAccess>(
@ -5945,25 +5951,31 @@ fn can_connect<F: Fn(Block) -> bool, W: WorldAccess>(world: &W, pos: Position, f
}
fn can_connect_fence(block: Block) -> bool {
matches!(block, Block::Fence { .. }
| Block::SpruceFence { .. }
| Block::BirchFence { .. }
| Block::JungleFence { .. }
| Block::DarkOakFence { .. }
| Block::AcaciaFence { .. }
| Block::FenceGate { .. }
| Block::SpruceFenceGate { .. }
| Block::BirchFenceGate { .. }
| Block::JungleFenceGate { .. }
| Block::DarkOakFenceGate { .. }
| Block::AcaciaFenceGate { .. })
matches!(
block,
Block::Fence { .. }
| Block::SpruceFence { .. }
| Block::BirchFence { .. }
| Block::JungleFence { .. }
| Block::DarkOakFence { .. }
| Block::AcaciaFence { .. }
| Block::FenceGate { .. }
| Block::SpruceFenceGate { .. }
| Block::BirchFenceGate { .. }
| Block::JungleFenceGate { .. }
| Block::DarkOakFenceGate { .. }
| Block::AcaciaFenceGate { .. }
)
}
fn can_connect_glasspane(block: Block) -> bool {
matches!(block, Block::Glass { .. }
| Block::StainedGlass { .. }
| Block::GlassPane { .. }
| Block::StainedGlassPane { .. })
matches!(
block,
Block::Glass { .. }
| Block::StainedGlass { .. }
| Block::GlassPane { .. }
| Block::StainedGlassPane { .. }
)
}
fn can_connect_redstone<W: WorldAccess>(world: &W, pos: Position, dir: Direction) -> RedstoneSide {
@ -6198,7 +6210,12 @@ fn door_collision(facing: Direction, hinge: Side, open: bool) -> Vec<Aabb3<f64>>
}
fn update_repeater_state<W: WorldAccess>(world: &W, pos: Position, facing: Direction) -> bool {
let f = |dir| matches!(world.get_block(pos.shift(dir)), Block::RepeaterPowered { .. });
let f = |dir| {
matches!(
world.get_block(pos.shift(dir)),
Block::RepeaterPowered { .. }
)
};
f(facing.clockwise()) || f(facing.counter_clockwise())
}

View File

@ -601,8 +601,8 @@ impl ComponentMem {
data: vec![],
component_size: mem::size_of::<T>(),
drop_func: Box::new(|data| unsafe {
let mut val: T = mem::MaybeUninit::uninit().assume_init();
ptr::copy(data as *mut T, &mut val, 1);
let mut val = mem::MaybeUninit::<T>::uninit();
ptr::copy(data as *mut T, val.as_mut_ptr(), 1);
mem::drop(val);
}),
}

View File

@ -491,20 +491,12 @@ impl Program {
pub fn uniform_location(&self, name: &str) -> Option<Uniform> {
let u = unsafe { glow_context().get_uniform_location(self.0, name) };
if let Some(u) = u {
Some(Uniform(u))
} else {
None
}
u.map(Uniform)
}
pub fn attribute_location(&self, name: &str) -> Option<Attribute> {
let a = unsafe { glow_context().get_attrib_location(self.0, name) };
if let Some(a) = a {
Some(Attribute(a as i32))
} else {
None
}
a.map(|a| Attribute(a as i32))
}
}
@ -805,7 +797,7 @@ impl Drop for MappedBuffer {
unsafe {
glow_context().unmap_buffer(self.target);
}
mem::forget(mem::replace(&mut self.inner, Vec::new()));
mem::forget(std::mem::take(&mut self.inner))
}
}

View File

@ -631,53 +631,53 @@ fn handle_window_event<T>(
use winit::event::*;
match event {
Event::MainEventsCleared => return true,
Event::DeviceEvent { event, .. } => {
if let DeviceEvent::MouseMotion {
Event::DeviceEvent {
event: DeviceEvent::MouseMotion {
delta: (xrel, yrel),
} = event
{
let (rx, ry) = if xrel > 1000.0 || yrel > 1000.0 {
// Heuristic for if we were passed an absolute value instead of relative
// Workaround https://github.com/tomaka/glutin/issues/1084 MouseMotion event returns absolute instead of relative values, when running Linux in a VM
// Note SDL2 had a hint to handle this scenario:
// sdl2::hint::set_with_priority("SDL_MOUSE_RELATIVE_MODE_WARP", "1", &sdl2::hint::Hint::Override);
let s = 8000.0 + 0.01;
(
(xrel - game.last_mouse_xrel) / s,
(yrel - game.last_mouse_yrel) / s,
)
} else {
let s = 2000.0 + 0.01;
(xrel / s, yrel / s)
};
},
..
} => {
let (rx, ry) = if xrel > 1000.0 || yrel > 1000.0 {
// Heuristic for if we were passed an absolute value instead of relative
// Workaround https://github.com/tomaka/glutin/issues/1084 MouseMotion event returns absolute instead of relative values, when running Linux in a VM
// Note SDL2 had a hint to handle this scenario:
// sdl2::hint::set_with_priority("SDL_MOUSE_RELATIVE_MODE_WARP", "1", &sdl2::hint::Hint::Override);
let s = 8000.0 + 0.01;
(
(xrel - game.last_mouse_xrel) / s,
(yrel - game.last_mouse_yrel) / s,
)
} else {
let s = 2000.0 + 0.01;
(xrel / s, yrel / s)
};
game.last_mouse_xrel = xrel;
game.last_mouse_yrel = yrel;
game.last_mouse_xrel = xrel;
game.last_mouse_yrel = yrel;
use std::f64::consts::PI;
use std::f64::consts::PI;
if game.focused {
window.set_cursor_grab(true).unwrap();
window.set_cursor_visible(false);
if let Some(player) = game.server.player {
let rotation = game
.server
.entities
.get_component_mut(player, game.server.rotation)
.unwrap();
rotation.yaw -= rx;
rotation.pitch -= ry;
if rotation.pitch < (PI / 2.0) + 0.01 {
rotation.pitch = (PI / 2.0) + 0.01;
}
if rotation.pitch > (PI / 2.0) * 3.0 - 0.01 {
rotation.pitch = (PI / 2.0) * 3.0 - 0.01;
}
if game.focused {
window.set_cursor_grab(true).unwrap();
window.set_cursor_visible(false);
if let Some(player) = game.server.player {
let rotation = game
.server
.entities
.get_component_mut(player, game.server.rotation)
.unwrap();
rotation.yaw -= rx;
rotation.pitch -= ry;
if rotation.pitch < (PI / 2.0) + 0.01 {
rotation.pitch = (PI / 2.0) + 0.01;
}
if rotation.pitch > (PI / 2.0) * 3.0 - 0.01 {
rotation.pitch = (PI / 2.0) * 3.0 - 0.01;
}
} else {
window.set_cursor_grab(false).unwrap();
window.set_cursor_visible(true);
}
} else {
window.set_cursor_grab(false).unwrap();
window.set_cursor_visible(true);
}
}

View File

@ -547,7 +547,7 @@ impl Factory {
ambient_occlusion: raw.ambient_occlusion,
weight: raw.weight,
};
let elements = ::std::mem::replace(&mut raw.elements, vec![]);
let elements = std::mem::take(&mut raw.elements);
for el in elements {
let all_dirs = Direction::all();
for (i, face) in el.faces.iter().enumerate() {

View File

@ -1902,31 +1902,29 @@ impl Server {
}
fn load_block_entities(&mut self, block_entities: Vec<Option<crate::nbt::NamedTag>>) {
for optional_block_entity in block_entities {
if let Some(block_entity) = optional_block_entity {
let x = block_entity.1.get("x").unwrap().as_int().unwrap();
let y = block_entity.1.get("y").unwrap().as_int().unwrap();
let z = block_entity.1.get("z").unwrap().as_int().unwrap();
if let Some(tile_id) = block_entity.1.get("id") {
let tile_id = tile_id.as_str().unwrap();
let action;
match tile_id {
// Fake a sign update
"Sign" => action = 9,
// Not something we care about, so break the loop
_ => continue,
}
self.on_block_entity_update(packet::play::clientbound::UpdateBlockEntity {
location: Position::new(x, y, z),
action,
nbt: Some(block_entity.clone()),
});
} else {
warn!(
"Block entity at ({},{},{}) missing id tag: {:?}",
x, y, z, block_entity
);
for block_entity in block_entities.into_iter().flatten() {
let x = block_entity.1.get("x").unwrap().as_int().unwrap();
let y = block_entity.1.get("y").unwrap().as_int().unwrap();
let z = block_entity.1.get("z").unwrap().as_int().unwrap();
if let Some(tile_id) = block_entity.1.get("id") {
let tile_id = tile_id.as_str().unwrap();
let action;
match tile_id {
// Fake a sign update
"Sign" => action = 9,
// Not something we care about, so break the loop
_ => continue,
}
self.on_block_entity_update(packet::play::clientbound::UpdateBlockEntity {
location: Position::new(x, y, z),
action,
nbt: Some(block_entity.clone()),
});
} else {
warn!(
"Block entity at ({},{},{}) missing id tag: {:?}",
x, y, z, block_entity
);
}
}
}

View File

@ -661,15 +661,12 @@ impl World {
let cpos = CPos(x, z);
{
let chunk = if new {
if new {
self.chunks.insert(cpos, Chunk::new(cpos));
self.chunks.get_mut(&cpos).unwrap()
} else {
if !self.chunks.contains_key(&cpos) {
return Ok(());
}
self.chunks.get_mut(&cpos).unwrap()
};
} else if !self.chunks.contains_key(&cpos) {
return Ok(());
}
let chunk = self.chunks.get_mut(&cpos).unwrap();
for i in 0..16 {
if chunk.sections[i].is_none() {
@ -816,15 +813,12 @@ impl World {
) -> Result<(), protocol::Error> {
let cpos = CPos(x, z);
{
let chunk = if new {
if new {
self.chunks.insert(cpos, Chunk::new(cpos));
self.chunks.get_mut(&cpos).unwrap()
} else {
if !self.chunks.contains_key(&cpos) {
return Ok(());
}
self.chunks.get_mut(&cpos).unwrap()
};
} else if !self.chunks.contains_key(&cpos) {
return Ok(());
}
let chunk = self.chunks.get_mut(&cpos).unwrap();
// Block type array - whole byte per block
let mut block_types = [[0u8; 4096]; 16];
@ -1015,15 +1009,12 @@ impl World {
let cpos = CPos(x, z);
{
let chunk = if new {
if new {
self.chunks.insert(cpos, Chunk::new(cpos));
self.chunks.get_mut(&cpos).unwrap()
} else {
if !self.chunks.contains_key(&cpos) {
return Ok(());
}
self.chunks.get_mut(&cpos).unwrap()
};
} else if !self.chunks.contains_key(&cpos) {
return Ok(());
}
let chunk = self.chunks.get_mut(&cpos).unwrap();
for i in 0..16 {
if chunk.sections[i].is_none() {