Skip to content

Commit

Permalink
Merge pull request #317 from tomassedovic/bugfix/segfault_and_warnings
Browse files Browse the repository at this point in the history
Protect against segfault and clean up warnings
  • Loading branch information
tomassedovic authored Jan 30, 2021
2 parents d27df89 + 7323243 commit d4ad074
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ path = "src/lib.rs"

[dependencies]
bitflags = "0.1"
lazy_static = "0.1"
lazy_static = "1.4"
rustc-serialize = { optional = true, version = "0.3" }
serde = { optional = true, version = "1.0" }
serde_derive = { optional = true, version = "1.0" }
Expand Down
4 changes: 2 additions & 2 deletions examples/samples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ impl Render for NoiseSample {

if let Some((_, Event::Key(key))) = event {
match key.printable {
'1'...'9' =>
'1'..='9' =>
self.func = {
let number = key.printable.to_digit(10).unwrap() as u8;
NoiseFunction::from_value(number - 1)
Expand Down Expand Up @@ -778,7 +778,7 @@ struct PathSample<'a> {
}

const TORCH_RADIUS : f32 = 10.0;
const SQUARED_TORCH_RADIUS : f32 = (TORCH_RADIUS*TORCH_RADIUS);
const SQUARED_TORCH_RADIUS : f32 = TORCH_RADIUS*TORCH_RADIUS;

static SMAP : [&'static str; 20] = [
"##############################################",
Expand Down
2 changes: 1 addition & 1 deletion src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl <T, U: AsNative<T> + ?Sized> AsNative<T> for Box<U> {

pub fn keycode_from_native(input: self::ffi::TCOD_keycode_t) -> Option<KeyCode> {
match input as u32 {
x @ 0 ... 66 => Some(unsafe { transmute(x) }),
x @ 0 ..= 66 => Some(unsafe { transmute(x) }),
_ => None
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/pathfinding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl<'a> AStar<'a> {
let mut x: c_int = 0;
let mut y: c_int = 0;
ffi::TCOD_path_get(self.tcod_path, index, &mut x, &mut y);
(Some((x, y)))
Some((x, y))
}
}

Expand Down Expand Up @@ -278,8 +278,10 @@ impl<'a> Dijkstra<'a> {
}

pub fn reverse(&mut self) {
unsafe {
ffi::TCOD_dijkstra_reverse(self.tcod_path);
if !self.is_empty() {
unsafe {
ffi::TCOD_dijkstra_reverse(self.tcod_path);
}
}
}

Expand Down

0 comments on commit d4ad074

Please sign in to comment.