Appease Clippy

This commit is contained in:
Alex Bethel 2022-01-02 13:17:17 -06:00
parent 50024fa8fa
commit 54b9f2778c
3 changed files with 19 additions and 21 deletions

View file

@ -86,8 +86,7 @@ impl DungeonLevel {
.all(|(_x, _y, tile)| *tile != &DungeonTile::Floor)
{
' '
} else {
if neighborhood
} else if neighborhood
.iter()
.any(|(tile_x, _y, tile)| *tile_x == x && *tile == &DungeonTile::Floor)
{
@ -96,7 +95,6 @@ impl DungeonLevel {
'|'
}
}
}
DungeonTile::Hallway => '#',
}
}
@ -109,7 +107,7 @@ impl Display for DungeonLevel {
write!(f, "{}", self.render_tile(x, y))?;
}
write!(f, "\n")?;
writeln!(f)?;
}
Ok(())

View file

@ -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);
}
}

View file

@ -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`.
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();
}
}