Compare commits

..

2 Commits

Author SHA1 Message Date
06ea3ee61d column major 2024-09-26 15:06:27 -07:00
4b9b5f5182 update common 2024-09-16 15:46:52 -07:00
6 changed files with 36 additions and 59 deletions

54
Cargo.lock generated

@ -10,9 +10,9 @@ checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc"
[[package]]
name = "arrayvec"
version = "0.7.6"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
[[package]]
name = "binrw"
@ -44,12 +44,6 @@ version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
[[package]]
name = "bnum"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50202def95bf36cb7d1d7a7962cea1c36a3f8ad42425e5d2b71d7acb8041b5b8"
[[package]]
name = "bytemuck"
version = "1.16.3"
@ -62,18 +56,6 @@ version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
[[package]]
name = "fixed_wide"
version = "0.1.0"
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
checksum = "7a8d6e10c51c9df39ead915c62288afbc41d13e00368e526037e530ee5c58e13"
dependencies = [
"arrayvec",
"bnum",
"paste",
"ratio_ops",
]
[[package]]
name = "glam"
version = "0.28.0"
@ -91,29 +73,12 @@ dependencies = [
"syn 2.0.72",
]
[[package]]
name = "linear_ops"
version = "0.1.0"
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
checksum = "b2e6977ac24f47086d8a7a2d4ae1c720e86dfdc8407cf5e34c18bfa01053c456"
dependencies = [
"fixed_wide",
"paste",
"ratio_ops",
]
[[package]]
name = "owo-colors"
version = "3.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
[[package]]
name = "paste"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
[[package]]
name = "proc-macro2"
version = "1.0.86"
@ -132,30 +97,21 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "ratio_ops"
version = "0.1.0"
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
checksum = "01239195d6afe0509e7e3511b716c0540251dfe7ece0a9a5a27116afb766c42c"
[[package]]
name = "strafesnet_common"
version = "0.5.0"
version = "0.4.0"
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
checksum = "d8fcc44793ae84a1d80882f367980913292241c94eb87584de4010bdad4a918d"
checksum = "ea4126f6fbf9aecf89c9e319290f0221d177dcaa8659b4b9e3d82acc37829f12"
dependencies = [
"arrayvec",
"bitflags",
"fixed_wide",
"glam",
"id",
"linear_ops",
"ratio_ops",
]
[[package]]
name = "strafesnet_snf"
version = "0.2.0"
version = "0.1.3"
dependencies = [
"binrw",
"id",

@ -1,6 +1,6 @@
[package]
name = "strafesnet_snf"
version = "0.2.0"
version = "0.1.3"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -8,4 +8,4 @@ edition = "2021"
[dependencies]
binrw = "0.14.0"
id = { version = "0.1.0", registry = "strafesnet" }
strafesnet_common = { version = "0.5.0", registry = "strafesnet" }
strafesnet_common = { version = "0.4.0", registry = "strafesnet" }

@ -1,6 +1,6 @@
//file format "sniff"
use binrw::{binrw,BinReaderExt,io::TakeSeekExt};
use binrw::{binrw, BinReaderExt, io::TakeSeekExt};
#[derive(Debug)]
pub enum Error{
@ -92,7 +92,7 @@ impl<R:BinReaderExt> File<R>{
data:input,
})
}
pub(crate) fn data_mut(&mut self)->&mut R{
pub(crate) fn as_mut(&mut self)->&mut R{
&mut self.data
}
pub(crate) fn block_reader(&mut self,block_id:BlockId)->Result<binrw::io::TakeSeek<&mut R>,Error>{
@ -102,7 +102,7 @@ impl<R:BinReaderExt> File<R>{
let block_start=self.header.block_location[block_id.get() as usize];
let block_end=self.header.block_location[block_id.get() as usize+1];
self.data.seek(std::io::SeekFrom::Start(block_start)).map_err(Error::Seek)?;
Ok(self.data_mut().take_seek(block_end-block_start))
Ok(self.as_mut().take_seek(block_end-block_start))
}
pub(crate) fn fourcc(&self)->FourCC{
self.header.fourcc

@ -214,7 +214,7 @@ pub struct StreamableMap<R:BinReaderExt>{
impl<R:BinReaderExt> StreamableMap<R>{
pub(crate) fn new(mut file:crate::file::File<R>)->Result<Self,Error>{
//assume the file seek is in the right place to start reading a map header
let header:MapHeader=file.data_mut().read_le().map_err(Error::InvalidHeader)?;
let header:MapHeader=file.as_mut().read_le().map_err(Error::InvalidHeader)?;
let modes=header.modes.into_iter().map(TryInto::try_into).collect::<Result<_,_>>().map_err(Error::InvalidMode)?;
let attributes=header.attributes.into_iter().map(Into::into).collect();
let render_configs=header.render_configs.into_iter().map(Into::into).collect();

@ -1,3 +1,26 @@
pub const fn flag(b:bool,mask:u8)->u8{
(-(b as i8) as u8)&mask
}
#[binrw::binrw]
#[brw(little,repr=u8)]
pub enum Boolio{
True,
False
}
impl Into<bool> for Boolio{
fn into(self)->bool{
match self{
Boolio::True=>true,
Boolio::False=>false,
}
}
}
impl From<bool> for Boolio{
fn from(value:bool)->Self{
match value{
true=>Boolio::True,
false=>Boolio::False,
}
}
}

@ -1,12 +1,10 @@
use super::common::flag;
use super::common::{flag,Boolio};
use super::integer::{Time,Planar64,Planar64Vec3};
#[binrw::binrw]
#[brw(little)]
pub struct ContactingLadder{
#[br(map=|paused:u8|paused!=0)]
#[bw(map=|paused:&bool|*paused as u8)]
pub sticky:bool,
pub sticky:Boolio,
}
impl Into<strafesnet_common::gameplay_attributes::ContactingLadder> for ContactingLadder{
fn into(self)->strafesnet_common::gameplay_attributes::ContactingLadder{