mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Complete bare minimum to seem logged in
This commit is contained in:
68
rc_chat_room/src/data/channel.rs
Normal file
68
rc_chat_room/src/data/channel.rs
Normal file
@@ -0,0 +1,68 @@
|
||||
use polariton::operation::{Typed, Arr};
|
||||
|
||||
pub struct ChatChannelInfo {
|
||||
pub channel_name: String,
|
||||
pub members: Vec<ChatChannelMember>,
|
||||
pub channel_ty: ChatChannelType,
|
||||
}
|
||||
|
||||
impl ChatChannelInfo {
|
||||
pub fn as_transmissible(&self) -> Typed {
|
||||
Typed::HashMap(vec![
|
||||
(Typed::Str("channelName".into()), Typed::Str(self.channel_name.clone().into())),
|
||||
(Typed::Str("members".into()), Typed::Arr(Arr {
|
||||
ty: 104, // hashtable
|
||||
items: self.members.iter().map(|x| x.as_transmissible()).collect(),
|
||||
})),
|
||||
(Typed::Str("channelType".into()), Typed::Int(self.channel_ty as _)),
|
||||
].into())
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ChatChannelMember {
|
||||
pub name: String,
|
||||
pub use_custom_avatar: bool,
|
||||
pub state: ChatPlayerState,
|
||||
pub custom_avatar: Vec<u8>, // always PNG?
|
||||
pub avatar_id: i32,
|
||||
}
|
||||
|
||||
impl ChatChannelMember {
|
||||
pub fn as_transmissible(&self) -> Typed {
|
||||
Typed::HashMap(vec![
|
||||
(Typed::Str("name".into()), Typed::Str(self.name.clone().into())),
|
||||
(Typed::Str("useCustomAvatar".into()), Typed::Bool(self.use_custom_avatar.into())),
|
||||
(Typed::Str("state".into()), Typed::Int(self.state as _)),
|
||||
if self.use_custom_avatar {
|
||||
(Typed::Str("customAvatar".into()), Typed::Bytes(self.custom_avatar.clone().into()))
|
||||
} else {
|
||||
(Typed::Str("avatarId".into()), Typed::Int(self.avatar_id))
|
||||
},
|
||||
].into())
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[repr(u8)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum ChatChannelType {
|
||||
None = 0,
|
||||
Public = 1,
|
||||
Battle = 2,
|
||||
BattleTeam = 3,
|
||||
Platoon = 4,
|
||||
Custom = 5,
|
||||
Clan = 6,
|
||||
Private = 7,
|
||||
CustomGame = 8,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[repr(u8)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum ChatPlayerState {
|
||||
Idk0 = 0,
|
||||
Idk1 = 1,
|
||||
Idk2 = 2,
|
||||
// FIXME
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
pub mod channel;
|
||||
|
||||
58
rc_chat_room/src/operations/all_joined_channels.rs
Normal file
58
rc_chat_room/src/operations/all_joined_channels.rs
Normal file
@@ -0,0 +1,58 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Arr};
|
||||
|
||||
use crate::data::channel::*;
|
||||
|
||||
const PARAM_KEY: u8 = 18;
|
||||
|
||||
pub(super) fn all_channels_provider() -> SimpleFunc<11, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Arr(Arr {
|
||||
ty: 104, // hashtable
|
||||
items: vec![
|
||||
ChatChannelInfo {
|
||||
channel_name: "RE_public_channel0".to_owned(),
|
||||
members: vec![
|
||||
ChatChannelMember {
|
||||
name: "RE_chat0_username0".to_owned(),
|
||||
use_custom_avatar: false,
|
||||
state: ChatPlayerState::Idk1,
|
||||
custom_avatar: Vec::default(),
|
||||
avatar_id: 2,
|
||||
},
|
||||
ChatChannelMember {
|
||||
name: "RE_chat0_username1".to_owned(),
|
||||
use_custom_avatar: false,
|
||||
state: ChatPlayerState::Idk2,
|
||||
custom_avatar: Vec::default(),
|
||||
avatar_id: 3,
|
||||
},
|
||||
],
|
||||
channel_ty: ChatChannelType::Public,
|
||||
}.as_transmissible(),
|
||||
ChatChannelInfo {
|
||||
channel_name: "RE_custom_channel1".to_owned(),
|
||||
members: vec![
|
||||
ChatChannelMember {
|
||||
name: "RE_chat1_username0".to_owned(),
|
||||
use_custom_avatar: false,
|
||||
state: ChatPlayerState::Idk0,
|
||||
custom_avatar: Vec::default(),
|
||||
avatar_id: 2,
|
||||
},
|
||||
ChatChannelMember {
|
||||
name: "RE_chat1_username1".to_owned(),
|
||||
use_custom_avatar: false,
|
||||
state: ChatPlayerState::Idk1,
|
||||
custom_avatar: Vec::default(),
|
||||
avatar_id: 3,
|
||||
},
|
||||
],
|
||||
channel_ty: ChatChannelType::Custom,
|
||||
}.as_transmissible(),
|
||||
],
|
||||
}));
|
||||
Ok(params.into())
|
||||
})
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
mod more_auth;
|
||||
mod chat_ignores;
|
||||
mod pending_sanctions;
|
||||
mod all_joined_channels;
|
||||
|
||||
use polariton_server::operations::OperationsHandler;
|
||||
|
||||
@@ -9,5 +10,6 @@ pub fn handler() -> OperationsHandler<crate::UserTy> {
|
||||
.without_state(more_auth::MoreLobbyAuth)
|
||||
.without_state(chat_ignores::ignores_provider())
|
||||
.without_state(pending_sanctions::pending_sanctions_checker())
|
||||
.without_state(all_joined_channels::all_channels_provider())
|
||||
//.without_state(polariton_server::operations::Ack::<00000, _>::default())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user