diff --git a/core/src/instance.rs b/core/src/instance.rs index 3c7f8b0f..79467015 100644 --- a/core/src/instance.rs +++ b/core/src/instance.rs @@ -11,7 +11,6 @@ use chrono::prelude::*; use chrono::Duration; use player::{Player, Score}; -use mob::{bot_player, instance_mobs}; use game::{Game}; use item::{Item}; use vbox; @@ -504,6 +503,7 @@ impl Instance { #[cfg(test)] mod tests { use super::*; + use mob::{bot_player, instance_mobs}; #[test] fn instance_pve_test() { diff --git a/core/src/vbox.rs b/core/src/vbox.rs index 7de39112..6110f2ec 100644 --- a/core/src/vbox.rs +++ b/core/src/vbox.rs @@ -9,8 +9,6 @@ use rand::distributions::{WeightedIndex}; use failure::Error; use failure::err_msg; -use construct::{Colours}; - use item::*; pub type VboxIndices = Option>>; @@ -217,6 +215,7 @@ impl Vbox { #[cfg(test)] mod tests { use super::*; + use construct::{Colours}; #[test] fn combine_test() { diff --git a/server/src/account.rs b/server/src/account.rs index a162a22c..08d1ca74 100644 --- a/server/src/account.rs +++ b/server/src/account.rs @@ -42,7 +42,7 @@ impl Account { false => None, }; - Ok(Player::new(self.id, Some(self.img), &self.name, constructs)) + Ok(Player::new(self.id, img, &self.name, constructs)) } pub fn anonymous() -> Account { @@ -103,7 +103,7 @@ pub fn chat_wheel(_db: &Db, _id: Uuid) -> Result, Error> { ]) } -pub fn select_name(db: &Db, name: &String) -> Result { +pub fn _select_name(db: &Db, name: &String) -> Result { let query = " SELECT id, name, balance, subscribed, img FROM accounts diff --git a/server/src/events.rs b/server/src/events.rs index fab2bfca..8208c821 100644 --- a/server/src/events.rs +++ b/server/src/events.rs @@ -6,7 +6,7 @@ use std::time; use uuid::Uuid; use failure::Error; -use failure::{err_msg, format_err}; +use failure::{format_err}; use crossbeam_channel::{Sender, Receiver}; @@ -15,7 +15,6 @@ use names; use rpc::RpcMessage; use warden::{GameEvent}; -use mail::Mail; pub type EventsTx = Sender; type Id = Uuid; @@ -35,7 +34,6 @@ pub struct Events { pub tx: Sender, rx: Receiver, - mail: Sender, warden: Sender, clients: HashMap, } @@ -72,12 +70,11 @@ struct WsClient { } impl Events { - pub fn new(tx: Sender, rx: Receiver, warden: Sender, mail: Sender) -> Events { + pub fn new(tx: Sender, rx: Receiver, warden: Sender) -> Events { Events { tx, rx, warden, - mail, clients: HashMap::new(), } } @@ -101,17 +98,6 @@ impl Events { } } - fn get_client(&mut self, id: Id) -> Result<&mut WsClient, Error> { - match self.clients.get_mut(&id) { - Some(c) => Ok(c), - None => Err(format_err!("connection not found id={:?}", id)), - } - } - - fn remove_client(&mut self, id: Id) { - self.clients.remove(&id); - } - fn event(&mut self, msg: Event) -> Result<(), Error> { match msg { Event::Connect(id, account, tx) => { @@ -157,7 +143,7 @@ impl Events { trace!("unsubscribe id={:?} object={:?}", id, obj); match self.clients.get_mut(&id) { - Some(mut client) => { + Some(client) => { client.subs.remove(&obj); trace!("unsubscribe subscriptions removed={:?}", client.subs.len()); Ok(()) @@ -194,7 +180,9 @@ impl Events { if !dead.is_empty() { trace!("dead connections={:?}", dead.len()); - dead.iter().for_each(|id| self.remove_client(*id)); + for id in dead.iter() { + self.clients.remove(id); + } } trace!("push subscribers={:?}", subs); diff --git a/server/src/http.rs b/server/src/http.rs index 9c244317..88e7b51b 100644 --- a/server/src/http.rs +++ b/server/src/http.rs @@ -111,7 +111,7 @@ pub fn json_response(status: status::Status, response: Json) -> Response { return Response::with((content_type, status, json)); } -pub fn json_object(status: status::Status, object: String) -> Response { +pub fn _json_object(status: status::Status, object: String) -> Response { let content_type = "application/json".parse::().unwrap(); return Response::with((content_type, status, object)); } diff --git a/server/src/img.rs b/server/src/img.rs index 705d86cd..ef14b0ec 100644 --- a/server/src/img.rs +++ b/server/src/img.rs @@ -72,7 +72,7 @@ enum ConstructShapes { Line, V, Tri, - Plus, + // Plus, Blank, } @@ -203,9 +203,7 @@ pub fn shapes_write(id: Uuid) -> Result { write!(&mut svg, "", fill = colour, width = width, x0 = x0, y0 = y0, x1 = x1, y1 = y1, x2 = x2, y2 = y2, rotation = rotation, x_translate = -x_translate, y_translate = -y_translate)?; }, - ConstructShapes::Plus => { - - }, + // ConstructShapes::Plus => { }, ConstructShapes::Blank => (), } } diff --git a/server/src/lib.rs b/server/src/lib.rs index 26fa9e31..b8e9060c 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -122,11 +122,11 @@ pub fn start() { let warden_tick_tx = warden_tx.clone(); let (mail_tx, mail_rx) = unbounded(); - let http_mail_tx = mail_tx.clone(); + let _http_mail_tx = mail_tx.clone(); // create a clone of the tx so ws handler can tell events // about connection status - let events = events::Events::new(events_tx, events_rx, events_warden_tx, mail_tx); + let events = events::Events::new(events_tx, events_rx, events_warden_tx); let warden = warden::Warden::new(warden_tx, warden_rx, events.tx.clone(), pool.clone()); let pg_pool = pool.clone(); diff --git a/server/src/mail.rs b/server/src/mail.rs index 0fdffc7b..d5083021 100644 --- a/server/src/mail.rs +++ b/server/src/mail.rs @@ -261,7 +261,7 @@ pub fn set(tx: &mut Transaction, account: Uuid, email: &String) -> Result<(Uuid, return Ok((id, confirm_token)); } -pub fn listen(rx: Receiver) -> SmtpTransport { +pub fn listen(_rx: Receiver) -> SmtpTransport { let sender = env::var("MAIL_ADDRESS") .expect("MAIL_ADDRESS must be set"); @@ -271,7 +271,7 @@ pub fn listen(rx: Receiver) -> SmtpTransport { let domain = env::var("MAIL_DOMAIN") .expect("MAIL_DOMAIN must be set"); - let mut mailer = SmtpClient::new_simple("smtp.gmail.com").unwrap() + let mailer = SmtpClient::new_simple("smtp.gmail.com").unwrap() .hello_name(ClientId::Domain(domain)) .credentials(Credentials::new(sender, password)) .smtp_utf8(true) @@ -281,19 +281,6 @@ pub fn listen(rx: Receiver) -> SmtpTransport { info!("mail connected"); - // loop { - // match rx.recv() { - // Ok(m) => match send_mail(&mut mailer, m) { - // Ok(r) => info!("{:?}", r), - // Err(e) => warn!("{:?}", e), - // }, - // Err(e) => { - // error!("{:?}", e); - // panic!("mail thread cannot continue"); - // }, - // }; - // } - // Explicitly close the SMTP transaction as we enabled connection reuse // mailer.close(); return mailer; diff --git a/server/src/mtx.rs b/server/src/mtx.rs index 5fc66763..7968c468 100644 --- a/server/src/mtx.rs +++ b/server/src/mtx.rs @@ -86,7 +86,7 @@ impl Mtx { } } - pub fn delete(tx: &mut Transaction, id: Uuid) -> Result<(), Error> { + pub fn _delete(tx: &mut Transaction, id: Uuid) -> Result<(), Error> { let query = " DELETE FROM mtx diff --git a/server/src/pg.rs b/server/src/pg.rs index ec56a9be..97444249 100644 --- a/server/src/pg.rs +++ b/server/src/pg.rs @@ -143,7 +143,7 @@ pub fn listen(pool: PgPool, events: Sender) -> Result<(), Error> { } -pub fn construct_delete(tx: &mut Transaction, id: Uuid, account_id: Uuid) -> Result<(), Error> { +pub fn _construct_delete(tx: &mut Transaction, id: Uuid, account_id: Uuid) -> Result<(), Error> { let query = " DELETE FROM constructs @@ -163,7 +163,7 @@ pub fn construct_delete(tx: &mut Transaction, id: Uuid, account_id: Uuid) -> Res return Ok(()); } -pub fn construct_get(tx: &mut Transaction, id: Uuid, account_id: Uuid) -> Result { +pub fn _construct_get(tx: &mut Transaction, id: Uuid, account_id: Uuid) -> Result { let query = " SELECT data FROM constructs @@ -290,7 +290,7 @@ pub fn game_get(tx: &mut Transaction, id: Uuid) -> Result { return Ok(game); } -pub fn select(db: &Db, id: Uuid) -> Result { +pub fn _game_select(db: &Db, id: Uuid) -> Result { let query = " SELECT * FROM games @@ -312,7 +312,7 @@ pub fn select(db: &Db, id: Uuid) -> Result { return Ok(game); } -pub fn list(db: &Db, number: u32) -> Result, Error> { +pub fn _game_list(db: &Db, number: u32) -> Result, Error> { let query = " SELECT data FROM games @@ -815,7 +815,7 @@ pub fn instance_game_finished(tx: &mut Transaction, game: &Game, instance_id: Uu Ok(()) } -pub fn bot_instance() -> Instance { +pub fn _bot_instance() -> Instance { let mut instance = Instance::new(); let bot_player = bot_player(); diff --git a/server/src/warden.rs b/server/src/warden.rs index 1e6a729a..644e78db 100644 --- a/server/src/warden.rs +++ b/server/src/warden.rs @@ -1,7 +1,5 @@ use std::time::{Duration}; -use uuid::Uuid; - use crossbeam_channel::{tick, Sender, Receiver}; // Db Commons @@ -24,13 +22,12 @@ use pg::{ pvp, }; -type Id = usize; type Pair = (PvpRequest, PvpRequest); pub enum GameEvent { Upkeep, - Finish(Uuid), + // Finish(Uuid), Match(Pair), } @@ -76,10 +73,10 @@ impl Warden { match msg { GameEvent::Upkeep => self.on_upkeep(), GameEvent::Match(pair) => self.on_match(pair), - GameEvent::Finish(id) => { - info!("game finished id={:?}", id); - Ok(()) - }, + // GameEvent::Finish(id) => { + // info!("game finished id={:?}", id); + // Ok(()) + // }, } } @@ -131,7 +128,7 @@ impl Warden { fn fetch_games(mut tx: Transaction) -> Result { let games = games_need_upkeep(&mut tx)?; - for mut game in games { + for game in games { let game = game.upkeep(); match game_update(&mut tx, &game) { Ok(_) => (), @@ -146,7 +143,7 @@ fn fetch_games(mut tx: Transaction) -> Result { } fn fetch_instances(mut tx: Transaction) -> Result { - for mut instance in instances_need_upkeep(&mut tx)? { + for instance in instances_need_upkeep(&mut tx)? { let (instance, new_game) = instance.upkeep(); if let Some(game) = new_game {