maraiah: fix tests and move code to root

master
an 2019-06-22 00:55:08 -04:00
parent bfb91792ec
commit daebfd2da6
124 changed files with 2470 additions and 264 deletions

View File

@ -14,10 +14,10 @@ publish = false
serde_obj = ["serde"] serde_obj = ["serde"]
[workspace] [workspace]
members = ["source/leela", "source/tycho"] members = ["leela", "tycho"]
[dependencies] [dependencies]
bitflags = "1.0" bitflags = "1.1"
failure = {version = "0.1", features = ["std"]} failure = {version = "0.1", features = ["std"]}
serde = {version = "1.0", features = ["derive"], optional = true} serde = {version = "1.0", features = ["derive"], optional = true}
memchr = "2.0" memchr = "2.0"
@ -31,4 +31,4 @@ lto = true
[lib] [lib]
name = "maraiah" name = "maraiah"
path = "source/lib.rs" path = "maraiah/lib.rs"

14
leela/Cargo.toml Normal file
View File

@ -0,0 +1,14 @@
[package]
name = "maraiah-leela"
version = "0.0.0"
edition = "2018"
[dependencies]
clap = "2"
maraiah = {path = "..", features = ["serde_obj"]}
serde = "1.0"
serde_yaml = "0.8"
[[bin]]
name = "leela"
path = "main.rs"

View File

@ -1,13 +1,13 @@
#![allow(clippy::unit_arg)] #![allow(clippy::unit_arg)]
use maraiah::{err::*, file::*, image::*, sound::*, use maraiah::{err::*, file::*, image::*, machdr, map, shp, snd, sound::*};
machdr, map, shp, snd};
use std::{collections::HashSet, fs, io, slice::from_ref}; use std::{collections::HashSet, fs, io, slice::from_ref};
fn open(path: &str) -> ResultS<memmap::Mmap> /*
fn open(path: &str) -> ResultS<io::BufReader>
{ {
let fp = fs::File::open(path)?; let fp = fs::File::open(path)?;
Ok(unsafe {memmap::Mmap::map(&fp)?}) Ok(io::BufReader::new(fp))
} }
fn file_read<T, F>(path: &str, f: F) -> ResultS<T> fn file_read<T, F>(path: &str, f: F) -> ResultS<T>
@ -22,14 +22,15 @@ fn file_read<T, F>(path: &str, f: F) -> ResultS<T>
fn exists(path: String) -> Result<(), String> fn exists(path: String) -> Result<(), String>
{ {
match std::fs::metadata(path) { match std::fs::metadata(path) {
Ok(_) => Ok(()), Ok(_) => Ok(()),
Err(e) => Err(e.to_string()), Err(e) => Err(e.to_string()),
} }
} }
fn each_value<F>(opt: &clap::ArgMatches<'_>, fn each_value<F>(opt: &clap::ArgMatches<'_>,
name: &str, name: &str,
mut f: F) -> ResultS<()> mut f: F)
-> ResultS<()>
where F: FnMut(&str) -> ResultS<()> where F: FnMut(&str) -> ResultS<()>
{ {
if let Some(values) = opt.values_of(name) { if let Some(values) = opt.values_of(name) {
@ -91,43 +92,60 @@ fn sub_info_c(opt: &clap::ArgMatches<'_>) -> ResultS<()>
Ok(()) Ok(())
} }
*/
fn main() -> ResultS<()> fn main() -> ResultS<()>
{ {
use std::io::prelude::*;
let inp = include_bytes!("../tests/data/map/Test.in");
let mut rd = std::io::BufReader::new(&inp[..]);
let mp = map::head::read(&mut rd).unwrap();
let en = map::entr::read_all(&mp).unwrap();
let ed = map::data::read_all(mp.head(), &en).unwrap();
write!(&mut std::fs::File::create("dicks.txt").unwrap(), "{:#?}", ed);
/*
use clap::clap_app; use clap::clap_app;
let sub_data = let sub_data = clap_app! {
clap_app!(@subcommand data => @subcommand data =>
(about: "Dumps data into a discrete folder/YAML format")); (about: "Dumps data into a discrete folder/YAML format")
};
let sub_dump = let sub_dump = clap_app! {
clap_app!(@subcommand dump => @subcommand dump =>
(about: "Dumps particular parts of data") (about: "Dumps particular parts of data")
(@arg chunks: -c --chunks [name]... "Dumps named chunks from an entry") (@arg chunks: -c --chunks [name]... "Dumps named chunks from an entry")
(@group files => (@group files =>
(@attributes +required +multiple) (@attributes +required +multiple)
(@arg map: -m --map [file]... {exists} "Loads Map files") (@arg map: -m --map [file]... {exists} "Loads Map files")
(@arg shp: -s --shp [file]... {exists} "Loads Shapes files") (@arg shp: -s --shp [file]... {exists} "Loads Shapes files")
(@arg snd: -n --snd [file]... {exists} "Loads Sounds files"))); (@arg snd: -n --snd [file]... {exists} "Loads Sounds files"))
};
let sub_info = let sub_info = clap_app! {
clap_app!(@subcommand info => @subcommand info =>
(about: "Outputs debug info") (about: "Outputs debug info")
(@group files => (@group files =>
(@attributes +required +multiple) (@attributes +required +multiple)
(@arg map: -m --map [file]... {exists} "Loads Map files") (@arg map: -m --map [file]... {exists} "Loads Map files")
(@arg shp: -s --shp [file]... {exists} "Loads Shapes files") (@arg shp: -s --shp [file]... {exists} "Loads Shapes files")
(@arg snd: -n --snd [file]... {exists} "Loads Sounds files"))); (@arg snd: -n --snd [file]... {exists} "Loads Sounds files"))
};
let opt = let opt = clap_app! {
clap_app!((env!("CARGO_PKG_NAME")) => (env!("CARGO_PKG_NAME")) =>
(version: env!("CARGO_PKG_VERSION")) (version: maraiah::meta::version())
(author: env!("CARGO_PKG_AUTHORS")) (author: maraiah::meta::authors().replace(':', ", "))
(about: env!("CARGO_PKG_DESCRIPTION")) (about: maraiah::meta::description())
(setting: clap::AppSettings::SubcommandRequiredElseHelp) (setting: clap::AppSettings::SubcommandRequiredElseHelp)
(subcommand: sub_data) (subcommand: sub_data)
(subcommand: sub_dump) (subcommand: sub_dump)
(subcommand: sub_info)); (subcommand: sub_info)
};
let opt = opt.get_matches(); let opt = opt.get_matches();
@ -137,6 +155,7 @@ fn main() -> ResultS<()>
("info", Some(opt)) => sub_info_c(opt)?, ("info", Some(opt)) => sub_info_c(opt)?,
_ => unreachable!(), _ => unreachable!(),
} }
*/
Ok(()) Ok(())
} }

