mindustry logic execution, map- and schematic- parsing and rendering
fix walls not drawing
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | src/data/map.rs | 6 | ||||
| -rw-r--r-- | src/data/renderer.rs | 12 |
3 files changed, 8 insertions, 12 deletions
@@ -1,6 +1,6 @@ [package] name = "mindus" -version = "1.3.3" +version = "1.3.4" edition = "2021" description = "A library for working with mindustry data formats (eg schematics and maps) (fork of plandustry)" authors = [ diff --git a/src/data/map.rs b/src/data/map.rs index 9c633ea..6348477 100644 --- a/src/data/map.rs +++ b/src/data/map.rs @@ -459,7 +459,7 @@ impl<'l> Serializer<Map<'l>> for MapSerializer<'l> { Some( self.0 .get(block.get_name()) - .ok_or(ReadError::NoSuchBlock(block.to_string()))?, + .ok_or_else(|| ReadError::NoSuchBlock(block.to_string()))?, ) } else { None @@ -489,9 +489,9 @@ impl<'l> Serializer<Map<'l>> for MapSerializer<'l> { map[i].build.as_mut().unwrap().data = buff.read_i8()?; } else { let consecutives = buff.read_u8()? as usize; - for tile in map.tiles.iter_mut().take(consecutives).skip(i + 1) { + for i in i..=i + consecutives { if let Some(block) = block { - tile.set_block(block); + map.tiles[i].set_block(block); } } i += consecutives; diff --git a/src/data/renderer.rs b/src/data/renderer.rs index 58aba9b..c92f152 100644 --- a/src/data/renderer.rs +++ b/src/data/renderer.rs @@ -245,16 +245,12 @@ impl Renderable for Map<'_> { y as u32 * scale, ); } else { - let s = if let Some(build) = &tile.build() { - build.block.get_size() - } else { - 1 - }; + let build = tile.build().unwrap(); + let s = build.block.get_size(); let x = x - ((s - 1) / 2) as usize; let y = y - (s / 2) as usize; let ctx = (|| { - let b = tile.build()?; - if !b.block.wants_context() { + if !build.block.wants_context() { return None; } let pctx = PositionContext { @@ -264,7 +260,7 @@ impl Renderable for Map<'_> { }; let rctx = RenderingContext { cross: self.cross(j, &pctx), - rotation: b.rotation, + rotation: build.rotation, position: pctx, }; Some(rctx) |