mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Add basic stats tracking #30
This commit is contained in:
1 parent
580ce69839
commit
df017883c1
10 files changed
+331
-11
No files matched your search
@@ -0,0 +1,31 @@
|
||||
pub struct AssistBonus {
|
||||
msg_router: tokio::sync::mpsc::Sender<crate::matches::GameMessage>,
|
||||
}
|
||||
|
||||
pub(super) fn handler(init_ctx: &crate::InitConfig) -> crate::handlers::SimpleRlnl<rlnl::events::ingame::AssistBonus, AssistBonus> {
|
||||
crate::handlers::SimpleRlnl::new(AssistBonus::new(init_ctx))
|
||||
}
|
||||
|
||||
impl AssistBonus {
|
||||
fn new(init_ctx: &crate::InitConfig) -> Self {
|
||||
Self {
|
||||
msg_router: init_ctx.matches_chann.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl crate::handlers::RlnlEventCodeHandler for AssistBonus {
|
||||
type In = rlnl::events::ingame::AssistBonus;
|
||||
const CODE: rlnl::event_code::NetworkEvent = rlnl::event_code::NetworkEvent::AssistBonusRequest;
|
||||
|
||||
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::AssistBonus {
|
||||
user_id: user_info.user_id(),
|
||||
shootee: data.requester_player_id as u8,
|
||||
shooters: data.player_ids.into_iter().map(|x| x.player).collect(),
|
||||
}).await);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
pub struct DamageBonus {
|
||||
msg_router: tokio::sync::mpsc::Sender<crate::matches::GameMessage>,
|
||||
}
|
||||
|
||||
pub(super) fn handler(init_ctx: &crate::InitConfig) -> crate::handlers::SimpleRlnl<rlnl::events::ingame::DestroyedHealedCubesBonus, DamageBonus> {
|
||||
crate::handlers::SimpleRlnl::new(DamageBonus::new(init_ctx))
|
||||
}
|
||||
|
||||
impl DamageBonus {
|
||||
fn new(init_ctx: &crate::InitConfig) -> Self {
|
||||
Self {
|
||||
msg_router: init_ctx.matches_chann.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl crate::handlers::RlnlEventCodeHandler for DamageBonus {
|
||||
type In = rlnl::events::ingame::DestroyedHealedCubesBonus;
|
||||
const CODE: rlnl::event_code::NetworkEvent = rlnl::event_code::NetworkEvent::DestroyCubesBonusRequest;
|
||||
|
||||
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::DestroyCubesBonus {
|
||||
user_id: user_info.user_id(),
|
||||
info: data,
|
||||
}).await);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
pub struct HealBonus {
|
||||
msg_router: tokio::sync::mpsc::Sender<crate::matches::GameMessage>,
|
||||
}
|
||||
|
||||
pub(super) fn handler(init_ctx: &crate::InitConfig) -> crate::handlers::SimpleRlnl<rlnl::events::ingame::DestroyedHealedCubesBonus, HealBonus> {
|
||||
crate::handlers::SimpleRlnl::new(HealBonus::new(init_ctx))
|
||||
}
|
||||
|
||||
impl HealBonus {
|
||||
fn new(init_ctx: &crate::InitConfig) -> Self {
|
||||
Self {
|
||||
msg_router: init_ctx.matches_chann.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl crate::handlers::RlnlEventCodeHandler for HealBonus {
|
||||
type In = rlnl::events::ingame::DestroyedHealedCubesBonus;
|
||||
const CODE: rlnl::event_code::NetworkEvent = rlnl::event_code::NetworkEvent::HealCubesBonusRequest;
|
||||
|
||||
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::DestroyCubesBonus {
|
||||
user_id: user_info.user_id(),
|
||||
info: data,
|
||||
}).await);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
pub struct KillEnemyBonus {
|
||||
msg_router: tokio::sync::mpsc::Sender<crate::matches::GameMessage>,
|
||||
}
|
||||
|
||||
pub(super) fn handler(init_ctx: &crate::InitConfig) -> crate::handlers::SimpleRlnl<rlnl::events::ingame::Kill, KillEnemyBonus> {
|
||||
crate::handlers::SimpleRlnl::new(KillEnemyBonus::new(init_ctx))
|
||||
}
|
||||
|
||||
impl KillEnemyBonus {
|
||||
fn new(init_ctx: &crate::InitConfig) -> Self {
|
||||
Self {
|
||||
msg_router: init_ctx.matches_chann.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl crate::handlers::RlnlEventCodeHandler for KillEnemyBonus {
|
||||
type In = rlnl::events::ingame::Kill;
|
||||
const CODE: rlnl::event_code::NetworkEvent = rlnl::event_code::NetworkEvent::KillBonusRequest;
|
||||
|
||||
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::KillBonus {
|
||||
user_id: user_info.user_id(),
|
||||
shootee: data.killee_player_id,
|
||||
shooter: data.killer_player_id,
|
||||
}).await);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,10 @@ mod client_unregister;
|
||||
mod flipper_start;
|
||||
mod self_destruct_elimination;
|
||||
mod map_ping;
|
||||
mod kill_bonus;
|
||||
mod assist_bonus;
|
||||
mod damage_bonus;
|
||||
mod heal_bonus;
|
||||
|
||||
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))
|
||||
@@ -79,10 +83,8 @@ pub async fn handler(init_ctx: &crate::InitConfig) -> crate::handler::LnlEventHa
|
||||
{literustlib::packet::Property::Unreliable as u8},
|
||||
rlnl::events::ingame::DestroyCubeEffectOnly,
|
||||
>::handler(init_ctx))
|
||||
.add(crate::handlers::Stub::<
|
||||
{rlnl::event_code::NetworkEvent::DestroyCubesBonusRequest as i16},
|
||||
rlnl::events::ingame::DestroyedHealedCubesBonus,
|
||||
>::handler(init_ctx))
|
||||
.add(damage_bonus::handler(init_ctx))
|
||||
.add(heal_bonus::handler(init_ctx))
|
||||
.add(crate::handlers::Broadcaster::<
|
||||
false,
|
||||
{rlnl::event_code::NetworkEvent::HealSelf as i16},
|
||||
@@ -90,10 +92,8 @@ pub async fn handler(init_ctx: &crate::InitConfig) -> crate::handler::LnlEventHa
|
||||
{literustlib::packet::Property::ReliableOrdered as u8},
|
||||
rlnl::events::HealedCubes,
|
||||
>::handler(init_ctx))
|
||||
.add(crate::handlers::Stub::<
|
||||
{rlnl::event_code::NetworkEvent::KillBonusRequest as i16},
|
||||
rlnl::events::ingame::Kill, // FIXME this is not a player ID -- it's actually sending 2 bytes not 1
|
||||
>::handler(init_ctx))
|
||||
.add(kill_bonus::handler(init_ctx))
|
||||
.add(assist_bonus::handler(init_ctx))
|
||||
.add(kill_player::handler(init_ctx))
|
||||
.add(crate::handlers::Broadcaster::<
|
||||
true,
|
||||
|
||||
Reference in new issue
Block a user