View File

@ -559,7 +559,7 @@ impl OptU16
} }
} }
impl fmt::Debug for OptU16 impl fmt::Display for OptU16
{ {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
{ {
@ -570,6 +570,17 @@ impl fmt::Debug for OptU16
} }
} }
impl fmt::Debug for OptU16
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
{
match self.get() {
None => write!(f, "OptU16::none()"),
Some(n) => write!(f, "OptU16::from({})", n),
}
}
}
impl PartialEq<[u8; 4]> for Ident impl PartialEq<[u8; 4]> for Ident
{ {
#[inline] #[inline]

View File

@ -16,7 +16,6 @@
/// use std::convert::TryFrom; /// use std::convert::TryFrom;
/// ///
/// c_enum! { /// c_enum! {
/// #[derive(Debug)]
/// enum MyEnum: u16 /// enum MyEnum: u16
/// { /// {
/// Zero = 0, /// Zero = 0,
@ -43,7 +42,7 @@ macro_rules! c_enum
} }
) => { ) => {
$(#[$outer])* $(#[$outer])*
#[derive(Copy, Clone, Eq, Ord, PartialEq, PartialOrd)] #[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
#[repr($ti)] #[repr($ti)]
$vi enum $t $vi enum $t
{ {
@ -74,7 +73,6 @@ mod test
use std::convert::TryFrom; use std::convert::TryFrom;
c_enum! { c_enum! {
#[derive(Debug)]
enum TestEnum: u16 enum TestEnum: u16
{ {
Zero = 0, Zero = 0,

View File

@ -588,7 +588,9 @@ macro_rules! define_fixed_types {
{ {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
{ {
fmt::Display::fmt(self, f) write!(f,
concat!(stringify!($t), "::from_bits({})"),
self.to_bits())
} }
} }
)*}; )*};

View File

@ -75,7 +75,6 @@ bitflags! {
c_enum! { c_enum! {
/// A named type of damage taken by something. /// A named type of damage taken by something.
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))] #[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
#[derive(Debug)]
pub enum DamageType: u16 pub enum DamageType: u16
{ {
Explosion = 0, Explosion = 0,

View File

@ -134,7 +134,7 @@ pub struct Map
c_enum! { c_enum! {
/// The version of a Map file. /// The version of a Map file.
#[derive(Debug)] #[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
pub enum Ver: u16 pub enum Ver: u16
{ {
Base = 0, Base = 0,

View File

@ -101,7 +101,6 @@ bitflags! {
c_enum! { c_enum! {
/// The type of a `Light`. /// The type of a `Light`.
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))] #[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
#[derive(Debug)]
pub enum LightType: u16 pub enum LightType: u16
{ {
Normal = 0, Normal = 0,

View File

@ -45,7 +45,6 @@ pub struct LightFunc
c_enum! { c_enum! {
/// The type of function for a `LightFunc`. /// The type of function for a `LightFunc`.
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))] #[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
#[derive(Debug)]
pub enum LightFuncType: u16 pub enum LightFuncType: u16
{ {
Constant = 0, Constant = 0,

View File

@ -53,7 +53,6 @@ pub struct Media
c_enum! { c_enum! {
/// The liquid type of a `Media`. /// The liquid type of a `Media`.
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))] #[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
#[derive(Debug)]
pub enum MediaType: u16 pub enum MediaType: u16
{ {
Water = 0, Water = 0,

View File

@ -11,10 +11,10 @@ pub fn read(b: &[u8]) -> ResultS<Info>
let texture_id = u16[0]; let texture_id = u16[0];
let physics_id = u16[2]; let physics_id = u16[2];
let skypict_id = u16[4]; let skypict_id = u16[4];
let miss_flags = u16[6] flag MsnFlags; let miss_flags = u16[6] flag MissionFlags;
let envi_flags = u16[8] flag EnvFlags; let envi_flags = u16[8] flag EnvironmentFlags;
let level_name = mac_roman_cstr[18; 66] no_try; let level_name = mac_roman_cstr[18; 66] no_try;
let entr_flags = u32[84] flag EntFlags; let entr_flags = u32[84] flag EntryFlags;
} }
} }
@ -42,13 +42,13 @@ pub fn read_old(b: &[u8]) -> ResultS<Info>
let minf = read(b)?; let minf = read(b)?;
let mut entr_flags = if minf.entr_flags.is_empty() { let mut entr_flags = if minf.entr_flags.is_empty() {
EntFlags::SOLO EntryFlags::SOLO
} else { } else {
minf.entr_flags minf.entr_flags
}; };
if entr_flags.intersects(EntFlags::SOLO | EntFlags::CARNAGE) { if entr_flags.intersects(EntryFlags::SOLO | EntryFlags::CARNAGE) {
entr_flags.insert(EntFlags::CO_OP) entr_flags.insert(EntryFlags::CO_OP)
} }
Ok(Info{entr_flags, ..minf}) Ok(Info{entr_flags, ..minf})
@ -61,9 +61,9 @@ impl Default for Info
Self{texture_id: 0, Self{texture_id: 0,
physics_id: 1, physics_id: 1,
skypict_id: 0, skypict_id: 0,
miss_flags: MsnFlags::empty(), miss_flags: MissionFlags::empty(),
envi_flags: EnvFlags::empty(), envi_flags: EnvironmentFlags::empty(),
entr_flags: EntFlags::SOLO, entr_flags: EntryFlags::SOLO,
level_name: "Map".to_string()} level_name: "Map".to_string()}
} }
} }
@ -76,16 +76,16 @@ pub struct Info
pub texture_id: u16, pub texture_id: u16,
pub physics_id: u16, pub physics_id: u16,
pub skypict_id: u16, pub skypict_id: u16,
pub miss_flags: MsnFlags, pub miss_flags: MissionFlags,
pub envi_flags: EnvFlags, pub envi_flags: EnvironmentFlags,
pub entr_flags: EntFlags, pub entr_flags: EntryFlags,
pub level_name: String, pub level_name: String,
} }
bitflags! { bitflags! {
/// Static environment flags. /// Static environment flags.
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))] #[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
pub struct EnvFlags: u16 pub struct EnvironmentFlags: u16
{ {
const VACUUM = 1; const VACUUM = 1;
const MAGNETIC = 1 << 1; const MAGNETIC = 1 << 1;
@ -104,7 +104,7 @@ bitflags! {
bitflags! { bitflags! {
/// Static entry point flags. /// Static entry point flags.
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))] #[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
pub struct EntFlags: u32 pub struct EntryFlags: u32
{ {
const SOLO = 1; const SOLO = 1;
const CO_OP = 1 << 1; const CO_OP = 1 << 1;
@ -120,7 +120,7 @@ bitflags! {
bitflags! { bitflags! {
/// Static mission flags. /// Static mission flags.
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))] #[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
pub struct MsnFlags: u16 pub struct MissionFlags: u16
{ {
const EXTERMINATION = 1; const EXTERMINATION = 1;
const EXPLORATION = 1 << 1; const EXPLORATION = 1 << 1;

View File

@ -42,7 +42,7 @@ pub fn read(b: &[u8]) -> ResultS<(Polygon, usize)>
} }
let poly = read_poly_inter(b)?; let poly = read_poly_inter(b)?;
let ptype = PolyType::new(ptype, pdata)?; let ptype = PolygonType::new(ptype, pdata)?;
Ok((Polygon{ptype, ori_flr, ori_cei, med_ind, med_ctl, snd_ind, snd_amb, Ok((Polygon{ptype, ori_flr, ori_cei, med_ind, med_ctl, snd_ind, snd_amb,
snd_rnd, ..poly}, 128)) snd_rnd, ..poly}, 128))
@ -59,73 +59,73 @@ pub fn read_old(b: &[u8]) -> ResultS<(Polygon, usize)>
} }
let poly = read_poly_inter(b)?; let poly = read_poly_inter(b)?;
let ptype = PolyType::new_old(ptype, pdata)?; let ptype = PolygonType::new_old(ptype, pdata)?;
Ok((Polygon{ptype, ..poly}, 128)) Ok((Polygon{ptype, ..poly}, 128))
} }
impl PolyType impl PolygonType
{ {
/// Creates a `PolyType` from a `n`/`pdata` pair. /// Creates a `PolygonType` from a `n`/`pdata` pair.
pub fn new(n: u16, pdata: u16) -> Result<Self, ReprError> pub fn new(n: u16, pdata: u16) -> Result<Self, ReprError>
{ {
match n { match n {
0 => Ok(PolyType::Normal), 0 => Ok(PolygonType::Normal),
1 => Ok(PolyType::ImpassItem), 1 => Ok(PolygonType::ImpassItem),
2 => Ok(PolyType::ImpassMons), 2 => Ok(PolygonType::ImpassMons),
3 => Ok(PolyType::Hill), 3 => Ok(PolygonType::Hill),
4 => Ok(PolyType::Base), 4 => Ok(PolygonType::Base),
5 => Ok(PolyType::Platform(pdata)), 5 => Ok(PolygonType::Platform(pdata)),
6 => Ok(PolyType::TrigLightOn(pdata)), 6 => Ok(PolygonType::TrigLightOn(pdata)),
7 => Ok(PolyType::TrigPlatOn(pdata)), 7 => Ok(PolygonType::TrigPlatOn(pdata)),
8 => Ok(PolyType::TrigLightOff(pdata)), 8 => Ok(PolygonType::TrigLightOff(pdata)),
9 => Ok(PolyType::TrigPlatOff(pdata)), 9 => Ok(PolygonType::TrigPlatOff(pdata)),
10 => Ok(PolyType::Teleporter(pdata)), 10 => Ok(PolygonType::Teleporter(pdata)),
11 => Ok(PolyType::ZoneBorder), 11 => Ok(PolygonType::ZoneBorder),
12 => Ok(PolyType::Goal), 12 => Ok(PolygonType::Goal),
13 => Ok(PolyType::TrigMonsVis), 13 => Ok(PolygonType::TrigMonsVis),
14 => Ok(PolyType::TrigMonsInv), 14 => Ok(PolygonType::TrigMonsInv),
15 => Ok(PolyType::TrigMonsDual), 15 => Ok(PolygonType::TrigMonsDual),
16 => Ok(PolyType::TrigItems), 16 => Ok(PolygonType::TrigItems),
17 => Ok(PolyType::MustExplore), 17 => Ok(PolygonType::MustExplore),
18 => Ok(PolyType::AutoExit), 18 => Ok(PolygonType::AutoExit),
19 => Ok(PolyType::OuchMinor), 19 => Ok(PolygonType::OuchMinor),
20 => Ok(PolyType::OuchMajor), 20 => Ok(PolygonType::OuchMajor),
21 => Ok(PolyType::Glue), 21 => Ok(PolygonType::Glue),
22 => Ok(PolyType::GlueTrigger(pdata)), 22 => Ok(PolygonType::GlueTrigger(pdata)),
23 => Ok(PolyType::GlueSuper), 23 => Ok(PolygonType::GlueSuper),
n => Err(ReprError::new(n)), n => Err(ReprError::new(n)),
} }
} }
/// Creates a `PolyType` from a Marathon 1 compatible `n`/`pdata` pair. /// Creates a `PolygonType` 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 {
0 => Ok(PolyType::Normal), 0 => Ok(PolygonType::Normal),
1 => Ok(PolyType::ImpassItem), 1 => Ok(PolygonType::ImpassItem),
2 => Ok(PolyType::ImpassMons), 2 => Ok(PolygonType::ImpassMons),
3 => Ok(PolyType::OuchMinor), 3 => Ok(PolygonType::OuchMinor),
4 => Ok(PolyType::OuchMajor), 4 => Ok(PolygonType::OuchMajor),
5 => Ok(PolyType::Platform(pdata)), 5 => Ok(PolygonType::Platform(pdata)),
6 => Ok(PolyType::TrigLightOn(pdata)), 6 => Ok(PolygonType::TrigLightOn(pdata)),
7 => Ok(PolyType::TrigPlatOn(pdata)), 7 => Ok(PolygonType::TrigPlatOn(pdata)),
8 => Ok(PolyType::TrigLightOff(pdata)), 8 => Ok(PolygonType::TrigLightOff(pdata)),
9 => Ok(PolyType::TrigPlatOff(pdata)), 9 => Ok(PolygonType::TrigPlatOff(pdata)),
10 => Ok(PolyType::Teleporter(pdata)), 10 => Ok(PolygonType::Teleporter(pdata)),
11 => Ok(PolyType::Glue), 11 => Ok(PolygonType::Glue),
12 => Ok(PolyType::GlueTrigger(pdata)), 12 => Ok(PolygonType::GlueTrigger(pdata)),
13 => Ok(PolyType::GlueSuper), 13 => Ok(PolygonType::GlueSuper),
14 => Ok(PolyType::MustExplore), 14 => Ok(PolygonType::MustExplore),
15 => Ok(PolyType::AutoExit), 15 => Ok(PolygonType::AutoExit),
n => Err(ReprError::new(n)), n => Err(ReprError::new(n)),
} }
} }
} }
impl Default for PolyType impl Default for PolygonType
{ {
fn default() -> Self {PolyType::Normal} fn default() -> Self {PolygonType::Normal}
} }
/// A polygon segment. /// A polygon segment.
@ -133,7 +133,7 @@ impl Default for PolyType
#[derive(Clone, Debug, Default, Eq, PartialEq)] #[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct Polygon pub struct Polygon
{ {
pub ptype: PolyType, pub ptype: PolygonType,
pub tex_flr: OptU16, pub tex_flr: OptU16,
pub tex_cei: OptU16, pub tex_cei: OptU16,
pub hei_flr: Unit, pub hei_flr: Unit,
@ -154,7 +154,7 @@ pub struct Polygon
/// 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(Clone, Copy, Debug, Eq, PartialEq)] #[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum PolyType pub enum PolygonType
{ {
Normal, Normal,
ImpassItem, ImpassItem,
@ -185,7 +185,7 @@ pub enum PolyType
bitflags! { bitflags! {
/// Flags for `Polygon`. /// Flags for `Polygon`.
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))] #[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
pub struct PolyFlags: u16 pub struct PolygonFlags: u16
{ {
const DETACHED = 1 << 14; const DETACHED = 1 << 14;
} }

View File

@ -75,7 +75,6 @@ bitflags! {
c_enum! { c_enum! {
/// The texture type of a `Side`. /// The texture type of a `Side`.
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))] #[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
#[derive(Debug)]
pub enum SideType: u16 pub enum SideType: u16
{ {
Full = 0, Full = 0,

View File

@ -61,7 +61,6 @@ pub struct Trigger
c_enum! { c_enum! {
/// A bullet shell casing emitted by a weapon. /// A bullet shell casing emitted by a weapon.
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))] #[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
#[derive(Debug)]
pub enum CasingType: u16 pub enum CasingType: u16
{ {
Rifle = 0, Rifle = 0,

View File

@ -99,7 +99,6 @@ bitflags! {
c_enum! { c_enum! {
/// The type of functionality a weapon provides. /// The type of functionality a weapon provides.
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))] #[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
#[derive(Debug)]
pub enum WeaponType: u16 pub enum WeaponType: u16
{ {
Melee = 0, Melee = 0,

50
maraiah/meta.rs Normal file
View File

@ -0,0 +1,50 @@
//! Meta-information of this crate.
macro_rules! meta_str {
($($(#[$outer:meta])* $name:ident = $e:expr;)*) => {
$($(#[$outer])* pub const fn $name() -> &'static str {$e})*
pub mod ffi
{
$(
doc_comment! {
concat!("FFI variant of [`",
stringify!($name),
"`]\n\n[`",
stringify!($name),
"`]: ../fn.",
stringify!($name),
".html"),
pub const fn $name() -> crate::ffi::NT {c_str!($e)}
}
)*
}
}
}
meta_str!(
/// The authors of this crate, `:` separated.
authors = env!("CARGO_PKG_AUTHORS");
/// The description of this crate.
description = env!("CARGO_PKG_DESCRIPTION");
/// The home page of this crate.
homepage = env!("CARGO_PKG_HOMEPAGE");
/// The full license text of this crate.
license_text = include_str!("../LICENSE");
/// The name of this crate.
name = env!("CARGO_PKG_NAME");
/// The repository of this crate.
repository = env!("CARGO_PKG_REPOSITORY");
/// The full version of this crate.
version = env!("CARGO_PKG_VERSION");
/// The major version of this crate.
version_major = env!("CARGO_PKG_VERSION_MAJOR");
/// The minor version of this crate.
version_minor = env!("CARGO_PKG_VERSION_MINOR");
/// The patch version of this crate.
version_patch = env!("CARGO_PKG_VERSION_PATCH");
/// The pre-release version of this crate.
version_pre = env!("CARGO_PKG_VERSION_PRE");
);
// EOF

View File

@ -57,7 +57,6 @@ pub struct Collection
c_enum! { c_enum! {
/// The type of a collection. /// The type of a collection.
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))] #[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
#[derive(Debug)]
pub enum CollectionType: u16 pub enum CollectionType: u16
{ {
Unused = 0, Unused = 0,

View File

@ -71,7 +71,6 @@ pub struct Sequence
c_enum! { c_enum! {
/// The type of or number of views for a sequence. /// The type of or number of views for a sequence.
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))] #[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
#[derive(Debug)]
pub enum ViewType: u16 pub enum ViewType: u16
{ {
Anim = 1, Anim = 1,

View File

@ -89,7 +89,6 @@ bitflags! {
c_enum! { c_enum! {
/// The type of volume this sound has. /// The type of volume this sound has.
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))] #[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
#[derive(Debug)]
pub enum Volume: u16 pub enum Volume: u16
{ {
Quiet = 0, Quiet = 0,

View File

@ -8,7 +8,6 @@ impl Default for TransferMode
c_enum! { c_enum! {
/// A rendering style for many things. /// A rendering style for many things.
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))] #[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
#[derive(Debug)]
pub enum TransferMode: u16 pub enum TransferMode: u16
{ {
Normal = 0, Normal = 0,

View File

@ -1,17 +0,0 @@
[package]
name = "maraiah-leela"
version = "0.1.0"
authors = ["Alison Watson <marrub@greyserv.net>"]
description = "Maraiah testbed program."
edition = "2018"
[dependencies]
clap = "2"
maraiah = {path = "../..", features = ["serde_obj"]}
memmap = "0.7"
serde = "1.0"
serde_yaml = "0.8"
[[bin]]
name = "leela"
path = "main.rs"

View File

@ -1,51 +0,0 @@
//! Meta-information of this crate.
macro_rules! meta_str {
($($(#[$outer:meta])* $name:ident = $cname:ident = $e:expr;)*) => {
$(
$(#[$outer])* pub const $name: &'static str = $e;
)*
pub mod ffi
{
$(
doc_comment! {
concat!("FFI variant of [`",
stringify!($name),
"`]\n\n[`",
stringify!($name),
"`]: ../constant.",
stringify!($name),
".html"),
pub const $cname: crate::ffi::NT = c_str!($e);
}
)*
}
}
}
meta_str!(
/// The authors of this crate, `:` separated.
AUTHORS = AUTHORS_C = env!("CARGO_PKG_AUTHORS");
/// The description of this crate.
DESCRIPTION = DESCRIPTION_C = env!("CARGO_PKG_DESCRIPTION");
/// The home page of this crate.
HOMEPAGE = HOMEPAGE_C = env!("CARGO_PKG_HOMEPAGE");
/// The full license text of this crate.
LICENSE_TEXT = LICENSE_TEXT_C = include_str!("../LICENSE");
/// The name of this crate.
NAME = NAME_C = env!("CARGO_PKG_NAME");
/// The repository of this crate.
REPOSITORY = REPOSITORY_C = env!("CARGO_PKG_REPOSITORY");
/// The full version of this crate.
VERSION = VERSION_C = env!("CARGO_PKG_VERSION");
/// The major version of this crate.
VERSION_MAJOR = VERSION_MAJOR_C = env!("CARGO_PKG_VERSION_MAJOR");
/// The minor version of this crate.
VERSION_MINOR = VERSION_MINOR_C = env!("CARGO_PKG_VERSION_MINOR");
/// The patch version of this crate.
VERSION_PATCH = VERSION_PATCH_C = env!("CARGO_PKG_VERSION_PATCH");
/// The pre-release version of this crate.
VERSION_PRE = VERSION_PRE_C = env!("CARGO_PKG_VERSION_PRE");
);
// EOF

BIN
tests/data/m2/Map Normal file

Binary file not shown.

View File

@ -2,8 +2,8 @@ map::minf::Info{
texture_id: 0, texture_id: 0,
physics_id: 1, physics_id: 1,
skypict_id: 1, skypict_id: 1,
miss_flags: map::minf::MsnFlags::REPAIR, miss_flags: map::minf::MissionFlags::REPAIR,
envi_flags: map::minf::EnvFlags::empty(), envi_flags: map::minf::EnvironmentFlags::empty(),
entr_flags: map::minf::EntFlags::SOLO | map::minf::EntFlags::CO_OP, entr_flags: map::minf::EntryFlags::SOLO | map::minf::EntryFlags::CO_OP,
level_name: "Waterloo Waterpark".to_owned() level_name: "Waterloo Waterpark".to_owned()
} }

BIN
tests/data/map/testmap.in Normal file

Binary file not shown.

2185
tests/data/map/testmap.out Normal file

File diff suppressed because it is too large Load Diff

View File

@ -36,7 +36,7 @@ fn defl_alice_2()
fn defl_shapes() fn defl_shapes()
{ {
const INPUT: &[u8] = include_bytes!("data/defl/Shapes.in"); const INPUT: &[u8] = include_bytes!("data/defl/Shapes.in");
const OUTPUT: &[u8] = include_bytes!("data/defl/Shapes.out"); const OUTPUT: &[u8] = include_bytes!("data/m2/Shapes");
defl_gzip(INPUT, OUTPUT); defl_gzip(INPUT, OUTPUT);
} }

View File

@ -51,25 +51,65 @@ fn read_term_must_process()
} }
} }
#[test]
fn map_m2()
{
let inp = include_bytes!("data/m2/Map");
let mut rd = std::io::BufReader::new(&inp[..]);
let mp = map::head::read(&mut rd).unwrap();
let en = map::entr::read_all(&mp).unwrap();
assert!(map::data::read_all(mp.head(), &en).is_ok());
}
#[test]
#[ignore]
fn map_full_check()
{
use maraiah::{bin::OptU16,
map::{data::*, lins::*, lite::*, ltfn::*, minf::*, objs::*,
plac::*, pnts::*, poly::*},
xfer::TransferMode};
use std::collections::BTreeMap;
let inp = include_bytes!("data/map/testmap.in");
let mut rd = std::io::BufReader::new(&inp[..]);
let mp = map::head::read(&mut rd).unwrap();
let en = map::entr::read_all(&mp).unwrap();
let ed = map::data::read_all(mp.head(), &en).unwrap();
let mut out = BTreeMap::new();
out.insert(0, include!("data/map/testmap.out"));
assert_eq!(out, ed);
}
#[test] #[test]
fn map_must_not_process() fn map_must_not_process()
{ {
for inp in &RANDOM { for inp in &RANDOM {
map::minf::read(inp).err().unwrap(); bin::rd_array(inp, map::fxpx::read).err().unwrap();
map::minf::read_old(inp).err().unwrap();
bin::rd_array(inp, map::lins::read).err().unwrap(); bin::rd_array(inp, map::lins::read).err().unwrap();
bin::rd_array(inp, map::lite::read).err().unwrap(); bin::rd_array(inp, map::lite::read).err().unwrap();
bin::rd_array(inp, map::lite::read_old).err().unwrap();
bin::rd_array(inp, map::medi::read).err().unwrap(); bin::rd_array(inp, map::medi::read).err().unwrap();
bin::rd_array(inp, map::mnpx::read).err().unwrap();
bin::rd_array(inp, map::note::read).err().unwrap(); bin::rd_array(inp, map::note::read).err().unwrap();
bin::rd_array(inp, map::objs::read).err().unwrap(); bin::rd_array(inp, map::objs::read).err().unwrap();
bin::rd_array(inp, map::plat::read).err().unwrap(); bin::rd_array(inp, map::plat::read).err().unwrap();
bin::rd_array(inp, map::poly::read).err().unwrap(); bin::rd_array(inp, map::poly::read).err().unwrap();
bin::rd_array(inp, map::poly::read_old).err().unwrap();
bin::rd_array(inp, map::prpx::read).err().unwrap();
bin::rd_array(inp, map::sids::read).err().unwrap(); bin::rd_array(inp, map::sids::read).err().unwrap();
bin::rd_array(inp, map::sids::read_old).err().unwrap();
bin::rd_array(inp, map::term::read).err().unwrap(); bin::rd_array(inp, map::term::read).err().unwrap();
bin::rd_array(inp, map::trmg::read).err().unwrap(); bin::rd_array(inp, map::trmg::read).err().unwrap();
bin::rd_array(inp, map::lite::read_old).err().unwrap(); bin::rd_array(inp, map::wppx::read).err().unwrap();
bin::rd_array(inp, map::poly::read_old).err().unwrap(); map::minf::read(inp).err().unwrap();
bin::rd_array(inp, map::sids::read_old).err().unwrap(); map::minf::read_old(inp).err().unwrap();
} }
} }
@ -82,27 +122,9 @@ fn map_must_not_panic()
drop(bin::rd_array(inp, map::epnt::read)); drop(bin::rd_array(inp, map::epnt::read));
drop(bin::rd_array(inp, map::iidx::read)); drop(bin::rd_array(inp, map::iidx::read));
drop(bin::rd_array(inp, map::plac::read)); drop(bin::rd_array(inp, map::plac::read));
drop(bin::rd_array(inp, map::pxpx::read));
drop(bin::rd_array(inp, map::trmf::read)); drop(bin::rd_array(inp, map::trmf::read));
} }
} }
#[test]
fn phy_must_not_process()
{
for inp in &RANDOM {
bin::rd_array(inp, map::fxpx::read).err().unwrap();
bin::rd_array(inp, map::mnpx::read).err().unwrap();
bin::rd_array(inp, map::prpx::read).err().unwrap();
bin::rd_array(inp, map::wppx::read).err().unwrap();
}
}
#[test]
fn phy_must_not_panic()
{
for inp in &RANDOM {
drop(bin::rd_array(inp, map::pxpx::read));
}
}
// EOF // EOF

View File

@ -1,4 +1,4 @@
use maraiah::{image::{Color8, pict}}; use maraiah::image::{pict, Color8};
include!("data/rand.rs"); include!("data/rand.rs");

View File

@ -5,12 +5,11 @@ edition = "2018"
build = "build.rs" build = "build.rs"
[dependencies] [dependencies]
maraiah = {path = "../.."} maraiah = {path = ".."}
memmap = "0.7"
[build-dependencies] [build-dependencies]
cmake = "0.1" cmake = "0.1"
maraiah = {path = "../.."} maraiah = {path = ".."}
rust_qt_binding_generator = "0.3" rust_qt_binding_generator = "0.3"
[[bin]] [[bin]]

View File

Before

Width:  |  Height:  |  Size: 805 B

After

Width:  |  Height:  |  Size: 805 B

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 761 B

After

Width:  |  Height:  |  Size: 761 B

Some files were not shown because too many files have changed in this diff Show More