Support for Nested combat messages and JSPatch Notify from files #2

Merged
xeon merged 10 commits from nested-msgs into master 2024-09-14 09:05:18 +00:00
Showing only changes of commit 022d056901 - Show all commits

View file

@ -33,20 +33,22 @@ macro_rules! handle_request {
} }
macro_rules! handle_push { macro_rules! handle_push {
($($name:ident;)*) => { ($($name:ident $(, $inner_package:ident)?;)*) => {
fn handle_push(player: &mut super::player::Player, mut msg: Message) { fn handle_push(player: &mut super::player::Player, mut msg: Message) {
use ::shorekeeper_protocol::{MessageID, Protobuf}; use ::shorekeeper_protocol::{MessageID, Protobuf};
::paste::paste! { ::paste::paste! {
match msg.get_message_id() { match msg.get_message_id() {
$( $(
::shorekeeper_protocol::[<$name Push>]::MESSAGE_ID => { ::shorekeeper_protocol::$($inner_package::)?[<$name Push>]::MESSAGE_ID => {
let Ok(push) = ::shorekeeper_protocol::[<$name Push>]::decode(&*msg.remove_payload()) else { let Ok(push) = ::shorekeeper_protocol::$($inner_package::)?[<$name Push>]::decode(&*msg.remove_payload()) else {
tracing::debug!("failed to decode {}, player_id: {}", stringify!([<$name Push>]), player.basic_info.id); tracing::debug!("failed to decode {}, player_id: {}", stringify!($($inner_package::)?[<$name Push>]), player.basic_info.id);
return; return;
}; };
[<on_ $name:snake _push>](player, push); tracing::debug!("logic: processing push {}", stringify!($($inner_package::)?[<$name Push>]));
[<on_ $($inner_package:snake _)? $name:snake _push>](player, push);
}, },
)* )*
unhandled => ::tracing::warn!("can't find handler for push with message_id={unhandled}") unhandled => ::tracing::warn!("can't find handler for push with message_id={unhandled}")