Browse Source

Minor tweaks

Kevin Lee 1 year ago
parent
commit
f5750615fa
3 changed files with 7 additions and 4 deletions
  1. 1 0
      README.md
  2. 2 2
      imhex.txt
  3. 4 2
      src/ezcad/file.rs

+ 1 - 0
README.md

@@ -1,6 +1,7 @@
 # EzCAD Patcher
 
 This tool parses and patches EZCAD files with values specified in a YAML config file.
+The EZCAD format as implemented in this crate was reverse engineered from sample files, so use at your own risk.
 
 ## Usage
 

+ 2 - 2
imhex.txt

@@ -299,13 +299,13 @@ struct Hatch : ObjCommon {
     Field unknown_5[count_5];
     u32; // 1
     u32; // 16
-    u32 count_6; // 17
+    u32; // 17
     Field pen;
     Field unknown_6[2];
     String hatch_name;
     Field unknown_7[13];
     u32 num_lines;
-    HatchLine lines[num_lines];    
+    HatchLine lines[num_lines];
 };
 
 struct Object {

+ 4 - 2
src/ezcad/file.rs

@@ -4,9 +4,11 @@ use binrw::{BinRead, BinResult, BinWrite, BinWriterExt, Endian, FilePtr64};
 
 use crate::{array_of::ArrayOf, layer::Layer, pen::PenHeader, types::Rgba};
 
+const FILE_MAGIC: &[u8; 16] = b"E\0Z\0C\0A\0D\0X\06\04\0";
+
 #[derive(BinRead, Debug)]
+#[br(magic = b"E\0Z\0C\0A\0D\0X\06\04\0")]
 pub struct EzCadHeader {
-    _magic: [u16; 8],
     _unknown_1: [u8; 0x150],
     pub thumbnail_offset: FilePtr64<Thumbnail>,
     pub pens_offset: FilePtr64<PenHeader>,
@@ -26,7 +28,7 @@ impl BinWrite for EzCadHeader {
         endian: Endian,
         args: Self::Args<'_>,
     ) -> BinResult<()> {
-        self._magic.write_options(writer, endian, args)?;
+        FILE_MAGIC.write_options(writer, endian, args)?;
         self._unknown_1.write_options(writer, endian, args)?;
 
         // Save offset addresses and write placeholder (zeros) for now