chore(*): cargo fmt

This commit is contained in:
Lily Tsuru 2023-06-28 19:27:15 -04:00
parent 15d438f294
commit 94823a21e3
12 changed files with 50 additions and 44 deletions

View File

@ -3,8 +3,8 @@
pub mod package;
pub mod package_toc;
pub mod ps2_texture;
pub mod ps2_palette;
pub mod ps2_texture;
/// A trait validatable format objects should implement.
/// TODO: integrate this with some FourCC crate, or re-invent the wheel.
@ -32,6 +32,6 @@ pub fn make_c_string(bytes: &[u8]) -> Option<String> {
match std::str::from_utf8(bytes_without_null).ok() {
Some(string) => Some(String::from(string)),
None => None
None => None,
}
}

View File

@ -1,7 +1,7 @@
//! Package file format structures
use crate::lzss::header::LzssHeader;
use super::Validatable;
use crate::lzss::header::LzssHeader;
/// "EOF" header. The QuickBMS script uses this to seek to the PGRP entry.
#[repr(C)]
@ -13,7 +13,7 @@ pub struct PackageEofHeader {
pub stringtable_size: u32,
/// Start offset of the [PackageGroup] in the package file.
pub header_start_offset: u32
pub header_start_offset: u32,
}
/// A Package Group. I have no idea what this is yet
@ -29,7 +29,7 @@ pub struct PackageGroup {
pub group_file_count: u32,
/// Padding. Set to a fill of 0xCD.
pub pad: u32
pub pad: u32,
}
impl PackageGroup {
@ -87,10 +87,9 @@ pub struct PackageFileChunk {
pub file_uncompressed_size: u32,
/// LZSS header. Only used if the file chunk is compressed.
pub lzss_header: LzssHeader
pub lzss_header: LzssHeader,
}
impl PackageFileChunk {
/// 'PFIL'
pub const VALID_FOURCC: u32 = 0x4C494650;

View File

@ -17,7 +17,7 @@ pub struct Ps2PaletteHeader {
pub data_start: u32,
pub header_size: u32,
pub pad: [u32; 6] // reserved for game code, like .ps2_texture?
pub pad: [u32; 6], // reserved for game code, like .ps2_texture?
}
impl Ps2PaletteHeader {

View File

@ -65,9 +65,8 @@ impl Crc32Hash {
pub fn update_case_insensitive(&self, data: &[u8]) {
for b in data.iter() {
let old = self.state.take();
self.state.set(
CRC32_TABLE[((old ^ (*b & !0x20) as u32) & 0xff) as usize] ^ (old >> 8),
);
self.state
.set(CRC32_TABLE[((old ^ (*b & !0x20) as u32) & 0xff) as usize] ^ (old >> 8));
}
}

View File

@ -1,5 +1,5 @@
use std::mem::size_of;
use crate::format::Validatable;
use std::mem::size_of;
#[repr(C)]
#[derive(Debug, Default)]

View File

@ -6,4 +6,3 @@
// - if we can't do that, investigate reimplementing compression based on `lzss` crate?
pub mod header;

View File

@ -1,10 +1,8 @@
use std::fs::File;
use std::io::{Seek, SeekFrom};
use std::path::{PathBuf};
use std::path::PathBuf;
use crate::format::{
package_toc::*
};
use crate::format::package_toc::*;
use binext::BinaryRead;
use thiserror::Error;

View File

@ -27,7 +27,7 @@ impl Ps2Rgba {
r: ((value & 0x7C00) >> 7) as u8,
g: ((value & 0x03E0) >> 2) as u8,
b: ((value & 0x001F) << 3) as u8,
a: 255
a: 255,
};
}
}

View File

@ -2,9 +2,9 @@
//! This program should be run in the root directory
//! of an extracted (from image) copy of the game.
use std::{fs, path::Path};
use jmmt::hash::filename::*;
use jmmt::read::package_toc::{read_package_toc};
use jmmt::read::package_toc::read_package_toc;
use std::{fs, path::Path};
// TODO: A mode that will re-name everything back? This wouldn't be too hard to implement
@ -21,14 +21,22 @@ fn main() {
match read_package_toc(Path::new(package_toc_filename.as_str()).to_path_buf()) {
Ok(toc) => {
for toc_entry in toc {
let dat_src = format!("DATA/{}", dat_filename_from_hash(toc_entry.file_name_hash()));
let dat_src = format!(
"DATA/{}",
dat_filename_from_hash(toc_entry.file_name_hash())
);
let src_path = Path::new(dat_src.as_str());
let dat_clearname = format!("DATA/{}", toc_entry.file_name().expect("How did invalid ASCII get here?"));
let dat_clearname = format!(
"DATA/{}",
toc_entry
.file_name()
.expect("How did invalid ASCII get here?")
);
let dest_path = Path::new(dat_clearname.as_str());
if src_path.exists() {
match fs::rename(src_path, dest_path) {
Ok(_) => {},
Ok(_) => {}
Err(error) => {
println!("Error renaming {}: {}", src_path.display(), error);
return ();
@ -38,8 +46,11 @@ fn main() {
}
}
match fs::rename(Path::new(package_toc_filename.as_str()), Path::new("DATA/package.toc")) {
Ok(_) => {},
match fs::rename(
Path::new(package_toc_filename.as_str()),
Path::new("DATA/package.toc"),
) {
Ok(_) => {}
Err(error) => {
println!("Error renaming TOC file: {}", error);
return ();

View File

@ -1,7 +1,7 @@
use clap::{Parser, Subcommand};
use std::path::Path;
use jmmt::read::texture::Ps2TextureReader;
use std::path::Path;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]