Get part way through loading (to sync) #30

This commit is contained in:
NG (Graham) committed 2025-07-06 17:36:52 -04:00
1 parent 38ab4ba799
commit 1d404db209
31 files changed
+1049 -100

No files matched your search

+65
View File
@@ -0,0 +1,65 @@
pub enum GameMessage {
NewConnection {
user: std::sync::Arc<Box<dyn oj_rc_core::persist::user::MultiplayerUser + Send + Sync + 'static>>,
game_guid: String,
connection: std::sync::Arc<literustlib_server::Connection<crate::PacketData>>,
response: tokio::sync::oneshot::Sender<Option<ErrorMessage>>,
sender: std::sync::Arc<literustlib_server::DataSender<crate::PacketData>>,
},
LoadingProgress {
user_id: i32,
user_name: String,
progress: f32,
},
RequestLoadingProgress {
user_id: i32,
},
WeaponSelect {
user_id: i32,
machine_id: u8,
category: oj_rc_core::data::weapon_list::ItemCategory,
size: oj_rc_core::data::cube_list::ItemTier,
},
RequestLoadingSync {
user_id: i32,
},
Motion {
user_id: i32,
data: bytes::Bytes,
},
NoOp,
}
impl GameMessage {
pub fn user_id(&self) -> i32 {
match self {
Self::NewConnection { user, .. } => {
user.user_id()
}
Self::LoadingProgress { user_id, .. } => *user_id,
Self::RequestLoadingProgress { user_id, .. } => *user_id,
Self::WeaponSelect { user_id, .. } => *user_id,
Self::RequestLoadingSync { user_id, .. } => *user_id,
Self::Motion { user_id, .. } => *user_id,
Self::NoOp => unreachable!("NoOp is irrelevant for user ID"),
}
}
}
#[derive(Debug)]
pub struct ErrorMessage {
pub message: String,
pub inner: Option<Box<dyn std::error::Error + Send>>,
}
impl std::error::Error for ErrorMessage {}
impl core::fmt::Display for ErrorMessage {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
if let Some(inner) = &self.inner {
write!(f, "game communication error: {}; {}", self.message, inner)
} else {
write!(f, "game communication error: {}", self.message)
}
}
}