From 022d05690146e199c349fec895790e6e85a9f339 Mon Sep 17 00:00:00 2001 From: xavo95 Date: Fri, 13 Sep 2024 18:13:32 +0200 Subject: [PATCH] Nested Push messages --- game-server/src/logic/handler/mod.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/game-server/src/logic/handler/mod.rs b/game-server/src/logic/handler/mod.rs index e2008ea..72ae68a 100644 --- a/game-server/src/logic/handler/mod.rs +++ b/game-server/src/logic/handler/mod.rs @@ -33,20 +33,22 @@ macro_rules! handle_request { } macro_rules! handle_push { - ($($name:ident;)*) => { + ($($name:ident $(, $inner_package:ident)?;)*) => { fn handle_push(player: &mut super::player::Player, mut msg: Message) { use ::shorekeeper_protocol::{MessageID, Protobuf}; ::paste::paste! { match msg.get_message_id() { $( - ::shorekeeper_protocol::[<$name Push>]::MESSAGE_ID => { - let Ok(push) = ::shorekeeper_protocol::[<$name Push>]::decode(&*msg.remove_payload()) else { - tracing::debug!("failed to decode {}, player_id: {}", stringify!([<$name Push>]), player.basic_info.id); + ::shorekeeper_protocol::$($inner_package::)?[<$name Push>]::MESSAGE_ID => { + let Ok(push) = ::shorekeeper_protocol::$($inner_package::)?[<$name Push>]::decode(&*msg.remove_payload()) else { + tracing::debug!("failed to decode {}, player_id: {}", stringify!($($inner_package::)?[<$name Push>]), player.basic_info.id); return; }; - [](player, push); + tracing::debug!("logic: processing push {}", stringify!($($inner_package::)?[<$name Push>])); + + [](player, push); }, )* unhandled => ::tracing::warn!("can't find handler for push with message_id={unhandled}")