some minor things

png-branch
an 2019-03-03 00:44:45 -05:00
parent 4570d494ad
commit 1d057d66af
7 changed files with 38 additions and 41 deletions

View File

@ -13,7 +13,7 @@ fn crc_init() -> [u32; 256]
{
let mut t = [0; 256];
for (n, v) in t.iter_mut().enumerate() {
*v = (0..8).fold(u32::from(n), crc_accum);
*v = (0..8).fold(n as u32, crc_accum);
}
t
}

View File

@ -136,13 +136,12 @@ pub fn read_sids(b: &[u8]) -> ResultS<(Side, usize)>
/// Reads an old `SIDS` chunk.
pub fn read_old_sids(b: &[u8]) -> ResultS<(Side, usize)>
{
let (mut side, siz) = read_sids(b)?;
let (side, siz) = read_sids(b)?;
side.tex_tra.tex_id = OptU16::none();
side.shade = Fixed::from_int(0);
side.flags.insert(SideFlags::ItemOpt);
Ok((side, siz))
Ok((Side{tex_tra: SideTex{tex_id: OptU16::none(), ..side.tex_tra},
shade: 0.into(),
flags: side.flags | SideFlags::ItemOpt,
..side}, siz))
}
/// Reads a `POLY` chunk.
@ -181,9 +180,9 @@ pub fn read_poly(b: &[u8]) -> ResultS<(Polygon, usize)>
/// Reads an old `POLY` chunk.
pub fn read_old_poly(b: &[u8]) -> ResultS<(Polygon, usize)>
{
let (mut poly, siz) = read_poly(b)?;
let (poly, siz) = read_poly(b)?;
poly.ptype = match poly.ptype {
Ok((Polygon{ptype: match poly.ptype {
PolyType::Hill => PolyType::OuchMinor,
PolyType::Base => PolyType::OuchMajor,
PolyType::ZoneBorder => PolyType::Glue,
@ -192,15 +191,13 @@ pub fn read_old_poly(b: &[u8]) -> ResultS<(Polygon, usize)>
PolyType::TrigMonsInv => PolyType::MustExplore,
PolyType::TrigMonsDual => PolyType::AutoExit,
ptype => ptype,
};
poly.ori_flr = Point{x: Unit::from_int(0), y: Unit::from_int(0)};
poly.ori_cei = Point{x: Unit::from_int(0), y: Unit::from_int(0)};
poly.med_ind = OptU16::none();
poly.snd_amb = OptU16::none();
poly.snd_rnd = OptU16::none();
Ok((poly, siz))
},
ori_flr: Point{x: 0.into(), y: 0.into()},
ori_cei: Point{x: 0.into(), y: 0.into()},
med_ind: OptU16::none(),
snd_amb: OptU16::none(),
snd_rnd: OptU16::none(),
..poly}, siz))
}
/// Reads a `LITE` chunk.
@ -254,12 +251,11 @@ pub fn read_old_lite(b: &[u8]) -> ResultS<(Light, usize)>
LightFunc{ftype: func.ftype,
prd_nrm: if strobe {prd / 4 + 1} else {func.prd_nrm},
prd_dta: func.prd_dta,
val_nrm: if func.val_nrm > Fixed::from_int(0) {max} else {min},
val_nrm: if func.val_nrm > 0.into() {max} else {min},
val_dta: func.val_dta}
};
Ok((Light{ltype: lite.ltype,
flags,
Ok((Light{flags,
phase,
act_pri: old_lfun(&lite.act_pri),
act_sec: old_lfun(&lite.act_sec),
@ -267,7 +263,8 @@ pub fn read_old_lite(b: &[u8]) -> ResultS<(Light, usize)>
ina_pri: old_lfun(&lite.ina_pri),
ina_sec: old_lfun(&lite.ina_sec),
ina_mid: old_lfun(&lite.ina_mid),
tag: 0}, 32))
tag: 0,
..*lite}, 32))
}
/// Reads an `OBJS` chunk.
@ -595,7 +592,7 @@ pub struct Note
}
/// Static map information.
#[derive(Debug, PartialEq, serde::Serialize)]
#[derive(Debug, Default, PartialEq, serde::Serialize)]
pub struct Minf
{
pub env_code: u16,
@ -639,7 +636,7 @@ bitflags! {
bitflags! {
/// Static environment flags.
#[derive(serde::Serialize)]
#[derive(Default, serde::Serialize)]
pub struct EnvFlags: u16
{
const Vacuum = 1;
@ -660,7 +657,7 @@ bitflags! {
bitflags! {
/// Static entry point flags.
#[derive(serde::Serialize)]
#[derive(Default, serde::Serialize)]
pub struct EntFlags: u32
{
const Solo = 1;
@ -676,7 +673,7 @@ bitflags! {
bitflags! {
/// Static mission flags.
#[derive(serde::Serialize)]
#[derive(Default, serde::Serialize)]
pub struct MsnFlags: u16
{
const Extermination = 1;