diff --git a/src/exd.rs b/src/exd.rs index 8e8afe5..89b1ff0 100644 --- a/src/exd.rs +++ b/src/exd.rs @@ -1,13 +1,13 @@ use crate::common::Language; use crate::exh::{ColumnDataType, ExcelColumnDefinition, ExcelDataPagination, EXH}; use crate::gamedata::MemoryBuffer; -use binrw::BinRead; -use binrw::{binread, Endian, ReadOptions}; +use binrw::binrw; +use binrw::{BinRead, Endian, ReadOptions}; use std::io::{Cursor, Seek, SeekFrom}; -#[binread] -#[br(magic = b"EXDF")] -#[br(big)] +#[binrw] +#[brw(magic = b"EXDF")] +#[brw(big)] #[allow(dead_code)] struct EXDHeader { version: u16, @@ -17,23 +17,23 @@ struct EXDHeader { index_size: u32, } -#[binread] -#[br(big)] +#[binrw] +#[brw(big)] struct ExcelDataOffset { row_id: u32, pub offset: u32, } -#[binread] -#[br(big)] +#[binrw] +#[brw(big)] #[allow(dead_code)] struct ExcelDataRowHeader { data_size: u32, row_count: u16, } -#[binread] -#[br(big)] +#[binrw] +#[brw(big)] #[allow(dead_code)] pub struct EXD { header: EXDHeader, @@ -41,7 +41,7 @@ pub struct EXD { #[br(count = header.index_size / core::mem::size_of::() as u32)] data_offsets: Vec, - #[br(ignore)] + #[brw(ignore)] pub rows: Vec, } diff --git a/src/fiin.rs b/src/fiin.rs index e54d4e7..98cdecb 100644 --- a/src/fiin.rs +++ b/src/fiin.rs @@ -7,7 +7,7 @@ use std::io::Cursor; #[binrw] #[brw(magic = b"FileInfo")] #[derive(Debug)] -#[br(little)] +#[brw(little)] pub struct FileInfo { #[brw(pad_before = 16)] #[br(ignore)] diff --git a/src/log.rs b/src/log.rs index 662cfae..d5ad1e2 100644 --- a/src/log.rs +++ b/src/log.rs @@ -1,11 +1,11 @@ use crate::gamedata::MemoryBuffer; -use binrw::binread; +use binrw::binrw; use binrw::BinRead; use std::io::{Cursor, Seek, SeekFrom}; -#[binread] +#[binrw] #[allow(dead_code)] -#[br(little)] +#[brw(little)] pub struct ChatLogHeader { content_size: u32, file_size: u32, @@ -14,8 +14,8 @@ pub struct ChatLogHeader { offset_entries: Vec, } -#[binread] -#[br(repr = u8)] +#[binrw] +#[brw(repr = u8)] #[derive(Debug)] enum EventFilter { SystemMessages = 3, @@ -28,9 +28,9 @@ enum EventFilter { EnemyBattle = 170, } -#[binread] +#[binrw] #[derive(Debug)] -#[br(repr = u8)] +#[brw(repr = u8)] enum EventChannel { System = 0, ServerAnnouncement = 3, @@ -44,19 +44,20 @@ enum EventChannel { Unknown6 = 170, } -#[binread] +#[binrw] #[derive(Debug)] #[allow(dead_code)] -#[br(little)] +#[brw(little)] pub struct ChatLogEntry { timestamp: u32, filter: EventFilter, channel: EventChannel, #[br(temp)] + #[bw(calc = 1)] garbage: u32, - #[br(ignore)] + #[brw(ignore)] message: String, } diff --git a/src/model.rs b/src/model.rs index 6d798d5..af2b302 100755 --- a/src/model.rs +++ b/src/model.rs @@ -33,8 +33,8 @@ pub struct ModelFileHeader { pub has_edge_geometry: bool, } -#[binread] -#[br(repr = u8)] +#[binrw] +#[brw(repr = u8)] #[derive(Debug)] enum ModelFlags1 { DustOcclusionEnabled = 0x80, @@ -47,8 +47,8 @@ enum ModelFlags1 { ShadowDisabled = 0x01, } -#[binread] -#[br(repr = u8)] +#[binrw] +#[brw(repr = u8)] #[derive(Debug)] enum ModelFlags2 { None = 0x0, @@ -62,7 +62,7 @@ enum ModelFlags2 { Unknown3 = 0x01, } -#[binread] +#[binrw] #[derive(Debug)] #[allow(dead_code)] pub struct ModelHeader { @@ -107,7 +107,7 @@ pub struct ModelHeader { bg_crest_change_material_index: u8, } -#[binread] +#[binrw] #[derive(Debug)] #[allow(dead_code)] struct MeshLod { @@ -142,7 +142,7 @@ struct MeshLod { index_data_offset: u32, } -#[binread] +#[binrw] #[derive(Debug)] #[allow(dead_code)] struct Mesh { @@ -163,7 +163,7 @@ struct Mesh { vertex_stream_count: u8, } -#[binread] +#[binrw] #[derive(Debug)] #[allow(dead_code)] struct Submesh { @@ -176,7 +176,7 @@ struct Submesh { bone_count: u16, } -#[binread] +#[binrw] #[derive(Debug)] #[allow(dead_code)] struct BoneTable { @@ -186,7 +186,7 @@ struct BoneTable { bone_count: u8, } -#[binread] +#[binrw] #[derive(Debug)] #[allow(dead_code)] struct BoundingBox { @@ -194,10 +194,10 @@ struct BoundingBox { max: [f32; 4], } -#[binread] +#[binrw] #[derive(Debug)] #[allow(dead_code)] -#[br(little)] +#[brw(little)] struct ModelData { header: ModelHeader, @@ -229,12 +229,14 @@ struct ModelData { // TODO: implement shapes #[br(temp)] + #[bw(ignore)] submesh_bone_map_size: u32, #[br(count = submesh_bone_map_size / 2, err_context("lods = {:#?}", lods))] submesh_bone_map: Vec, #[br(temp)] + #[bw(ignore)] padding_amount: u8, #[br(pad_before = padding_amount)] @@ -247,7 +249,7 @@ struct ModelData { bone_bounding_boxes: Vec, } -#[binread] +#[binrw] #[derive(Debug)] #[allow(dead_code)] struct ElementId { @@ -257,8 +259,8 @@ struct ElementId { rotate: [f32; 3], } -#[binread] -#[br(repr = u8)] +#[binrw] +#[brw(repr = u8)] #[derive(Copy, Clone, Debug, PartialEq)] enum VertexType { Invalid = 0, @@ -270,8 +272,8 @@ enum VertexType { Half4 = 14, } -#[binread] -#[br(repr = u8)] +#[binrw] +#[brw(repr = u8)] #[derive(Copy, Clone, Debug)] enum VertexUsage { Position = 0, @@ -284,10 +286,10 @@ enum VertexUsage { Color = 7, } -#[binread] +#[binrw] #[derive(Copy, Clone, Debug)] #[allow(dead_code)] -#[br(little)] +#[brw(little)] struct VertexElement { stream: u8, offset: u8, diff --git a/src/mtrl.rs b/src/mtrl.rs index 575422f..60a4b86 100644 --- a/src/mtrl.rs +++ b/src/mtrl.rs @@ -1,8 +1,8 @@ use crate::gamedata::MemoryBuffer; -use binrw::{binread, BinRead}; +use binrw::{binread, BinRead, binrw}; use std::io::Cursor; -#[binread] +#[binrw] #[derive(Debug)] #[allow(dead_code)] struct MaterialFileHeader { @@ -17,7 +17,7 @@ struct MaterialFileHeader { additional_data_size: u8, } -#[binread] +#[binrw] #[derive(Debug)] struct MaterialHeader { shader_value_list_size: u16, @@ -27,7 +27,7 @@ struct MaterialHeader { sampler_count: u16, } -#[binread] +#[binrw] #[derive(Debug)] #[allow(dead_code)] struct ColorSet { @@ -36,7 +36,7 @@ struct ColorSet { index: u8, } -#[binread] +#[binrw] #[derive(Debug)] #[allow(dead_code)] struct ColorSetInfo { @@ -44,7 +44,7 @@ struct ColorSetInfo { data: Vec, } -#[binread] +#[binrw] #[derive(Debug)] #[allow(dead_code)] struct ColorSetDyeInfo { @@ -52,7 +52,7 @@ struct ColorSetDyeInfo { data: Vec, } -#[binread] +#[binrw] #[derive(Debug)] #[allow(dead_code)] struct ShaderKey { @@ -60,7 +60,7 @@ struct ShaderKey { value: u32, } -#[binread] +#[binrw] #[derive(Debug)] #[allow(dead_code)] struct Constant { @@ -69,7 +69,7 @@ struct Constant { value_size: u16, } -#[binread] +#[binrw] #[derive(Debug)] #[allow(dead_code)] struct Sampler { @@ -79,7 +79,7 @@ struct Sampler { texture_index: u8, } -#[binread] +#[binrw] #[derive(Debug)] #[allow(dead_code)] #[br(little)] diff --git a/src/tex.rs b/src/tex.rs index 8b1cb6a..76c85cf 100644 --- a/src/tex.rs +++ b/src/tex.rs @@ -1,5 +1,5 @@ use crate::gamedata::MemoryBuffer; -use binrw::binread; +use binrw::{binread, binrw}; use binrw::BinRead; use bitflags::bitflags; use std::cmp::min; @@ -8,7 +8,7 @@ use texpresso::Format; // Attributes and Format are adapted from Lumina (https://github.com/NotAdam/Lumina/blob/master/src/Lumina/Data/Files/TexFile.cs) bitflags! { - #[binread] + #[binrw] struct TextureAttribute : u32 { const DISCARD_PER_FRAME = 0x1; const DISCARD_PER_MAP = 0x2; @@ -37,8 +37,8 @@ bitflags! { } } -#[binread] -#[br(repr = u32)] +#[binrw] +#[brw(repr = u32)] #[derive(Debug)] enum TextureFormat { B8G8R8A8 = 0x1450, @@ -46,10 +46,10 @@ enum TextureFormat { BC5 = 0x3431, } -#[binread] +#[binrw] #[derive(Debug)] #[allow(dead_code)] -#[br(little)] +#[brw(little)] struct TexHeader { attribute: TextureAttribute, format: TextureFormat,