summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/client.rs6
-rw-r--r--src/connection.rs12
-rw-r--r--src/dashboard.rs6
-rw-r--r--src/engines.rs12
-rw-r--r--src/navigation.rs6
5 files changed, 21 insertions, 21 deletions
diff --git a/src/bin/client.rs b/src/bin/client.rs
index bb99485..1c64b39 100644
--- a/src/bin/client.rs
+++ b/src/bin/client.rs
@@ -28,9 +28,9 @@ fn main() {
stream.write(send.as_bytes()).unwrap();
- let mut data = String::new();
- buff_r.read_line(&mut data).unwrap();
- let modules : Vec<Module> = serde_json::from_str(&data.replace("\n","")).unwrap();
+ let mut recv = String::new();
+ buff_r.read_line(&mut recv).unwrap();
+ let modules : Vec<Module> = serde_json::from_str(&recv.replace("\n","")).unwrap();
println!("Choose your module:");
for (i, module) in modules.iter().enumerate() {
diff --git a/src/connection.rs b/src/connection.rs
index 954cd27..77afc06 100644
--- a/src/connection.rs
+++ b/src/connection.rs
@@ -20,9 +20,9 @@ impl Connection {
pub fn new(mut stream : TcpStream, masses : &mut Vec<Box<Mass>>) -> Connection {
let mut buff_r = BufReader::new(stream.try_clone().unwrap());
- let mut data = String::new();
- buff_r.read_line(&mut data).unwrap();
- let name = &data[..data.find(":").unwrap()];
+ let mut recv = String::new();
+ buff_r.read_line(&mut recv).unwrap();
+ let name = &recv[..recv.find(":").unwrap()];
match masses.iter().find(|ship| ship.name() == name).is_some() {
false => masses.push(Box::new(Ship::new(name, (0.0, 0.0, 0.0)))),
@@ -35,9 +35,9 @@ impl Connection {
let modules = ship.get_modules();
stream.write(modules.as_bytes()).unwrap();
- let mut data = String::new();
- buff_r.read_line(&mut data).unwrap();
- let module : Module = serde_json::from_str(&data.replace("\n","")).unwrap();
+ let mut recv = String::new();
+ buff_r.read_line(&mut recv).unwrap();
+ let module : Module = serde_json::from_str(&recv.replace("\n","")).unwrap();
stream.set_nonblocking(true).unwrap();
diff --git a/src/dashboard.rs b/src/dashboard.rs
index e552127..94b4519 100644
--- a/src/dashboard.rs
+++ b/src/dashboard.rs
@@ -11,9 +11,9 @@ use connection::Connection;
pub fn client_dashboard(mut buff_r : BufReader<TcpStream>) {
loop {
- let mut data = String::new();
- buff_r.read_line(&mut data).unwrap();
- let ship : Ship = serde_json::from_str(&data).unwrap();
+ let mut recv = String::new();
+ buff_r.read_line(&mut recv).unwrap();
+ let ship : Ship = serde_json::from_str(&recv).unwrap();
println!("{:?}", ship);
}
}
diff --git a/src/engines.rs b/src/engines.rs
index d7ae865..3966c1b 100644
--- a/src/engines.rs
+++ b/src/engines.rs
@@ -18,10 +18,10 @@ pub fn client_engines(mut stream : TcpStream, mut buff_r : BufReader<TcpStream>)
let mut stdin = async_stdin().bytes();
loop {
- let mut data = String::new();
- buff_r.read_line(&mut data).unwrap();
+ let mut recv = String::new();
+ buff_r.read_line(&mut recv).unwrap();
- let has_target = match data.as_bytes() {
+ let has_target = match recv.as_bytes() {
b"true\n" => true,
_ => false
};
@@ -72,9 +72,9 @@ impl Connection {
}
let mut acceleration = (0.0, 0.0, 0.0);
- let mut data = String::new();
- match self.buff_r.read_line(&mut data) {
- Ok(result) => match data.as_bytes() {
+ let mut recv = String::new();
+ match self.buff_r.read_line(&mut recv) {
+ Ok(result) => match recv.as_bytes() {
b"5\n" => acceleration.0 += 0.1,
b"0\n" => acceleration.0 -= 0.1,
b"8\n" => acceleration.1 += 0.1,
diff --git a/src/navigation.rs b/src/navigation.rs
index 84aca86..f9fa92a 100644
--- a/src/navigation.rs
+++ b/src/navigation.rs
@@ -19,10 +19,10 @@ pub fn client_navigation(name : String, mut stream : TcpStream, mut buff_r : Buf
let mut stdin = async_stdin().bytes();
loop {
- let mut data = String::new();
- buff_r.read_line(&mut data).unwrap();
+ let mut recv = String::new();
+ buff_r.read_line(&mut recv).unwrap();
- let string_masses = data.split(";");
+ let string_masses = recv.split(";");
let mut masses : Vec<Box<Mass>> = Vec::new();
for string_mass in string_masses {
if string_mass.len() <= 1 {