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

Remove hardcoded "win32" string in repository filename functions

Second part to that recent refactor, so eventually it might be possible
to read DATs from other platforms.
This commit is contained in:
Joshua Goins 2024-04-15 19:43:16 -04:00
parent e146b31bd4
commit 57d13f0b21
3 changed files with 12 additions and 12 deletions

View file

@ -66,3 +66,11 @@ pub enum Platform {
PS3, PS3,
PS4, PS4,
} }
pub fn get_platform_string(id: &Platform) -> &'static str {
match &id {
Platform::Win32 => "win32",
Platform::PS3 => "ps3.d",
Platform::PS4 => "ps4.d",
}
}

View file

@ -12,7 +12,7 @@ use binrw::BinRead;
use binrw::binrw; use binrw::binrw;
use tracing::{debug, warn}; use tracing::{debug, warn};
use crate::common::{Platform, Region}; use crate::common::{get_platform_string, Platform, Region};
use crate::sqpack::read_data_block_patch; use crate::sqpack::read_data_block_patch;
#[binread] #[binread]
@ -263,14 +263,6 @@ struct SqpkFileOperationData {
path: String, path: String,
} }
fn get_platform_string(id: &Platform) -> &'static str {
match &id {
Platform::Win32 => "win32",
Platform::PS3 => "ps3.d",
Platform::PS4 => "ps4.d",
}
}
#[derive(BinRead, PartialEq, Debug)] #[derive(BinRead, PartialEq, Debug)]
#[br(big)] #[br(big)]
struct SqpkTargetInfo { struct SqpkTargetInfo {

View file

@ -6,7 +6,7 @@ use std::cmp::Ordering::{Greater, Less};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use binrw::binrw; use binrw::binrw;
use crate::common::{Platform, read_version}; use crate::common::{get_platform_string, Platform, read_version};
use crate::repository::RepositoryType::{Base, Expansion}; use crate::repository::RepositoryType::{Base, Expansion};
/// The type of repository, discerning game data from expansion data. /// The type of repository, discerning game data from expansion data.
@ -177,7 +177,7 @@ impl Repository {
category as i32, category as i32,
self.expansion(), self.expansion(),
0, 0,
"win32" get_platform_string(&self.platform)
) )
} }
@ -193,7 +193,7 @@ impl Repository {
pub fn dat_filename(&self, category: Category, data_file_id: u32) -> String { pub fn dat_filename(&self, category: Category, data_file_id: u32) -> String {
let expansion = self.expansion(); let expansion = self.expansion();
let chunk = 0; let chunk = 0;
let platform = "win32"; let platform = get_platform_string(&self.platform);
format!( format!(
"{:02x}{expansion:02}{chunk:02}.{platform}.dat{data_file_id}", "{:02x}{expansion:02}{chunk:02}.{platform}.dat{data_file_id}",