diff options
author | Daniel Schadt <kingdread@gmx.de> | 2020-08-04 00:13:58 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2020-08-04 00:13:58 +0200 |
commit | cb4ade7710f6fa171130edeeabfa2db2fb1c526b (patch) | |
tree | 0c254c52dcc537c0ffef2de27566d2098e3c511b | |
parent | 1eb04b8496dcdf626f8d4651f66955a0ea7c1102 (diff) | |
download | evtclib-cb4ade7710f6fa171130edeeabfa2db2fb1c526b.tar.gz evtclib-cb4ade7710f6fa171130edeeabfa2db2fb1c526b.tar.bz2 evtclib-cb4ade7710f6fa171130edeeabfa2db2fb1c526b.zip |
fix endianness for CBTS_ERROR
Otherwise the text will be garbled (reversed and probably cut short).
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | src/event.rs | 12 |
2 files changed, 9 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index d8c0124..c7c6b4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file. ## Unreleased +### Fixed +- Fixed the conversion from `CBTS_ERROR` to `EventKind::Error` not having the + correct text. ## 0.4.0 - 2020-07-24 ### Added diff --git a/src/event.rs b/src/event.rs index d0d3181..f9ee8e5 100644 --- a/src/event.rs +++ b/src/event.rs @@ -6,7 +6,7 @@ use super::raw; use std::convert::TryFrom; use std::io; -use byteorder::{BigEndian, WriteBytesExt}; +use byteorder::{BigEndian, WriteBytesExt, LE}; use getset::{CopyGetters, Getters}; use num_traits::FromPrimitive; use thiserror::Error; @@ -515,11 +515,11 @@ fn get_api_guild_string(bytes: &[u8; 16]) -> Option<String> { fn get_error_bytes(raw_event: &raw::CbtEvent) -> [u8; 32] { let mut result = [0; 32]; let mut cursor = io::Cursor::new(&mut result as &mut [u8]); - cursor.write_u64::<BigEndian>(raw_event.time).unwrap(); - cursor.write_u64::<BigEndian>(raw_event.src_agent).unwrap(); - cursor.write_u64::<BigEndian>(raw_event.dst_agent).unwrap(); - cursor.write_i32::<BigEndian>(raw_event.value).unwrap(); - cursor.write_i32::<BigEndian>(raw_event.buff_dmg).unwrap(); + cursor.write_u64::<LE>(raw_event.time).unwrap(); + cursor.write_u64::<LE>(raw_event.src_agent).unwrap(); + cursor.write_u64::<LE>(raw_event.dst_agent).unwrap(); + cursor.write_i32::<LE>(raw_event.value).unwrap(); + cursor.write_i32::<LE>(raw_event.buff_dmg).unwrap(); result } |