From 9784fdbafe6ed10f7b0500c129ab3d2f3dfd5567 Mon Sep 17 00:00:00 2001 From: techmetx11 Date: Tue, 25 Jun 2024 18:59:19 +0100 Subject: [PATCH] Added size in response for convenience --- README.md | 1 + src/opcode.rs | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 37f8c1d..04ee6be 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ The data afterwards depends on the supplied opcode, Please consult the **Operati | Name | Size (bytes) | Description | |------------|--------------|---------------------------------------| |request_id | 4 | The ID for the request that this response is meant for | +|size | 4 | Size of the response (excluding size of request id)| The data afterwards depends on the supplied opcode, Please consult the **Operations** chapter for more information. diff --git a/src/opcode.rs b/src/opcode.rs index 82fa1ab..34e58de 100644 --- a/src/opcode.rs +++ b/src/opcode.rs @@ -96,18 +96,23 @@ impl Encoder for OpcodeDecoder { ) -> Result<(), Self::Error> { dst.put_u32(item.request_id); match item.opcode { - JobOpcode::ForceUpdate => match item.update_status { - Ok(_x) => dst.put_u16(0xF44F), - Err(FetchUpdateStatus::PlayerAlreadyUpdated) => dst.put_u16(0xFFFF), - Err(_x) => dst.put_u16(0x0000), - }, + JobOpcode::ForceUpdate => { + dst.put_u32(2); + match item.update_status { + Ok(_x) => dst.put_u16(0xF44F), + Err(FetchUpdateStatus::PlayerAlreadyUpdated) => dst.put_u16(0xFFFF), + Err(_x) => dst.put_u16(0x0000), + } + } JobOpcode::DecryptSignature | JobOpcode::DecryptNSignature => { + dst.put_u32(2 + u32::try_from(item.signature.len()).unwrap()); dst.put_u16(u16::try_from(item.signature.len()).unwrap()); if !item.signature.is_empty() { dst.put_slice(item.signature.as_bytes()); } } JobOpcode::GetSignatureTimestamp => { + dst.put_u32(8); dst.put_u64(item.signature_timestamp); } _ => {}