diff options
author | metamuffin <yvchraiqi@protonmail.com> | 2022-06-09 18:38:42 +0200 |
---|---|---|
committer | metamuffin <yvchraiqi@protonmail.com> | 2022-06-09 18:38:42 +0200 |
commit | 96e2ffc5f1ce1ff6163fc7fa31d51a6c36a9c0d5 (patch) | |
tree | 49c5aebcedd151bfb7517e83d49ab83af75b494e /client/src/world/map.rs | |
parent | f74ac9e9ed20d3958e180e8fc7fd328fcdfbbbec (diff) | |
download | twclient-96e2ffc5f1ce1ff6163fc7fa31d51a6c36a9c0d5.tar twclient-96e2ffc5f1ce1ff6163fc7fa31d51a6c36a9c0d5.tar.bz2 twclient-96e2ffc5f1ce1ff6163fc7fa31d51a6c36a9c0d5.tar.zst |
sdkljhfgjkhsdfgkjlhsgdf
Diffstat (limited to 'client/src/world/map.rs')
-rw-r--r-- | client/src/world/map.rs | 26 |
1 files changed, 15 insertions, 11 deletions
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<usize>, pub tiles: Array2<Tile>, pub kind: LayerTilemapType, + pub offset: (i32, i32), } pub struct Map { pub layers: Vec<Layer>, pub tilesets: HashMap<Option<usize>, Array2<Color>>, + 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<Self, Error> { + pub fn load(file: File, name: &str, crc: i32) -> Result<Self, Error> { 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), + }) } } |