Browse Source

Removed some warnings

master
Thomas Johnson 2 years ago
parent
commit
5db18b9477
  1. 2
      Cargo.toml
  2. 13
      src/main.rs
  3. 7
      src/world/entity/mod.rs
  4. 4
      src/world/entity/player.rs
  5. 5
      src/world/mod.rs
  6. 6
      src/world/render.rs

2
Cargo.toml

@ -1,5 +1,5 @@
[package]
name = "spring2020"
name = "rogue-engine"
version = "0.1.0"
authors = ["thajohns <thajohns@clarkson.edu>", "The Notorious Thug of the North <northug@clarkson.edu>"]
edition = "2018"

13
src/main.rs

@ -3,7 +3,7 @@ extern crate rogue_util;
pub mod world;
use rogue_util::{coord::*, grid::{region::{Region, RegionConfig}, path::Traversable}};
use rogue_util::{coord::*, grid::path::Traversable};
use termion::{raw::IntoRawMode, input::TermRead};
use std::io::{self, Write};
@ -36,19 +36,18 @@ fn main() -> io::Result<()>
let mut rs = world::render::RenderState::new(V2i(width as isize, height as isize));
loop {
w.render(&mut rs, &mut stdout);
stdout.flush();
w.render(&mut rs, &mut stdout)?;
stdout.flush()?;
if let Some(()) = w.step() { break; }
}
eprintln!("{}{}",
print!("{}{}",
termion::clear::All,
termion::cursor::Goto(1, 1),
);
std::mem::drop(stdout);
print!("Thank you for playi");
io::stdout().flush();
rand_distr::Poisson::new(-1.0).unwrap();
println!("insert finalization here");
io::stdout().flush()?;
Ok(())
}

7
src/world/entity/mod.rs

@ -1,8 +1,7 @@
pub mod player;
use super::*;
use rogue_util::{coord::*, raster, grid::{Grid, region::Region}};
use std::collections::HashMap;
use rogue_util::{coord::*, raster, grid::Grid};
use std::fmt::Debug;
pub trait Visible {
@ -124,11 +123,11 @@ pub trait Entity {
fn class(&self) -> usize { 0 }
fn hp(&self) -> isize { 100 }
fn set_hp(&mut self, hp: isize) {}
fn set_hp(&mut self, _hp: isize) {}
fn char(&self) -> char { 'E' }
fn sight(&self) -> usize { DEFAULT_SIGHT_RADIUS }
fn act_time(&self) -> usize { DEFAULT_ACT_TIME }
fn is_dead(&self) -> bool { self.hp() <= 0 }
fn act(&mut self, obs: &Observation) -> Action { Action::Wait }
fn act(&mut self, _obs: &Observation) -> Action { Action::Wait }
}

4
src/world/entity/player.rs

@ -5,7 +5,7 @@ use std::io;
pub struct Player<R> {
pos: V2i,
hp: usize,
hp: usize, // TODO
time: usize,
input: R,
}
@ -35,7 +35,7 @@ impl<R> Entity for Player<R>
}
fn char(&self) -> char { '@' }
fn act(&mut self, obs: &Observation) -> Action {
fn act(&mut self, _obs: &Observation) -> Action {
use termion::event::Key::*;
loop {
match self.input.next().unwrap().unwrap() {

5
src/world/mod.rs

@ -41,7 +41,6 @@ impl Traversable for Tile {
}
pub struct World {
seed: u64,
cur_region: usize,
regions: Vec<RefCell<Region<Tile>>>,
entities: Vec<RefCell<Box<dyn Entity>>>, // NB: Player is ent 0
@ -61,7 +60,6 @@ impl World {
.build().expect("Failed to make World");
// TODO: Worldgen on start_region
World {
seed,
cur_region: 0,
regions: vec![RefCell::new(start_region)],
entities: vec![
@ -150,7 +148,7 @@ impl World {
}
pub fn perform_act<E: DerefMut<Target=Box<dyn Entity>>>(&self, mut e: E, act: entity::Action) -> Option<()> {
use entity::{Action::*, LinfDir};
use entity::{Action::*};
match act {
Wait => (),
Move(d) => {
@ -167,7 +165,6 @@ impl World {
},
Quit => {
return Some(());
panic!("Thank you for playing Wing Commander");
},
}
None

6
src/world/render.rs

@ -13,7 +13,7 @@ pub struct Neighbors<'a, T: Debug> {
}
impl<'a, T: Debug + Default> Neighbors<'a, T> {
pub fn from_region_pos<'r: 'a>(r: &'r Region<T>, p: V2i, def: &'a T) -> Neighbors<'a, T> {
pub fn from_region_pos<'r: 'a>(r: &'r Region<T>, p: V2i, _def: &'a T) -> Neighbors<'a, T> {
Neighbors {
ul: r.get(p + V2i(-1, -1)),
u: r.get(p + V2i(0, -1)),
@ -131,7 +131,7 @@ impl RenderState {
R: Renderer<Tile=Tile>,
W: Write
{
self.refresh_term_size();
self.refresh_term_size()?;
let screen = self.screen_rect();
@ -148,7 +148,7 @@ impl RenderState {
screen_buffer.push(renderer.render(Neighbors::from_region_pos(region, pt, &def_tile)));
}
write!(out, "{}", unsafe { core::str::from_utf8_unchecked(&screen_buffer) });
write!(out, "{}", unsafe { core::str::from_utf8_unchecked(&screen_buffer) })?;
Ok(())
}

Loading…
Cancel
Save