mindustry logic execution, map- and schematic- parsing and rendering
skip modded/unknown blocks
| -rw-r--r-- | mindus/Cargo.toml | 2 | ||||
| -rw-r--r-- | mindus/src/data/schematic.rs | 13 | ||||
| -rw-r--r-- | mindus/src/exe/draw.rs | 4 |
3 files changed, 11 insertions, 8 deletions
diff --git a/mindus/Cargo.toml b/mindus/Cargo.toml index bccb4ce..be1ca28 100644 --- a/mindus/Cargo.toml +++ b/mindus/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mindus" -version = "5.0.30" +version = "5.0.31" edition = "2021" description = "A library for working with mindustry data formats (eg schematics and maps) (fork of plandustry)" authors = [ diff --git a/mindus/src/data/schematic.rs b/mindus/src/data/schematic.rs index 0c315ec..85363df 100644 --- a/mindus/src/data/schematic.rs +++ b/mindus/src/data/schematic.rs @@ -1,7 +1,7 @@ //! schematic parsing use std::collections::hash_map::Entry; use std::collections::HashMap; -use std::fmt::{self, Write}; +use std::fmt::{self, Display, Write}; use thiserror::Error; use crate::block::ratios::{Io, IoBuilder}; @@ -508,10 +508,13 @@ impl Serializable for Schematic { let mut block_table = Vec::with_capacity(num_table as usize); for _ in 0..num_table { let name = buff.read_utf()?; - match BLOCK_REGISTRY.get(name) { - None => return Err(ReadError::NoSuchBlock(name.to_owned())), - Some(b) => block_table.push(b), - } + block_table.push( + BLOCK_REGISTRY + .get(name) + .copied() + // wont get rendered + .unwrap_or(&crate::block::METAL_FLOOR), + ); } let num_blocks = buff.read_i32()?; if num_blocks < 0 || num_blocks as u32 > MAX_BLOCKS { diff --git a/mindus/src/exe/draw.rs b/mindus/src/exe/draw.rs index 70b03b1..08f84c7 100644 --- a/mindus/src/exe/draw.rs +++ b/mindus/src/exe/draw.rs @@ -14,11 +14,10 @@ pub fn main(args: Args) { Schematic::deserialize(&mut DataRead::new(&v)) } else { match Schematic::deserialize_base64(&curr) { - Err(mindus::data::schematic::R64Error::Base64(e)) => { + Err(e) => { print_err!(e, "Could not read schematic"); continue; } - Err(mindus::data::schematic::R64Error::Content(e)) => Err(e), Ok(o) => Ok(o), } } { @@ -29,6 +28,7 @@ pub fn main(args: Args) { && v == "1" { i.save("x.png"); + println!("drawn"); continue; } } |