mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Add map ping support #30
This commit is contained in:
30
rc_multiplayer/src/events/map_ping.rs
Normal file
30
rc_multiplayer/src/events/map_ping.rs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
pub struct PingMap {
|
||||||
|
msg_router: tokio::sync::mpsc::Sender<crate::matches::GameMessage>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn handler(init_ctx: &crate::InitConfig) -> crate::handlers::SimpleRlnl<rlnl::events::ingame::MapPing, PingMap> {
|
||||||
|
crate::handlers::SimpleRlnl::new(PingMap::new(init_ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PingMap {
|
||||||
|
fn new(init_ctx: &crate::InitConfig) -> Self {
|
||||||
|
Self {
|
||||||
|
msg_router: init_ctx.matches_chann.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl crate::handlers::RlnlEventCodeHandler for PingMap {
|
||||||
|
type In = rlnl::events::ingame::MapPing;
|
||||||
|
const CODE: rlnl::event_code::NetworkEvent = rlnl::event_code::NetworkEvent::MapPingEvent;
|
||||||
|
|
||||||
|
async fn handle(&self, data: Self::In, _peer: &std::sync::Arc<literustlib_server::Connection<crate::PacketData>>, user: &crate::UserData, _sender: &std::sync::Arc<literustlib_server::DataSender<crate::PacketData>>) {
|
||||||
|
if let Some(user_info) = user.user().await {
|
||||||
|
super::log_channel_send_failure(self.msg_router.send(crate::matches::GameMessage::MapPing {
|
||||||
|
user_id: user_info.user_id(),
|
||||||
|
ping: data,
|
||||||
|
}).await);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ mod kill_player;
|
|||||||
mod client_unregister;
|
mod client_unregister;
|
||||||
mod flipper_start;
|
mod flipper_start;
|
||||||
mod self_destruct_elimination;
|
mod self_destruct_elimination;
|
||||||
|
mod map_ping;
|
||||||
|
|
||||||
pub async fn handler(init_ctx: &crate::InitConfig) -> crate::handler::LnlEventHandler {
|
pub async fn handler(init_ctx: &crate::InitConfig) -> crate::handler::LnlEventHandler {
|
||||||
crate::handler::LnlEventHandler::new(init_ctx.users.clone(), crate::vehicle_motion::handler(init_ctx))
|
crate::handler::LnlEventHandler::new(init_ctx.users.clone(), crate::vehicle_motion::handler(init_ctx))
|
||||||
@@ -173,6 +174,7 @@ pub async fn handler(init_ctx: &crate::InitConfig) -> crate::handler::LnlEventHa
|
|||||||
rlnl::events::ingame::UpdateVotingAfterBattle,
|
rlnl::events::ingame::UpdateVotingAfterBattle,
|
||||||
>::handler(init_ctx))
|
>::handler(init_ctx))
|
||||||
.add(self_destruct_elimination::handler(init_ctx))
|
.add(self_destruct_elimination::handler(init_ctx))
|
||||||
|
.add(map_ping::handler(init_ctx))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@@ -208,6 +210,7 @@ mod _broadcast_impls {
|
|||||||
impl Broadcastable for rlnl::events::ingame::CosmeticAction {}
|
impl Broadcastable for rlnl::events::ingame::CosmeticAction {}
|
||||||
impl Broadcastable for rlnl::events::ingame::UpdateVotingAfterBattle {}
|
impl Broadcastable for rlnl::events::ingame::UpdateVotingAfterBattle {}
|
||||||
impl Broadcastable for rlnl::events::ingame::TeleportActivateEffect {}
|
impl Broadcastable for rlnl::events::ingame::TeleportActivateEffect {}
|
||||||
|
impl Broadcastable for rlnl::events::ingame::MapPing {}
|
||||||
|
|
||||||
impl Broadcastable for rlnl::events::sync::UpdateGameModeSettings {}
|
impl Broadcastable for rlnl::events::sync::UpdateGameModeSettings {}
|
||||||
impl Broadcastable for rlnl::events::GameTime {}
|
impl Broadcastable for rlnl::events::GameTime {}
|
||||||
|
|||||||
@@ -535,6 +535,18 @@ impl <L: super::CustomGameLogic> GenericGamemodeEngine<L> {
|
|||||||
).await;
|
).await;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
super::GameMessage::MapPing { user_id: _, ping } => {
|
||||||
|
for (id, conn) in self.users.read().await.iter() {
|
||||||
|
if (*id as i32) != ping.sender && (conn.descriptor.team as i32) == ping.team_id {
|
||||||
|
crate::events::log_lnl_send_failure(conn.connection.rlnl().send_data(
|
||||||
|
&ping,
|
||||||
|
rlnl::event_code::NetworkEvent::PlayerQuitRequestComplete,
|
||||||
|
literustlib::packet::Property::ReliableOrdered,
|
||||||
|
&conn.connection.connection
|
||||||
|
).await);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
super::GameMessage::BroadcastRlnl { user_id, event, event_in, property, data } => {
|
super::GameMessage::BroadcastRlnl { user_id, event, event_in, property, data } => {
|
||||||
if self.custom_logic_handler.on_broadcast(&self, user_id, event, event_in, property, &data, false).await {
|
if self.custom_logic_handler.on_broadcast(&self, user_id, event, event_in, property, &data, false).await {
|
||||||
if let Some(data) = data {
|
if let Some(data) = data {
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ pub enum GameMessage {
|
|||||||
FlippingStarted { // flip yeah!
|
FlippingStarted { // flip yeah!
|
||||||
user_id: i32,
|
user_id: i32,
|
||||||
},
|
},
|
||||||
|
MapPing {
|
||||||
|
user_id: i32,
|
||||||
|
ping: rlnl::events::ingame::MapPing,
|
||||||
|
},
|
||||||
BroadcastRlnl {
|
BroadcastRlnl {
|
||||||
user_id: i32,
|
user_id: i32,
|
||||||
event: rlnl::event_code::NetworkEvent,
|
event: rlnl::event_code::NetworkEvent,
|
||||||
@@ -82,6 +86,7 @@ impl GameMessage {
|
|||||||
Self::DestroyVehicle { user_id, .. } => *user_id,
|
Self::DestroyVehicle { user_id, .. } => *user_id,
|
||||||
Self::SelfDestruct { user_id, .. } => *user_id,
|
Self::SelfDestruct { user_id, .. } => *user_id,
|
||||||
Self::FlippingStarted { user_id, .. } => *user_id,
|
Self::FlippingStarted { user_id, .. } => *user_id,
|
||||||
|
Self::MapPing { user_id, .. } => *user_id,
|
||||||
Self::BroadcastRlnl { user_id, .. } => *user_id,
|
Self::BroadcastRlnl { user_id, .. } => *user_id,
|
||||||
Self::RebroadcastRlnl { skip_user_id, .. } => *skip_user_id,
|
Self::RebroadcastRlnl { skip_user_id, .. } => *skip_user_id,
|
||||||
Self::Motion { user_id, .. } => *user_id,
|
Self::Motion { user_id, .. } => *user_id,
|
||||||
|
|||||||
Reference in New Issue
Block a user