From 28004f7b4da282e34f0d4bd0ba815a671f51ac2a Mon Sep 17 00:00:00 2001 From: DJMrTV Date: Mon, 3 Feb 2025 20:37:31 +0100 Subject: [PATCH] fix(rmc): fix sending back errors crashing --- src/rmc/response.rs | 4 ++-- src/rmc/structures/qresult.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rmc/response.rs b/src/rmc/response.rs index 30ec03f..cc82b17 100644 --- a/src/rmc/response.rs +++ b/src/rmc/response.rs @@ -7,8 +7,7 @@ use crate::prudp::packet::flags::{NEED_ACK, RELIABLE}; use crate::prudp::packet::PacketOption::FragmentId; use crate::prudp::packet::types::DATA; use crate::prudp::socket::{ConnectionData, SocketData}; - - +use crate::rmc::structures::qresult::ERROR_MASK; pub enum RMCResponseResult { Success{ @@ -67,6 +66,7 @@ pub fn generate_response(protocol_id: u8, response: RMCResponseResult) -> io::Re } => { data_out.push(0); let error_code_val: u32 = error_code.into(); + let error_code_val = error_code_val | ERROR_MASK; data_out.write_all(bytes_of(&error_code_val))?; data_out.write_all(bytes_of(&call_id))?; } diff --git a/src/rmc/structures/qresult.rs b/src/rmc/structures/qresult.rs index 6a16074..d4a5078 100644 --- a/src/rmc/structures/qresult.rs +++ b/src/rmc/structures/qresult.rs @@ -5,7 +5,7 @@ use crate::endianness::{IS_BIG_ENDIAN, ReadExtensions}; use crate::rmc::response::ErrorCode; use crate::rmc::structures::{RmcSerialize, Result}; -const ERROR_MASK: u32 = 1 << 31; +pub const ERROR_MASK: u32 = 1 << 31; #[derive(Pod, Zeroable, Copy, Clone, SwapEndian)] #[repr(transparent)]