mirror of
https://github.com/redstrate/Physis.git
synced 2025-04-20 11:47:46 +00:00
Fix write support for character appearance data, add test
This commit is contained in:
parent
b8cc68eb30
commit
445a90a0fa
1 changed files with 15 additions and 3 deletions
|
@ -99,7 +99,7 @@ fn convert_subrace_dat(subrace: &Subrace) -> u8 {
|
||||||
#[binrw]
|
#[binrw]
|
||||||
#[br(little)]
|
#[br(little)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[br(magic = 0x2013FF14u32)]
|
#[brw(magic = 0x2013FF14u32)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct CharacterData {
|
pub struct CharacterData {
|
||||||
/// The "version" of the game this was created with.
|
/// The "version" of the game this was created with.
|
||||||
|
@ -107,7 +107,7 @@ pub struct CharacterData {
|
||||||
pub version: u32,
|
pub version: u32,
|
||||||
|
|
||||||
/// The checksum of the data fields.
|
/// The checksum of the data fields.
|
||||||
#[br(pad_after = 4)]
|
#[brw(pad_after = 4)]
|
||||||
pub checksum: u32,
|
pub checksum: u32,
|
||||||
|
|
||||||
/// The race of the character.
|
/// The race of the character.
|
||||||
|
@ -203,11 +203,12 @@ pub struct CharacterData {
|
||||||
|
|
||||||
/// The timestamp when the preset was created.
|
/// The timestamp when the preset was created.
|
||||||
/// This is a UTC time in seconds since the Unix epoch.
|
/// This is a UTC time in seconds since the Unix epoch.
|
||||||
#[br(pad_before = 1)]
|
#[brw(pad_before = 1)]
|
||||||
pub timestamp: u32,
|
pub timestamp: u32,
|
||||||
|
|
||||||
// TODO: this is terrible, just read until string nul terminator
|
// TODO: this is terrible, just read until string nul terminator
|
||||||
#[br(count = 164)]
|
#[br(count = 164)]
|
||||||
|
#[bw(pad_size_to = 164)]
|
||||||
#[br(map = read_string)]
|
#[br(map = read_string)]
|
||||||
#[bw(map = write_string)]
|
#[bw(map = write_string)]
|
||||||
comment: String,
|
comment: String,
|
||||||
|
@ -404,4 +405,15 @@ mod tests {
|
||||||
assert_eq!(chardat.voice, 160);
|
assert_eq!(chardat.voice, 160);
|
||||||
assert_eq!(chardat.comment, "Shadowbringers Comment Text");
|
assert_eq!(chardat.comment, "Shadowbringers Comment Text");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn write_shadowbringers() {
|
||||||
|
let mut d = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||||
|
d.push("resources/tests/chardat");
|
||||||
|
d.push("shadowbringers.dat");
|
||||||
|
|
||||||
|
let chardat_bytes = &read(d).unwrap();
|
||||||
|
let chardat = CharacterData::from_existing(chardat_bytes).unwrap();
|
||||||
|
assert_eq!(*chardat_bytes, chardat.write_to_buffer().unwrap());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue