Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanpoland committed Dec 21, 2024
1 parent 1e050b3 commit 7fe2694
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 28 deletions.
8 changes: 3 additions & 5 deletions plugin_api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,12 @@ fn update_cargo_toml(plugin_paths: &[PluginInfo]) -> 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()
}
_ => {
None => {
contents.trim_end().to_string()
}
};
Expand Down Expand Up @@ -222,7 +221,6 @@ fn generate_imports_file(plugin_paths: &[PluginInfo], out_dir: &Path) -> std::io

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 plugin_paths {
Expand Down
7 changes: 0 additions & 7 deletions plugin_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 plugin_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
1 change: 0 additions & 1 deletion plugin_api/src/plugin_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 chronos_plugin;
Expand Down
2 changes: 1 addition & 1 deletion plugins/chronos_plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub trait PluginConstruct {

// Implement constructor for Plugin
impl PluginConstruct for Plugin {
fn new(plugins: HashMap<String, (Pluginstate, Plugin)>) -> Plugin {
fn new(_plugins: HashMap<String, (Pluginstate, Plugin)>) -> Plugin {
Self::start_time_server();
Plugin {}
}
Expand Down
8 changes: 4 additions & 4 deletions plugins/player_lib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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 PebbleVault;
// use socketioxide::packet::Str;
// use PebbleVault;

pub trait PluginAPI {
fn player_joined(&self, socket: SocketRef, player: Arc<RwLock<horizon_data_types::Player>>);
Expand All @@ -19,7 +19,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 Down Expand Up @@ -140,5 +140,5 @@ impl Character {
}
}

fn setup_listeners(socket: SocketRef, player: Arc<RwLock<Player>>) {
fn setup_listeners(_socket: SocketRef, _player: Arc<RwLock<Player>>) {
}
6 changes: 3 additions & 3 deletions server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
static CTRL_C_HANDLER: Once = Once::new();
use std::sync::Once;
use once_cell::sync::Lazy;
use server::{config::server_config, start};
use splash::splash;
use anyhow::{Context, Result};
use horizon_logger::{HorizonLogger, log_info, log_debug, log_warn, log_error, log_critical};
use horizon_logger::{HorizonLogger, log_info};

mod server;
mod splash;
mod collision;
// mod collision;

//------------------------------------------------------------------------------
// Global Logger Configuration
Expand Down
1 change: 0 additions & 1 deletion server/src/server/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use anyhow::{Context, Result};
use env_logger::Logger;
use horizon_logger::log_warn;
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
Expand Down
1 change: 1 addition & 0 deletions server/src/server/event_rep/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use horizon_data_types::Vec3D;

mod structs;

#[allow(dead_code)]
struct Actor {
name: String,
location: Vec3D,
Expand Down
6 changes: 5 additions & 1 deletion server/src/server/event_rep/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ pub struct PebbleVaultCustomData {
pub value: i32,
}


#[allow(dead_code, unused_variables)]
pub struct EventManager<'a, T: Clone + Serialize + for<'de> Deserialize<'de> + PartialEq + Sized> {
vault_ref: &'a mut PebbleVault::VaultManager<T>,
}

#[allow(dead_code, unused_variables)]
impl<'a, T: Clone + Serialize + for<'de> Deserialize<'de> + PartialEq + Sized> EventManager<'a, T> {
pub fn new(pebble_vault_ref: &'a mut PebbleVault::VaultManager<T>) -> Self {
Self {
Expand All @@ -55,13 +56,15 @@ impl<'a, T: Clone + Serialize + for<'de> Deserialize<'de> + PartialEq + Sized> E
}
}

#[allow(dead_code, unused_variables)]
pub struct Event {
instigator: SocketRef,
origin: Vec3D,
radius: f64,
data: Data<serde_json::Value>,
}

#[allow(dead_code)]
impl Event {
pub fn new(instigator: SocketRef, origin: Vec3D, radius: f64, data: Data<serde_json::Value>) -> Self {
Self {
Expand All @@ -81,6 +84,7 @@ impl Event {
}
}

#[allow(dead_code, unused_variables, unused_mut)]
pub fn test() {
let mut vault_manager = VAULT_MANAGER.lock().unwrap();
let mut evt_manager = EventManager::new(&mut *vault_manager);
Expand Down
16 changes: 11 additions & 5 deletions server/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@

use crate::LOGGER;
use anyhow::{Context, Result};
use axum::{routing::get, serve, Router};
use axum::{routing::get, Router};
use config::ServerConfig;
use horizon_data_types::Player;
use horizon_logger::{log_critical, log_debug, log_error, log_info, log_warn};
use horizon_logger::{log_debug, log_error, log_info};
use horizon_plugin_api::LoadedPlugin;
use parking_lot::RwLock;
use plugin_api::{Plugin, Pluginstate};
use socketioxide::{
extract::{AckSender, Data, SocketRef},
SocketIo,
Expand All @@ -34,8 +33,6 @@ use uuid::Uuid;
pub mod config;
mod event_rep;
use lazy_static::lazy_static;
use plugin_api::plugin_imports::*;


lazy_static! {
static ref SERVER: Server = Server::new().unwrap();
Expand All @@ -46,6 +43,8 @@ lazy_static! {
//-----------------------------------------------------------------------------
// Horizon Server Struct
//-----------------------------------------------------------------------------

#[allow(dead_code)]
pub struct HorizonServer {
config: ServerConfig,
threads: RwLock<Vec<Arc<HorizonThread>>>,
Expand Down Expand Up @@ -90,12 +89,15 @@ impl HorizonServer {
//-----------------------------------------------------------------------------
// Horizon Thread Structhorizon_plugin_api::Plugin
//-----------------------------------------------------------------------------

#[allow(dead_code)]
struct HorizonThread {
players: Mutex<Vec<Player>>,
plugins: HashMap<String, LoadedPlugin>,
handle: tokio::task::JoinHandle<()>,
}

#[allow(dead_code, unused_variables)]
impl HorizonThread {
fn new() -> Self {
let mut plugin_manager = plugin_api::PluginManager::new();
Expand All @@ -115,6 +117,7 @@ impl HorizonThread {
}
}

#[allow(dead_code)]
fn id(&self) -> usize {
self.players
.try_lock()
Expand Down Expand Up @@ -156,6 +159,7 @@ async fn handle_socket_ack(Data(data): Data<serde_json::Value>, ack: AckSender)
}
}

#[allow(dead_code, unused_must_use, unused_variables)]
fn on_connect(socket: SocketRef, Data(data): Data<serde_json::Value>) {
//socket.on("connect", |socket: SocketRef, _| {
log_info!(LOGGER, "SOCKET NET", "New connection from {}", socket.id);
Expand Down Expand Up @@ -191,6 +195,8 @@ fn on_connect(socket: SocketRef, Data(data): Data<serde_json::Value>) {
//-----------------------------------------------------------------------------
// Server startup
//-----------------------------------------------------------------------------

#[allow(dead_code, unused_variables)]
pub async fn start() -> anyhow::Result<()> {
let start_time = std::time::Instant::now();

Expand Down

0 comments on commit 7fe2694

Please sign in to comment.