mindustry logic execution, map- and schematic- parsing and rendering
fix foggy maps
| -rw-r--r-- | mindus/Cargo.toml | 2 | ||||
| -rw-r--r-- | mindus/src/data/map.rs | 8 | ||||
| -rw-r--r-- | mindus/src/item/storage.rs | 19 |
3 files changed, 12 insertions, 17 deletions
diff --git a/mindus/Cargo.toml b/mindus/Cargo.toml index 90b674c..84f5f6e 100644 --- a/mindus/Cargo.toml +++ b/mindus/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mindus" -version = "5.0.15" +version = "5.0.16" 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/map.rs b/mindus/src/data/map.rs index de474db..3def550 100644 --- a/mindus/src/data/map.rs +++ b/mindus/src/data/map.rs @@ -331,11 +331,13 @@ impl Build { if mask & 4 != 0 { read_liquids(buff, &mut self.liquids)?; } - // "efficiency"? - buff.skip(2)?; + // "efficiency" + _ = buff.read_u8()? as f64 / 255.; + _ = buff.read_u8()? as f64 / 255.; + if version == 4 { // visible flags for fog - buff.skip(4)?; + _ = buff.read_u64()?; } // "overridden by subclasses" self.block.read(self, buff)?; diff --git a/mindus/src/item/storage.rs b/mindus/src/item/storage.rs index b028e1c..7fccccc 100644 --- a/mindus/src/item/storage.rs +++ b/mindus/src/item/storage.rs @@ -31,6 +31,12 @@ impl<T: std::fmt::Debug + TryFrom<u16>> std::fmt::Debug for Storage<T> { } } +impl<T: TryFrom<u16> + fmt::Debug> fmt::Display for Storage<T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_map().entries(self.iter_nonzero()).finish() + } +} + impl<T> Storage<T> where u16: From<T>, @@ -377,19 +383,6 @@ impl<T> PartialEq for Storage<T> { } } -impl<T: TryFrom<u16> + fmt::Display> fmt::Display for Storage<T> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let mut iter = self.iter_nonzero(); - if let Some((ty, cnt)) = iter.next() { - write!(f, "{cnt} {ty}")?; - for (ty, cnt) in iter { - write!(f, ", {cnt} {ty}")?; - } - } - Ok(()) - } -} - #[derive(Clone, Copy, Debug, Eq, PartialEq, thiserror::Error)] #[error("adding {add} to current {have} would exceed {max}")] pub struct TryAddError { |