Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix debug build #163

Merged
merged 2 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/parser/src/first_pass/read_bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use bitter::LittleEndianReader;
use std::fmt;

pub struct Bitreader<'a> {
reader: LittleEndianReader<'a>,
pub reader: LittleEndianReader<'a>,
pub bits_left: u32,
pub bits: u64,
pub total_bits_left: u32,
Expand Down Expand Up @@ -52,7 +52,9 @@ impl<'a> Bitreader<'a> {
#[inline(always)]
pub fn refill(&mut self) {
let refilled = self.reader.refill_lookahead();
self.bits = self.reader.peek(refilled);
if refilled > 0 {
self.bits = self.reader.peek(refilled);
}
self.bits_left = refilled;
}
#[inline(always)]
Expand Down
2 changes: 0 additions & 2 deletions src/parser/src/parse_demo.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::time::Instant;

use crate::first_pass::parser::FirstPassOutput;
use crate::first_pass::parser_settings::check_multithreadability;
use crate::first_pass::parser_settings::{FirstPassParser, ParserInputs};
Expand Down
17 changes: 9 additions & 8 deletions src/parser/src/second_pass/entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ impl<'a> SecondPassParser<'a> {
if bitreader.bits_left < HUFFMAN_CODE_MAXLEN {
bitreader.refill();
}

let peeked_bits = bitreader.peek(HUFFMAN_CODE_MAXLEN);
let (symbol, code_len) = self.huffman_lookup_table[peeked_bits as usize];
bitreader.consume(code_len as u32);
Expand Down Expand Up @@ -301,14 +302,14 @@ impl<'a> SecondPassParser<'a> {
pub fn debug_inspect(
_result: &Variant,
field: &Field,
tick: i32,
_tick: i32,
field_info: Option<FieldInfo>,
path: &FieldPath,
is_fullpacket: bool,
is_baseline: bool,
cls: &Class,
cls_id: &u32,
entity_id: &i32,
_path: &FieldPath,
_is_fullpacket: bool,
_is_baseline: bool,
_cls: &Class,
_cls_id: &u32,
_entity_id: &i32,
) {
if let Field::Value(_v) = field {
if _v.full_name.contains("Custom") {
Expand Down Expand Up @@ -584,7 +585,7 @@ impl<'a> SecondPassParser<'a> {
&mut self,
bitreader: &mut Bitreader,
entity_id: &i32,
events_to_emit: &mut Vec<GameEventInfo>,
_events_to_emit: &mut Vec<GameEventInfo>,
) -> Result<(), DemoParserError> {
let cls_id: u32 = bitreader.read_nbits(8)?;
// Both of these are not used. Don't think they are interesting for the parser
Expand Down
4 changes: 0 additions & 4 deletions src/parser/src/second_pass/game_events.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
use std::sync::Arc;

use super::entities::RoundEnd;
use crate::first_pass::prop_controller::PropInfo;
use crate::first_pass::prop_controller::IS_ALIVE_ID;
use crate::first_pass::prop_controller::ITEM_PURCHASE_COST;
use crate::first_pass::prop_controller::ITEM_PURCHASE_COUNT;
use crate::first_pass::prop_controller::ITEM_PURCHASE_DEF_IDX;
use crate::first_pass::prop_controller::ITEM_PURCHASE_NEW_DEF_IDX;
use crate::first_pass::prop_controller::WEAPON_FLOAT;
use crate::first_pass::prop_controller::WEAPON_PAINT_SEED;
use crate::first_pass::prop_controller::WEAPON_STICKERS_ID;
use crate::first_pass::read_bits::DemoParserError;
use crate::first_pass::stringtables::UserInfo;
use crate::maps::ROUND_WIN_REASON;
Expand Down
2 changes: 1 addition & 1 deletion src/parser/src/second_pass/parser_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ pub fn create_huffman_lookup_table() -> Vec<(u8, u8)> {
for x in v {
let shifta = msb(x);
for (idx, pair) in idx_msb_map.iter().enumerate() {
if x == idx as u32 >> pair - shifta {
if x == idx as u32 >> pair.wrapping_sub(shifta) {
let peekbits = (idx as u64).reverse_bits() >> RIGHTSHIFT_BITORDER;
huffman_table[idx as usize] = huffman_table[x as usize];
huffman_rev_table[peekbits as usize] = huffman_table[x as usize];
Expand Down
10 changes: 9 additions & 1 deletion src/parser/src/second_pass/voice_data.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
// there has to be a better way to disable multiple :D
#[cfg(feature = "voice")]
use crate::first_pass::read_bits::DemoParserError;
#[cfg(feature = "voice")]
use ahash::AHashMap;
#[cfg(feature = "voice")]
use csgoproto::netmessages::CSVCMsg_VoiceData;
#[cfg(feature = "voice")]
use opus::Decoder;
#[cfg(feature = "voice")]
use rayon::iter::IntoParallelRefIterator;
#[cfg(feature = "voice")]
use rayon::iter::ParallelIterator;
use std::i16;

#[cfg(feature = "voice")]
#[derive(Debug)]
struct VoicePacket {
pub length: u16,
pub voice_type: u8,
}
#[cfg(feature = "voice")]
const FRAME_SIZE: usize = 480;
#[cfg(feature = "voice")]
const AVG_BYTES_PER_PACKET: usize = 1600;

#[cfg(feature = "voice")]
Expand Down
Loading