Skip to content

Commit

Permalink
Fixed clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ozkriff committed Nov 20, 2017
1 parent 16a833a commit 90f845c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions hate/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ pub fn load<P: AsRef<Path>>(path: P) -> Vec<u8> {
let mut file = match File::open(&fullpath) {
Ok(file) => file,
Err(err) => {
panic!("Can`t open file '{}' ({})", fullpath.display(), err);
panic!("Can`t open file '{}' ({})", fullpath.display(), err)
}
};
match file.read_to_end(&mut buf) {
Ok(_) => buf,
Err(err) => {
panic!("Can`t read file '{}' ({})", fullpath.display(), err);
panic!("Can`t read file '{}' ({})", fullpath.display(), err)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::fmt::Debug;
pub struct Distance(pub i32);

/// Cube coordinates
/// http://www.redblobgames.com/grids/hexagons/#coordinates-cube
/// <http://www.redblobgames.com/grids/hexagons/#coordinates-cube>
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct PosCube<T: Debug + Copy = i32> {
pub x: T,
Expand All @@ -14,7 +14,7 @@ pub struct PosCube<T: Debug + Copy = i32> {
}

/// Axial coordinates
/// http://www.redblobgames.com/grids/hexagons/#coordinates-axial
/// <http://www.redblobgames.com/grids/hexagons/#coordinates-axial>
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub struct PosHex<T: Debug + Copy = i32> {
/// column
Expand Down Expand Up @@ -52,7 +52,7 @@ pub fn hex_round(hex: PosHex<f32>) -> PosHex {
cube_to_hex(cube_round(hex_to_cube_f(hex)))
}

/// http://www.redblobgames.com/grids/hexagons/#rounding
/// <http://www.redblobgames.com/grids/hexagons/#rounding>
pub fn cube_round(cube: PosCube<f32>) -> PosCube {
let mut rx = cube.x.round();
let mut ry = cube.y.round();
Expand Down Expand Up @@ -200,7 +200,7 @@ pub enum Dir {
SouthWest,
}

/// http://www.redblobgames.com/grids/hexagons/#neighbors-axial
/// <http://www.redblobgames.com/grids/hexagons/#neighbors-axial>
const DIR_TO_POS_DIFF: [[i32; 2]; 6] = [[1, 0], [1, -1], [0, -1], [-1, 0], [-1, 1], [0, 1]];

impl Dir {
Expand Down
4 changes: 2 additions & 2 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use core::map::{hex_round, PosHex};

const SQRT_OF_3: f32 = 1.732050;

/// http://www.redblobgames.com/grids/hexagons/#hex-to-pixel
/// <http://www.redblobgames.com/grids/hexagons/#hex-to-pixel>
pub fn hex_to_point(size: f32, hex: PosHex) -> Point {
let x = size * SQRT_OF_3 * (hex.q as f32 + hex.r as f32 / 2.0);
let y = size * 3.0 / 2.0 * hex.r as f32;
Point(vec2(x, y))
}

/// http://www.redblobgames.com/grids/hexagons/#pixel-to-hex
/// <http://www.redblobgames.com/grids/hexagons/#pixel-to-hex>
pub fn point_to_hex(size: f32, point: Point) -> PosHex {
let q = (point.0.x * SQRT_OF_3 / 3.0 - point.0.y / 3.0) / size;
let r = point.0.y * 2.0 / 3.0 / size;
Expand Down
14 changes: 7 additions & 7 deletions src/screen/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl Game {
self.deselect();
let command = command::Command::EndTurn(command::EndTurn);
let mut actions = Vec::new();
actions.push(self.do_command_inner(context, command));
actions.push(self.do_command_inner(context, &command));
actions.push(self.do_ai(context));
self.add_actions(actions);
}
Expand All @@ -199,7 +199,7 @@ impl Game {
loop {
let command = self.ai.command(&self.state).unwrap();
debug!("AI: command = {:?}", command);
actions.push(self.do_command_inner(context, command.clone()));
actions.push(self.do_command_inner(context, &command));
actions.push(Box::new(action::Sleep::new(Time(0.3)))); // ??
if let command::Command::EndTurn(_) = command {
break;
Expand All @@ -222,19 +222,19 @@ impl Game {
fn do_command_inner(
&mut self,
context: &mut Context,
command: command::Command,
command: &command::Command,
) -> Box<Action> {
debug!("do_command_inner: {:?}", command);
let mut actions = Vec::new();
let state = &mut self.state;
let view = &mut self.view;
core::execute(state, &command, &mut |state, event, phase| {
core::execute(state, command, &mut |state, event, phase| {
actions.push(visualize::visualize(state, view, context, event, phase));
}).expect("Can't execute command");
Box::new(action::Sequence::new(actions))
}

fn do_command(&mut self, context: &mut Context, command: command::Command) {
fn do_command(&mut self, context: &mut Context, command: &command::Command) {
let action = self.do_command_inner(context, command);
self.add_action(action);
}
Expand Down Expand Up @@ -309,7 +309,7 @@ impl Game {
if check(&self.state, &command_attack).is_err() {
return;
}
self.do_command(context, command_attack);
self.do_command(context, &command_attack);
let parts = self.state.parts();
if parts.agent.get_opt(selected_unit_id).is_some() {
self.pathfinder.fill_map(&self.state, selected_unit_id);
Expand All @@ -323,7 +323,7 @@ impl Game {
if check(&self.state, &command_move).is_err() {
return;
}
self.do_command(context, command_move);
self.do_command(context, &command_move);
if self.state.parts().agent.get_opt(id).is_some() {
self.pathfinder.fill_map(&self.state, id);
}
Expand Down

0 comments on commit 90f845c

Please sign in to comment.