From 0d80bb58aa1fe64b77f72dd2b7b98fc9e34c3e79 Mon Sep 17 00:00:00 2001 From: Andy Date: Sun, 1 Sep 2019 14:28:20 -0300 Subject: [PATCH] dropped BB prefix. Have ChecksumAck::new take an argument to set ack. Added basic test to check le_bytes. --- src/packet/login.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/packet/login.rs b/src/packet/login.rs index 3e880c7..72a12a3 100644 --- a/src/packet/login.rs +++ b/src/packet/login.rs @@ -29,8 +29,6 @@ impl LoginWelcome { } } - - #[pso_packet(0x93)] pub struct Login { pub flag: u32, @@ -194,21 +192,21 @@ impl RedirectClient { } #[pso_packet(0x1E8)] -pub struct BBChecksum { +pub struct Checksum { pub flag: u32, } #[pso_packet(0x2E8)] -pub struct BBChecksumAck { +pub struct ChecksumAck { pub flag: u32, pub ack: u32, } -impl BBChecksumAck { - pub fn new() -> BBChecksumAck { - BBChecksumAck { +impl ChecksumAck { + pub fn new(ack: u32) -> ChecksumAck { + ChecksumAck { flag: 0, - ack: 1, + ack: ack, } } } @@ -256,4 +254,10 @@ mod tests { assert!(bytes[8 + 0x114] == key_config[0]); assert!(bytes[8 + 0x114 + 0x16C] == joystick_config[0]); } + + #[test] + fn test_login_checksum_ack() { + let mut checksum_ack = super::ChecksumAck::new(1); + assert!(u32::to_le_bytes(checksum_ack.ack) == [0x01, 0x00, 0x00, 0x00]); + } }