1
Fork 0
mirror of https://github.com/redstrate/Physis.git synced 2025-04-20 19:57:45 +00:00

Remove some warnings

This commit is contained in:
Joshua Goins 2022-07-27 21:21:50 -04:00
parent 0a99c6f7a7
commit be9c850fc1
8 changed files with 34 additions and 51 deletions

View file

@ -1,7 +1,6 @@
use std::io::{Cursor, Read, Seek, SeekFrom}; use std::io::{Cursor, Read, Seek, SeekFrom};
use binrw::BinRead; use binrw::BinRead;
use binrw::binrw; use binrw::binrw;
use crate::compression::no_header_decompress;
use crate::gamedata::MemoryBuffer; use crate::gamedata::MemoryBuffer;
use crate::model::ModelHeader; use crate::model::ModelHeader;
use std::io::Write; use std::io::Write;

View file

@ -1,5 +1,4 @@
use std::collections::HashMap; use std::io::{Cursor, Seek, SeekFrom};
use std::io::{BufRead, BufReader, Cursor, Seek, SeekFrom};
use crate::gamedata::MemoryBuffer; use crate::gamedata::MemoryBuffer;
use binrw::{binread, Endian, ReadOptions}; use binrw::{binread, Endian, ReadOptions};
use crate::common::Language; use crate::common::Language;

View file

@ -1,5 +1,4 @@
use std::collections::HashMap; use std::io::Cursor;
use std::io::{BufRead, BufReader, Cursor};
use crate::gamedata::MemoryBuffer; use crate::gamedata::MemoryBuffer;
use binrw::binread; use binrw::binread;
use crate::common::Language; use crate::common::Language;

View file

