diff options
author | tcmal <me@aria.rip> | 2024-08-25 17:44:23 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-08-25 17:44:23 +0100 |
commit | 439219e74090c7158f8dbc33fed4107a5eb7c003 (patch) | |
tree | 7ba62254b2d888578ff6c1c8de4f0f35c01c75dd /stockton-levels/src/q3/effects.rs | |
parent | 04f17923d38171f07f72603a54237f20ca3572dd (diff) |
refactor(levels): no longer q3 specific
Diffstat (limited to 'stockton-levels/src/q3/effects.rs')
-rw-r--r-- | stockton-levels/src/q3/effects.rs | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/stockton-levels/src/q3/effects.rs b/stockton-levels/src/q3/effects.rs deleted file mode 100644 index 369ed80..0000000 --- a/stockton-levels/src/q3/effects.rs +++ /dev/null @@ -1,48 +0,0 @@ -use std::str; - -use super::Q3BspFile; -use crate::coords::CoordSystem; -use crate::helpers::slice_to_u32; -use crate::traits::effects::*; -use crate::types::{ParseError, Result}; - -/// The size of one effect definition -const EFFECT_SIZE: usize = 64 + 4 + 4; - -pub fn from_data(data: &[u8], n_brushes: u32) -> Result<Box<[Effect]>> { - if data.len() % EFFECT_SIZE != 0 { - return Err(ParseError::Invalid); - } - let length = data.len() / EFFECT_SIZE; - - let mut effects = Vec::with_capacity(length); - for n in 0..length { - let raw = &data[n * EFFECT_SIZE..(n + 1) * EFFECT_SIZE]; - - let brush_idx = slice_to_u32(&raw[64..68]); - if brush_idx >= n_brushes { - return Err(ParseError::Invalid); - } - - effects.push(Effect { - name: str::from_utf8(&raw[..64]) - .map_err(|_| ParseError::Invalid)? - .to_owned(), - brush_idx, - }); - } - - Ok(effects.into_boxed_slice()) -} - -impl<T: CoordSystem> HasEffects<T> for Q3BspFile<T> { - type EffectsIter<'a> = std::slice::Iter<'a, Effect>; - - fn effects_iter(&self) -> Self::EffectsIter<'_> { - self.effects.iter() - } - - fn get_effect(&self, index: u32) -> &Effect { - &self.effects[index as usize] - } -} |