Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions crates/bvh-region/src/query/ray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,24 @@ impl<T: Debug> Bvh<T> {
Node::Leaf(elems) => {
// Only a leaf: check all elements directly.
for elem in elems {
if let Some(t) = get_aabb(elem).intersect_ray(&ray) {
if t < closest_t && t.into_inner() >= 0.0 {
if let Some(t) = get_aabb(elem).intersect_ray(&ray)
&& t < closest_t && t.into_inner() >= 0.0 {
closest_t = t;
closest_elem = Some(elem);
}
}
}
}
Node::Internal(internal) => {
let mut heap: BinaryHeap<_> = BinaryHeap::new();

// Check if the ray hits the root node's AABB
if let Some(t) = internal.aabb.intersect_ray(&ray) {
if t.into_inner() >= 0.0 {
if let Some(t) = internal.aabb.intersect_ray(&ray)
&& t.into_inner() >= 0.0 {
heap.push(Reverse(NodeOrd {
node: internal,
by: t,
}));
}
}

while let Some(Reverse(current)) = heap.pop() {
let node = current.node;
Expand All @@ -57,23 +55,21 @@ impl<T: Debug> Bvh<T> {
for child in node.children(self) {
match child {
Node::Internal(child_node) => {
if let Some(t) = child_node.aabb.intersect_ray(&ray) {
if t < closest_t && t.into_inner() >= 0.0 {
if let Some(t) = child_node.aabb.intersect_ray(&ray)
&& t < closest_t && t.into_inner() >= 0.0 {
heap.push(Reverse(NodeOrd {
node: child_node,
by: t,
}));
}
}
}
Node::Leaf(elems) => {
for elem in elems {
if let Some(t) = get_aabb(elem).intersect_ray(&ray) {
if t < closest_t && t.into_inner() >= 0.0 {
if let Some(t) = get_aabb(elem).intersect_ray(&ray)
&& t < closest_t && t.into_inner() >= 0.0 {
closest_t = t;
closest_elem = Some(elem);
}
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/geometry/src/aabb.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::manual_midpoint)]

use std::{
fmt::{Debug, Display},
ops::Add,
Expand Down
10 changes: 4 additions & 6 deletions crates/hyperion-clap-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,18 @@ pub fn derive_command_permission(input: TokenStream) -> TokenStream {
// Extract the group from the `#[command_permission(group = "Admin")]` attribute
let mut group = None;
for attr in &input.attrs {
if attr.path().is_ident("command_permission") {
if let Err(err) = attr.parse_nested_meta(|meta| {
if meta.path.is_ident("group") {
if let Ok(Lit::Str(lit)) = meta.value()?.parse::<Lit>() {
if attr.path().is_ident("command_permission")
&& let Err(err) = attr.parse_nested_meta(|meta| {
if meta.path.is_ident("group")
&& let Ok(Lit::Str(lit)) = meta.value()?.parse::<Lit>() {
group = Some(lit);
}
}
Ok(())
}) {
return Error::new_spanned(attr, format!("Failed to parse attribute: {err}"))
.to_compile_error()
.into();
}
}
}

let group_ident = match group {
Expand Down
8 changes: 4 additions & 4 deletions crates/hyperion-inventory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,12 @@ impl PlayerInventory {
stack.item
});

let result = registry


registry
.get_result_2x2(items)
.cloned()
.unwrap_or(ItemStack::EMPTY);

result
.unwrap_or(ItemStack::EMPTY)
}

#[must_use]
Expand Down
5 changes: 2 additions & 3 deletions crates/hyperion-item/src/builder/book.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ impl BookBuilder {
let page = page.into();
let json = format!(r#"{{"text":"{page}"}}"#);

if let Some(nbt) = &mut self.item.nbt {
if let nbt::Value::List(nbt::List::String(pages)) = nbt.get_mut("pages").unwrap() {
if let Some(nbt) = &mut self.item.nbt
&& let nbt::Value::List(nbt::List::String(pages)) = nbt.get_mut("pages").unwrap() {
pages.push(json);
}
}

self
}
Expand Down
2 changes: 2 additions & 0 deletions crates/hyperion-proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#![feature(never_type)]
#![feature(stmt_expr_attributes)]
#![feature(gen_blocks)]
#![expect(incomplete_features, reason = "generic_const_exprs")]
#![feature(generic_const_exprs)]
#![allow(
clippy::redundant_pub_crate,
clippy::cast_possible_truncation,
Expand Down
2 changes: 1 addition & 1 deletion crates/hyperion-utils/src/cached_save.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn cached_save<U: reqwest::IntoUrl + 'static>(
// Convert the byte stream into an AsyncRead

let reader = StreamReader::new(byte_stream.map(|result| {
result.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))
result.map_err(std::io::Error::other)
}));

let directory = directory.clone();
Expand Down
5 changes: 2 additions & 3 deletions crates/hyperion/src/common/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ impl Config {
info!("configuration file not found, using defaults");

// make required folders
if let Some(parent) = path.as_ref().parent() {
if let Err(e) = std::fs::create_dir_all(parent) {
if let Some(parent) = path.as_ref().parent()
&& let Err(e) = std::fs::create_dir_all(parent) {
// this might happen on a read-only filesystem (i.e.,
// when running on a CI, profiling in Instruments, etc.)
warn!(
Expand All @@ -87,7 +87,6 @@ impl Config {
);
return Ok(Self::default());
}
}

// write default config to file
let default_config = Self::default();
Expand Down
5 changes: 3 additions & 2 deletions crates/hyperion/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#![feature(trivial_bounds)]
#![feature(pointer_is_aligned_to)]
#![feature(thread_local)]
#![feature(duration_constructors_lite)]

pub const CHUNK_HEIGHT_SPAN: u32 = 384; // 512; // usually 384

Expand Down Expand Up @@ -96,7 +97,7 @@ pub fn adjust_file_descriptor_limits(recommended_min: u64) -> std::io::Result<()
rlim_max: 0, // Initialize hard limit to 0
};

if unsafe { getrlimit(RLIMIT_NOFILE, &mut limits) } == 0 {
if unsafe { getrlimit(RLIMIT_NOFILE, &raw mut limits) } == 0 {
// Create a stack-allocated buffer...

info!("current soft limit: {}", limits.rlim_cur);
Expand All @@ -117,7 +118,7 @@ pub fn adjust_file_descriptor_limits(recommended_min: u64) -> std::io::Result<()

info!("setting soft limit to: {}", limits.rlim_cur);

if unsafe { setrlimit(RLIMIT_NOFILE, &limits) } != 0 {
if unsafe { setrlimit(RLIMIT_NOFILE, &raw const limits) } != 0 {
error!("Failed to set the file handle limits");
return Err(std::io::Error::last_os_error());
}
Expand Down
7 changes: 3 additions & 4 deletions crates/hyperion/src/simulation/blocks/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,18 @@ impl RegionManagerTask {
}

async fn get_or_create_region(&mut self, coord: IVec2) -> std::io::Result<Arc<Region>> {
if let Some(region) = self.regions.get(&coord) {
if let Some(region) = region.upgrade() {
if let Some(region) = self.regions.get(&coord)
&& let Some(region) = region.upgrade() {
return Ok(region);
}
}

self.create_and_insert_region(coord).await
}

async fn create_and_insert_region(&mut self, coord: IVec2) -> std::io::Result<Arc<Region>> {
let file = self.region_file(coord.x, coord.y).await?;
let region =
Region::open(&file).map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
Region::open(&file).map_err(std::io::Error::other)?;
let region = Arc::new(region);
let region_weak = Arc::downgrade(&region);
self.regions.insert(coord, region_weak);
Expand Down
2 changes: 1 addition & 1 deletion crates/hyperion/src/simulation/metadata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ macro_rules! define_and_register_components {

impl MetadataChanges {
#[must_use]
pub fn is_empty(&self) -> bool {
pub const fn is_empty(&self) -> bool {
self.0.is_empty()
}

Expand Down
6 changes: 2 additions & 4 deletions crates/hyperion/src/storage/buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ unsafe impl Buf for bytes::BytesMut {
// self
self.reserve(len);
let cap = self.spare_capacity_mut();
let cap = unsafe { cap.assume_init_mut() };
cap
(unsafe { cap.assume_init_mut() }) as _
}

fn advance(&mut self, len: usize) -> Self::Output {
Expand All @@ -42,8 +41,7 @@ unsafe impl Buf for Vec<u8> {
// self
self.reserve(len);
let cap = self.spare_capacity_mut();
let cap = unsafe { cap.assume_init_mut() };
cap
(unsafe { cap.assume_init_mut() }) as _
}

fn advance(&mut self, len: usize) -> Self::Output {
Expand Down
1 change: 0 additions & 1 deletion crates/simd-utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![feature(portable_simd)]
#![feature(trusted_len)]
#![feature(slice_as_chunks)]
#![feature(pointer_is_aligned_to)]

use core::simd;
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "nightly-2025-02-22"
channel = "nightly-2025-06-26"
components = ["rustfmt", "clippy"]
profile = "minimal"
5 changes: 2 additions & 3 deletions tools/packet-inspector/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,10 @@ impl GuiApp {
// Persistent Storage
let mut shared_state = SharedState::new(ctx);

if let Some(storage) = cc.storage {
if let Some(value) = eframe::get_value::<SharedState>(storage, eframe::APP_KEY) {
if let Some(storage) = cc.storage
&& let Some(value) = eframe::get_value::<SharedState>(storage, eframe::APP_KEY) {
shared_state = value.merge(shared_state);
}
}

let autostart = shared_state.autostart;
let shared_state = Arc::new(RwLock::new(shared_state));
Expand Down
5 changes: 2 additions & 3 deletions tools/packet-inspector/src/app/packet_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,10 @@ fn draw_packet_list(state: &mut SharedState, ui: &mut Ui) {
.stick_to_bottom(!state.update_scroll)
.show(ui, |ui| {
for (i, packet) in packets.iter().enumerate() {
if let Some(filtered) = state.packet_filter.get(packet) {
if !filtered {
if let Some(filtered) = state.packet_filter.get(packet)
&& !filtered {
continue;
}
}

let selected = { state.selected_packet == Some(i) };

Expand Down
5 changes: 2 additions & 3 deletions tools/packet-inspector/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,13 @@ impl Proxy {
.process(PacketSide::Serverbound, state, threshold, &packet)
.await?;

if state == PacketState::Handshaking {
if let Some(handshake) = extrapolate_packet::<HandshakeC2s<'_>>(&packet) {
if state == PacketState::Handshaking
&& let Some(handshake) = extrapolate_packet::<HandshakeC2s<'_>>(&packet) {
*state_lock.write().await = match handshake.next_state {
HandshakeNextState::Status => PacketState::Status,
HandshakeNextState::Login => PacketState::Login,
};
}
}

server_writer.send_packet_raw(&packet).await?;
}
Expand Down
2 changes: 2 additions & 0 deletions tools/rust-mc-bot/src/packet_utils.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::manual_abs_diff)]

use std::{convert::TryInto, io, io::Write, mem};

pub struct Buf {
Expand Down
Loading