diff options
author | tom barrett <spalf0@gmail.com> | 2018-04-12 04:33:23 -0500 |
---|---|---|
committer | tom barrett <spalf0@gmail.com> | 2018-04-12 04:33:23 -0500 |
commit | 573ba69d810914c153a578747414b3d631e61bbc (patch) | |
tree | 4ce164db9d28ede9778d75ddb4f6922ea1dc1a91 /src/bin | |
parent | ab797e7f30e5e8913faf73516346129b9a620550 (diff) |
completely restructured code and fixed navigation bug
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/client.rs | 26 | ||||
-rw-r--r-- | src/bin/server.rs | 7 |
2 files changed, 17 insertions, 16 deletions
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<Module> = serde_json::from_str(&recv.replace("\n","")).unwrap(); + let modules : Vec<ModuleType> = 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<String, Box<Mass>> { let mut masses : HashMap<String, Box<Mass>> = HashMap::new(); for _ in 0..10 { - masses.insert("zz".to_string(), Box::new(Astroid::new())); + masses.insert(rand_name(), Box::new(Astroid::new())); } masses |