From 927e29bb43f48b569c24753240147a0cc481d836 Mon Sep 17 00:00:00 2001 From: Kyler <59854022+KylerOlsen@users.noreply.github.com> Date: Tue, 23 Jan 2024 20:32:20 -0700 Subject: [PATCH] Changed test blocking parity from static mut: bool to static: AtomicBool --- src/login_handle.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/login_handle.rs b/src/login_handle.rs index b91cbc7..6d08b7a 100644 --- a/src/login_handle.rs +++ b/src/login_handle.rs @@ -1,5 +1,6 @@ // Yeahbut December 2023 +use core::sync::atomic::{AtomicBool, Ordering}; use tokio::net::tcp::{OwnedReadHalf, OwnedWriteHalf}; use purple_cello_mc_protocol::{ @@ -19,13 +20,12 @@ enum PlayerAllowed { } fn check_player(player: Player) -> Result { - static mut PARITY: bool = true; + static PARITY: AtomicBool = AtomicBool::new(true); let parity: bool; - unsafe { - parity = PARITY; - PARITY = !PARITY; - } - if parity { //player.name.to_lowercase() == "yeahbut" { + parity = PARITY.load(Ordering::Relaxed); + PARITY.store(!parity, Ordering::Relaxed); + if parity { + // if player.name.to_lowercase() == "yeahbut" { Ok(PlayerAllowed::True(player)) } else { Ok(PlayerAllowed::False("Testing blocking, try again.".to_string()))