Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tcod version 5 is broken #64

Open
HarrisonHemstreet opened this issue Mar 13, 2021 · 2 comments
Open

tcod version 5 is broken #64

HarrisonHemstreet opened this issue Mar 13, 2021 · 2 comments

Comments

@HarrisonHemstreet
Copy link

No description provided.

@tomassedovic
Copy link
Owner

Greetings @HarrisonHemstreet. Thanks for the bug report, but that's little to go on. It would be helpful to know what/how exactly is broken. At the minimum describe what you're doing (what commands you run etc.) and paste the error messages you see here.

I found this project and tried to run it locally: https://github.com/HarrisonHemstreet/RougueLike-Rust

And while it built correctly, when I pressed a key, it panicked with:

thread 'main' panicked at 'attempted to leave type `bindings::ffi::TCOD_key_t` uninitialized, which is invalid', /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/mem/mod.rs:659:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/panicking.rs:50:5
   3: core::mem::uninitialized
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/mem/mod.rs:659:9
   4: tcod::input::check_for_event
             at /home/shadower/.cargo/registry/src/github.com-1ecc6299db9ec823/tcod-0.15.0/src/input.rs:193:53
   5: rouguelike_rust::play_game
             at ./src/main.rs:1835:15
   6: rouguelike_rust::main_menu
             at ./src/main.rs:1917:17
   7: rouguelike_rust::main
             at ./src/main.rs:1960:5
   8: core::ops::function::FnOnce::call_once
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

This has been fixed in the master branch of tcod-rs, so updating your Cargo.toml to this should fix it:

[package]
name = "rouguelike-rust"
version = "0.1.0"
authors = ["Harrison <harrisonhemstreet@gmail.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tcod = { git = "https://github.com/tomassedovic/tcod-rs.git", features = ["serialization"] }
rand = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

[dependencies.tcod-sys]
git = "https://github.com/tomassedovic/tcod-rs.git"
features = ["dynlib"]

(it changes the version field for both tcod and tcod-sys with a link to the git repo)

But both tcod (the Rust bindings, not the original libtcod C/C++ library) and this tutorial are no longer maintained. I recommend you check out this tutorial instead: http://bfnightly.bracketproductions.com/rustbook/

It is maintained and uses the bracket-lib crate which is written in pure Rust and again, is maintained.

@frederickjjoubert
Copy link

I am not sure if this is related or not, but I made it to the end of part 7 before I experienced an issue.

In part 7, when we get to the part where we have to change the way we check for input to this:

// Check for Input.
match input::check_for_event(input::MOUSE | input::KEY_PRESS) {
    Some((_, Event::Mouse(m))) => tcod.mouse = m,
    Some((_, Event::Key(k))) => tcod.key = k,
    _ => tcod.key = Default::default(),
}

Then Default::default() would throw a run time error (panic) for me.

I could not find any problems or differences between my code against the code on github.

Sorry, I don't have the error handy to copy and paste, I changed my .toml file to the code posted above, and it appears to have fixed the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants