Browse Source

maraiah: fix tests and move code to root

Alison Watson 1 month ago
parent
commit
daebfd2da6
100 changed files with 2435 additions and 214 deletions
  1. 3
    3
      Cargo.toml
  2. 14
    0
      leela/Cargo.toml
  3. 48
    29
      leela/main.rs
  4. 12
    1
      maraiah/bin.rs
  5. 0
    0
      maraiah/bit.rs
  6. 1
    3
      maraiah/cenum.rs
  7. 0
    0
      maraiah/cksum.rs
  8. 0
    0
      maraiah/defl.rs
  9. 0
    0
      maraiah/doc.rs
  10. 0
    0
      maraiah/err.rs
  11. 0
    0
      maraiah/ffi.rs
  12. 0
    0
      maraiah/file.rs
  13. 3
    1
      maraiah/fixed.rs
  14. 0
    0
      maraiah/image.rs
  15. 0
    0
      maraiah/image/pict.rs
  16. 0
    0
      maraiah/image/pict/clut.rs
  17. 0
    0
      maraiah/image/pict/pm.rs
  18. 0
    0
      maraiah/image/pict/pm/area.rs
  19. 0
    0
      maraiah/image/pict/pm/head.rs
  20. 0
    0
      maraiah/image/pict/pm/ind.rs
  21. 0
    0
      maraiah/image/pict/pm/r5g5b5.rs
  22. 0
    0
      maraiah/image/pict/pm/rgb8.rs
  23. 0
    0
      maraiah/image/pict/rle.rs
  24. 0
    0
      maraiah/image/ppm.rs
  25. 0
    0
      maraiah/image/tga.rs
  26. 0
    0
      maraiah/lib.rs
  27. 0
    0
      maraiah/machdr.rs
  28. 0
    0
      maraiah/map.rs
  29. 0
    0
      maraiah/map/ambi.rs
  30. 0
    0
      maraiah/map/attk.rs
  31. 0
    0
      maraiah/map/bonk.rs
  32. 0
    1
      maraiah/map/damg.rs
  33. 0
    0
      maraiah/map/data.rs
  34. 0
    0
      maraiah/map/entr.rs
  35. 0
    0
      maraiah/map/epnt.rs
  36. 0
    0
      maraiah/map/fxpx.rs
  37. 1
    1
      maraiah/map/head.rs
  38. 0
    0
      maraiah/map/iidx.rs
  39. 0
    0
      maraiah/map/lins.rs
  40. 0
    1
      maraiah/map/lite.rs
  41. 0
    1
      maraiah/map/ltfn.rs
  42. 0
    1
      maraiah/map/medi.rs
  43. 15
    15
      maraiah/map/minf.rs
  44. 0
    0
      maraiah/map/mnpx.rs
  45. 0
    0
      maraiah/map/name.rs
  46. 0
    0
      maraiah/map/note.rs
  47. 0
    0
      maraiah/map/objs.rs
  48. 0
    0
      maraiah/map/plac.rs
  49. 0
    0
      maraiah/map/plat.rs
  50. 0
    0
      maraiah/map/pnts.rs
  51. 50
    50
      maraiah/map/poly.rs
  52. 0
    0
      maraiah/map/prpx.rs
  53. 0
    0
      maraiah/map/pxpx.rs
  54. 0
    1
      maraiah/map/sids.rs
  55. 0
    0
      maraiah/map/stex.rs
  56. 0
    0
      maraiah/map/term.rs
  57. 0
    1
      maraiah/map/trig.rs
  58. 0
    0
      maraiah/map/trmf.rs
  59. 0
    0
      maraiah/map/trmg.rs
  60. 0
    1
      maraiah/map/wppx.rs
  61. 50
    0
      maraiah/meta.rs
  62. 0
    0
      maraiah/shp.rs
  63. 0
    0
      maraiah/shp/bmap.rs
  64. 0
    0
      maraiah/shp/clut.rs
  65. 0
    1
      maraiah/shp/coll.rs
  66. 0
    0
      maraiah/shp/fram.rs
  67. 0
    1
      maraiah/shp/sequ.rs
  68. 0
    0
      maraiah/snd.rs
  69. 0
    1
      maraiah/snd/defs.rs
  70. 0
    0
      maraiah/snd/snds.rs
  71. 0
    0
      maraiah/sound.rs
  72. 0
    0
      maraiah/sound/wav.rs
  73. 0
    0
      maraiah/text.rs
  74. 0
    1
      maraiah/xfer.rs
  75. 0
    17
      source/leela/Cargo.toml
  76. 0
    51
      source/meta.rs
  77. BIN
      tests/data/m2/Map
  78. 0
    0
      tests/data/m2/Shapes
  79. 3
    3
      tests/data/map/minf.out
  80. BIN
      tests/data/map/testmap.in
  81. 2185
    0
      tests/data/map/testmap.out
  82. 1
    1
      tests/defl.rs
  83. 46
    24
      tests/map.rs
  84. 1
    1
      tests/pict.rs
  85. 0
    0
      tycho/CMakeLists.txt
  86. 2
    3
      tycho/Cargo.toml
  87. 0
    0
      tycho/bindings.json
  88. 0
    0
      tycho/build.rs
  89. 0
    0
      tycho/cc_headers/mapprops.h
  90. 0
    0
      tycho/cc_headers/menu.h
  91. 0
    0
      tycho/cc_headers/project.h
  92. 0
    0
      tycho/cc_headers/tycho.h
  93. 0
    0
      tycho/cc_source/main.cc
  94. 0
    0
      tycho/cc_source/mapprops.cc
  95. 0
    0
      tycho/cc_source/menu.cc
  96. 0
    0
      tycho/cc_source/project.cc
  97. 0
    0
      tycho/resources/color/lines.png
  98. 0
    0
      tycho/resources/color/map.png
  99. 0
    0
      tycho/resources/color/pfhor-hand.png
  100. 0
    0
      tycho/resources/color/points.png

+ 3
- 3
Cargo.toml View File

@@ -14,10 +14,10 @@ publish     = false
14 14
 serde_obj = ["serde"]
15 15
 
16 16
 [workspace]
17
-members = ["source/leela", "source/tycho"]
17
+members = ["leela", "tycho"]
18 18
 
19 19
 [dependencies]
20
-bitflags = "1.0"
20
+bitflags = "1.1"
21 21
 failure  = {version = "0.1", features = ["std"]}
22 22
 serde    = {version = "1.0", features = ["derive"], optional = true}
23 23
 memchr   = "2.0"
@@ -31,4 +31,4 @@ lto           = true
31 31
 
32 32
 [lib]
33 33
 name = "maraiah"
34
-path = "source/lib.rs"
34
+path = "maraiah/lib.rs"

+ 14
- 0
leela/Cargo.toml View File

@@ -0,0 +1,14 @@
1
+[package]
2
+name    = "maraiah-leela"
3
+version = "0.0.0"
4
+edition = "2018"
5
+
6
+[dependencies]
7
+clap       = "2"
8
+maraiah    = {path = "..", features = ["serde_obj"]}
9
+serde      = "1.0"
10
+serde_yaml = "0.8"
11
+
12
+[[bin]]
13
+name = "leela"
14
+path = "main.rs"

source/leela/main.rs → leela/main.rs View File

@@ -1,13 +1,13 @@
1 1
 #![allow(clippy::unit_arg)]
2 2
 
3
-use maraiah::{err::*, file::*, image::*, sound::*,
4
-              machdr, map, shp, snd};
3
+use maraiah::{err::*, file::*, image::*, machdr, map, shp, snd, sound::*};
5 4
 use std::{collections::HashSet, fs, io, slice::from_ref};
6 5
 
7
-fn open(path: &str) -> ResultS<memmap::Mmap>
6
+/*
7
+fn open(path: &str) -> ResultS<io::BufReader>
8 8
 {
9 9
    let fp = fs::File::open(path)?;
10
-   Ok(unsafe {memmap::Mmap::map(&fp)?})
10
+   Ok(io::BufReader::new(fp))
11 11
 }
12 12
 
13 13
 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>
22 22
 fn exists(path: String) -> Result<(), String>
23 23
 {
24 24
    match std::fs::metadata(path) {
25
-      Ok(_)  => Ok(()),
25
+      Ok(_) => Ok(()),
26 26
       Err(e) => Err(e.to_string()),
27 27
    }
28 28
 }
29 29
 
30 30
 fn each_value<F>(opt: &clap::ArgMatches<'_>,
31 31
                  name: &str,
32
-                 mut f: F) -> ResultS<()>
32
+                 mut f: F)
33
+                 -> ResultS<()>
33 34
    where F: FnMut(&str) -> ResultS<()>
34 35
 {
35 36
    if let Some(values) = opt.values_of(name) {
@@ -91,43 +92,60 @@ fn sub_info_c(opt: &clap::ArgMatches<'_>) -> ResultS<()>
91 92
 
92 93
    Ok(())
93 94
 }
95
+*/
94 96
 
95 97
 fn main() -> ResultS<()>
96 98
 {
99
+   use std::io::prelude::*;
100
+
101
+   let inp = include_bytes!("../tests/data/map/Test.in");
102
+   let mut rd = std::io::BufReader::new(&inp[..]);
103
+
104
+   let mp = map::head::read(&mut rd).unwrap();
105
+   let en = map::entr::read_all(&mp).unwrap();
106
+   let ed = map::data::read_all(mp.head(), &en).unwrap();
107
+
108
+   write!(&mut std::fs::File::create("dicks.txt").unwrap(), "{:#?}", ed);
109
+
110
+   /*
97 111
    use clap::clap_app;
98 112
 
99
-   let sub_data =
100
-      clap_app!(@subcommand data =>
101
-         (about: "Dumps data into a discrete folder/YAML format"));
113
+   let sub_data = clap_app! {
114
+      @subcommand data =>
115
+         (about: "Dumps data into a discrete folder/YAML format")
116
+   };
102 117
 
103
-   let sub_dump =
104
-      clap_app!(@subcommand dump =>
118
+   let sub_dump = clap_app! {
119
+      @subcommand dump =>
105 120
          (about: "Dumps particular parts of data")
106 121
          (@arg chunks: -c --chunks [name]... "Dumps named chunks from an entry")
107 122
          (@group files =>
108
-            (@attributes +required +multiple)
109
-            (@arg map: -m --map [file]... {exists} "Loads Map files")
110
-            (@arg shp: -s --shp [file]... {exists} "Loads Shapes files")
111
-            (@arg snd: -n --snd [file]... {exists} "Loads Sounds files")));
112
-
113
-   let sub_info =
114
-      clap_app!(@subcommand info =>
123
+          (@attributes +required +multiple)
124
+          (@arg map: -m --map [file]... {exists} "Loads Map files")
125
+          (@arg shp: -s --shp [file]... {exists} "Loads Shapes files")
126
+          (@arg snd: -n --snd [file]... {exists} "Loads Sounds files"))
127
+   };
128
+
129
+   let sub_info = clap_app! {
130
+      @subcommand info =>
115 131
          (about: "Outputs debug info")
116 132
          (@group files =>
117
-            (@attributes +required +multiple)
118
-            (@arg map: -m --map [file]... {exists} "Loads Map files")
119
-            (@arg shp: -s --shp [file]... {exists} "Loads Shapes files")
120
-            (@arg snd: -n --snd [file]... {exists} "Loads Sounds files")));
121
-
122
-   let opt =
123
-      clap_app!((env!("CARGO_PKG_NAME")) =>
124
-         (version:    env!("CARGO_PKG_VERSION"))
125
-         (author:     env!("CARGO_PKG_AUTHORS"))
126
-         (about:      env!("CARGO_PKG_DESCRIPTION"))
133
+          (@attributes +required +multiple)
134
+          (@arg map: -m --map [file]... {exists} "Loads Map files")
135
+          (@arg shp: -s --shp [file]... {exists} "Loads Shapes files")
136
+          (@arg snd: -n --snd [file]... {exists} "Loads Sounds files"))
137
+   };
138
+
139
+   let opt = clap_app! {
140
+      (env!("CARGO_PKG_NAME")) =>
141
+         (version:    maraiah::meta::version())
142
+         (author:     maraiah::meta::authors().replace(':', ", "))
143
+         (about:      maraiah::meta::description())
127 144
          (setting:    clap::AppSettings::SubcommandRequiredElseHelp)
128 145
          (subcommand: sub_data)
129 146
          (subcommand: sub_dump)
130
-         (subcommand: sub_info));
147
+         (subcommand: sub_info)
148
+   };
131 149
 
132 150
    let opt = opt.get_matches();
133 151
 
@@ -137,6 +155,7 @@ fn main() -> ResultS<()>
137 155
       ("info", Some(opt)) => sub_info_c(opt)?,
138 156
       _ => unreachable!(),
139 157
    }
158
+   */
140 159
 
141 160
    Ok(())
142 161
 }

source/bin.rs → maraiah/bin.rs View File

@@ -559,7 +559,7 @@ impl OptU16
559 559
    }
560 560
 }
561 561
 
562
-impl fmt::Debug for OptU16
562
+impl fmt::Display for OptU16
563 563
 {
564 564
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
565 565
    {
@@ -570,6 +570,17 @@ impl fmt::Debug for OptU16
570 570
    }
571 571
 }
572 572
 
573
+impl fmt::Debug for OptU16
574
+{
575
+   fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
576
+   {
577
+      match self.get() {
578
+         None    => write!(f, "OptU16::none()"),
579
+         Some(n) => write!(f, "OptU16::from({})", n),
580
+      }
581
+   }
582
+}
583
+
573 584
 impl PartialEq<[u8; 4]> for Ident
574 585
 {
575 586
    #[inline]

source/bit.rs → maraiah/bit.rs View File


source/cenum.rs → maraiah/cenum.rs View File

@@ -16,7 +16,6 @@
16 16
 /// use std::convert::TryFrom;
17 17
 ///
18 18
 /// c_enum! {
19
-///    #[derive(Debug)]
20 19
 ///    enum MyEnum: u16
21 20
 ///    {
22 21
 ///       Zero = 0,
@@ -43,7 +42,7 @@ macro_rules! c_enum
43 42
       }
