aboutsummaryrefslogtreecommitdiff
path: root/azalea
diff options
context:
space:
mode:
Diffstat (limited to 'azalea')
-rw-r--r--azalea/build.rs11
-rw-r--r--azalea/src/pathfinder/mod.rs12
2 files changed, 22 insertions, 1 deletions
diff --git a/azalea/build.rs b/azalea/build.rs
index faed1365..9dd6b738 100644
--- a/azalea/build.rs
+++ b/azalea/build.rs
@@ -1,6 +1,17 @@
use std::{env, process::Command};
fn main() {
+ check_nightly();
+
+ // save the optimization level, used by the pathfinder to warn if optimizations
+ // are off
+ println!(
+ "cargo::rustc-env=OPT_LEVEL={}",
+ env::var("OPT_LEVEL").unwrap()
+ );
+}
+
+fn check_nightly() {
// If using `rustup`, check the toolchain via `RUSTUP_TOOLCHAIN`
if let Ok(toolchain) = env::var("RUSTUP_TOOLCHAIN") {
if toolchain.contains("nightly") {
diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs
index 8df04b14..6f1a0d8a 100644
--- a/azalea/src/pathfinder/mod.rs
+++ b/azalea/src/pathfinder/mod.rs
@@ -32,7 +32,7 @@ use std::{
collections::VecDeque,
sync::{
Arc,
- atomic::{self, AtomicUsize},
+ atomic::{self, AtomicBool, AtomicUsize},
},
thread,
time::{Duration, Instant},
@@ -306,6 +306,16 @@ pub fn goto_listener(
continue;
};
+ // this env variable is set from the build.rs
+ if env!("OPT_LEVEL") == "0" {
+ static WARNED: AtomicBool = AtomicBool::new(false);
+ if !WARNED.swap(true, atomic::Ordering::Relaxed) {
+ warn!(
+ "Azalea was compiled with no optimizations, which may result in significantly reduced pathfinding performance. Consider following the steps at https://azalea.matdoes.dev/azalea/#optimization for faster performance in debug mode."
+ )
+ }
+ }
+
let cur_pos = player_pos_to_block_pos(**position);
if event.goal.success(cur_pos) {