From 23871101b40ae16717767cedee3a8824d7ef67d2 Mon Sep 17 00:00:00 2001 From: Marrub Date: Tue, 5 Feb 2019 04:28:29 -0500 Subject: [PATCH] fix side data interpretation --- MarathonData.md | 5 ++++- src/marathon/map.rs | 29 ++++------------------------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/MarathonData.md b/MarathonData.md index 6e3f0cb..0a15204 100644 --- a/MarathonData.md +++ b/MarathonData.md @@ -633,7 +633,7 @@ Side is 64 bytes. | Point | Collision top-right | ExTRight | | Point | Collision bottom-left | ExBLeft | | Point | Collision bottom-right | ExBRight | -| u16 | Control Panel Type | PanelType | +| u16 | Control panel preset number | PanelType | | i16 | Control panel permutation | PanelPerm | | u16 | First texture transfer mode | XferPri | | u16 | Second texture transfer mode | XferSec | @@ -1041,6 +1041,9 @@ exit upon reading them. ### Control Panel Type ### +This is used internally for each control panel preset and determines the +permutation each one uses. + | Value | Description | Permutation | Name | | ----- | ----------- | ----------- | ---- | | 0 | Oxygen refuel | None | Oxygen | diff --git a/src/marathon/map.rs b/src/marathon/map.rs index ae7236c..8eb533d 100644 --- a/src/marathon/map.rs +++ b/src/marathon/map.rs @@ -55,6 +55,7 @@ fn read_side_tex(b: &[u8]) -> ResultS { let offs = Point::read(&b[0..4])?; let tex_id = b.c_u16b(4)?; + let tex_id = if tex_id == 65535 {None} else {Some(tex_id)}; Ok(SideTex{offs, tex_id}) } @@ -80,13 +81,7 @@ impl Chunked for Side let xfer_tra = b.c_u16b(46)?; let shade = b.c_u32b(48)?; let flags = SideFlags::from_bits_truncate(flags); - let paneltyp = - if flags.contains(SideFlags::Panel) { - Some(PanelType::from_repr(paneltyp)?) - } else { - None - }; - let shade = Fx32::from_bits(shade); + let shade = Fx32::from_bits(shade); Ok(Side{stype, flags, tex_pri, tex_sec, tex_tra, ex_tleft, ex_trigh, ex_bleft, ex_brigh, paneltyp, paneldat, xfer_pri, xfer_sec, xfer_tra, shade}) @@ -148,7 +143,7 @@ pub struct Line pub struct SideTex { offs: Point, - tex_id: u16, + tex_id: Option, } #[derive(Debug)] @@ -163,7 +158,7 @@ pub struct Side ex_trigh: Point, ex_bleft: Point, ex_brigh: Point, - paneltyp: Option, + paneltyp: u16, paneldat: i16, xfer_pri: u16, xfer_sec: u16, @@ -262,22 +257,6 @@ bitflags! { } } -c_enum! { - #[derive(Debug)] - pub enum PanelType: u16 - { - 0 => Oxygen, - 1 => Shield, - 2 => Shield2x, - 3 => Shield3x, - 4 => Light, - 5 => Platform, - 6 => Tag, - 7 => PatternBuf, - 8 => Terminal, - } -} - impl fmt::Debug for Point { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result