Skip to content

Commit

Permalink
Fixed map strings and sequencer
Browse files Browse the repository at this point in the history
  • Loading branch information
sorokya committed Dec 31, 2023
1 parent 3d326a2 commit b6d8367
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/data/eo_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,11 @@ impl EoReader {

let mut buf = self.read_bytes(length)?.to_vec();
decode_string(&mut buf);
let (cow, _, _) = WINDOWS_1252.decode(&buf);
let position_of_break = match buf.iter().position(|b| *b == 0xff) {
Some(position_of_break) => position_of_break,
None => length - 1,
};
let (cow, _, _) = WINDOWS_1252.decode(&buf[..position_of_break]);
Ok(cow.to_string())
}

Expand Down
6 changes: 4 additions & 2 deletions src/packet/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ impl Sequencer {

/// returns the next sequence value
pub fn next_sequence(&mut self) -> i32 {
let result = self.start + self.counter;
self.counter = (self.counter + 1) % 10;
let result = self.start + self.counter;
result
}

Expand Down Expand Up @@ -75,7 +75,9 @@ pub fn get_init_sequence_start(s1: i32, s2: i32) -> i32 {
/// used by the server for Ping packet
pub fn get_ping_sequence_bytes(start: i32) -> [i32; 2] {
let mut rng = rand::thread_rng();
let seq1 = start + rng.gen_range(0..CHAR_MAX - 1);
let seq1_max = start + 252;
let seq1_min = start;
let seq1 = rng.gen_range(seq1_min..=seq1_max);
let seq2 = seq1 - start;
[seq1, seq2]
}
Expand Down

0 comments on commit b6d8367

Please sign in to comment.