Rename PrimaryAssetNameProperty to GenericProperty

This commit is contained in:
Joshua Goins 2025-03-02 14:12:26 -05:00
parent 9424aa72fa
commit 6b436b7af2
4 changed files with 13 additions and 14 deletions

View file

@ -54,8 +54,8 @@ pub fn serialized_struct(_metadata: TokenStream, input: TokenStream)
// Add "None" field // Add "None" field
let none_field_stream = quote! { let none_field_stream = quote! {
#[br(temp)] #[br(temp)]
#[bw(calc = crate::structs::PrimaryAssetNameProperty { property_name: "None".to_string(), type_name: "".to_string(), key: None } )] #[bw(calc = crate::structs::GenericProperty { property_name: "None".to_string(), type_name: "".to_string(), key: None } )]
none_field: crate::structs::PrimaryAssetNameProperty none_field: crate::structs::GenericProperty
}; };
let buffer = ::syn::parse::Parser::parse2( let buffer = ::syn::parse::Parser::parse2(
syn::Field::parse_named, syn::Field::parse_named,

View file

@ -3,16 +3,16 @@ use crate::common::{
}; };
use crate::guid::Guid; use crate::guid::Guid;
use crate::struct_property::{Struct, calc_size_in_bytes}; use crate::struct_property::{Struct, calc_size_in_bytes};
use crate::structs::{PrimaryAssetNameProperty, PropertyBase}; use crate::structs::{GenericProperty, PropertyBase};
use binrw::{BinRead, BinResult, binrw}; use binrw::{BinRead, BinResult, binrw};
// parse until we can't parse no more. kind of a hack for how we run into the end of Persistent.Sav // parse until we can't parse no more. kind of a hack for how we run into the end of Persistent.Sav
#[binrw::parser(reader, endian)] #[binrw::parser(reader, endian)]
fn cc() -> BinResult<Vec<PrimaryAssetNameProperty>> { fn cc() -> BinResult<Vec<GenericProperty>> {
let mut result = Vec::<PrimaryAssetNameProperty>::new(); let mut result = Vec::<GenericProperty>::new();
loop { loop {
if let Ok(str) = PrimaryAssetNameProperty::read_options(reader, endian, ()) { if let Ok(str) = GenericProperty::read_options(reader, endian, ()) {
result.push(str); result.push(str);
} else { } else {
break; break;
@ -25,7 +25,7 @@ fn cc() -> BinResult<Vec<PrimaryAssetNameProperty>> {
#[derive(Debug)] #[derive(Debug)]
pub struct MapSubStructProperty { pub struct MapSubStructProperty {
#[br(parse_with = cc)] #[br(parse_with = cc)]
fields: Vec<PrimaryAssetNameProperty>, fields: Vec<GenericProperty>,
} }
#[binrw] #[binrw]

View file

@ -1,16 +1,16 @@
use crate::common::{read_string_with_length, write_string_with_length}; use crate::common::{read_string_with_length, write_string_with_length};
use crate::map_property::{KeyType, MapSubStrProperty}; use crate::map_property::{KeyType, MapSubStrProperty};
use crate::struct_property::Struct; use crate::struct_property::Struct;
use crate::structs::PrimaryAssetNameProperty; use crate::structs::GenericProperty;
use binrw::{BinRead, BinResult, binrw}; use binrw::{BinRead, BinResult, binrw};
// hack, we should be checking for "none" instead // hack, we should be checking for "none" instead
#[binrw::parser(reader, endian)] #[binrw::parser(reader, endian)]
fn cc() -> BinResult<Vec<PrimaryAssetNameProperty>> { fn cc() -> BinResult<Vec<GenericProperty>> {
let mut result = Vec::<PrimaryAssetNameProperty>::new(); let mut result = Vec::<GenericProperty>::new();
loop { loop {
if let Ok(str) = PrimaryAssetNameProperty::read_options(reader, endian, ()) { if let Ok(str) = GenericProperty::read_options(reader, endian, ()) {
result.push(str); result.push(str);
} else { } else {
break; break;
@ -27,7 +27,7 @@ pub enum SetValue {
#[br(pre_assert("StructProperty" == magic && name != "OpenedStrongBoxIds" && name != "AcquiredItemBoxIds"))] #[br(pre_assert("StructProperty" == magic && name != "OpenedStrongBoxIds" && name != "AcquiredItemBoxIds"))]
Struct { Struct {
#[br(parse_with = cc)] #[br(parse_with = cc)]
fields: Vec<PrimaryAssetNameProperty>, fields: Vec<GenericProperty>,
}, },
#[br(pre_assert("StringProperty" == magic || "NameProperty" == magic))] #[br(pre_assert("StringProperty" == magic || "NameProperty" == magic))]
String(MapSubStrProperty), String(MapSubStrProperty),

View file

@ -45,10 +45,9 @@ pub struct SaveSlotInfoStruct {
pub players: ArrayProperty, pub players: ArrayProperty,
} }
// TODO: replace all usage of this with StructField
#[binrw] #[binrw]
#[derive(Debug)] #[derive(Debug)]
pub struct PrimaryAssetNameProperty { pub struct GenericProperty {
#[br(parse_with = read_string_with_length)] #[br(parse_with = read_string_with_length)]
#[bw(write_with = write_string_with_length)] #[bw(write_with = write_string_with_length)]
pub property_name: String, pub property_name: String,