@ -1,4 +1,3 @@
use std::ffi::OsStr;
use std::fs; use std::fs;
use std::fs::DirEntry; use std::fs::DirEntry;
use std::path::PathBuf; use std::path::PathBuf;
@ -21,7 +20,7 @@ pub struct GameData {
} }
fn is_valid(path: &str) -> bool { fn is_valid(path: &str) -> bool {
let mut d = PathBuf::from(path); let d = PathBuf::from(path);
if fs::metadata(d.as_path()).is_err() { if fs::metadata(d.as_path()).is_err() {
println!("Failed game directory."); println!("Failed game directory.");

View file

@ -30,7 +30,9 @@ const BOOT_COMPONENT_FILES: [&str; 18] = [
const GAME_COMPONENT_FILES: [&str; 1] = ["ffxivgame.ver"]; const GAME_COMPONENT_FILES: [&str; 1] = ["ffxivgame.ver"];
#[repr(C)] #[repr(C)]
struct Unshield; struct Unshield {
_private: [u8; 0]
}
#[link(name = "unshield")] #[link(name = "unshield")]
extern "C" { extern "C" {
@ -46,9 +48,8 @@ extern "C" {
/// Installs the game from the provided retail installer. /// Installs the game from the provided retail installer.
pub unsafe fn install_game(installer_path : &str, game_directory : &str) { pub unsafe fn install_game(installer_path : &str, game_directory : &str) {
let installer_file = std::fs::read(installer_path).unwrap(); let installer_file = fs::read(installer_path).unwrap();
let mut file_size = installer_file.len();
let mut last_position = 0; let mut last_position = 0;
let mut last_filename = ""; let mut last_filename = "";
for filename in FILES_TO_EXTRACT { for filename in FILES_TO_EXTRACT {
@ -69,13 +70,10 @@ pub unsafe fn install_game(installer_path : &str, game_directory : &str) {
} else { } else {
new_file.write(&installer_file[last_position + 33..position - 42]); new_file.write(&installer_file[last_position + 33..position - 42]);
} }
last_position = position;
} }
last_position = position; last_position = position;
last_filename = filename; last_filename = filename;
file_size -= (position + 4) - last_position;
} }
let mut new_file = File::create(last_filename).unwrap(); let mut new_file = File::create(last_filename).unwrap();
@ -85,7 +83,6 @@ pub unsafe fn install_game(installer_path : &str, game_directory : &str) {
fs::create_dir_all(format!("{game_directory}/boot")); fs::create_dir_all(format!("{game_directory}/boot"));
fs::create_dir_all(format!("{game_directory}/game")); fs::create_dir_all(format!("{game_directory}/game"));
unsafe {
// set unshield to shut up // set unshield to shut up
unshield_set_log_level(0); unshield_set_log_level(0);
@ -111,6 +108,5 @@ pub unsafe fn install_game(installer_path : &str, game_directory : &str) {
} }
unshield_close(unshield); unshield_close(unshield);
}
} }

View file

@ -1,10 +1,5 @@
extern crate core; extern crate core;
use std::fs;
use std::path::PathBuf;
use crate::bootdata::BootData;
use crate::gamedata::GameData;
pub mod gamedata; pub mod gamedata;
/// Reading game data repositories, such as "ffxiv" and "ex1", and so on. /// Reading game data repositories, such as "ffxiv" and "ex1", and so on.

View file

@ -1,10 +1,9 @@
use std::fs; use std::fs;
use std::fs::{File, OpenOptions}; use std::fs::{File, OpenOptions};
use std::io::{Cursor, Seek, SeekFrom, Write}; use std::io::{Seek, SeekFrom, Write};
use binrw::BinRead; use binrw::BinRead;
use binrw::binread; use binrw::binread;
use crate::{BootData, GameData}; use crate::sqpack::read_data_block_patch;
use crate::sqpack::{read_data_block, read_data_block_patch};
use core::cmp::min; use core::cmp::min;
use crate::patch::TargetHeaderKind::Version; use crate::patch::TargetHeaderKind::Version;
@ -304,7 +303,7 @@ fn get_expansion_folder(sub_id : u16) -> String {
match expansion_id { match expansion_id {
0 => "ffxiv".to_string(), 0 => "ffxiv".to_string(),
(x) => format!("ex{}", x) x => format!("ex{}", x)
} }
} }
@ -338,7 +337,7 @@ pub fn process_patch(data_dir : &str, path : &str) {
SqpkOperation::AddData(add) => { SqpkOperation::AddData(add) => {
let filename = get_dat_filename(data_dir, add.main_id, add.sub_id, add.file_id); let filename = get_dat_filename(data_dir, add.main_id, add.sub_id, add.file_id);
let (left, right) = filename.rsplit_once('/').unwrap(); let (left, _) = filename.rsplit_once('/').unwrap();
fs::create_dir_all(left); fs::create_dir_all(left);
let mut new_file = OpenOptions::new() let mut new_file = OpenOptions::new()
@ -365,7 +364,7 @@ pub fn process_patch(data_dir : &str, path : &str) {
SqpkOperation::ExpandData(expand) => { SqpkOperation::ExpandData(expand) => {
let filename = get_dat_filename(data_dir, expand.main_id, expand.sub_id, expand.file_id); let filename = get_dat_filename(data_dir, expand.main_id, expand.sub_id, expand.file_id);
let (left, right) = filename.rsplit_once('/').unwrap(); let (left, _) = filename.rsplit_once('/').unwrap();
fs::create_dir_all(left); fs::create_dir_all(left);
let mut new_file = OpenOptions::new() let mut new_file = OpenOptions::new()
@ -376,7 +375,7 @@ pub fn process_patch(data_dir : &str, path : &str) {
write_empty_file_block_at(&mut new_file, expand.block_offset, expand.block_number); write_empty_file_block_at(&mut new_file, expand.block_offset, expand.block_number);
} }
SqpkOperation::HeaderUpdate(header) => { SqpkOperation::HeaderUpdate(header) => {
let mut file_path : String; let file_path : String;
match header.file_kind { match header.file_kind {
TargetFileKind::Dat => { TargetFileKind::Dat => {
@ -387,7 +386,7 @@ pub fn process_patch(data_dir : &str, path : &str) {
} }
} }
let (left, right) = file_path.rsplit_once('/').unwrap(); let (left, _) = file_path.rsplit_once('/').unwrap();
fs::create_dir_all(left); fs::create_dir_all(left);
let mut new_file = OpenOptions::new() let mut new_file = OpenOptions::new()
@ -406,7 +405,7 @@ pub fn process_patch(data_dir : &str, path : &str) {
SqpkFileOperation::AddFile => { SqpkFileOperation::AddFile => {
let new_path = data_dir.to_owned() + "/" + &fop.path; let new_path = data_dir.to_owned() + "/" + &fop.path;
let (left, right) = new_path.rsplit_once('/').unwrap(); let (left, _) = new_path.rsplit_once('/').unwrap();
fs::create_dir_all(left); fs::create_dir_all(left);
@ -439,9 +438,6 @@ pub fn process_patch(data_dir : &str, path : &str) {
SqpkFileOperation::RemoveAll => { SqpkFileOperation::RemoveAll => {
println!("STUB: SqpkFileOperation::RemoveAll"); println!("STUB: SqpkFileOperation::RemoveAll");
} }
_ => {
panic!("Unhandled operation!");
}
} }
} }
_ => {} _ => {}

View file

@ -65,7 +65,7 @@ pub fn read_data_block_patch<T : Read + Seek>(mut buf : T) -> Option<Vec<u8>> {
Some(decompressed_data) Some(decompressed_data)
} }
CompressionMode::Uncompressed { file_size } => { CompressionMode::Uncompressed { file_size } => {
let new_file_size : usize = ((file_size as usize + 143) & 0xFFFFFF80); let new_file_size : usize = (file_size as usize + 143) & 0xFFFFFF80;
let mut local_data: Vec<u8> = vec![0; file_size as usize]; let mut local_data: Vec<u8> = vec![0; file_size as usize];
buf.read_exact(&mut local_data).ok()?; buf.read_exact(&mut local_data).ok()?;