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
let none_field_stream = quote! {
#[br(temp)]
#[bw(calc = crate::structs::PrimaryAssetNameProperty { property_name: "None".to_string(), type_name: "".to_string(), key: None } )]
none_field: crate::structs::PrimaryAssetNameProperty
#[bw(calc = crate::structs::GenericProperty { property_name: "None".to_string(), type_name: "".to_string(), key: None } )]
none_field: crate::structs::GenericProperty
};
let buffer = ::syn::parse::Parser::parse2(
syn::Field::parse_named,

View file

@ -3,16 +3,16 @@ use crate::common::{
};
use crate::guid::Guid;
use crate::struct_property::{Struct, calc_size_in_bytes};
use crate::structs::{PrimaryAssetNameProperty, PropertyBase};
use crate::structs::{GenericProperty, PropertyBase};
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
#[binrw::parser(reader, endian)]
fn cc() -> BinResult<Vec<PrimaryAssetNameProperty>> {
let mut result = Vec::<PrimaryAssetNameProperty>::new();
fn cc() -> BinResult<Vec<GenericProperty>> {
let mut result = Vec::<GenericProperty>::new();
loop {
if let Ok(str) = PrimaryAssetNameProperty::read_options(reader, endian, ()) {
if let Ok(str) = GenericProperty::read_options(reader, endian, ()) {
result.push(str);
} else {
break;
@ -25,7 +25,7 @@ fn cc() -> BinResult<Vec<PrimaryAssetNameProperty>> {
#[derive(Debug)]
pub struct MapSubStructProperty {
#[br(parse_with = cc)]
fields: Vec<PrimaryAssetNameProperty>,
fields: Vec<GenericProperty>,
}
#[binrw]

View file

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

View file

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