From 573ba69d810914c153a578747414b3d631e61bbc Mon Sep 17 00:00:00 2001 From: tom barrett Date: Thu, 12 Apr 2018 04:33:23 -0500 Subject: completely restructured code and fixed navigation bug --- src/bin/client.rs | 26 +++++++++++++------------- src/bin/server.rs | 7 ++++--- 2 files changed, 17 insertions(+), 16 deletions(-) (limited to 'src/bin') diff --git a/src/bin/client.rs b/src/bin/client.rs index 7eb89ae..5460652 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -1,16 +1,16 @@ +extern crate space; +extern crate serde_json; + use std::io; use std::io::prelude::*; use std::io::BufReader; use std::net::TcpStream; -extern crate serde_json; - -extern crate space; -use space::mining::client_mining; -use space::engines::client_engines; -use space::dashboard::client_dashboard; -use space::navigation::client_navigation; -use space::module::Module; +use space::module::ModuleType; +use space::client::mining::client_mining; +use space::client::engines::client_engines; +use space::client::dashboard::client_dashboard; +use space::client::navigation::client_navigation; fn main() { let mut name = String::new(); @@ -31,7 +31,7 @@ fn main() { let mut recv = String::new(); buff_r.read_line(&mut recv).unwrap(); - let modules : Vec = serde_json::from_str(&recv.replace("\n","")).unwrap(); + let modules : Vec = serde_json::from_str(&recv.replace("\n","")).unwrap(); println!("Choose your module:"); for (i, module) in modules.iter().enumerate() { @@ -46,9 +46,9 @@ fn main() { stream.write(send.as_bytes()).unwrap(); match module { - Module::Dashboard => client_dashboard(buff_r), - Module::Engines => client_engines(stream, buff_r), - Module::Navigation => client_navigation(name, stream, buff_r), - Module::Mining => client_mining(stream, buff_r), + ModuleType::Dashboard => client_dashboard(buff_r), + ModuleType::Engines => client_engines(stream, buff_r), + ModuleType::Navigation => client_navigation(name, stream, buff_r), + ModuleType::Mining => client_mining(stream, buff_r), } } diff --git a/src/bin/server.rs b/src/bin/server.rs index f7aaffe..c5954b0 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -1,19 +1,20 @@ +extern crate space; + use std::thread::sleep; use std::time::Duration; use std::net::TcpListener; use std::collections::HashMap; -extern crate space; use space::mass::Mass; +use space::math::rand_name; use space::astroid::Astroid; use space::connection::Connection; - fn populate() -> HashMap> { let mut masses : HashMap> = HashMap::new(); for _ in 0..10 { - masses.insert("zz".to_string(), Box::new(Astroid::new())); + masses.insert(rand_name(), Box::new(Astroid::new())); } masses -- cgit v1.2.3