44 43
    ) => {
45 44
       $(#[$outer])*
46
-      #[derive(Copy, Clone, Eq, Ord, PartialEq, PartialOrd)]
45
+      #[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
47 46
       #[repr($ti)]
48 47
       $vi enum $t
49 48
       {
@@ -74,7 +73,6 @@ mod test
74 73
    use std::convert::TryFrom;
75 74
 
76 75
    c_enum! {
77
-      #[derive(Debug)]
78 76
       enum TestEnum: u16
79 77
       {
80 78
          Zero = 0,

source/cksum.rs → maraiah/cksum.rs View File


source/defl.rs → maraiah/defl.rs View File


source/doc.rs → maraiah/doc.rs View File


source/err.rs → maraiah/err.rs View File


source/ffi.rs → maraiah/ffi.rs View File


source/file.rs → maraiah/file.rs View File


source/fixed.rs → maraiah/fixed.rs View File

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

source/image.rs → maraiah/image.rs View File


source/image/pict.rs → maraiah/image/pict.rs View File


source/image/pict/clut.rs → maraiah/image/pict/clut.rs View File


source/image/pict/pm.rs → maraiah/image/pict/pm.rs View File


source/image/pict/pm/area.rs → maraiah/image/pict/pm/area.rs View File


source/image/pict/pm/head.rs → maraiah/image/pict/pm/head.rs View File


source/image/pict/pm/ind.rs → maraiah/image/pict/pm/ind.rs View File


source/image/pict/pm/r5g5b5.rs → maraiah/image/pict/pm/r5g5b5.rs View File


source/image/pict/pm/rgb8.rs → maraiah/image/pict/pm/rgb8.rs View File


source/image/pict/rle.rs → maraiah/image/pict/rle.rs View File


source/image/ppm.rs → maraiah/image/ppm.rs View File


source/image/tga.rs → maraiah/image/tga.rs View File


source/lib.rs → maraiah/lib.rs View File


source/machdr.rs → maraiah/machdr.rs View File


source/map.rs → maraiah/map.rs View File


source/map/ambi.rs → maraiah/map/ambi.rs View File


source/map/attk.rs → maraiah/map/attk.rs View File


source/map/bonk.rs → maraiah/map/bonk.rs View File


source/map/damg.rs → maraiah/map/damg.rs View File

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

source/map/data.rs → maraiah/map/data.rs View File


source/map/entr.rs → maraiah/map/entr.rs View File


source/map/epnt.rs → maraiah/map/epnt.rs View File


source/map/fxpx.rs → maraiah/map/fxpx.rs View File


source/map/head.rs → maraiah/map/head.rs View File

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

source/map/iidx.rs → maraiah/map/iidx.rs View File


source/map/lins.rs → maraiah/map/lins.rs View File


source/map/lite.rs → maraiah/map/lite.rs View File

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

source/map/ltfn.rs → maraiah/map/ltfn.rs View File

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

source/map/medi.rs → maraiah/map/medi.rs View File

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

source/map/minf.rs → maraiah/map/minf.rs View File

@@ -11,10 +11,10 @@ pub fn read(b: &[u8]) -> ResultS<Info>
11 11
          let texture_id = u16[0];
12 12
          let physics_id = u16[2];
13 13
          let skypict_id = u16[4];
14
-         let miss_flags = u16[6] flag MsnFlags;
15
-         let envi_flags = u16[8] flag EnvFlags;
14
+         let miss_flags = u16[6] flag MissionFlags;
15
+         let envi_flags = u16[8] flag EnvironmentFlags;
16 16
          let level_name = mac_roman_cstr[18; 66] no_try;
17
-         let entr_flags = u32[84] flag EntFlags;
17
+         let entr_flags = u32[84] flag EntryFlags;
18 18
       }
19 19
    }
20 20
 
@@ -42,13 +42,13 @@ pub fn read_old(b: &[u8]) -> ResultS<Info>
42 42
    let minf = read(b)?;
43 43
 
44 44
    let mut entr_flags = if minf.entr_flags.is_empty() {
45
-      EntFlags::SOLO
45
+      EntryFlags::SOLO
46 46
    } else {
47 47
       minf.entr_flags
48 48
    };
49 49
 
50
-   if entr_flags.intersects(EntFlags::SOLO | EntFlags::CARNAGE) {
51
-      entr_flags.insert(EntFlags::CO_OP)
50
+   if entr_flags.intersects(EntryFlags::SOLO | EntryFlags::CARNAGE) {
51
+      entr_flags.insert(EntryFlags::CO_OP)
52 52
    }
53 53
 
54 54
    Ok(Info{entr_flags, ..minf})
@@ -61,9 +61,9 @@ impl Default for Info
61 61
       Self{texture_id: 0,
62 62
            physics_id: 1,
63 63
            skypict_id: 0,
64
-           miss_flags: MsnFlags::empty(),
65
-           envi_flags: EnvFlags::empty(),
66
-           entr_flags: EntFlags::SOLO,
64
+           miss_flags: MissionFlags::empty(),
65
+           envi_flags: EnvironmentFlags::empty(),
66
+           entr_flags: EntryFlags::SOLO,
67 67
            level_name: "Map".to_string()}
68 68
    }
69 69
 }
@@ -76,16 +76,16 @@ pub struct Info
76 76
    pub texture_id: u16,
77 77
    pub physics_id: u16,
78 78
    pub skypict_id: u16,
79
-   pub miss_flags: MsnFlags,
80
-   pub envi_flags: EnvFlags,
81
-   pub entr_flags: EntFlags,
79
+   pub miss_flags: MissionFlags,
80
+   pub envi_flags: EnvironmentFlags,
81
+   pub entr_flags: EntryFlags,
82 82
    pub level_name: String,
83 83
 }
84 84
 
85 85
 bitflags! {
86 86
    /// Static environment flags.
87 87
    #[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
88
-   pub struct EnvFlags: u16
88
+   pub struct EnvironmentFlags: u16
89 89
    {
90 90
       const VACUUM     = 1;
91 91
       const MAGNETIC   = 1 << 1;
@@ -104,7 +104,7 @@ bitflags! {
104 104
 bitflags! {
105 105
    /// Static entry point flags.
106 106
    #[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
107
-   pub struct EntFlags: u32
107
+   pub struct EntryFlags: u32
108 108
    {
109 109
       const SOLO    = 1;
110 110
       const CO_OP   = 1 << 1;
@@ -120,7 +120,7 @@ bitflags! {
120 120
 bitflags! {
121 121
    /// Static mission flags.
122 122
    #[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
123
-   pub struct MsnFlags: u16
123
+   pub struct MissionFlags: u16
124 124
    {
125 125
       const EXTERMINATION  = 1;
126 126
       const EXPLORATION    = 1 << 1;

source/map/mnpx.rs → maraiah/map/mnpx.rs View File


source/map/name.rs → maraiah/map/name.rs View File


source/map/note.rs → maraiah/map/note.rs View File


source/map/objs.rs → maraiah/map/objs.rs View File


source/map/plac.rs → maraiah/map/plac.rs View File


source/map/plat.rs → maraiah/map/plat.rs View File


source/map/pnts.rs → maraiah/map/pnts.rs View File


source/map/poly.rs → maraiah/map/poly.rs View File

@@ -42,7 +42,7 @@ pub fn read(b: &[u8]) -> ResultS<(Polygon, usize)>
42 42
    }
43 43
 
44 44
    let poly  = read_poly_inter(b)?;
45
-   let ptype = PolyType::new(ptype, pdata)?;
45
+   let ptype = PolygonType::new(ptype, pdata)?;
46 46
 
47 47
    Ok((Polygon{ptype, ori_flr, ori_cei, med_ind, med_ctl, snd_ind, snd_amb,
48 48
                snd_rnd, ..poly}, 128))
@@ -59,73 +59,73 @@ pub fn read_old(b: &[u8]) -> ResultS<(Polygon, usize)>
59 59
    }
60 60
 
61 61
    let poly  = read_poly_inter(b)?;
62
-   let ptype = PolyType::new_old(ptype, pdata)?;
62
+   let ptype = PolygonType::new_old(ptype, pdata)?;
63 63
 
64 64
    Ok((Polygon{ptype, ..poly}, 128))
65 65
 }
66 66
 
67
-impl PolyType
67
+impl PolygonType
68 68
 {
69
-   /// Creates a `PolyType` from a `n`/`pdata` pair.
69
+   /// Creates a `PolygonType` from a `n`/`pdata` pair.
70 70
    pub fn new(n: u16, pdata: u16) -> Result<Self, ReprError>
71 71
    {
72 72
       match n {
73
-         0  => Ok(PolyType::Normal),
74
-         1  => Ok(PolyType::ImpassItem),
75
-         2  => Ok(PolyType::ImpassMons),
76
-         3  => Ok(PolyType::Hill),
77
-         4  => Ok(PolyType::Base),
78
-         5  => Ok(PolyType::Platform(pdata)),
79
-         6  => Ok(PolyType::TrigLightOn(pdata)),
80
-         7  => Ok(PolyType::TrigPlatOn(pdata)),
81
-         8  => Ok(PolyType::TrigLightOff(pdata)),
82
-         9  => Ok(PolyType::TrigPlatOff(pdata)),
83
-         10 => Ok(PolyType::Teleporter(pdata)),
84
-         11 => Ok(PolyType::ZoneBorder),
85
-         12 => Ok(PolyType::Goal),
86
-         13 => Ok(PolyType::TrigMonsVis),
87
-         14 => Ok(PolyType::TrigMonsInv),
88
-         15 => Ok(PolyType::TrigMonsDual),
89
-         16 => Ok(PolyType::TrigItems),
90
-         17 => Ok(PolyType::MustExplore),
91
-         18 => Ok(PolyType::AutoExit),
92
-         19 => Ok(PolyType::OuchMinor),
93
-         20 => Ok(PolyType::OuchMajor),
94
-         21 => Ok(PolyType::Glue),
95
-         22 => Ok(PolyType::GlueTrigger(pdata)),
96
-         23 => Ok(PolyType::GlueSuper),
73
+         0  => Ok(PolygonType::Normal),
74
+         1  => Ok(PolygonType::ImpassItem),
75
+         2  => Ok(PolygonType::ImpassMons),
76
+         3  => Ok(PolygonType::Hill),
77
+         4  => Ok(PolygonType::Base),
78
+         5  => Ok(PolygonType::Platform(pdata)),
79
+         6  => Ok(PolygonType::TrigLightOn(pdata)),
80
+         7  => Ok(PolygonType::TrigPlatOn(pdata)),
81
+         8  => Ok(PolygonType::TrigLightOff(pdata)),
82
+         9  => Ok(PolygonType::TrigPlatOff(pdata)),
83
+         10 => Ok(PolygonType::Teleporter(pdata)),
84
+         11 => Ok(PolygonType::ZoneBorder),
85
+         12 => Ok(PolygonType::Goal),
86
+         13 => Ok(PolygonType::TrigMonsVis),
87
+         14 => Ok(PolygonType::TrigMonsInv),
88
+         15 => Ok(PolygonType::TrigMonsDual),
89
+         16 => Ok(PolygonType::TrigItems),
90
+         17 => Ok(PolygonType::MustExplore),
91
+         18 => Ok(PolygonType::AutoExit),
92
+         19 => Ok(PolygonType::OuchMinor),
93
+         20 => Ok(PolygonType::OuchMajor),
94
+         21 => Ok(PolygonType::Glue),
95
+         22 => Ok(PolygonType::GlueTrigger(pdata)),
96
+         23 => Ok(PolygonType::GlueSuper),
97 97
          n  => Err(ReprError::new(n)),
98 98
       }
99 99
    }
100 100
 
101
-   /// Creates a `PolyType` from a Marathon 1 compatible `n`/`pdata` pair.
101
+   /// Creates a `PolygonType` from a Marathon 1 compatible `n`/`pdata` pair.
102 102
    fn new_old(n: u16, pdata: u16) -> Result<Self, ReprError>
103 103
    {
104 104
       match n {
105
-         0  => Ok(PolyType::Normal),
106
-         1  => Ok(PolyType::ImpassItem),
107
-         2  => Ok(PolyType::ImpassMons),
108
-         3  => Ok(PolyType::OuchMinor),
109
-         4  => Ok(PolyType::OuchMajor),
110
-         5  => Ok(PolyType::Platform(pdata)),
111
-         6  => Ok(PolyType::TrigLightOn(pdata)),
112
-         7  => Ok(PolyType::TrigPlatOn(pdata)),
113
-         8  => Ok(PolyType::TrigLightOff(pdata)),
114
-         9  => Ok(PolyType::TrigPlatOff(pdata)),
115
-         10 => Ok(PolyType::Teleporter(pdata)),
116
-         11 => Ok(PolyType::Glue),
117
-         12 => Ok(PolyType::GlueTrigger(pdata)),
118
-         13 => Ok(PolyType::GlueSuper),
119
-         14 => Ok(PolyType::MustExplore),
120
-         15 => Ok(PolyType::AutoExit),
105
+         0  => Ok(PolygonType::Normal),
106
+         1  => Ok(PolygonType::ImpassItem),
107
+         2  => Ok(PolygonType::ImpassMons),
108
+         3  => Ok(PolygonType::OuchMinor),
109
+         4  => Ok(PolygonType::OuchMajor),
110
+         5  => Ok(PolygonType::Platform(pdata)),
111
+         6  => Ok(PolygonType::TrigLightOn(pdata)),
112
+         7  => Ok(PolygonType::TrigPlatOn(pdata)),
113
+         8  => Ok(PolygonType::TrigLightOff(pdata)),
114
+         9  => Ok(PolygonType::TrigPlatOff(pdata)),
115
+         10 => Ok(PolygonType::Teleporter(pdata)),
116
+         11 => Ok(PolygonType::Glue),
117
+         12 => Ok(PolygonType::GlueTrigger(pdata)),
118
+         13 => Ok(PolygonType::GlueSuper),
119
+         14 => Ok(PolygonType::MustExplore),
120
+         15 => Ok(PolygonType::AutoExit),
121 121
          n  => Err(ReprError::new(n)),
122 122
       }
123 123
    }
124 124
 }
125 125
 
126
-impl Default for PolyType
126
+impl Default for PolygonType
127 127
 {
128
-   fn default() -> Self {PolyType::Normal}
128
+   fn default() -> Self {PolygonType::Normal}
129 129
 }
130 130
 
131 131
 /// A polygon segment.
@@ -133,7 +133,7 @@ impl Default for PolyType
133 133
 #[derive(Clone, Debug, Default, Eq, PartialEq)]
134 134
 pub struct Polygon
135 135
 {
136
-   pub ptype:   PolyType,
136
+   pub ptype:   PolygonType,
137 137
    pub tex_flr: OptU16,
138 138
    pub tex_cei: OptU16,
139 139
    pub hei_flr: Unit,
@@ -154,7 +154,7 @@ pub struct Polygon
154 154
 /// The action type of a `Polygon`.
155 155
 #[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
156 156
 #[derive(Clone, Copy, Debug, Eq, PartialEq)]
157
-pub enum PolyType
157
+pub enum PolygonType
158 158
 {
159 159
    Normal,
160 160
    ImpassItem,
@@ -185,7 +185,7 @@ pub enum PolyType
185 185
 bitflags! {
186 186
    /// Flags for `Polygon`.
187 187
    #[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
188
-   pub struct PolyFlags: u16
188
+   pub struct PolygonFlags: u16
189 189
    {
190 190
       const DETACHED = 1 << 14;
191 191
    }

source/map/prpx.rs → maraiah/map/prpx.rs View File


source/map/pxpx.rs → maraiah/map/pxpx.rs View File


source/map/sids.rs → maraiah/map/sids.rs View File

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

source/map/stex.rs → maraiah/map/stex.rs View File


source/map/term.rs → maraiah/map/term.rs View File


source/map/trig.rs → maraiah/map/trig.rs View File

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

source/map/trmf.rs → maraiah/map/trmf.rs View File


source/map/trmg.rs → maraiah/map/trmg.rs View File


source/map/wppx.rs → maraiah/map/wppx.rs View File

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

+ 50
- 0
maraiah/meta.rs View File

@@ -0,0 +1,50 @@
1
+//! Meta-information of this crate.
2
+
3
+macro_rules! meta_str {
4
+   ($($(#[$outer:meta])* $name:ident = $e:expr;)*) => {
5
+      $($(#[$outer])* pub const fn $name() -> &'static str {$e})*
6
+
7
+      pub mod ffi
8
+      {
9
+         $(
10
+         doc_comment! {
11
+            concat!("FFI variant of [`",
12
+                    stringify!($name),
13
+                    "`]\n\n[`",
14
+                    stringify!($name),
15
+                    "`]: ../fn.",
16
+                    stringify!($name),
17
+                    ".html"),
18
+            pub const fn $name() -> crate::ffi::NT {c_str!($e)}
19
+         }
20
+         )*
21
+      }
22
+   }
23
+}
24
+
25
+meta_str!(
26
+   /// The authors of this crate, `:` separated.
27
+   authors       = env!("CARGO_PKG_AUTHORS");
28
+   /// The description of this crate.
29
+   description   = env!("CARGO_PKG_DESCRIPTION");
30
+   /// The home page of this crate.
31
+   homepage      = env!("CARGO_PKG_HOMEPAGE");
32
+   /// The full license text of this crate.
33
+   license_text  = include_str!("../LICENSE");
34
+   /// The name of this crate.
35
+   name          = env!("CARGO_PKG_NAME");
36
+   /// The repository of this crate.
37
+   repository    = env!("CARGO_PKG_REPOSITORY");
38
+   /// The full version of this crate.
39
+   version       = env!("CARGO_PKG_VERSION");
40
+   /// The major version of this crate.
41
+   version_major = env!("CARGO_PKG_VERSION_MAJOR");
42
+   /// The minor version of this crate.
43
+   version_minor = env!("CARGO_PKG_VERSION_MINOR");
44
+   /// The patch version of this crate.
45
+   version_patch = env!("CARGO_PKG_VERSION_PATCH");
46
+   /// The pre-release version of this crate.
47
+   version_pre   = env!("CARGO_PKG_VERSION_PRE");
48
+);
49
+
50
+// EOF

source/shp.rs → maraiah/shp.rs View File


source/shp/bmap.rs → maraiah/shp/bmap.rs View File


source/shp/clut.rs → maraiah/shp/clut.rs View File


source/shp/coll.rs → maraiah/shp/coll.rs View File

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

source/shp/fram.rs → maraiah/shp/fram.rs View File


source/shp/sequ.rs → maraiah/shp/sequ.rs View File

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

source/snd.rs → maraiah/snd.rs View File


source/snd/defs.rs → maraiah/snd/defs.rs View File

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

source/snd/snds.rs → maraiah/snd/snds.rs View File


source/sound.rs → maraiah/sound.rs View File


source/sound/wav.rs → maraiah/sound/wav.rs View File


source/text.rs → maraiah/text.rs View File


source/xfer.rs → maraiah/xfer.rs View File

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

+ 0
- 17
source/leela/Cargo.toml View File

@@ -1,17 +0,0 @@
1
-[package]
2
-name        = "maraiah-leela"
3
-version     = "0.1.0"
4
-authors     = ["Alison Watson <marrub@greyserv.net>"]
5
-description = "Maraiah testbed program."
6
-edition     = "2018"
7
-
8
-[dependencies]
9
-clap       = "2"
10
-maraiah    = {path = "../..", features = ["serde_obj"]}
11
-memmap     = "0.7"
12
-serde      = "1.0"
13
-serde_yaml = "0.8"
14
-
15
-[[bin]]
16
-name = "leela"
17
-path = "main.rs"

+ 0
- 51
source/meta.rs View File

@@ -1,51 +0,0 @@
1
-//! Meta-information of this crate.
2
-
3
-macro_rules! meta_str {
4
-   ($($(#[$outer:meta])* $name:ident = $cname:ident = $e:expr;)*) => {
5
-      $(
6
-      $(#[$outer])* pub const $name:  &'static str = $e;
7
-      )*
8
-      pub mod ffi
9
-      {
10
-         $(
11
-         doc_comment! {
12
-            concat!("FFI variant of [`",
13
-                    stringify!($name),
14
-                    "`]\n\n[`",
15
-                    stringify!($name),
16
-                    "`]: ../constant.",
17
-                    stringify!($name),
18
-                    ".html"),
19
-            pub const $cname: crate::ffi::NT = c_str!($e);
20
-         }
21
-         )*
22
-      }
23
-   }
24
-}
25
-
26
-meta_str!(
27
-   /// The authors of this crate, `:` separated.
28
-   AUTHORS       = AUTHORS_C        = env!("CARGO_PKG_AUTHORS");
29
-   /// The description of this crate.
30
-   DESCRIPTION   = DESCRIPTION_C    = env!("CARGO_PKG_DESCRIPTION");
31
-   /// The home page of this crate.
32
-   HOMEPAGE      = HOMEPAGE_C       = env!("CARGO_PKG_HOMEPAGE");
33
-   /// The full license text of this crate.
34
-   LICENSE_TEXT  = LICENSE_TEXT_C   = include_str!("../LICENSE");
35
-   /// The name of this crate.
36
-   NAME          = NAME_C           = env!("CARGO_PKG_NAME");
37
-   /// The repository of this crate.
38
-   REPOSITORY    = REPOSITORY_C     = env!("CARGO_PKG_REPOSITORY");
39
-   /// The full version of this crate.
40
-   VERSION       = VERSION_C        = env!("CARGO_PKG_VERSION");
41
-   /// The major version of this crate.
42
-   VERSION_MAJOR = VERSION_MAJOR_C  = env!("CARGO_PKG_VERSION_MAJOR");
43
-   /// The minor version of this crate.
44
-   VERSION_MINOR = VERSION_MINOR_C  = env!("CARGO_PKG_VERSION_MINOR");
45
-   /// The patch version of this crate.
46
-   VERSION_PATCH = VERSION_PATCH_C  = env!("CARGO_PKG_VERSION_PATCH");
47
-   /// The pre-release version of this crate.
48
-   VERSION_PRE   = VERSION_PRE_C    = env!("CARGO_PKG_VERSION_PRE");
49
-);
50
-
51
-// EOF

BIN
tests/data/m2/Map View File


tests/data/defl/Shapes.out → tests/data/m2/Shapes View File


+ 3
- 3
tests/data/map/minf.out View File

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

BIN
tests/data/map/testmap.in View File


+ 2185
- 0
tests/data/map/testmap.out
File diff suppressed because it is too large
View File


+ 1
- 1
tests/defl.rs View File

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

+ 46
- 24
tests/map.rs View File

@@ -51,25 +51,65 @@ fn read_term_must_process()
51 51
    }
52 52
 }
53 53
 
54
+#[test]
55
+fn map_m2()
56
+{
57
+   let inp = include_bytes!("data/m2/Map");
58
+   let mut rd = std::io::BufReader::new(&inp[..]);
59
+
60
+   let mp = map::head::read(&mut rd).unwrap();
61
+   let en = map::entr::read_all(&mp).unwrap();
62
+
63
+   assert!(map::data::read_all(mp.head(), &en).is_ok());
64
+}
65
+
66
+#[test]
67
+#[ignore]
68
+fn map_full_check()
69
+{
70
+   use maraiah::{bin::OptU16,
71
+                 map::{data::*, lins::*, lite::*, ltfn::*, minf::*, objs::*,
72
+                       plac::*, pnts::*, poly::*},
73
+                 xfer::TransferMode};
74
+   use std::collections::BTreeMap;
75
+
76
+   let inp = include_bytes!("data/map/testmap.in");
77
+   let mut rd = std::io::BufReader::new(&inp[..]);
78
+
79
+   let mp = map::head::read(&mut rd).unwrap();
80
+   let en = map::entr::read_all(&mp).unwrap();
81
+   let ed = map::data::read_all(mp.head(), &en).unwrap();
82
+
83
+   let mut out = BTreeMap::new();
84
+
85
+   out.insert(0, include!("data/map/testmap.out"));
86
+
87
+   assert_eq!(out, ed);
88
+}
89
+
54 90
 #[test]
55 91
 fn map_must_not_process()
56 92
 {
57 93
    for inp in &RANDOM {
58
-      map::minf::read(inp).err().unwrap();
59
-      map::minf::read_old(inp).err().unwrap();
94
+      bin::rd_array(inp, map::fxpx::read).err().unwrap();
60 95
       bin::rd_array(inp, map::lins::read).err().unwrap();
61 96
       bin::rd_array(inp, map::lite::read).err().unwrap();
97
+      bin::rd_array(inp, map::lite::read_old).err().unwrap();
62 98
       bin::rd_array(inp, map::medi::read).err().unwrap();
99
+      bin::rd_array(inp, map::mnpx::read).err().unwrap();
63 100
       bin::rd_array(inp, map::note::read).err().unwrap();
64 101
       bin::rd_array(inp, map::objs::read).err().unwrap();
65 102
       bin::rd_array(inp, map::plat::read).err().unwrap();
66 103
       bin::rd_array(inp, map::poly::read).err().unwrap();
104
+      bin::rd_array(inp, map::poly::read_old).err().unwrap();
105
+      bin::rd_array(inp, map::prpx::read).err().unwrap();
67 106
       bin::rd_array(inp, map::sids::read).err().unwrap();
107
+      bin::rd_array(inp, map::sids::read_old).err().unwrap();
68 108
       bin::rd_array(inp, map::term::read).err().unwrap();
69 109
       bin::rd_array(inp, map::trmg::read).err().unwrap();
70
-      bin::rd_array(inp, map::lite::read_old).err().unwrap();
71
-      bin::rd_array(inp, map::poly::read_old).err().unwrap();
72
-      bin::rd_array(inp, map::sids::read_old).err().unwrap();
110
+      bin::rd_array(inp, map::wppx::read).err().unwrap();
111
+      map::minf::read(inp).err().unwrap();
112
+      map::minf::read_old(inp).err().unwrap();
73 113
    }
74 114
 }
75 115
 
@@ -82,26 +122,8 @@ fn map_must_not_panic()
82 122
       drop(bin::rd_array(inp, map::epnt::read));
83 123
       drop(bin::rd_array(inp, map::iidx::read));
84 124
       drop(bin::rd_array(inp, map::plac::read));
85
-      drop(bin::rd_array(inp, map::trmf::read));
86
-   }
87
-}
88
-
89
-#[test]
90
-fn phy_must_not_process()
91
-{
92
-   for inp in &RANDOM {
93
-      bin::rd_array(inp, map::fxpx::read).err().unwrap();
94
-      bin::rd_array(inp, map::mnpx::read).err().unwrap();
95
-      bin::rd_array(inp, map::prpx::read).err().unwrap();
96
-      bin::rd_array(inp, map::wppx::read).err().unwrap();
97
-   }
98
-}
99
-
100
-#[test]
101
-fn phy_must_not_panic()
102
-{
103
-   for inp in &RANDOM {
104 125
       drop(bin::rd_array(inp, map::pxpx::read));
126
+      drop(bin::rd_array(inp, map::trmf::read));
105 127
    }
106 128
 }
107 129
 

+ 1
- 1
tests/pict.rs View File

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

source/tycho/CMakeLists.txt → tycho/CMakeLists.txt View File


source/tycho/Cargo.toml → tycho/Cargo.toml View File

@@ -5,12 +5,11 @@ edition = "2018"
5 5
 build   = "build.rs"
6 6
 
7 7
 [dependencies]
8
-maraiah = {path = "../.."}
9
-memmap  = "0.7"
8
+maraiah = {path = ".."}
10 9
 
11 10
 [build-dependencies]
12 11
 cmake                     = "0.1"
13
-maraiah                   = {path = "../.."}
12
+maraiah                   = {path = ".."}
14 13
 rust_qt_binding_generator = "0.3"
15 14
 
16 15
 [[bin]]

source/tycho/bindings.json → tycho/bindings.json View File


source/tycho/build.rs → tycho/build.rs View File


source/tycho/cc_headers/mapprops.h → tycho/cc_headers/mapprops.h View File


source/tycho/cc_headers/menu.h → tycho/cc_headers/menu.h View File


source/tycho/cc_headers/project.h → tycho/cc_headers/project.h View File


source/tycho/cc_headers/tycho.h → tycho/cc_headers/tycho.h View File


source/tycho/cc_source/main.cc → tycho/cc_source/main.cc View File


source/tycho/cc_source/mapprops.cc → tycho/cc_source/mapprops.cc View File


source/tycho/cc_source/menu.cc → tycho/cc_source/menu.cc View File


source/tycho/cc_source/project.cc → tycho/cc_source/project.cc View File


source/tycho/resources/color/lines.png → tycho/resources/color/lines.png View File


source/tycho/resources/color/map.png → tycho/resources/color/map.png View File


source/tycho/resources/color/pfhor-hand.png → tycho/resources/color/pfhor-hand.png View File


source/tycho/resources/color/points.png → tycho/resources/color/points.png View File


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

Loading…
Cancel
Save