-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5411e8e
Showing
21 changed files
with
1,299 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "eq_files" | ||
version = "0.1.0" | ||
authors = ["Anarelion <[email protected]>"] | ||
edition = "2021" | ||
|
||
[dependencies] | ||
bytes = "1.0" | ||
thiserror = "1.0" | ||
tracing = "0.1" | ||
compress = "0.2" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
mod pfs; | ||
mod utils; | ||
mod wld; | ||
|
||
use std::string::FromUtf8Error; | ||
|
||
pub use crate::pfs::PackFile; | ||
pub use crate::wld::WldFile; | ||
use bytes::Bytes; | ||
use thiserror::Error; | ||
|
||
#[derive(Debug, Error)] | ||
pub enum EQFilesError { | ||
#[error("unknown error")] | ||
UnknownError, | ||
#[error("invalid magic number {0:x}")] | ||
InvalidMagicNumber(u32), | ||
#[error("Invalid WLD version: {0:x}")] | ||
InvalidVersionNumber(u32), | ||
#[error("error decoding string")] | ||
ErrorDecodingString(#[from] FromUtf8Error), | ||
} | ||
|
||
pub(crate) trait Decoder { | ||
type Settings; | ||
|
||
fn new(input: &mut Bytes, settings: Self::Settings) -> Result<Self, EQFilesError> | ||
where | ||
Self: Sized; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use bytes::{Buf, Bytes}; | ||
|
||
#[derive(Clone, PartialEq)] | ||
pub struct PackFileBlock { | ||
pub compressed_size: u32, | ||
pub uncompressed_size: u32, | ||
pub data: Bytes, | ||
} | ||
|
||
impl crate::Decoder for PackFileBlock { | ||
type Settings = (); | ||
|
||
fn new(input: &mut Bytes, _: Self::Settings) -> Result<Self, crate::EQFilesError> | ||
where | ||
Self: Sized, | ||
{ | ||
let compressed_size = input.get_u32_le(); | ||
let uncompressed_size = input.get_u32_le(); | ||
let data = crate::utils::take(input, compressed_size as usize); | ||
Ok(PackFileBlock { | ||
compressed_size, | ||
uncompressed_size, | ||
data, | ||
}) | ||
} | ||
} |
Oops, something went wrong.