mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Implement most of the occasional packets sent in elimination, expand interface for custom game logic #30
This commit is contained in:
1 parent
dfde0247a4
commit
52493bf166
22 files changed
+482
-41
No files matched your search
@@ -1,3 +1,5 @@
|
||||
use byteserde::prelude::ByteDeserializeSlice;
|
||||
|
||||
pub struct VehicleMotionHandler {
|
||||
msg_router: tokio::sync::mpsc::Sender<crate::matches::GameMessage>,
|
||||
}
|
||||
@@ -18,10 +20,19 @@ impl VehicleMotionHandler {
|
||||
impl crate::RobotMotionHandler for VehicleMotionHandler {
|
||||
async fn handle(&self, data: &bytes::Bytes, user: &crate::UserData) {
|
||||
if let Some(user_info) = user.user().await {
|
||||
crate::events::log_channel_send_failure(self.msg_router.send(crate::matches::GameMessage::Motion {
|
||||
user_id: user_info.user_id(),
|
||||
data: data.to_owned(),
|
||||
}).await);
|
||||
let mut des = byteserde::des_slice::ByteDeserializerSlice::new(&data);
|
||||
match rlnl::machine_motion::MachineMotion::byte_deserialize(&mut des) {
|
||||
Ok(motion_data) => {
|
||||
crate::events::log_channel_send_failure(self.msg_router.send(crate::matches::GameMessage::Motion {
|
||||
user_id: user_info.user_id(),
|
||||
motion: motion_data,
|
||||
}).await);
|
||||
},
|
||||
Err(e) => {
|
||||
log::error!("Bad deserialization for machine motion, bytes {:?}: {}", &data[..], e);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
log::error!("Failed to handle motion unknown user");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user