trait impls
parent
1ddc5a43af
commit
f4efbfab80
|
@ -459,6 +459,24 @@ impl fmt::Debug for Ident
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PartialEq<[u8; 4]> for Ident
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn eq(&self, o: &[u8; 4]) -> bool {self.0 == *o}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> PartialEq<[u8; 4]> for &'a Ident
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn eq(&self, o: &[u8; 4]) -> bool {PartialEq::eq(*self, o)}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> PartialEq<&'a [u8; 4]> for Ident
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn eq(&self, o: & &'a [u8; 4]) -> bool {PartialEq::eq(self, *o)}
|
||||||
|
}
|
||||||
|
|
||||||
/// A four-character-code identifier.
|
/// A four-character-code identifier.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
|
@ -466,15 +484,19 @@ impl fmt::Debug for Ident
|
||||||
/// ```
|
/// ```
|
||||||
/// use maraiah::durandal::bin::Ident;
|
/// use maraiah::durandal::bin::Ident;
|
||||||
///
|
///
|
||||||
/// assert_eq!(Ident(*b"POLY").0, *b"POLY");
|
/// assert_eq!( Ident(*b"POLY").0, *b"POLY");
|
||||||
|
/// assert_eq!( Ident(*b"POLY"), *b"POLY");
|
||||||
|
/// assert_eq!( Ident(*b"POLY"), b"POLY");
|
||||||
|
/// assert_eq!(&Ident(*b"POLY"), *b"POLY");
|
||||||
|
/// assert_eq!(&Ident(*b"POLY"), b"POLY");
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Clone, Copy, Default, PartialEq)]
|
#[derive(Clone, Copy, Default, Eq, PartialEq)]
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub struct Ident(/** The individual bytes of this identifier. */ pub [u8; 4]);
|
pub struct Ident(/** The individual bytes of this identifier. */ pub [u8; 4]);
|
||||||
|
|
||||||
/// An object identified by a `u16` which may be `u16::max_value()` to
|
/// An object identified by a `u16` which may be `u16::max_value()` to
|
||||||
/// represent a nulled value.
|
/// represent a nulled value.
|
||||||
#[derive(Clone, Copy, Default, PartialEq)]
|
#[derive(Clone, Copy, Default, Eq, PartialEq)]
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub struct OptU16(Option<NonZeroU16>);
|
pub struct OptU16(Option<NonZeroU16>);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/// use maraiah::{c_enum, durandal::err::ReprError};
|
/// use maraiah::{c_enum, durandal::err::ReprError};
|
||||||
///
|
///
|
||||||
/// c_enum! {
|
/// c_enum! {
|
||||||
/// #[derive(Debug, PartialEq)]
|
/// #[derive(Debug)]
|
||||||
/// enum MyEnum: u16
|
/// enum MyEnum: u16
|
||||||
/// {
|
/// {
|
||||||
/// 0 => Zero,
|
/// 0 => Zero,
|
||||||
|
@ -42,7 +42,7 @@ macro_rules! c_enum
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
$(#[$outer])*
|
$(#[$outer])*
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone, Eq, Ord, PartialEq, PartialOrd)]
|
||||||
$vi enum $t
|
$vi enum $t
|
||||||
{
|
{
|
||||||
$($en,)+
|
$($en,)+
|
||||||
|
@ -68,7 +68,7 @@ mod test
|
||||||
use crate::durandal::err::ReprError;
|
use crate::durandal::err::ReprError;
|
||||||
|
|
||||||
c_enum! {
|
c_enum! {
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug)]
|
||||||
enum TestEnum: u16
|
enum TestEnum: u16
|
||||||
{
|
{
|
||||||
0 => Zero,
|
0 => Zero,
|
||||||
|
|
|
@ -87,7 +87,7 @@ impl fmt::Display for ErrMsg
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A representation error for an integer.
|
/// A representation error for an integer.
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||||
pub struct ReprError(i64);
|
pub struct ReprError(i64);
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
@ -22,9 +22,9 @@ macro_rules! fixed_ref_binop {
|
||||||
type Output = <$t as $imp<$u>>::Output;
|
type Output = <$t as $imp<$u>>::Output;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn $method(self, other: $u) -> <$t as $imp<$u>>::Output
|
fn $method(self, o: $u) -> <$t as $imp<$u>>::Output
|
||||||
{
|
{
|
||||||
$imp::$method(*self, other)
|
$imp::$method(*self, o)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,9 +33,9 @@ macro_rules! fixed_ref_binop {
|
||||||
type Output = <$t as $imp<$u>>::Output;
|
type Output = <$t as $imp<$u>>::Output;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn $method(self, other: &'a $u) -> <$t as $imp<$u>>::Output
|
fn $method(self, o: &'a $u) -> <$t as $imp<$u>>::Output
|
||||||
{
|
{
|
||||||
$imp::$method(self, *other)
|
$imp::$method(self, *o)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,9 +44,9 @@ macro_rules! fixed_ref_binop {
|
||||||
type Output = <$t as $imp<$u>>::Output;
|
type Output = <$t as $imp<$u>>::Output;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn $method(self, other: &'a $u) -> <$t as $imp<$u>>::Output
|
fn $method(self, o: &'a $u) -> <$t as $imp<$u>>::Output
|
||||||
{
|
{
|
||||||
$imp::$method(*self, *other)
|
$imp::$method(*self, *o)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -57,7 +57,7 @@ macro_rules! fixed_ref_op_assign {
|
||||||
impl<'a> $imp<&'a $u> for $t
|
impl<'a> $imp<&'a $u> for $t
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn $method(&mut self, other: &'a $u) {$imp::$method(self, *other);}
|
fn $method(&mut self, o: &'a $u) {$imp::$method(self, *o);}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ macro_rules! define_fixed_types {
|
||||||
) => {$(
|
) => {$(
|
||||||
$(#[$outer])*
|
$(#[$outer])*
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Copy, Clone, Default, PartialEq, PartialOrd)]
|
#[derive(Copy, Clone, Default, Eq, Ord, PartialEq, PartialOrd)]
|
||||||
pub struct $t($ti);
|
pub struct $t($ti);
|
||||||
|
|
||||||
impl $t
|
impl $t
|
||||||
|
@ -354,7 +354,7 @@ macro_rules! define_fixed_types {
|
||||||
impl AddAssign for $t
|
impl AddAssign for $t
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn add_assign(&mut self, other: $t) {self.0 += other.0}
|
fn add_assign(&mut self, o: $t) {self.0 += o.0}
|
||||||
}
|
}
|
||||||
|
|
||||||
fixed_ref_op_assign! {impl AddAssign, add_assign for $t, $t}
|
fixed_ref_op_assign! {impl AddAssign, add_assign for $t, $t}
|
||||||
|
@ -362,7 +362,7 @@ macro_rules! define_fixed_types {
|
||||||
impl SubAssign for $t
|
impl SubAssign for $t
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sub_assign(&mut self, other: $t) {self.0 -= other.0}
|
fn sub_assign(&mut self, o: $t) {self.0 -= o.0}
|
||||||
}
|
}
|
||||||
|
|
||||||
fixed_ref_op_assign! {impl SubAssign, sub_assign for $t, $t}
|
fixed_ref_op_assign! {impl SubAssign, sub_assign for $t, $t}
|
||||||
|
@ -370,7 +370,7 @@ macro_rules! define_fixed_types {
|
||||||
impl MulAssign for $t
|
impl MulAssign for $t
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn mul_assign(&mut self, other: $t) {self.0 = (*self * other).0}
|
fn mul_assign(&mut self, o: $t) {self.0 = (*self * o).0}
|
||||||
}
|
}
|
||||||
|
|
||||||
fixed_ref_op_assign! {impl MulAssign, mul_assign for $t, $t}
|
fixed_ref_op_assign! {impl MulAssign, mul_assign for $t, $t}
|
||||||
|
@ -378,7 +378,7 @@ macro_rules! define_fixed_types {
|
||||||
impl DivAssign for $t
|
impl DivAssign for $t
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn div_assign(&mut self, other: $t) {self.0 = (*self / other).0}
|
fn div_assign(&mut self, o: $t) {self.0 = (*self / o).0}
|
||||||
}
|
}
|
||||||
|
|
||||||
fixed_ref_op_assign! {impl DivAssign, div_assign for $t, $t}
|
fixed_ref_op_assign! {impl DivAssign, div_assign for $t, $t}
|
||||||
|
|
|
@ -140,7 +140,7 @@ pub trait Image
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Any color which may be represented as RGBA16.
|
/// Any color which may be represented as RGBA16.
|
||||||
pub trait Color: Sized + Copy + Clone
|
pub trait Color: Sized + Copy + Clone + Eq + PartialEq
|
||||||
{
|
{
|
||||||
/// Returns the red component.
|
/// Returns the red component.
|
||||||
fn r(&self) -> u16;
|
fn r(&self) -> u16;
|
||||||
|
@ -227,12 +227,12 @@ impl Color for Color8
|
||||||
|
|
||||||
/// An RGB16 color.
|
/// An RGB16 color.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct Color16(u16, u16, u16);
|
pub struct Color16(u16, u16, u16);
|
||||||
|
|
||||||
/// An RGB8 color.
|
/// An RGB8 color.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct Color8(u8, u8, u8);
|
pub struct Color8(u8, u8, u8);
|
||||||
|
|
||||||
/// An RGB16 image.
|
/// An RGB16 image.
|
||||||
|
|
|
@ -124,6 +124,8 @@ impl Sound for Sound16
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A 16-bit PCM stream.
|
/// A 16-bit PCM stream.
|
||||||
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Sound16
|
pub struct Sound16
|
||||||
{
|
{
|
||||||
rate: u16,
|
rate: u16,
|
||||||
|
|
|
@ -433,7 +433,8 @@ pub fn read_note(b: &[u8]) -> ResultS<(Note, usize)>
|
||||||
|
|
||||||
impl PolyType
|
impl PolyType
|
||||||
{
|
{
|
||||||
fn new(n: u16, pdata: u16) -> Result<Self, ReprError>
|
/// Creates a `PolyType` from a `n`/`pdata` pair.
|
||||||
|
pub fn new(n: u16, pdata: u16) -> Result<Self, ReprError>
|
||||||
{
|
{
|
||||||
match n {
|
match n {
|
||||||
0 => Ok(PolyType::Normal),
|
0 => Ok(PolyType::Normal),
|
||||||
|
@ -464,6 +465,7 @@ impl PolyType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates a `PolyType` from a Marathon 1 compatible `n`/`pdata` pair.
|
||||||
fn new_old(n: u16, pdata: u16) -> Result<Self, ReprError>
|
fn new_old(n: u16, pdata: u16) -> Result<Self, ReprError>
|
||||||
{
|
{
|
||||||
match n {
|
match n {
|
||||||
|
@ -509,7 +511,7 @@ impl Default for Minf
|
||||||
|
|
||||||
/// A point in world-space.
|
/// A point in world-space.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Clone, Debug, Default, PartialEq)]
|
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
|
||||||
pub struct Point
|
pub struct Point
|
||||||
{
|
{
|
||||||
pub x: Unit,
|
pub x: Unit,
|
||||||
|
@ -518,7 +520,7 @@ pub struct Point
|
||||||
|
|
||||||
/// A line segment.
|
/// A line segment.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Line
|
pub struct Line
|
||||||
{
|
{
|
||||||
pub flags: LineFlags,
|
pub flags: LineFlags,
|
||||||
|
@ -532,7 +534,7 @@ pub struct Line
|
||||||
|
|
||||||
/// The texture of a side segment.
|
/// The texture of a side segment.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct SideTex
|
pub struct SideTex
|
||||||
{
|
{
|
||||||
pub offs: Point,
|
pub offs: Point,
|
||||||
|
@ -541,7 +543,7 @@ pub struct SideTex
|
||||||
|
|
||||||
/// One side of a line segment.
|
/// One side of a line segment.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Side
|
pub struct Side
|
||||||
{
|
{
|
||||||
pub stype: SideType,
|
pub stype: SideType,
|
||||||
|
@ -559,7 +561,7 @@ pub struct Side
|
||||||
|
|
||||||
/// A polygon segment.
|
/// A polygon segment.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default, Eq, PartialEq)]
|
||||||
pub struct Polygon
|
pub struct Polygon
|
||||||
{
|
{
|
||||||
pub ptype: PolyType,
|
pub ptype: PolyType,
|
||||||
|
@ -582,7 +584,7 @@ pub struct Polygon
|
||||||
|
|
||||||
/// A light function.
|
/// A light function.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct LightFunc
|
pub struct LightFunc
|
||||||
{
|
{
|
||||||
pub ftype: LightFuncType,
|
pub ftype: LightFuncType,
|
||||||
|
@ -594,7 +596,7 @@ pub struct LightFunc
|
||||||
|
|
||||||
/// A dynamic polygon light.
|
/// A dynamic polygon light.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Light
|
pub struct Light
|
||||||
{
|
{
|
||||||
pub ltype: LightType,
|
pub ltype: LightType,
|
||||||
|
@ -611,7 +613,7 @@ pub struct Light
|
||||||
|
|
||||||
/// An object in the world.
|
/// An object in the world.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Object
|
pub struct Object
|
||||||
{
|
{
|
||||||
pub group: u16,
|
pub group: u16,
|
||||||
|
@ -627,7 +629,7 @@ pub struct Object
|
||||||
|
|
||||||
/// The difficulty definition for various object types.
|
/// The difficulty definition for various object types.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct ObjectFreq
|
pub struct ObjectFreq
|
||||||
{
|
{
|
||||||
pub rnd_loc: bool,
|
pub rnd_loc: bool,
|
||||||
|
@ -640,7 +642,7 @@ pub struct ObjectFreq
|
||||||
|
|
||||||
/// An ambient sound definition.
|
/// An ambient sound definition.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct SoundAmbi
|
pub struct SoundAmbi
|
||||||
{
|
{
|
||||||
pub index: u16,
|
pub index: u16,
|
||||||
|
@ -649,7 +651,7 @@ pub struct SoundAmbi
|
||||||
|
|
||||||
/// A randomly played sound definition.
|
/// A randomly played sound definition.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct SoundRand
|
pub struct SoundRand
|
||||||
{
|
{
|
||||||
pub no_dir: bool,
|
pub no_dir: bool,
|
||||||
|
@ -666,7 +668,7 @@ pub struct SoundRand
|
||||||
|
|
||||||
/// A media, as in a part of a polygon which goes up the middle of the wall.
|
/// A media, as in a part of a polygon which goes up the middle of the wall.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Media
|
pub struct Media
|
||||||
{
|
{
|
||||||
pub mtype: MediaType,
|
pub mtype: MediaType,
|
||||||
|
@ -685,7 +687,7 @@ pub struct Media
|
||||||
|
|
||||||
/// Extra information for polygons with platforms.
|
/// Extra information for polygons with platforms.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Platform
|
pub struct Platform
|
||||||
{
|
{
|
||||||
pub ptype: u16,
|
pub ptype: u16,
|
||||||
|
@ -700,7 +702,7 @@ pub struct Platform
|
||||||
|
|
||||||
/// Overhead map annotations.
|
/// Overhead map annotations.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Note
|
pub struct Note
|
||||||
{
|
{
|
||||||
pub pos: Point,
|
pub pos: Point,
|
||||||
|
@ -710,7 +712,7 @@ pub struct Note
|
||||||
|
|
||||||
/// Static map information.
|
/// Static map information.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Minf
|
pub struct Minf
|
||||||
{
|
{
|
||||||
pub texture_id: u16,
|
pub texture_id: u16,
|
||||||
|
@ -724,7 +726,7 @@ pub struct Minf
|
||||||
|
|
||||||
/// The action type of a `Polygon`.
|
/// The action type of a `Polygon`.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub enum PolyType
|
pub enum PolyType
|
||||||
{
|
{
|
||||||
Normal,
|
Normal,
|
||||||
|
|
|
@ -284,7 +284,7 @@ fn read_attack(b: &[u8]) -> ResultS<Attack>
|
||||||
|
|
||||||
/// Static physics information.
|
/// Static physics information.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Physics
|
pub struct Physics
|
||||||
{
|
{
|
||||||
pub acc_ang: Fixed,
|
pub acc_ang: Fixed,
|
||||||
|
@ -317,7 +317,7 @@ pub struct Physics
|
||||||
|
|
||||||
/// An effect definition.
|
/// An effect definition.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Effect
|
pub struct Effect
|
||||||
{
|
{
|
||||||
pub collection: u16,
|
pub collection: u16,
|
||||||
|
@ -330,7 +330,7 @@ pub struct Effect
|
||||||
|
|
||||||
/// A weapon definition.
|
/// A weapon definition.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Weapon
|
pub struct Weapon
|
||||||
{
|
{
|
||||||
pub amp_bob: Fixed,
|
pub amp_bob: Fixed,
|
||||||
|
@ -362,7 +362,7 @@ pub struct Weapon
|
||||||
|
|
||||||
/// The definition of one of two triggers for a weapon.
|
/// The definition of one of two triggers for a weapon.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Trigger
|
pub struct Trigger
|
||||||
{
|
{
|
||||||
pub burst: u16,
|
pub burst: u16,
|
||||||
|
@ -387,7 +387,7 @@ pub struct Trigger
|
||||||
|
|
||||||
/// A projectile definition.
|
/// A projectile definition.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Projectile
|
pub struct Projectile
|
||||||
{
|
{
|
||||||
pub collection: OptU16,
|
pub collection: OptU16,
|
||||||
|
@ -411,7 +411,7 @@ pub struct Projectile
|
||||||
|
|
||||||
/// A monster definition.
|
/// A monster definition.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Monster
|
pub struct Monster
|
||||||
{
|
{
|
||||||
pub collection: u16,
|
pub collection: u16,
|
||||||
|
@ -469,7 +469,7 @@ pub struct Monster
|
||||||
|
|
||||||
/// A damage definition.
|
/// A damage definition.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Damage
|
pub struct Damage
|
||||||
{
|
{
|
||||||
pub dtype: DamageType,
|
pub dtype: DamageType,
|
||||||
|
@ -481,7 +481,7 @@ pub struct Damage
|
||||||
|
|
||||||
/// The definition of a monster's attack.
|
/// The definition of a monster's attack.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Attack
|
pub struct Attack
|
||||||
{
|
{
|
||||||
pub ptype: OptU16,
|
pub ptype: OptU16,
|
||||||
|
|
|
@ -479,7 +479,6 @@ struct Header
|
||||||
}
|
}
|
||||||
|
|
||||||
c_enum! {
|
c_enum! {
|
||||||
#[derive(PartialEq, PartialOrd)]
|
|
||||||
enum Depth: u16
|
enum Depth: u16
|
||||||
{
|
{
|
||||||
1 => Bits1,
|
1 => Bits1,
|
||||||
|
@ -492,7 +491,6 @@ c_enum! {
|
||||||
}
|
}
|
||||||
|
|
||||||
c_enum! {
|
c_enum! {
|
||||||
#[derive(PartialEq)]
|
|
||||||
enum PackType: u16
|
enum PackType: u16
|
||||||
{
|
{
|
||||||
0 => Default,
|
0 => Default,
|
||||||
|
|
|
@ -318,7 +318,7 @@ impl Color for ColorShp
|
||||||
|
|
||||||
/// A color in an `ImageShp`'s color table.
|
/// A color in an `ImageShp`'s color table.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||||
pub enum ColorShp
|
pub enum ColorShp
|
||||||
{
|
{
|
||||||
/// A completely translucent color.
|
/// A completely translucent color.
|
||||||
|
@ -336,7 +336,7 @@ pub enum ColorShp
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An unpacked Shape bitmap.
|
/// An unpacked Shape bitmap.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Bitmap
|
pub struct Bitmap
|
||||||
{
|
{
|
||||||
w: usize,
|
w: usize,
|
||||||
|
@ -348,6 +348,7 @@ pub struct Bitmap
|
||||||
|
|
||||||
/// An image from a Shape. This mainly just exists so that `Bitmap` can use the
|
/// An image from a Shape. This mainly just exists so that `Bitmap` can use the
|
||||||
/// `Image` trait.
|
/// `Image` trait.
|
||||||
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct ImageShp<'a, 'b>
|
pub struct ImageShp<'a, 'b>
|
||||||
{
|
{
|
||||||
bmp: &'a Bitmap,
|
bmp: &'a Bitmap,
|
||||||
|
@ -356,7 +357,7 @@ pub struct ImageShp<'a, 'b>
|
||||||
|
|
||||||
/// A frame, also known as a low level shape.
|
/// A frame, also known as a low level shape.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Frame
|
pub struct Frame
|
||||||
{
|
{
|
||||||
/// The flags for this frame.
|
/// The flags for this frame.
|
||||||
|
@ -389,7 +390,7 @@ pub struct Frame
|
||||||
|
|
||||||
/// A sequence, also known as a high level shape.
|
/// A sequence, also known as a high level shape.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Sequence
|
pub struct Sequence
|
||||||
{
|
{
|
||||||
/// The display name for this sequence.
|
/// The display name for this sequence.
|
||||||
|
@ -427,7 +428,7 @@ pub struct Sequence
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A collection of color tables, bitmaps, frames and sequences.
|
/// A collection of color tables, bitmaps, frames and sequences.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Collection
|
pub struct Collection
|
||||||
{
|
{
|
||||||
/// The type of collection this is.
|
/// The type of collection this is.
|
||||||
|
@ -492,14 +493,14 @@ c_enum! {
|
||||||
pub enum ViewType: u16
|
pub enum ViewType: u16
|
||||||
{
|
{
|
||||||
1 => Anim,
|
1 => Anim,
|
||||||
|
2 => Anim8from2,
|
||||||
3 => Anim4from3,
|
3 => Anim4from3,
|
||||||
4 => Anim4,
|
4 => Anim4,
|
||||||
9 => Anim5from3,
|
|
||||||
11 => Anim5,
|
|
||||||
2 => Anim8from2,
|
|
||||||
5 => Anim8from5,
|
5 => Anim8from5,
|
||||||
8 => Anim8,
|
8 => Anim8,
|
||||||
|
9 => Anim5from3,
|
||||||
10 => Still,
|
10 => Still,
|
||||||
|
11 => Anim5,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,7 @@ pub fn read_sounds(b: &[u8]) -> ResultS<Vec<SoundTable>>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A sound definition containing one, many or no sounds.
|
/// A sound definition containing one, many or no sounds.
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct SoundDef
|
pub struct SoundDef
|
||||||
{
|
{
|
||||||
/// The volume type for this sound.
|
/// The volume type for this sound.
|
||||||
|
|
|
@ -98,7 +98,7 @@ impl Default for GroupType
|
||||||
|
|
||||||
/// A terminal definition, with collections of groups and faces.
|
/// A terminal definition, with collections of groups and faces.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Terminal
|
pub struct Terminal
|
||||||
{
|
{
|
||||||
pub lines: u16,
|
pub lines: u16,
|
||||||
|
@ -108,7 +108,7 @@ pub struct Terminal
|
||||||
|
|
||||||
/// A text face.
|
/// A text face.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Face
|
pub struct Face
|
||||||
{
|
{
|
||||||
pub start: usize,
|
pub start: usize,
|
||||||
|
@ -118,7 +118,7 @@ pub struct Face
|
||||||
|
|
||||||
/// A terminal command grouping.
|
/// A terminal command grouping.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Group
|
pub struct Group
|
||||||
{
|
{
|
||||||
pub flags: GroupFlags,
|
pub flags: GroupFlags,
|
||||||
|
@ -128,7 +128,7 @@ pub struct Group
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Interim structure.
|
/// Interim structure.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct InterGroup
|
pub struct InterGroup
|
||||||
{
|
{
|
||||||
pub flags: GroupFlags,
|
pub flags: GroupFlags,
|
||||||
|
@ -140,7 +140,7 @@ pub struct InterGroup
|
||||||
|
|
||||||
/// The command of a `Group`.
|
/// The command of a `Group`.
|
||||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||||
pub enum GroupType
|
pub enum GroupType
|
||||||
{
|
{
|
||||||
Logon(u16),
|
Logon(u16),
|
||||||
|
|
|
@ -32,6 +32,7 @@ fn defl_alice_2()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[ignore]
|
||||||
fn defl_shapes()
|
fn defl_shapes()
|
||||||
{
|
{
|
||||||
const INPUT: &[u8] = include_bytes!("data/defl/Shapes.in");
|
const INPUT: &[u8] = include_bytes!("data/defl/Shapes.in");
|
||||||
|
|
Loading…
Reference in New Issue