1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Update to work with polariton v0.2

This commit is contained in:
NGnius (Graham)
2025-03-08 17:16:02 -05:00
parent f004ca8565
commit be37f8913a
83 changed files with 428 additions and 1202 deletions

View File

@@ -13,7 +13,7 @@ pub struct ClanMember {
}
impl ClanMember {
pub fn as_transmissible(&self) -> Typed {
pub fn as_transmissible<C>(&self) -> Typed<C> {
Typed::HashMap(vec![
(Typed::Str("userName".into()), Typed::Str(self.username.clone().into())),
(Typed::Str("displayName".into()), Typed::Str(self.display_name.clone().into())),
@@ -59,7 +59,7 @@ pub struct ClanInfo {
}
impl ClanInfo {
pub fn as_transmissible(&self) -> Typed {
pub fn as_transmissible<C>(&self) -> Typed<C> {
Typed::HashMap(vec![
(Typed::Str("clanName".into()), Typed::Str(self.clan_name.clone().into())),
(Typed::Str("clanDescription".into()), Typed::Str(self.clan_description.clone().into())),

View File

@@ -10,7 +10,7 @@ pub struct ClanInviteInfo {
}
impl ClanInviteInfo {
pub fn as_transmissible(&self) -> Typed {
pub fn as_transmissible<C>(&self) -> Typed<C> {
Typed::HashMap(vec![
(Typed::Str("userName".into()), Typed::Str(self.username.clone().into())),
(Typed::Str("displayName".into()), Typed::Str(self.display_name.clone().into())),

View File

@@ -0,0 +1,21 @@
#[derive(Debug, Clone)]
pub enum CustomType {
FriendInfo, // TODO actually serialise
}
pub struct CustomTypeSerdes;
impl polariton::serdes::CustomSerdes<CustomType> for CustomTypeSerdes {
fn dump(_c: &CustomType, w: &mut dyn std::io::Write) -> std::io::Result<usize> {
let payload = vec![ // FIXME don't manually serialize
0u8, // byte custom type
0u8, 5u8, // short custom object size
3u8, 0u8, 0u8, 0u8, 0u8, // content
];
w.write(&payload)
}
fn parse(_r: &mut dyn std::io::Read) -> std::io::Result<CustomType> {
Ok(CustomType::FriendInfo)
}
}

View File

@@ -7,7 +7,7 @@ pub struct AvatarInfo {
}
impl AvatarInfo {
pub fn as_transmissible(&self) -> Typed {
pub fn as_transmissible<C>(&self) -> Typed<C> {
Typed::HashMap(vec![
(Typed::Str("name".into()), Typed::Str(self.name.clone().into())),
(Typed::Str("useCustomAvatar".into()), Typed::Bool(self.use_custom_avatar.into())),

View File

@@ -1,3 +1,4 @@
pub mod friend;
pub mod clan_invite;
pub mod clan;
pub mod custom;