Skip to content
This repository has been archived by the owner on Dec 24, 2024. It is now read-only.

Commit

Permalink
feat: update dependencies / fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgazelka committed Oct 19, 2023
1 parent 8fae23a commit 4acd675
Show file tree
Hide file tree
Showing 20 changed files with 180 additions and 136 deletions.
176 changes: 103 additions & 73 deletions Cargo.lock

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ homepage = "https://github.com/andrewgazelka/SwarmBot"
[dependencies]

# parsing arguments
clap = { version = "4.0.32", features = ["derive"] }
clap = { version = "4.4.6", features = ["derive"] }

# reading from csv
csv = "1.1"
csv = "1.3"

# serialization, deserialization
serde = { version = "1.0", features = ["derive"] }
Expand All @@ -26,7 +26,7 @@ serde = { version = "1.0", features = ["derive"] }
tokio-socks = "0.5"

# tokio
tokio = { version = "1.24", features = [
tokio = { version = "1.33", features = [
"rt",
"io-std",
"io-util",
Expand All @@ -47,10 +47,10 @@ flate2 = { version = "1.0", features = [
], default-features = false }

# get_u8, etc extensions
bytes = "1.1"
bytes = "1.5"

# threads
rayon = "1.5"
rayon = "1.8"

# mojang https api
reqwest = { version = "0.11", features = ["json", "socks"] }
Expand All @@ -72,28 +72,28 @@ sha1 = "0.10"
serde_json = "1.0"

# quite a few uses
itertools = "0.10"
itertools = "0.11"

# for data storage

# chat parsing
regex = "1.5"
regex = "1.10"

# efficient hashmap
indexmap = { version = "1.7", features = ["std"] }
indexmap = { version = "2.0", features = ["std"] }

float-ord = "0.3"

# for num casting
num = "0.4"

# for printing stuff out
crossterm = "0.25"
crossterm = "0.27"

colored = "2.0"

# for small stack-allocated arrays
smallvec = { version = "1.7", features = ["const_generics"] }
smallvec = { version = "1.11", features = ["const_generics"] }

# for parsing nbt
hematite-nbt = "0.5"
Expand All @@ -107,13 +107,13 @@ tokio-tungstenite = "0.20.1"
futures = "0.3"

interfaces = { package = "swarmbot-interfaces", path = "interfaces", version = "0.1.2" }
anyhow = "1.0.68"
bincode = "2.0.0-alpha.2"
hex-literal = "0.3.4"
anyhow = "1.0.75"
bincode = "2.0.0-rc.3"
hex-literal = "0.4.1"
cfb8 = "0.7"
tokio-stream = "0.1.11"
tokio-stream = "0.1.14"
once_cell = { version = "1.18.0", features = ["parking_lot"] }
async-trait = "0.1.68"
async-trait = "0.1.74"
tungstenite = "0.20.1"

[dev-dependencies]
Expand Down
8 changes: 4 additions & 4 deletions interfaces/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ serde = { version = "1.0", features = ["derive"] }

tokio-tungstenite = "0.20.1"
tungstenite = "0.20.1"
tokio = { version = "1.24", features = [
tokio = { version = "1.33", features = [
"rt",
"io-std",
"io-util",
Expand All @@ -28,8 +28,8 @@ swarm-bot-packets = { path = "../packets", version = "0.2.0" }
colored = "2.0"

# chat parsing
regex = "1.5"
regex = "1.10"

itertools = "0.10.3"
num = "0.4.0"
itertools = "0.11.0"
num = "0.4.1"
once_cell = { version = "1.18.0", features = ["parking_lot"] }
4 changes: 2 additions & 2 deletions packets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ license = "MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bytes = "1.0"
bytes = "1.5"
swarm-bot-packets-macro = { path = "packets_macro", version = "0.1.2" } # from a path in the local filesystem
tokio = { version = "1.24", features = ["full"] }
tokio = { version = "1.33", features = ["full"] }
6 changes: 3 additions & 3 deletions packets/packets_macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ license = "GPL-2.0-or-later"


[dependencies]
syn = { version = "1.0.57", features = ["full", "fold"] }
quote = "1.0.8"
proc-macro2 = "1.0.27"
syn = { version = "2.0.38", features = ["full", "fold"] }
quote = "1.0.33"
proc-macro2 = "1.0.69"

[lib]
proc-macro = true
32 changes: 18 additions & 14 deletions packets/packets_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@ use proc_macro::TokenStream;
use quote::quote;
use syn::{
parse::{Parse, ParseStream},
parse_macro_input, DeriveInput, ItemEnum, ItemStruct, Token,
parse_macro_input, DeriveInput, ItemEnum, ItemStruct, Meta, Token,
};

struct MyParams(syn::LitInt, syn::Ident);
struct PacketParams(syn::LitInt, syn::Ident);

impl Parse for MyParams {
impl Parse for PacketParams {
fn parse(input: ParseStream) -> syn::Result<Self> {
let content;
syn::parenthesized!(content in input);
let type1 = content.parse()?;
content.parse::<Token![,]>()?;
let type2 = content.parse()?;
Ok(MyParams(type1, type2))
let type1 = input.parse()?;
input.parse::<Token![,]>()?;
let type2 = input.parse()?;
Ok(PacketParams(type1, type2))
}
}

Expand All @@ -24,16 +22,22 @@ impl Parse for MyParams {
pub fn packet(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput);

let packe_attr = input
let packet_attr = input
.attrs
.iter()
.find(|attr| attr.path.is_ident("packet"))
.expect("need packet attibute");
.find(|attr| attr.path().is_ident("packet"))
.expect("need packet attribute");

let name = input.ident;

let MyParams(id, kind) =
syn::parse(packe_attr.tokens.clone().into()).expect("Invalid attributes!");
// let tokens = packet_attr.to_token_stream();
let Meta::List(meta) = &packet_attr.meta else {
panic!("Invalid attributes!");
};

let tokens = meta.tokens.clone();

let PacketParams(id, kind) = syn::parse(tokens.into()).expect("Invalid attributes!");

let expanded = quote! {

Expand Down
1 change: 0 additions & 1 deletion src/bootstrap/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ impl UserCache {
access_id: res.access_token,
client_id: res.client_token,
};
let valid_user = valid_user;
self.cache
.insert(valid_user.email.clone(), User::Valid(valid_user.clone()));
Some((mojang, proxy, valid_user))
Expand Down
8 changes: 6 additions & 2 deletions src/client/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ async fn command_receiver(
Err(_e) => continue 'wloop,
};

let Value::Object(map) = &mut v else { bail!("invalid value") };
let Value::Object(map) = &mut v else {
bail!("invalid value")
};

let Value::String(path) = map.remove("path").expect("no path elem") else { bail!("invalid path") };
let Value::String(path) = map.remove("path").expect("no path elem") else {
bail!("invalid path")
};

let command = process(&path, v).expect("invalid command");
tx.send(command).unwrap();
Expand Down
4 changes: 3 additions & 1 deletion src/client/follow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ impl Follower {
/// Generally paths will converge within maximally 3 or 4 blocks
const ITERS_UNTIL_FAIL: usize = 100;

let Some(other) = Self::new(result) else { return };
let Some(other) = Self::new(result) else {
return;
};

let on = self.xs.front();

Expand Down
12 changes: 8 additions & 4 deletions src/client/pathfind/incremental/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ struct AStarState<T: Node> {

/// Takes ownership of all nodes and returns a path ending at `goal_idx` which
/// will start at a starting idx determined by tracing `parent_map`
/// HashMap<idx,idx> until there is no parent (i.e., the root node). This is the
/// most efficient path, so there should be no circles assuming non-negative
/// `HashMap<idx,idx>` until there is no parent (i.e., the root node). This is
/// the most efficient path, so there should be no circles assuming non-negative
/// weights.
fn reconstruct_path<T: Clone>(
vec: &[T],
Expand Down Expand Up @@ -245,7 +245,9 @@ impl<T: Node> AStar<T> {
) -> Increment<PathResult<T::Record>> {
// obtain the state. If we have already finished the state is Option as we did
// Option#take(..). We should not ever call this in that state.
let Some(state) = self.state.as_mut() else { panic!("called after finished") };
let Some(state) = self.state.as_mut() else {
panic!("called after finished")
};

if let Some(node) = state.open_set.pop() {
let parent = node.contents;
Expand All @@ -260,7 +262,9 @@ impl<T: Node> AStar<T> {
return Increment::Finished(PathResult::complete(path));
}

let Progression::Movements(neighbors) = progressor.progressions(&parent) else { return Increment::InProgress };
let Progression::Movements(neighbors) = progressor.progressions(&parent) else {
return Increment::InProgress;
};

let parent_record = parent.get_record();
let parent_record_idx = state.record_to_idx[&parent_record];
Expand Down
4 changes: 2 additions & 2 deletions src/client/pathfind/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ impl<T: Clone, C: Clone + PartialOrd + PartialEq> Clone for MinHeapNode<T, C> {

impl<T, C: PartialOrd + PartialEq> Ord for MinHeapNode<T, C> {
fn cmp(&self, other: &Self) -> Ordering {
self.partial_cmp(other).unwrap_or(Ordering::Equal)
other.score.partial_cmp(&self.score).unwrap()
}
}

impl<T, C: PartialOrd + PartialEq> PartialOrd for MinHeapNode<T, C> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
other.score.partial_cmp(&self.score)
Some(self.cmp(other))
}
}

Expand Down
1 change: 0 additions & 1 deletion src/client/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ impl<T: Minecraft + 'static> Runner<T> {
// Safety:
// TODO
let global_state = unsafe { global_state_sync.state() };
let states_sync = states_sync;
rayon::scope(|s| {
for state_sync in states_sync {
let (state, actions) = state_sync.0;
Expand Down
4 changes: 3 additions & 1 deletion src/client/tasks/lazy_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ impl<T: TaskStream> TaskTrait for LazyStream<T> {
}

fn expensive(&mut self, end_by: Instant, local: &mut LocalState, global: &GlobalState) {
let Some(current) = self.current.as_mut() else { return };
let Some(current) = self.current.as_mut() else {
return;
};
current.expensive(end_by, local, global);
}
}
4 changes: 3 additions & 1 deletion src/client/tasks/navigate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ impl<H: Heuristic + Send + Sync, G: GoalCheck + Send + Sync> TaskTrait for Navig
local: &mut LocalState,
global: &mut GlobalState,
) -> bool {
let Some(follower) = self.follower.as_mut() else { return false };
let Some(follower) = self.follower.as_mut() else {
return false;
};

if follower.should_recalc() {
println!("recalc");
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn main() {
local.block_on(&rt, async move {
match run().await {
// this should never happen as this should be an infinite loop
Ok(_) => println!("Program exited without errors somehow"),
Ok(()) => println!("Program exited without errors somehow"),

// print the error in non-debug fashion
Err(err) => println!("{err:?}"),
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/io/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl AsyncRead for EncryptedReader {
buf: &mut ReadBuf<'_>,
) -> Poll<std::io::Result<()>> {
let filled_before = buf.filled().len();
Pin::new(&mut self.reader).poll_read(cx, buf).map_ok(|_| {
Pin::new(&mut self.reader).poll_read(cx, buf).map_ok(|()| {
let filled_after = buf.filled().len();

let to_encrypt = &mut buf.filled_mut()[filled_before..filled_after];
Expand Down
6 changes: 0 additions & 6 deletions src/storage/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,6 @@ impl WorldBlocks {
let x = (x - (chunk_x << 4)) as u8;
let z = (z - (chunk_z << 4)) as u8;

let chunk_x = chunk_x;
let chunk_z = chunk_z;

let loc = ChunkLocation(chunk_x, chunk_z);
let column = self.storage.get(&loc)?;

Expand Down Expand Up @@ -294,9 +291,6 @@ impl WorldBlocks {
let x = (x - (chunk_x << 4)) as u8;
let z = (z - (chunk_z << 4)) as u8;

let chunk_x = chunk_x;
let chunk_z = chunk_z;

let loc = ChunkLocation(chunk_x, chunk_z);

let column = self.storage.entry(loc).or_default();
Expand Down
4 changes: 3 additions & 1 deletion src/storage/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ impl ChunkData<HighMemoryChunkSection> {
let chunk_y = y - (section_idx << 4);

let mut res = [BlockState::AIR; 16 * 16];
let Some(section) = self.sections[section_idx as usize].as_ref() else { return res };
let Some(section) = self.sections[section_idx as usize].as_ref() else {
return res;
};

let mut idx = 0;

Expand Down
4 changes: 3 additions & 1 deletion src/storage/entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ pub struct WorldEntities {

impl WorldEntities {
pub fn update_entity(&mut self, entity_id: u32, bot_id: u32, location: LocationOrigin) {
let Some(entity) = self.entities.get_mut(&entity_id) else { return };
let Some(entity) = self.entities.get_mut(&entity_id) else {
return;
};
let id = entity.owner.get_or_insert(bot_id);
if *id == bot_id {
entity.location.apply_change(location);
Expand Down
4 changes: 2 additions & 2 deletions swarmbot-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition = "2021"

[dependencies]
swarmbot-interfaces = { path = "../interfaces" }
clap = { version = "4.1.1" , features = ["derive"]}
clap = { version = "4.4.6" , features = ["derive"]}
serde = "1.0"
tokio-tungstenite = "0.20.1"
tokio = { version = "1.24.1" , features = ["full"] }
tokio = { version = "1.33.0" , features = ["full"] }
anyhow = "1.0"
futures = "0.3"
serde_json = "1.0"

0 comments on commit 4acd675

Please sign in to comment.