Appease Clippy
This commit is contained in:
parent
50024fa8fa
commit
54b9f2778c
16
src/game.rs
16
src/game.rs
|
@ -86,15 +86,13 @@ impl DungeonLevel {
|
|||
.all(|(_x, _y, tile)| *tile != &DungeonTile::Floor)
|
||||
{
|
||||
' '
|
||||
} else if neighborhood
|
||||
.iter()
|
||||
.any(|(tile_x, _y, tile)| *tile_x == x && *tile == &DungeonTile::Floor)
|
||||
{
|
||||
'-'
|
||||
} else {
|
||||
if neighborhood
|
||||
.iter()
|
||||
.any(|(tile_x, _y, tile)| *tile_x == x && *tile == &DungeonTile::Floor)
|
||||
{
|
||||
'-'
|
||||
} else {
|
||||
'|'
|
||||
}
|
||||
'|'
|
||||
}
|
||||
}
|
||||
DungeonTile::Hallway => '#',
|
||||
|
@ -109,7 +107,7 @@ impl Display for DungeonLevel {
|
|||
write!(f, "{}", self.render_tile(x, y))?;
|
||||
}
|
||||
|
||||
write!(f, "\n")?;
|
||||
writeln!(f)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use components::{register_all, Position, CharRender};
|
||||
use components::{register_all, CharRender, Position};
|
||||
use game::{BranchConfig, DungeonLevel};
|
||||
|
||||
use specs::prelude::*;
|
||||
|
@ -31,6 +31,6 @@ fn main() {
|
|||
.build();
|
||||
|
||||
loop {
|
||||
dispatcher.dispatch(&mut world);
|
||||
dispatcher.dispatch(&world);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
//! ECS systems.
|
||||
|
||||
use std::sync::Mutex;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use pancurses::{Window, endwin, initscr};
|
||||
use pancurses::{endwin, initscr, Window};
|
||||
use specs::prelude::*;
|
||||
|
||||
use crate::{components::{Position, CharRender}, game::DungeonLevel};
|
||||
use crate::{
|
||||
components::{CharRender, Position},
|
||||
game::DungeonLevel,
|
||||
};
|
||||
|
||||
/// System for drawing the state of the game, and potentially waiting
|
||||
/// (blocking) for user input.
|
||||
|
@ -15,18 +18,16 @@ pub struct IOSystem {
|
|||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref WINDOW_INITIALIZED: Mutex<bool> = Mutex::new(false);
|
||||
static ref WINDOW_INITIALIZED: AtomicBool = AtomicBool::new(false);
|
||||
}
|
||||
|
||||
impl IOSystem {
|
||||
pub fn new() -> Self {
|
||||
let mut init = WINDOW_INITIALIZED.lock().unwrap();
|
||||
if *init {
|
||||
// See the note on `impl Send for IOSystem`.
|
||||
// See the note on `impl Send for IOSystem`.
|
||||
if WINDOW_INITIALIZED.swap(true, Ordering::Relaxed) {
|
||||
panic!("Refusing to initialize the renderer twice");
|
||||
}
|
||||
|
||||
*init = true;
|
||||
Self { window: initscr() }
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +35,7 @@ impl IOSystem {
|
|||
impl Drop for IOSystem {
|
||||
fn drop(&mut self) {
|
||||
endwin();
|
||||
*WINDOW_INITIALIZED.lock().unwrap() = false;
|
||||
WINDOW_INITIALIZED.store(false, Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,4 +71,3 @@ impl<'a> System<'a> for IOSystem {
|
|||
self.window.getch();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue