From 9fbcc91f9c796b4289552b23fad34b6fd4a25168 Mon Sep 17 00:00:00 2001 From: Mika Attila Date: Wed, 6 Jul 2016 20:50:05 +0200 Subject: [PATCH] Stupid workaround for https://github.com/rust-lang/rust/issues/30905 --- rustfmt.toml | 2 + src/gamedata_io/audio.rs | 7 +- src/gamedata_io/code.rs | 7 +- src/gamedata_io/fonts.rs | 6 +- src/gamedata_io/functions.rs | 7 +- src/gamedata_io/meta_data.rs | 7 +- src/gamedata_io/mod.rs | 8 +- src/gamedata_io/options.rs | 7 +- src/gamedata_io/scripts.rs | 7 +- src/gamedata_io/sounds.rs | 6 +- src/gamedata_io/sprites.rs | 4 +- src/gamedata_io/strings.rs | 4 +- src/gamedata_io/textures.rs | 4 +- src/gamedata_io/variables.rs | 7 +- src/lib.rs | 360 +++++++++++++++++------------------ 15 files changed, 225 insertions(+), 218 deletions(-) create mode 100644 rustfmt.toml diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..855f20f --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,2 @@ +reorder-imports = true +write-mode = "overwrite" diff --git a/src/gamedata_io/audio.rs b/src/gamedata_io/audio.rs index 1f4efef..461a77e 100644 --- a/src/gamedata_io/audio.rs +++ b/src/gamedata_io/audio.rs @@ -1,7 +1,8 @@ use std::io; -use byteorder::{ReadBytesExt, WriteBytesExt, LittleEndian}; -use {GameDataRead, GameDataWrite, Audio, AudioData}; -use gamedata_io::{Chunk, get_chunk_header, ReadError, read_into_byte_vec, Tell}; +use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; +use {GameDataRead, GameDataWrite}; +use unexposed::{Audio, AudioData}; +use gamedata_io::{Chunk, ReadError, Tell, get_chunk_header, read_into_byte_vec}; impl<'a> Chunk<'a> for Audio { const TYPE_ID: &'static [u8; 4] = b"AUDO"; diff --git a/src/gamedata_io/code.rs b/src/gamedata_io/code.rs index 4fa52d9..378abfc 100644 --- a/src/gamedata_io/code.rs +++ b/src/gamedata_io/code.rs @@ -1,7 +1,8 @@ use std::io; -use byteorder::{ReadBytesExt, WriteBytesExt, LittleEndian}; -use {GameDataRead, GameDataWrite, Code, CodeChunk}; -use gamedata_io::{Chunk, get_chunk_header, ReadError, read_into_byte_vec, Tell}; +use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; +use {GameDataRead, GameDataWrite}; +use unexposed::{Code, CodeChunk}; +use gamedata_io::{Chunk, ReadError, Tell, get_chunk_header, read_into_byte_vec}; pub fn write_offsets(code: &Code, writer: &mut W, diff --git a/src/gamedata_io/fonts.rs b/src/gamedata_io/fonts.rs index d2ee8b8..66f9631 100644 --- a/src/gamedata_io/fonts.rs +++ b/src/gamedata_io/fonts.rs @@ -1,7 +1,7 @@ use std::io; -use byteorder::{ReadBytesExt, WriteBytesExt, LittleEndian}; -use {GameDataRead, GameDataWrite, Font, Fonts}; -use gamedata_io::{Chunk, get_chunk_header, ReadError, read_into_byte_vec, Tell}; +use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; +use {Font, Fonts, GameDataRead, GameDataWrite}; +use gamedata_io::{Chunk, ReadError, Tell, get_chunk_header, read_into_byte_vec}; pub struct Offset { pub name: u32, diff --git a/src/gamedata_io/functions.rs b/src/gamedata_io/functions.rs index cb58fdf..ff97e5a 100644 --- a/src/gamedata_io/functions.rs +++ b/src/gamedata_io/functions.rs @@ -1,7 +1,8 @@ use std::io; -use byteorder::{ReadBytesExt, WriteBytesExt, LittleEndian}; -use {GameDataRead, GameDataWrite, Function, Functions}; -use gamedata_io::{Chunk, get_chunk_header, ReadError}; +use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; +use {GameDataRead, GameDataWrite}; +use gamedata_io::{Chunk, ReadError, get_chunk_header}; +use unexposed::{Function, Functions}; pub fn write_offsets(funs: &Functions, writer: &mut W, diff --git a/src/gamedata_io/meta_data.rs b/src/gamedata_io/meta_data.rs index 710454f..aae2a06 100644 --- a/src/gamedata_io/meta_data.rs +++ b/src/gamedata_io/meta_data.rs @@ -1,7 +1,8 @@ use std::io; -use byteorder::{ReadBytesExt, WriteBytesExt, LittleEndian}; -use {GameDataRead, GameDataWrite, MetaData}; -use gamedata_io::{Chunk, get_chunk_header, ReadError, Tell}; +use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; +use {GameDataRead, GameDataWrite}; +use gamedata_io::{Chunk, ReadError, Tell, get_chunk_header}; +use unexposed::MetaData; #[derive(Clone, Copy)] pub struct Offsets { diff --git a/src/gamedata_io/mod.rs b/src/gamedata_io/mod.rs index dfdb3a9..a4b84c6 100644 --- a/src/gamedata_io/mod.rs +++ b/src/gamedata_io/mod.rs @@ -1,10 +1,10 @@ //! Implementation of Reading/Writing the Game Maker Studio data format. use std::io::{self, Seek}; -use byteorder::{self, ReadBytesExt, WriteBytesExt, LittleEndian}; -use super::{GameData, MetaData, Options, Extn, Sounds, AudioGroups, Sprites, Backgrounds, Paths, - Scripts, Shaders, Fonts, Timelines, Objects, Rooms, Dafl, Tpag, Code, Variables, - Functions, Strings, Textures, Audio, GameDataRead, GameDataWrite}; +use byteorder::{self, LittleEndian, ReadBytesExt, WriteBytesExt}; +use super::{Fonts, GameData, GameDataRead, GameDataWrite, Sounds, Sprites, Strings, Textures}; + +use unexposed::*; mod meta_data; mod options; diff --git a/src/gamedata_io/options.rs b/src/gamedata_io/options.rs index b32b3bb..8befa16 100644 --- a/src/gamedata_io/options.rs +++ b/src/gamedata_io/options.rs @@ -1,7 +1,8 @@ use std::io; -use byteorder::{ReadBytesExt, WriteBytesExt, LittleEndian}; -use {GameDataRead, GameDataWrite, Options}; -use gamedata_io::{Chunk, get_chunk_header, ReadError}; +use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; +use {GameDataRead, GameDataWrite}; +use gamedata_io::{Chunk, ReadError, get_chunk_header}; +use unexposed::Options; #[derive(Clone, Copy)] pub struct Offsets { diff --git a/src/gamedata_io/scripts.rs b/src/gamedata_io/scripts.rs index 1794348..afa2e2d 100644 --- a/src/gamedata_io/scripts.rs +++ b/src/gamedata_io/scripts.rs @@ -1,7 +1,8 @@ use std::io; -use byteorder::{ReadBytesExt, WriteBytesExt, LittleEndian}; -use {GameDataRead, GameDataWrite, Script, Scripts}; -use gamedata_io::{Chunk, get_chunk_header, ReadError, Tell}; +use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; +use {GameDataRead, GameDataWrite}; +use gamedata_io::{Chunk, ReadError, Tell, get_chunk_header}; +use unexposed::{Script, Scripts}; pub fn write_offsets(scripts: &Scripts, writer: &mut W, diff --git a/src/gamedata_io/sounds.rs b/src/gamedata_io/sounds.rs index 24f959b..c1a0ba1 100644 --- a/src/gamedata_io/sounds.rs +++ b/src/gamedata_io/sounds.rs @@ -1,7 +1,7 @@ use std::io; -use byteorder::{ReadBytesExt, WriteBytesExt, LittleEndian}; -use {GameDataRead, GameDataWrite, Sounds, Sound}; -use gamedata_io::{Chunk, get_chunk_header, ReadError, Tell}; +use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; +use {GameDataRead, GameDataWrite, Sound, Sounds}; +use gamedata_io::{Chunk, ReadError, Tell, get_chunk_header}; pub struct Offsets { pub name_offset: u32, diff --git a/src/gamedata_io/sprites.rs b/src/gamedata_io/sprites.rs index bca84ae..2a5b75b 100644 --- a/src/gamedata_io/sprites.rs +++ b/src/gamedata_io/sprites.rs @@ -1,7 +1,7 @@ use std::io; -use byteorder::{ReadBytesExt, WriteBytesExt, LittleEndian}; +use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use {GameDataRead, GameDataWrite, Sprite, Sprites}; -use gamedata_io::{Chunk, get_chunk_header, ReadError, read_into_byte_vec, Tell}; +use gamedata_io::{Chunk, ReadError, Tell, get_chunk_header, read_into_byte_vec}; pub fn write_offsets(sprites: &Sprites, writer: &mut W, diff --git a/src/gamedata_io/strings.rs b/src/gamedata_io/strings.rs index 654218c..20292fb 100644 --- a/src/gamedata_io/strings.rs +++ b/src/gamedata_io/strings.rs @@ -1,7 +1,7 @@ use std::io; -use byteorder::{self, ReadBytesExt, WriteBytesExt, LittleEndian}; +use byteorder::{self, LittleEndian, ReadBytesExt, WriteBytesExt}; use {GameDataRead, GameDataWrite, Strings}; -use gamedata_io::{Chunk, get_chunk_header, ReadError, Tell}; +use gamedata_io::{Chunk, ReadError, Tell, get_chunk_header}; impl<'a> Chunk<'a> for Strings { const TYPE_ID: &'static [u8; 4] = b"STRG"; diff --git a/src/gamedata_io/textures.rs b/src/gamedata_io/textures.rs index 026feec..002cd6b 100644 --- a/src/gamedata_io/textures.rs +++ b/src/gamedata_io/textures.rs @@ -1,7 +1,7 @@ use std::io; -use byteorder::{ReadBytesExt, WriteBytesExt, LittleEndian, BigEndian}; +use byteorder::{BigEndian, LittleEndian, ReadBytesExt, WriteBytesExt}; use {GameDataRead, GameDataWrite, Texture, Textures}; -use gamedata_io::{Chunk, get_chunk_header, ReadError, read_into_byte_vec, Tell}; +use gamedata_io::{Chunk, ReadError, Tell, get_chunk_header, read_into_byte_vec}; const IMAGE_DATA_ALIGNMENT: u32 = 128; diff --git a/src/gamedata_io/variables.rs b/src/gamedata_io/variables.rs index f1dab1b..8498966 100644 --- a/src/gamedata_io/variables.rs +++ b/src/gamedata_io/variables.rs @@ -1,7 +1,8 @@ use std::io; -use byteorder::{ReadBytesExt, WriteBytesExt, LittleEndian}; -use {GameDataRead, GameDataWrite, Variable, Variables}; -use gamedata_io::{Chunk, get_chunk_header, ReadError}; +use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; +use {GameDataRead, GameDataWrite}; +use gamedata_io::{Chunk, ReadError, get_chunk_header}; +use unexposed::{Variable, Variables}; pub fn write_offsets(variables: &Variables, writer: &mut W, diff --git a/src/lib.rs b/src/lib.rs index fa131d6..2c29375 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,6 +29,7 @@ pub use gamedata_io::{ReadError, StringReadError}; use std::io::{self, Read, Write}; use std::path; +use unexposed::*; /// The data of a Game Maker Studio game. /// @@ -54,7 +55,7 @@ pub struct GameData { dafl: Dafl, tpag: Tpag, /// The code data of the game. - pub code: Code, + code: Code, variables: Variables, functions: Functions, /// The strings of the game. @@ -117,77 +118,185 @@ impl GameData { } } -/// Contains various metadata, for example, the window width/height/title. -pub struct MetaData { - // Possibly some kind of GEN8 version number. Unsure. - // But let's assume, since we need to take multiple versions into consideration, and - // this value seems to differ for different versions. - possibly_gen8_version: u32, - game_id_1_index: usize, // Some kind of game id - default_index: usize, // Points to "Default" - unk2: u32, - unk3: u32, - unk4: u32, - unk5: u32, - unk6: u32, - unk7: u32, - unk8: u32, - game_id_2_index: usize, // Some kind of game id, identical to game_id_1 - unk9: u32, - unk10: u32, - unk11: u32, - unk12: u32, - window_width: u32, - window_height: u32, - unk13: u32, - unk14: u32, - unk15: u32, - unk16: u32, - unk17: u32, - unk18: u32, - unk19: u32, - unk20: u32, - window_title_index: usize, - unknown: Vec, -} +mod unexposed { + /// Contains various metadata, for example, the window width/height/title. + pub struct MetaData { + // Possibly some kind of GEN8 version number. Unsure. + // But let's assume, since we need to take multiple versions into consideration, and + // this value seems to differ for different versions. + pub possibly_gen8_version: u32, + pub game_id_1_index: usize, // Some kind of game id + pub default_index: usize, // Points to "Default" + pub unk2: u32, + pub unk3: u32, + pub unk4: u32, + pub unk5: u32, + pub unk6: u32, + pub unk7: u32, + pub unk8: u32, + pub game_id_2_index: usize, // Some kind of game id, identical to game_id_1 + pub unk9: u32, + pub unk10: u32, + pub unk11: u32, + pub unk12: u32, + pub window_width: u32, + pub window_height: u32, + pub unk13: u32, + pub unk14: u32, + pub unk15: u32, + pub unk16: u32, + pub unk17: u32, + pub unk18: u32, + pub unk19: u32, + pub unk20: u32, + pub window_title_index: usize, + pub unknown: Vec, + } + /// Game Maker project Options + pub struct Options { + pub unk1: u32, // Unknown + pub unk2: u32, // Unknown + pub icon_offset: u32, // Points to texture data (icon?) + pub unk3: u32, + pub unk4: u32, + pub unk5: u32, + pub unk6: u32, + pub unk7: u32, + pub unk8: u32, + pub unk9: u32, + pub unk10: u32, + pub unk11: u32, + pub unk12: u32, + pub unk13: u32, + pub unk14: u32, + pub unk15: u32, + pub constant1_name_index: usize, // Offset of the name of this constant in the string table + pub constant2_name_index: usize, // Offset of the name of this constant in the string table + pub constant3_name_index: usize, // Offset of the name of this constant in the string table + pub constant4_name_index: usize, // Offset of the name of this constant in the string table + pub constant5_name_index: usize, // Offset of the name of this constant in the string table + pub constant6_name_index: usize, // Offset of the name of this constant in the string table + pub constant7_name_index: usize, // Offset of the name of this constant in the string table + pub constant8_name_index: usize, // Offset of the name of this constant in the string table + pub constant9_name_index: usize, // Offset of the name of this constant in the string table + pub constant10_name_index: usize, // Offset of the name of this constant in the string table + pub constant11_name_index: usize, // Offset of the name of this constant in the string table + pub constant12_name_index: usize, // Offset of the name of this constant in the string table + pub constant13_name_index: usize, // Offset of the name of this constant in the string table + pub constant14_name_index: usize, // Offset of the name of this constant in the string table + } -/// Game Maker project Options -pub struct Options { - unk1: u32, // Unknown - unk2: u32, // Unknown - icon_offset: u32, // Points to texture data (icon?) - unk3: u32, - unk4: u32, - unk5: u32, - unk6: u32, - unk7: u32, - unk8: u32, - unk9: u32, - unk10: u32, - unk11: u32, - unk12: u32, - unk13: u32, - unk14: u32, - unk15: u32, - constant1_name_index: usize, // Offset of the name of this constant in the string table - constant2_name_index: usize, // Offset of the name of this constant in the string table - constant3_name_index: usize, // Offset of the name of this constant in the string table - constant4_name_index: usize, // Offset of the name of this constant in the string table - constant5_name_index: usize, // Offset of the name of this constant in the string table - constant6_name_index: usize, // Offset of the name of this constant in the string table - constant7_name_index: usize, // Offset of the name of this constant in the string table - constant8_name_index: usize, // Offset of the name of this constant in the string table - constant9_name_index: usize, // Offset of the name of this constant in the string table - constant10_name_index: usize, // Offset of the name of this constant in the string table - constant11_name_index: usize, // Offset of the name of this constant in the string table - constant12_name_index: usize, // Offset of the name of this constant in the string table - constant13_name_index: usize, // Offset of the name of this constant in the string table - constant14_name_index: usize, // Offset of the name of this constant in the string table -} + /// Purpose unknown. + pub struct Extn { + pub raw: Vec, // Data not analyzed yet + } + /// Collection of audio groups. Not present in all games. + pub struct AudioGroups { + pub raw: Vec, // Data not analyzed yet + } + /// A collection of backgrounds. + pub struct Backgrounds { + pub raw: Vec, // Data not analyzed yet + } + + /// A collection of paths. + pub struct Paths { + pub raw: Vec, // Data not analyzed yet + } + + /// A game maker script. + pub struct Script { + /// Index of the name of the script in the string table + pub name_index: usize, + pub unknown: u32, // Unknown + } + + /// A collection of scripts. + pub struct Scripts { + /// The scripts. + pub scripts: Vec