Skip to content

Commit

Permalink
Removed more warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanpoland committed Dec 21, 2024
1 parent 7fe2694 commit 5aa26fc
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 43 deletions.
17 changes: 8 additions & 9 deletions backend_api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn main() {
}

// Update individual backend Cargo.toml files if they have .allow-imports
if let Err(e) = update_backend_cargo_tomls(&plugins_dir, &plugin_paths, &backends_dir, &backend_paths) {
if let Err(e) = update_backend_cargo_tomls(&plugin_paths, &backends_dir, &backend_paths) {
println!("cargo:warning=Failed to update backend Cargo.toml files: {}", e);
std::process::exit(1);
}
Expand Down Expand Up @@ -167,6 +167,7 @@ fn discover_backends(backends_dir: &Path) -> Vec<BackendInfo> {
const AUTO_GENERATED_START: &str = "###### BEGIN AUTO-GENERATED BACKEND DEPENDENCIES - DO NOT EDIT THIS SECTION ######";
const AUTO_GENERATED_END: &str = "###### END AUTO-GENERATED BACKEND DEPENDENCIES ######";


fn update_cargo_toml(backend_paths: &[BackendInfo]) -> std::io::Result<()> {
let cargo_path = "Cargo.toml";
let mut contents = String::new();
Expand All @@ -175,10 +176,9 @@ fn update_cargo_toml(backend_paths: &[BackendInfo]) -> std::io::Result<()> {
contents = contents.replace("\r\n", "\n");

let start_idx = contents.find(AUTO_GENERATED_START);
let end_idx = contents.find(AUTO_GENERATED_END);

let base_contents = match (start_idx, end_idx) {
(Some(start), Some(end)) => {
let base_contents = match start_idx {
Some(start) => {
contents[..start].trim_end().to_string()
}
_ => {
Expand Down Expand Up @@ -215,12 +215,12 @@ fn update_cargo_toml(backend_paths: &[BackendInfo]) -> std::io::Result<()> {
Ok(())
}

fn update_backend_cargo_tomls(plugins_dir: &Path, plugin_paths: &[PluginInfo], backends_dir: &Path, backend_paths: &[BackendInfo]) -> std::io::Result<()> {
fn update_backend_cargo_tomls(plugin_paths: &[PluginInfo], backends_dir: &Path, backend_paths: &[BackendInfo]) -> std::io::Result<()> {
println!("cargo:warning=Starting update_backend_cargo_tomls");
println!("cargo:warning=Found {} plugins and {} backends", plugin_paths.len(), backend_paths.len());

// Update each backend Cargo.toml if it has .allow-imports
for (name, version, backend_dir, has_allow) in backend_paths.iter() {
for (name, _, backend_dir, has_allow) in backend_paths.iter() {
println!("cargo:warning=Checking backend {} (allow_imports: {})", name, has_allow);

if !*has_allow {
Expand Down Expand Up @@ -257,8 +257,8 @@ fn update_backend_cargo_tomls(plugins_dir: &Path, plugin_paths: &[PluginInfo], b

println!("cargo:warning=Found markers in file: start={:?}, end={:?}", start_idx.is_some(), end_idx.is_some());

let base_contents = match (start_idx, end_idx) {
(Some(start), Some(end)) => {
let base_contents = match start_idx {
Some(start) => {
contents[..start].trim_end().to_string()
}
_ => {
Expand Down Expand Up @@ -316,7 +316,6 @@ fn generate_imports_file(backend_paths: &[BackendInfo], out_dir: &Path) -> std::

writeln!(file, "// This file is automatically generated by build.rs")?;
writeln!(file, "// Do not edit this file manually!\n")?;
writeln!(file, "use horizon_plugin_api::{{Pluginstate, LoadedPlugin, Plugin}};")?;
writeln!(file, "use std::collections::HashMap;\n")?;

for (name, _, _, _) in backend_paths {
Expand Down
1 change: 0 additions & 1 deletion backend_api/src/backend_imports.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// This file is automatically generated by build.rs
// Do not edit this file manually!

use horizon_plugin_api::{Pluginstate, LoadedPlugin, Plugin};
use std::collections::HashMap;

pub use stars_beyond;
Expand Down
7 changes: 0 additions & 7 deletions backend_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ pub use horizon_plugin_api::{Plugin, Pluginstate, Version, get_plugin, LoadedPlu
pub mod plugin_macro;
pub mod backend_imports;

// Define the current plugin version
const PLUGIN_API_VERSION: Version = Version {
major: 0,
minor: 1,
hotfix: 0
};

#[derive(Clone)]
pub struct PluginManager {
plugins: HashMap<String,(Pluginstate,Plugin)>
Expand Down
6 changes: 3 additions & 3 deletions backends/stars_beyond/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use horizon_data_types::Player;
use socketioxide::extract::SocketRef;
pub use horizon_plugin_api::{Plugin, Pluginstate, LoadedPlugin};
use socketioxide::packet::Str;
use parking_lot::RwLock;
use std::sync::Arc;
use std::collections::HashMap;
// use socketioxide::packet::Str;

pub trait PluginAPI {
fn player_joined(&self, socket: SocketRef, player: Arc<RwLock<horizon_data_types::Player>>);
Expand All @@ -18,7 +18,7 @@ pub trait PluginConstruct {
}

impl PluginConstruct for Plugin {
fn new(plugins: HashMap<String, (Pluginstate, Plugin)>) -> Plugin {
fn new(_plugins: HashMap<String, (Pluginstate, Plugin)>) -> Plugin {
Plugin {}
}

Expand All @@ -35,5 +35,5 @@ impl PluginAPI for Plugin {
}


fn setup_listeners(socket: SocketRef, player: Arc<RwLock<Player>>) {
fn setup_listeners(_socket: SocketRef, _player: Arc<RwLock<Player>>) {
}
4 changes: 2 additions & 2 deletions plugin_api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ fn update_plugin_cargo_tomls(plugins_dir: &Path, plugin_paths: &[PluginInfo]) ->
.collect();

// Update each plugin that has .allow-imports
for (name, version, plugin_dir, has_allow) in plugin_paths {
for (name, _, plugin_dir, has_allow) in plugin_paths {
if !has_allow {
continue;
}
Expand All @@ -171,7 +171,7 @@ fn update_plugin_cargo_tomls(plugins_dir: &Path, plugin_paths: &[PluginInfo]) ->
let end_idx = contents.find(AUTO_GENERATED_END);

let base_contents = match (start_idx, end_idx) {
(Some(start), Some(end)) => {
(Some(start), Some(_)) => {
contents[..start].trim_end().to_string()
}
_ => {
Expand Down
1 change: 1 addition & 0 deletions server/src/server/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub struct ServerConfig {
pub num_thread_pools: u32,
}

#[allow(dead_code)]
impl ServerConfig {
fn new() -> Self {
Self {
Expand Down
23 changes: 2 additions & 21 deletions server/src/server/event_rep/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use uuid::Uuid;
use rayon::prelude::*;
use horizon_data_types::Vec3D;


Expand All @@ -15,6 +14,7 @@ struct Actor {
replication_distance: f64,
}

#[allow(dead_code, unused_variables)]
impl Actor {
fn new(name: &str, has_collision: bool) -> Self {
Self {
Expand All @@ -38,26 +38,7 @@ impl Actor {
}
}

fn main() {
let actors = vec![
Actor::new("Actor1", true),
Actor::new("Actor2", false),
Actor::new("Actor3", true),
// Add more actors as needed
];

let collidable_actors: Vec<&Actor> = actors.iter().filter(|actor| actor.has_collision).collect();

collidable_actors.par_iter().enumerate().for_each(|(i, actor1)| {
collidable_actors.iter().skip(i + 1).for_each(|actor2| {
if actor1.check_collision(actor2) {
println!("Collision detected between {} and {}", actor1.name, actor2.name);
}
});
});
}


#[allow(dead_code, unused_variables, unused_mut)]
fn get_overlapping_colissions(main_actor: Actor, actors: Vec<Actor>) -> Vec<Uuid> {
let mut overlapping_collisions = Vec::new();

Expand Down

0 comments on commit 5aa26fc

Please sign in to comment.