From 96e2ffc5f1ce1ff6163fc7fa31d51a6c36a9c0d5 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Thu, 9 Jun 2022 18:38:42 +0200 Subject: sdkljhfgjkhsdfgkjlhsgdf --- client/src/world/map.rs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'client/src/world/map.rs') diff --git a/client/src/world/map.rs b/client/src/world/map.rs index c72bfa9..c6355f2 100644 --- a/client/src/world/map.rs +++ b/client/src/world/map.rs @@ -23,11 +23,14 @@ pub struct Layer { pub image: Option, pub tiles: Array2, pub kind: LayerTilemapType, + pub offset: (i32, i32), } pub struct Map { pub layers: Vec, pub tilesets: HashMap, Array2>, + pub name: String, + pub crc: i32, } impl Map { @@ -35,10 +38,12 @@ impl Map { Self { layers: Vec::new(), tilesets: HashMap::new(), + crc: 0, + name: String::from("twclient dummy map"), } } - pub fn load(file: File) -> Result { + pub fn load(file: File, name: &str, crc: i32) -> Result { info!("loading map"); let datafile = datafile::Reader::new(file).unwrap(); let mut map = mapfile::Reader::from_datafile(datafile); @@ -47,17 +52,10 @@ impl Map { for group_idx in map.group_indices() { let group = map.group(group_idx).unwrap(); - if group.parallax_x != 100 - || group.parallax_y != 100 - || group.offset_x != 0 - || group.offset_y != 0 - || group.clipping.is_some() - { + if group.parallax_x != 100 || group.parallax_y != 100 || group.clipping.is_some() { warn!( - "skipping layer: {}: off_x:{} off_y:{} parallax_x:{} parallax_y:{} clipping:{:?}", + "skipping layer: {}: parallax_x:{} parallax_y:{} clipping:{:?}", pretty::AlmostString::new(&group.name), - group.offset_x, - group.offset_y, group.parallax_x, group.parallax_y, group.clipping, @@ -88,6 +86,7 @@ impl Map { image: normal.image, kind: tilemap.type_, tiles, + offset: (group.offset_x, group.offset_y), }); } } @@ -146,6 +145,11 @@ impl Map { layers.len(), tilesets.len() ); - Ok(Self { tilesets, layers }) + Ok(Self { + tilesets, + layers, + crc, + name: String::from(name), + }) } } -- cgit v1.2.3-70-g09d2