De-duplicate all the GUID structs, implement better debug display
This replaces several of the duplicate GUID-like structs, and throws them into a struct that more closely resembles FGuid.
This commit is contained in:
parent
5329fa08b2
commit
8713a48351
5 changed files with 27 additions and 34 deletions
17
src/guid.rs
Normal file
17
src/guid.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
use std::fmt;
|
||||||
|
use binrw::binrw;
|
||||||
|
|
||||||
|
// See https://dev.epicgames.com/documentation/en-us/unreal-engine/API/Runtime/Core/Misc/FGuid
|
||||||
|
#[binrw]
|
||||||
|
pub struct Guid {
|
||||||
|
pub a: u32,
|
||||||
|
pub b: u32,
|
||||||
|
pub c: u32,
|
||||||
|
pub d: u32
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for Guid {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.write_str(&format!("{:02X}{:02X}{:02X}{:02X}", self.a, self.b, self.c, self.d))
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ pub mod set_property;
|
||||||
pub mod str_property;
|
pub mod str_property;
|
||||||
pub mod struct_property;
|
pub mod struct_property;
|
||||||
mod structs;
|
mod structs;
|
||||||
|
mod guid;
|
||||||
|
|
||||||
use binrw::helpers::{until, until_eof};
|
use binrw::helpers::{until, until_eof};
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ use crate::struct_property::Struct;
|
||||||
use crate::structs::PrimaryAssetNameProperty;
|
use crate::structs::PrimaryAssetNameProperty;
|
||||||
use binrw::helpers::until_exclusive;
|
use binrw::helpers::until_exclusive;
|
||||||
use binrw::{BinRead, BinResult, binrw};
|
use binrw::{BinRead, BinResult, binrw};
|
||||||
|
use crate::guid::Guid;
|
||||||
|
|
||||||
// A struct without a name
|
// A struct without a name
|
||||||
#[binrw]
|
#[binrw]
|
||||||
|
@ -80,12 +81,6 @@ pub struct MapSubEnumProperty {
|
||||||
pub value: String,
|
pub value: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[binrw]
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct GuidStruct {
|
|
||||||
pub guid: [u8; 16],
|
|
||||||
}
|
|
||||||
|
|
||||||
// Used in MapProperty exclusively, seems to be a shortened version of some Properties
|
// Used in MapProperty exclusively, seems to be a shortened version of some Properties
|
||||||
#[binrw]
|
#[binrw]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -107,24 +102,6 @@ pub enum MabSubProperty {
|
||||||
Enum(MapSubEnumProperty),
|
Enum(MapSubEnumProperty),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[binrw]
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct GuidStructThing {
|
|
||||||
pub guid: [u8; 16],
|
|
||||||
}
|
|
||||||
|
|
||||||
#[binrw]
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct SomeIDStruct {
|
|
||||||
pub guid: [u8; 16],
|
|
||||||
}
|
|
||||||
|
|
||||||
#[binrw]
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct SomeID2Struct {
|
|
||||||
pub guid: [u8; 16],
|
|
||||||
}
|
|
||||||
|
|
||||||
#[binrw]
|
#[binrw]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct StringMapKey {
|
pub struct StringMapKey {
|
||||||
|
@ -146,11 +123,11 @@ pub enum MapKeyProperty {
|
||||||
#[br(pre_assert(*magic == KeyType::EnumAgain))]
|
#[br(pre_assert(*magic == KeyType::EnumAgain))]
|
||||||
EnumAgain(MapSubEnumProperty),
|
EnumAgain(MapSubEnumProperty),
|
||||||
#[br(pre_assert(*magic == KeyType::GUID))]
|
#[br(pre_assert(*magic == KeyType::GUID))]
|
||||||
GUID(GuidStructThing),
|
GUID(Guid),
|
||||||
#[br(pre_assert(*magic == KeyType::SomeID))]
|
#[br(pre_assert(*magic == KeyType::SomeID))]
|
||||||
SomeID(SomeIDStruct),
|
SomeID(Guid),
|
||||||
#[br(pre_assert(*magic == KeyType::SomeID2))]
|
#[br(pre_assert(*magic == KeyType::SomeID2))]
|
||||||
SomeID2(SomeID2Struct),
|
SomeID2(Guid),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[binrw]
|
#[binrw]
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
use crate::structs::{
|
use crate::structs::{CarryCountProperty, DAAssembleIdDataStruct, DABuildDataStruct, DACharacterCommonStatusStruct, DALoadOptionStruct, DAMachineColoringDataStruct, DAModuleColorStruct, DAModuleItemDataStruct, DateTimeStruct, GuidStruct, LinearColorStruct, PrimaryAssetIdStruct, PrimaryAssetNameProperty, SaveSlotInfoStruct};
|
||||||
CarryCountProperty, DAAssembleIdDataStruct, DABuildDataStruct, DACharacterCommonStatusStruct,
|
|
||||||
DALoadOptionStruct, DAMachineColoringDataStruct, DAModuleColorStruct, DAModuleItemDataStruct,
|
|
||||||
DateTimeStruct, GuidStruct, LinearColorStruct, PrimaryAssetIdStruct, PrimaryAssetNameProperty,
|
|
||||||
SaveSlotInfoStruct,
|
|
||||||
};
|
|
||||||
use binrw::binrw;
|
use binrw::binrw;
|
||||||
|
use crate::guid::Guid;
|
||||||
|
|
||||||
#[binrw]
|
#[binrw]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::Property;
|
use crate::Property;
|
||||||
use binrw::binrw;
|
use binrw::binrw;
|
||||||
use crate::common::read_string_with_length;
|
use crate::common::read_string_with_length;
|
||||||
|
use crate::guid::Guid;
|
||||||
|
|
||||||
#[binrw]
|
#[binrw]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -82,7 +83,8 @@ pub struct DAAssembleIdDataStruct {
|
||||||
#[binrw]
|
#[binrw]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct GuidStruct {
|
pub struct GuidStruct {
|
||||||
pub unk: [u8; 33],
|
#[br(pad_before = 17)]
|
||||||
|
pub guid: Guid
|
||||||
}
|
}
|
||||||
|
|
||||||
#[binrw]
|
#[binrw]
|
||||||
|
|
Loading…
Add table
Reference in a new issue