more stuff

This commit is contained in:
2024-04-18 00:16:37 +02:00
parent 4ad3e0ac5f
commit 2dea132d7f
4 changed files with 35 additions and 16 deletions

View File

@@ -1,8 +1,8 @@
use crate::{ use crate::{
dist_cell::read_dist_cells, dist_cell::{read_dist_cells, EnmaDistTableCell},
lane::EnmaLaneCell, lane::EnmaLaneCell,
non_guard::EnmaNonGuardCell,
section::{read_bank_cell, EnmaBankCell, EnmaSection}, section::{read_bank_cell, EnmaBankCell, EnmaSection},
sign::EnmaSignCell,
speed::EnmaSpeedCell, speed::EnmaSpeedCell,
windows_pe::WindowsPEFile, windows_pe::WindowsPEFile,
zebra::EnmaZebraCell, zebra::EnmaZebraCell,
@@ -72,6 +72,11 @@ pub fn read_area(file: &WindowsPEFile, address: u64) -> Result<EnmaArea, std::io
non_guard_right: read_dist_cells(file, area.non_guard_right_addr, area.max_dist, false)?, non_guard_right: read_dist_cells(file, area.non_guard_right_addr, area.max_dist, false)?,
speed: read_dist_cells(file, area.speed_addr, area.max_dist, true)?, speed: read_dist_cells(file, area.speed_addr, area.max_dist, true)?,
lane: read_dist_cells(file, area.lane_addr, area.max_dist, true)?, lane: read_dist_cells(file, area.lane_addr, area.max_dist, true)?,
non_lane_change: read_dist_cells(file, area.non_lane_change_addr, area.max_dist, false)?,
signs: read_dist_cells(file, area.signs_addr, area.max_dist, false)?,
notices: read_dist_cells(file, area.notices_addr, area.max_dist, false)?,
watches: read_dist_cells(file, area.watches_addr, area.max_dist, false)?,
on_comers: read_dist_cells(file, area.on_comers_addr, area.max_dist, false)?,
}) })
} }
@@ -90,10 +95,17 @@ pub struct EnmaArea {
pub zebra_left: Vec<EnmaZebraCell>, pub zebra_left: Vec<EnmaZebraCell>,
pub zebra_right: Vec<EnmaZebraCell>, pub zebra_right: Vec<EnmaZebraCell>,
pub gaps: Vec<f32>, pub gaps: Vec<f32>,
pub non_guard_left: Vec<EnmaNonGuardCell>, pub non_guard_left: Vec<EnmaDistTableCell>,
pub non_guard_right: Vec<EnmaNonGuardCell>, pub non_guard_right: Vec<EnmaDistTableCell>,
pub speed: Vec<EnmaSpeedCell>, pub speed: Vec<EnmaSpeedCell>,
pub lane: Vec<EnmaLaneCell>, pub lane: Vec<EnmaLaneCell>,
// TODO: other
pub non_lane_change: Vec<EnmaDistTableCell>,
pub signs: Vec<EnmaSignCell>,
pub notices: Vec<EnmaDistTableCell>,
pub watches: Vec<EnmaDistTableCell>,
pub on_comers: Vec<EnmaDistTableCell>,
// TODO: pillers
} }
#[derive(BinRead, Debug)] #[derive(BinRead, Debug)]

View File

@@ -1,6 +1,6 @@
use binrw::BinRead;
use crate::windows_pe::WindowsPEFile; use crate::windows_pe::WindowsPEFile;
use binrw::BinRead;
use serde::Serialize;
pub trait EnmaDistCell { pub trait EnmaDistCell {
fn dist(&self) -> f32; fn dist(&self) -> f32;
@@ -17,13 +17,20 @@ impl EnmaDistCell for f32 {
} }
} }
impl EnmaDistCell for (f32, i32) { #[derive(Debug, BinRead, Serialize)]
pub struct EnmaDistTableCell {
pub dist: f32,
pub unk1: f32,
pub flag: i32,
}
impl EnmaDistCell for EnmaDistTableCell {
fn dist(&self) -> f32 { fn dist(&self) -> f32 {
self.0 self.dist
} }
fn size() -> u64 { fn size() -> u64 {
8 0xc
} }
} }

View File

@@ -2,8 +2,8 @@ pub mod area;
pub mod dist_cell; pub mod dist_cell;
pub mod lane; pub mod lane;
pub mod meta; pub mod meta;
pub mod non_guard;
pub mod section; pub mod section;
pub mod sign;
pub mod speed; pub mod speed;
mod util; mod util;
pub mod windows_pe; pub mod windows_pe;

View File

@@ -4,19 +4,19 @@ use serde::Serialize;
use crate::dist_cell::EnmaDistCell; use crate::dist_cell::EnmaDistCell;
#[derive(Debug, BinRead, Serialize)] #[derive(Debug, BinRead, Serialize)]
pub struct EnmaNonGuardCell { pub struct EnmaSignCell {
pub dist: f32, pub dist: f32,
pub unk1: f32, pub unk2: f32,
// TODO: Is this a boolean? pub unk3: i32,
pub guard: i32, pub unk4: i32,
} }
impl EnmaDistCell for EnmaNonGuardCell { impl EnmaDistCell for EnmaSignCell {
fn dist(&self) -> f32 { fn dist(&self) -> f32 {
self.dist self.dist
} }
fn size() -> u64 { fn size() -> u64 {
0xc 0x10
} }
} }