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 binrw::BinRead;
use binrw::binrw;
use crate::compression::no_header_decompress;
use crate::gamedata::MemoryBuffer;
use crate::model::ModelHeader;
use std::io::Write;

View file

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

View file

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

View file

@ -1,4 +1,3 @@
use std::ffi::OsStr;
use std::fs;
use std::fs::DirEntry;
use std::path::PathBuf;
@ -21,7 +20,7 @@ pub struct GameData {
}
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() {
println!("Failed game directory.");

View file

@ -30,7 +30,9 @@ const BOOT_COMPONENT_FILES: [&str; 18] = [
const GAME_COMPONENT_FILES: [&str; 1] = ["ffxivgame.ver"];
#[repr(C)]
struct Unshield;
struct Unshield {
_private: [u8; 0]
}
#[link(name = "unshield")]
extern "C" {
@ -46,9 +48,8 @@ extern "C" {
/// Installs the game from the provided retail installer.
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_filename = "";
for filename in FILES_TO_EXTRACT {
@ -69,13 +70,10 @@ pub unsafe fn install_game(installer_path : &str, game_directory : &str) {
} else {
new_file.write(&installer_file[last_position + 33..position - 42]);
}
last_position = position;
}
last_position = position;
last_filename = filename;
file_size -= (position + 4) - last_position;
}
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}/game"));
unsafe {
// set unshield to shut up
unshield_set_log_level(0);
@ -112,5 +109,4 @@ pub unsafe fn install_game(installer_path : &str, game_directory : &str) {
unshield_close(unshield);
}
}

View file

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

View file

@ -1,10 +1,9 @@
use std::fs;
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 crate::{BootData, GameData};
use crate::sqpack::{read_data_block, read_data_block_patch};
use crate::sqpack::read_data_block_patch;
use core::cmp::min;
use crate::patch::TargetHeaderKind::Version;
@ -304,7 +303,7 @@ fn get_expansion_folder(sub_id : u16) -> String {
match expansion_id {
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) => {
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);
let mut new_file = OpenOptions::new()
@ -365,7 +364,7 @@ pub fn process_patch(data_dir : &str, path : &str) {
SqpkOperation::ExpandData(expand) => {
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);
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);
}
SqpkOperation::HeaderUpdate(header) => {
let mut file_path : String;
let file_path : String;
match header.file_kind {
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);
let mut new_file = OpenOptions::new()
@ -406,7 +405,7 @@ pub fn process_patch(data_dir : &str, path : &str) {
SqpkFileOperation::AddFile => {
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);
@ -439,9 +438,6 @@ pub fn process_patch(data_dir : &str, path : &str) {
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)
}
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];
buf.read_exact(&mut local_data).ok()?;