Skip to content

Commit

Permalink
Add support for loading iRosePH / iRose Odyssey files.
Browse files Browse the repository at this point in the history
Note that the client still tries to load iRose specific files which do
not exist in iRosePH/Odyssey, so make sure you provide a fallback
--data-path or --data-idx to an irose 129en installation.

e.g. you might use both of these args:
--data-iroseph-idx=F:\rose\clients\iRose Odyssey\data.idx
--data-idx=F:\rose\clients\129_129en\data.idx
  • Loading branch information
exjam committed Feb 25, 2024
1 parent 36315d6 commit e7187c2
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 28 deletions.
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ tokio = { version = "1.17", features = ["rt", "net", "sync", "macros", "io-util"
toml = "0.7.2"
quick-xml = { version = "0.26.0", features = ["serialize"] }
regex = "1"
rose-data = { git = "https://github.com/exjam/rose-offline", rev = "a499d3850446c22516c0d3f9336ff80088ed7cb1" }
rose-data-irose = { git = "https://github.com/exjam/rose-offline", rev = "a499d3850446c22516c0d3f9336ff80088ed7cb1" }
rose-file-readers = { git = "https://github.com/exjam/rose-offline", rev = "a499d3850446c22516c0d3f9336ff80088ed7cb1" }
rose-game-common = { git = "https://github.com/exjam/rose-offline", rev = "a499d3850446c22516c0d3f9336ff80088ed7cb1" }
rose-game-irose = { git = "https://github.com/exjam/rose-offline", rev = "a499d3850446c22516c0d3f9336ff80088ed7cb1" }
rose-network-common = { git = "https://github.com/exjam/rose-offline", rev = "a499d3850446c22516c0d3f9336ff80088ed7cb1" }
rose-network-irose = { git = "https://github.com/exjam/rose-offline", rev = "a499d3850446c22516c0d3f9336ff80088ed7cb1" }
rose-data = { git = "https://github.com/exjam/rose-offline", rev = "eb3a1488d2dcfc740a6664c93855a374958bfeac" }
rose-data-irose = { git = "https://github.com/exjam/rose-offline", rev = "eb3a1488d2dcfc740a6664c93855a374958bfeac" }
rose-file-readers = { git = "https://github.com/exjam/rose-offline", rev = "eb3a1488d2dcfc740a6664c93855a374958bfeac" }
rose-game-common = { git = "https://github.com/exjam/rose-offline", rev = "eb3a1488d2dcfc740a6664c93855a374958bfeac" }
rose-game-irose = { git = "https://github.com/exjam/rose-offline", rev = "eb3a1488d2dcfc740a6664c93855a374958bfeac" }
rose-network-common = { git = "https://github.com/exjam/rose-offline", rev = "eb3a1488d2dcfc740a6664c93855a374958bfeac" }
rose-network-irose = { git = "https://github.com/exjam/rose-offline", rev = "eb3a1488d2dcfc740a6664c93855a374958bfeac" }

[dependencies.bevy]
version = "0.11.2"
Expand Down
36 changes: 22 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use std::{

use rose_data::{CharacterMotionDatabaseOptions, NpcDatabaseOptions, ZoneId};
use rose_file_readers::{
AruaVfsIndex, HostFilesystemDevice, LtbFile, StbFile, TitanVfsIndex, VfsIndex,
AruaVfsIndex, HostFilesystemDevice, IrosePhVfsIndex, LtbFile, StbFile, TitanVfsIndex, VfsIndex,
VirtualFilesystem, VirtualFilesystemDevice, ZscFile,
};

Expand Down Expand Up @@ -146,26 +146,16 @@ pub enum FilesystemDeviceConfig {
AruaVfs(String),
#[serde(rename = "titanvfs")]
TitanVfs(String),
#[serde(rename = "iroseph")]
IrosePh(String),
}

#[derive(Deserialize)]
#[derive(Default, Deserialize)]
#[serde(default)]
pub struct FilesystemConfig {
pub devices: Vec<FilesystemDeviceConfig>,
}

impl Default for FilesystemConfig {
fn default() -> Self {
let mut devices = Vec::new();

if Path::new("data.idx").exists() {
devices.push(FilesystemDeviceConfig::Vfs("data.idx".into()));
}

Self { devices }
}
}

impl FilesystemConfig {
pub fn create_virtual_filesystem(&self) -> Option<Arc<VirtualFilesystem>> {
let mut vfs_devices: Vec<Box<dyn VirtualFilesystemDevice + Send + Sync>> = Vec::new();
Expand Down Expand Up @@ -222,6 +212,24 @@ impl FilesystemConfig {
log::info!("Loading game data from Vfs root path {}", path);
vfs_devices.push(Box::new(HostFilesystemDevice::new(index_root_path)));
}
FilesystemDeviceConfig::IrosePh(path) => {
let index_root_path = Path::new(path)
.parent()
.map(|path| path.into())
.unwrap_or_else(PathBuf::new);

log::info!("Loading game data from iRosePH {}", path);
vfs_devices.push(Box::new(
IrosePhVfsIndex::load(Path::new(path))
.unwrap_or_else(|_| panic!("Failed to load iRosePH VFS at {}", path)),
));

log::info!(
"Loading game data from iRosePH root path {}",
index_root_path.to_string_lossy()
);
vfs_devices.push(Box::new(HostFilesystemDevice::new(index_root_path)));
}
}
}

Expand Down
34 changes: 27 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ fn main() {
.help("Path to titanrose data.idx")
.takes_value(true),
)
.arg(
clap::Arg::new("data-iroseph-idx")
.long("data-iroseph-idx")
.help("Path to iRosePH data.idx")
.takes_value(true),
)
.arg(
clap::Arg::new("data-path")
.long("data-path")
Expand Down Expand Up @@ -207,32 +213,46 @@ fn main() {
config.game.ui_version = version.to_string();
}

if let Some(vfs_path) = matches.value_of("data-idx") {
if let Some(aruavfs_path) = matches.value_of("data-aruavfs-idx") {
config
.filesystem
.devices
.insert(0, FilesystemDeviceConfig::Vfs(vfs_path.into()));
.push(FilesystemDeviceConfig::AruaVfs(aruavfs_path.into()));
}

if let Some(aruavfs_path) = matches.value_of("data-aruavfs-idx") {
if let Some(titanvfs_path) = matches.value_of("data-titanvfs-idx") {
config
.filesystem
.devices
.insert(0, FilesystemDeviceConfig::AruaVfs(aruavfs_path.into()));
.push(FilesystemDeviceConfig::TitanVfs(titanvfs_path.into()));
}

if let Some(titanvfs_path) = matches.value_of("data-titanvfs-idx") {
if let Some(iroseph_path) = matches.value_of("data-iroseph-idx") {
config
.filesystem
.devices
.insert(0, FilesystemDeviceConfig::TitanVfs(titanvfs_path.into()));
.push(FilesystemDeviceConfig::IrosePh(iroseph_path.into()));
}

if let Some(vfs_path) = matches.value_of("data-idx") {
config
.filesystem
.devices
.push(FilesystemDeviceConfig::Vfs(vfs_path.into()));
}

if let Some(directory_path) = matches.value_of("data-path") {
config
.filesystem
.devices
.insert(0, FilesystemDeviceConfig::Directory(directory_path.into()));
.push(FilesystemDeviceConfig::Directory(directory_path.into()));
}

if config.filesystem.devices.is_empty() && Path::exists(Path::new("data.idx")) {
config
.filesystem
.devices
.push(FilesystemDeviceConfig::Vfs("data.idx".into()));
}

if matches.is_present("model-viewer") {
Expand Down

0 comments on commit e7187c2

Please sign in to comment.