MCPcopy Create free account
hub / github.com/LaihoE/Python-demoparser / update_string_table

Method update_string_table

src/parsing/stringtables.rs:94–180  ·  view source on GitHub ↗
(
        &mut self,
        data: &[u8],
        mut st: StringTable,
        _userinfo: bool,
        num_entries: i32,
        max_entries: i32,
        _user_data_size: i32,
        user_data_fixs

Source from the content-addressed store, hash-verified

92 }
93
94 pub fn update_string_table(
95 &mut self,
96 data: &[u8],
97 mut st: StringTable,
98 _userinfo: bool,
99 num_entries: i32,
100 max_entries: i32,
101 _user_data_size: i32,
102 user_data_fixsize: bool,
103 ) -> Option<StringTable> {
104 let mut buf = MyBitreader::new(data);
105 let entry_bits = (max_entries as f32).log2() as i32;
106 let mut entry_index = 0;
107 let mut last_inx: i32 = -1;
108 let mut history: Vec<String> = Vec::new();
109 let mut entry = String::new();
110
111 buf.read_boolie()?;
112
113 for _i in 0..num_entries {
114 let mut user_data = vec![];
115 entry_index = last_inx + 1;
116 if !buf.read_boolie()? {
117 entry_index = buf
118 .read_nbits(entry_bits.try_into().unwrap())?
119 .try_into()
120 .unwrap();
121 }
122 last_inx = entry_index;
123 if buf.read_boolie()? {
124 if buf.read_boolie()? {
125 let idx = buf.read_nbits(5)? as i32;
126 let bytes_to_copy = buf.read_nbits(5)?;
127 let s = &history[idx as usize];
128 let s_slice = &s[..bytes_to_copy as usize];
129 entry = s_slice.to_owned() + &buf.read_string(4096)?;
130 } else {
131 entry = buf.read_string(4096)?;
132 }
133 st.data[entry_index as usize].entry = entry.to_string()
134 }
135 if history.len() >= 32 {
136 history.remove(0);
137 }
138 history.push(entry.clone());
139 if buf.read_boolie()? {
140 user_data = if user_data_fixsize {
141 vec![buf
142 .read_nbits(st.uds.try_into().unwrap())?
143 .try_into()
144 .unwrap()]
145 } else {
146 let size = buf.read_nbits(14)?;
147 buf.read_bits_st(size)?
148 };
149 if st.name == "instancebaseline" {
150 let k = entry.parse::<u32>().unwrap_or(999999);
151 match self.serverclass_map.get(&(k as u16)) {

Callers 1

create_string_tableMethod · 0.80

Calls 6

parse_baselinesFunction · 0.85
read_boolieMethod · 0.80
read_nbitsMethod · 0.80
lenMethod · 0.80
read_bits_stMethod · 0.80
read_stringMethod · 0.45

Tested by

no test coverage detected