aboutsummaryrefslogtreecommitdiff
path: root/client/src/world/map.rs
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/world/map.rs')
-rw-r--r--client/src/world/map.rs26
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),
+ })
}
}