Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AsCurrency, StringTableEntry #127

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified resources/test/Profile_0.sav
100755 → 100644
Empty file.
Empty file modified resources/test/package_version_525.sav
100755 → 100644
Empty file.
Empty file modified resources/test/ro_64bit_fav.sav
100755 → 100644
Empty file.
Binary file added resources/test/string_table_entry.sav
Binary file not shown.
Empty file modified resources/test/vector2d.sav
100755 → 100644
Empty file.
12 changes: 7 additions & 5 deletions src/properties/text_property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ pub enum FTextHistory {
/// String table entry
StringTableEntry {
/// Table id
table_id: Box<FText>,
table_id: String,
/// Key
key: String,
},
Expand Down Expand Up @@ -488,7 +488,7 @@ impl FTextHistory {
}
}
TextHistoryType::StringTableEntry => {
let table_id = Box::new(FText::read(cursor, options)?);
let table_id = cursor.read_string()?;
let key = cursor.read_string()?;

FTextHistory::StringTableEntry { table_id, key }
Expand Down Expand Up @@ -632,7 +632,8 @@ impl FTextHistory {
format_options,
target_culture,
} => {
let mut len = 0;
cursor.write_enum(TextHistoryType::AsCurrency)?;
let mut len = 1;
len += cursor.write_fstring(currency_code.as_deref())?;
len += source_value.write(cursor, options)?;
len += 4;
Expand Down Expand Up @@ -701,8 +702,9 @@ impl FTextHistory {
}

FTextHistory::StringTableEntry { table_id, key } => {
let mut len = 0;
len += table_id.write(cursor, options)?;
cursor.write_enum(TextHistoryType::StringTableEntry)?;
let mut len = 1;
len += cursor.write_string(table_id)?;
len += cursor.write_string(key)?;
Ok(len)
}
Expand Down
1 change: 1 addition & 0 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub const SAVESLOT_03_PATH: &str = "resources/test/SaveSlot_03.sav";
pub const SLOT1_PATH: &str = "resources/test/Slot1.sav";
pub const SLOT2_PATH: &str = "resources/test/Slot2.sav";
pub const SLOT3_PATH: &str = "resources/test/Slot3.sav";
pub const STRING_TABLE_ENTRY: &str = "resources/test/string_table_entry.sav";
pub const TEXT_PROPERTY_NOARRAY: &str = "resources/test/text_property_noarray.bin";
pub const TRANSFORM_PATH: &str = "resources/test/transform.sav";
pub const VECTOR2D_PATH: &str = "resources/test/vector2d.sav";
5 changes: 5 additions & 0 deletions tests/gvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ fn slot3() {
test_gvas_file(SLOT3_PATH);
}

#[test]
fn string_table_entry() {
test_gvas_file(STRING_TABLE_ENTRY);
}

#[test]
fn text_property_noarray() {
test_gvas_file(TEXT_PROPERTY_NOARRAY);
Expand Down
Loading