Skip to content

Commit

Permalink
Rename fuelnet to racenet
Browse files Browse the repository at this point in the history
  • Loading branch information
widberg committed Aug 16, 2024
1 parent 432ffa9 commit e2e8b18
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions bff-cli/src/crc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::io::{self, BufRead, Read};

use bff::crc::{Asobo32, Asobo64, AsoboAlternate32, BlackSheep32, Kalisto32, Ubisoft64, FuelNet32};
use bff::crc::{Asobo32, Asobo64, AsoboAlternate32, BlackSheep32, Kalisto32, Ubisoft64, RaceNet32};
use bff::traits::NameHashFunction;
use clap::ValueEnum;

Expand All @@ -21,7 +21,7 @@ pub enum CrcAlgorithm {
#[value(alias("u64"))]
Ubisoft64,
#[value(alias("net"))]
FuelNet32,
RaceNet32,
}

#[derive(ValueEnum, Clone)]
Expand Down Expand Up @@ -84,8 +84,8 @@ fn hash(bytes: &[u8], starting: &i64, algorithm: &CrcAlgorithm, format: &CrcForm
}
CrcAlgorithm::Asobo64 => format_hash64(Asobo64::hash_options(bytes, starting), format),
CrcAlgorithm::Ubisoft64 => format_hash64(Ubisoft64::hash_options(bytes, starting), format),
CrcAlgorithm::FuelNet32 => {
format_hash(FuelNet32::hash_options(bytes, starting as i32), format)
CrcAlgorithm::RaceNet32 => {
format_hash(RaceNet32::hash_options(bytes, starting as i32), format)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions bff/src/crc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ mod asobo_alternate32;
mod blacksheep32;
mod kalisto32;
mod ubisoft64;
mod fuelnet32;
mod racenet32;

pub use asobo32::*;
pub use asobo64::*;
pub use asobo_alternate32::*;
pub use blacksheep32::*;
pub use kalisto32::*;
pub use ubisoft64::*;
pub use fuelnet32::*;
pub use racenet32::*;
14 changes: 7 additions & 7 deletions bff/src/crc/fuelnet32.rs → bff/src/crc/racenet32.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::traits::NameHashFunction;
use super::blacksheep32::CRC32_TABLE;

pub const fn fuelnet32(bytes: &[u8]) -> i32 {
fuelnet32_options(bytes, 0)
pub const fn racenet32(bytes: &[u8]) -> i32 {
racenet32_options(bytes, 0)
}

// https://github.com/lattera/freebsd/blob/401a161083850a9a4ce916f37520c084cff1543b/sys/libkern/crc32.c#L103-L113
pub const fn fuelnet32_options(bytes: &[u8], starting: i32) -> i32 {
pub const fn racenet32_options(bytes: &[u8], starting: i32) -> i32 {
let mut hash = !starting as u32;
let mut i: usize = 0;
while i < bytes.len() {
Expand All @@ -19,15 +19,15 @@ pub const fn fuelnet32_options(bytes: &[u8], starting: i32) -> i32 {
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct FuelNet32;
impl NameHashFunction for FuelNet32 {
pub struct RaceNet32;
impl NameHashFunction for RaceNet32 {
type Target = i32;

fn hash(bytes: &[u8]) -> Self::Target {
fuelnet32(bytes)
racenet32(bytes)
}

fn hash_options(bytes: &[u8], starting: Self::Target) -> Self::Target {
fuelnet32_options(bytes, starting)
racenet32_options(bytes, starting)
}
}

0 comments on commit e2e8b18

Please sign in to comment.