Fixed pointess generate_str function return

Also added a nice little helpful close window thingy
This commit is contained in:
2023-07-05 22:13:37 +01:00
parent 6004df73f7
commit 9f62e4894b
3 changed files with 64 additions and 29 deletions

View File

@@ -51,7 +51,7 @@ pub struct WadThingLump {
pub struct OpenWad {
path: PathBuf,
header: WadHeader,
_header: WadHeader,
nice_lumps: Vec<NiceWadLumpEntry>,
level_indicies: Vec<usize>,
}
@@ -59,6 +59,7 @@ pub struct OpenWad {
pub fn open_wad(path: &PathBuf) -> OpenWad {
let mut file = BufReader::new(File::open(path).unwrap());
let header: WadHeader = bincode::deserialize_from(&mut file).unwrap();
assert!(header.identifier == *b"IWAD" || header.identifier == *b"PWAD");
file.seek(SeekFrom::Start(header.file_offset_to_start as u64))
.unwrap();
let mut nice_lumps: Vec<NiceWadLumpEntry> = Vec::new();
@@ -84,7 +85,7 @@ pub fn open_wad(path: &PathBuf) -> OpenWad {
}
OpenWad {
path: path.clone(),
header,
_header: header,
nice_lumps,
level_indicies,
}
@@ -171,7 +172,7 @@ pub enum Enemy {
}
impl Enemy {
fn difficulty_value(enemy: &Self) -> u16 {
pub fn difficulty_value(enemy: &Self) -> u16 {
match enemy {
Self::FormerHuman => 2,
Self::WolfensteinSs => 2,
@@ -198,7 +199,7 @@ impl Enemy {
}
impl HealthAndArmour {
fn health_value(hoa: &Self) -> u16 {
pub fn health_value(hoa: &Self) -> u16 {
match hoa {
Self::Beserk => 100,
Self::Stimpack => 10,
@@ -272,8 +273,8 @@ mod tests {
"WAD test need freedoom1.wad - get it from here https://freedoom.github.io"
);
let ow = open_wad(&freedoom_iwad);
assert_eq!(&ow.header.identifier, b"IWAD");
assert_eq!(std::str::from_utf8(&ow.header.identifier).unwrap(), "IWAD");
assert_eq!(&ow._header.identifier, b"IWAD");
assert_eq!(std::str::from_utf8(&ow._header.identifier).unwrap(), "IWAD");
}
#[test]
@@ -327,7 +328,7 @@ mod tests {
#[test]
fn test_struct_size() {
// This probably isn't really neccesary... but it might catch a mistake, maybe?
// These shouldn't compile if the size is incorrect (I think)
// These shouldn't compile if the size is incorrect
const _HS: [u8; 12] = [0; std::mem::size_of::<WadHeader>()];
const _LDS: [u8; 16] = [0; std::mem::size_of::<WadLumpDirectoryEntry>()];
const _WTL: [u8; 10] = [0; std::mem::size_of::<WadThingLump>()];