about summary refs log tree commit diff
path: root/src/main.rs
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2019-07-09T00·58-0400
committerGriffin Smith <root@gws.fyi>2019-07-09T00·58-0400
commit5af2429ecb5742383cf0798ce23682d316bdb24d (patch)
tree0fba959d9a5bce5c749c8529b3f2ea7b557c5767 /src/main.rs
parent20f1ccb4600b88ac01768e912e6d5837534ca852 (diff)
Implement a global map of entities
Implement a global map of entities, which allows referencing by either
position or ID and updating the positions of existent entities, and put
the character in there.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 6b0ae18181ef..8d7222106c52 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -13,9 +13,12 @@ extern crate clap;
 extern crate prettytable;
 #[macro_use]
 extern crate lazy_static;
+#[cfg(test)]
 #[macro_use]
 extern crate maplit;
-
+#[macro_use]
+extern crate downcast_rs;
+extern crate backtrace;
 
 mod display;
 mod game;
@@ -24,12 +27,14 @@ mod types;
 mod entities;
 mod messages;
 mod settings;
+mod util;
 
 use clap::App;
 use game::Game;
 use prettytable::format::consts::FORMAT_BOX_CHARS;
 use settings::Settings;
 
+use backtrace::Backtrace;
 use std::io::{self, StdinLock, StdoutLock};
 use std::panic;
 
@@ -43,7 +48,16 @@ fn init(
     w: u16,
     h: u16,
 ) {
-    panic::set_hook(Box::new(|info| error!("{}", info)));
+    panic::set_hook(if settings.logging.print_backtrace {
+        Box::new(|info| {
+            (error!("{}\n{:#?}", info, Backtrace::new()))
+        })
+    } else {
+        Box::new(|info| {
+            (error!("{}\n{:#?}", info, Backtrace::new()))
+        })
+    });
+
     let game = Game::new(settings, stdout, stdin, w, h);
     game.run().unwrap()
 }