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 747f1fed13 - Show all commits

View file

@ -4,22 +4,22 @@ pub use scene::*;
use shorekeeper_protocol::message::Message; use shorekeeper_protocol::message::Message;
macro_rules! handle_request { macro_rules! handle_request {
($($name:ident;)*) => { ($($name:ident $(, $inner_package:ident)?;)*) => {
fn handle_request(player: &mut super::player::Player, mut msg: Message) { fn handle_request(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 Request>]::MESSAGE_ID => { ::shorekeeper_protocol::$($inner_package::)?[<$name Request>]::MESSAGE_ID => {
let Ok(request) = ::shorekeeper_protocol::[<$name Request>]::decode(&*msg.remove_payload()) else { let Ok(request) = ::shorekeeper_protocol::$($inner_package::)?[<$name Request>]::decode(&*msg.remove_payload()) else {
tracing::debug!("failed to decode {}, player_id: {}", stringify!([<$name Request>]), player.basic_info.id); tracing::debug!("failed to decode {}, player_id: {}", stringify!($($inner_package::)?[<$name Request>]), player.basic_info.id);
return; return;
}; };
tracing::debug!("logic: processing request {}", stringify!([<$name Request>])); tracing::debug!("logic: processing request {}", stringify!($($inner_package::)?[<$name Request>]));
let mut response = ::shorekeeper_protocol::[<$name Response>]::default(); let mut response = ::shorekeeper_protocol::$($inner_package::)?[<$name Response>]::default();
[<on_ $name:snake _request>](player, request, &mut response); [<on_ $name:snake _request>](player, request, &mut response);
player.respond(response, msg.get_rpc_id()); player.respond(response, msg.get_rpc_id());