Platoons social functionality (#91)

### Description

This implements and completes #87 (to the best of my knowledge)

### Game

Robocraft

### Please confirm

- [x] I am the legal owner or represent the owner of all work submitted
- [x] I consent to my submission being added to this FOSS project
- [ ] This PR used LLMs to generate some or all of the code changes

Reviewed-on: https://git.ngram.ca/OpenJam/rc-servers/pulls/91
Co-authored-by: NG (Graham) <ngniusness@gmail.com>
Co-committed-by: NG (Graham) <ngniusness@gmail.com>
This commit is contained in:
NG (Graham) authored and NGnius committed 2026-02-19 01:57:03 +00:00
1 parent a82488ab3a
commit 50b396f34a
49 files changed
+1152 -47

No files matched your search

+8
View File
@@ -4,3 +4,11 @@ pub mod friend_invite_declined;
pub mod friend_invite_cancelled;
pub mod friend_removed;
pub mod friend_status;
pub mod platoon_invite_received;
pub mod platoon_member_added;
pub mod platoon_member_left;
pub mod platoon_member_update;
pub mod platoon_removed;
pub mod platoon_leader_changed;
pub mod platoon_member_kick;
pub mod platoon_member_avatar_update;
@@ -0,0 +1,32 @@
#[derive(Clone)]
pub struct PlatoonInviteReceived {
pub inviter_public_id: String,
pub inviter_display_name: String,
pub avatar_id: Option<i32>, // None when using custom avatar
}
impl PlatoonInviteReceived {
pub const CODE: u8 = 10;
pub fn as_event_params<C>(&self) -> polariton::operation::ParameterTable<C> {
let mut params = std::collections::HashMap::with_capacity(4);
params.insert(19, polariton::operation::Typed::Str(self.inviter_public_id.clone().into()));
params.insert(75, polariton::operation::Typed::Str(self.inviter_display_name.clone().into()));
params.insert(13, polariton::operation::Typed::Bool(self.avatar_id.is_none()));
params.insert(14, polariton::operation::Typed::Int(self.avatar_id.unwrap_or_default()));
params.into()
}
}
impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for PlatoonInviteReceived {
const CHANNEL: u8 = 0;
const ENCRYPT: bool = true;
const RELIABLE: bool = true;
fn into_event(self) -> polariton::operation::Event<C> {
polariton::operation::Event {
code: Self::CODE,
params: self.as_event_params(),
}
}
}
@@ -0,0 +1,29 @@
#[derive(Clone)]
pub struct PlatoonLeaderChanged {
pub leader_public_id: String,
pub leader_display_name: String,
}
impl PlatoonLeaderChanged {
pub const CODE: u8 = 16;
pub fn as_event_params<C>(&self) -> polariton::operation::ParameterTable<C> {
let mut params = std::collections::HashMap::with_capacity(4);
params.insert(17, polariton::operation::Typed::Str(self.leader_public_id.clone().into()));
params.insert(75, polariton::operation::Typed::Str(self.leader_display_name.clone().into()));
params.into()
}
}
impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for PlatoonLeaderChanged {
const CHANNEL: u8 = 0;
const ENCRYPT: bool = true;
const RELIABLE: bool = true;
fn into_event(self) -> polariton::operation::Event<C> {
polariton::operation::Event {
code: Self::CODE,
params: self.as_event_params(),
}
}
}
@@ -0,0 +1,27 @@
#[derive(Clone)]
pub struct PlatoonNewMember {
pub new_member: crate::data::platoon::PlatoonMemberInfo,
}
impl PlatoonNewMember {
pub const CODE: u8 = 17;
pub fn as_event_params(&self) -> polariton::operation::ParameterTable<crate::data::custom::CustomType> {
let mut params = std::collections::HashMap::with_capacity(1);
params.insert(15, polariton::operation::Typed::Custom(crate::data::custom::CustomType::PlatoonMember(self.new_member.clone())));
params.into()
}
}
impl polariton_server::events::IntoEvent<crate::data::custom::CustomType> for PlatoonNewMember {
const CHANNEL: u8 = 0;
const ENCRYPT: bool = true;
const RELIABLE: bool = true;
fn into_event(self) -> polariton::operation::Event<crate::data::custom::CustomType> {
polariton::operation::Event {
code: Self::CODE,
params: self.as_event_params(),
}
}
}
@@ -0,0 +1,30 @@
#[derive(Clone)]
pub struct PlatoonMemberAvatarChanged {
pub member_public_id: String,
pub avatar_id: Option<i32>,
}
impl PlatoonMemberAvatarChanged {
pub const CODE: u8 = 14;
pub fn as_event_params<C>(&self) -> polariton::operation::ParameterTable<C> {
let mut params = std::collections::HashMap::with_capacity(2);
params.insert(1, polariton::operation::Typed::Str(self.member_public_id.clone().into()));
params.insert(13, polariton::operation::Typed::Bool(self.avatar_id.is_none()));
params.insert(14, polariton::operation::Typed::Int(self.avatar_id.unwrap_or_default()));
params.into()
}
}
impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for PlatoonMemberAvatarChanged {
const CHANNEL: u8 = 0;
const ENCRYPT: bool = true;
const RELIABLE: bool = true;
fn into_event(self) -> polariton::operation::Event<C> {
polariton::operation::Event {
code: Self::CODE,
params: self.as_event_params(),
}
}
}
@@ -0,0 +1,23 @@
#[derive(Clone)]
pub struct PlatoonMemberKick;
impl PlatoonMemberKick {
pub const CODE: u8 = 12;
pub fn as_event_params<C>(&self) -> polariton::operation::ParameterTable<C> {
polariton::operation::ParameterTable::<C>::with_capacity(0)
}
}
impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for PlatoonMemberKick {
const CHANNEL: u8 = 0;
const ENCRYPT: bool = true;
const RELIABLE: bool = true;
fn into_event(self) -> polariton::operation::Event<C> {
polariton::operation::Event {
code: Self::CODE,
params: self.as_event_params(),
}
}
}
@@ -0,0 +1,29 @@
#[derive(Clone)]
pub struct PlatoonMemberLeft {
pub member_public_id: String,
pub member_display_name: String,
}
impl PlatoonMemberLeft {
pub const CODE: u8 = 11;
pub fn as_event_params<C>(&self) -> polariton::operation::ParameterTable<C> {
let mut params = std::collections::HashMap::with_capacity(2);
params.insert(1, polariton::operation::Typed::Str(self.member_public_id.clone().into()));
params.insert(75, polariton::operation::Typed::Str(self.member_display_name.clone().into()));
params.into()
}
}
impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for PlatoonMemberLeft {
const CHANNEL: u8 = 0;
const ENCRYPT: bool = true;
const RELIABLE: bool = true;
fn into_event(self) -> polariton::operation::Event<C> {
polariton::operation::Event {
code: Self::CODE,
params: self.as_event_params(),
}
}
}
@@ -0,0 +1,31 @@
#[derive(Clone)]
pub struct PlatoonMemberStatusUpdate {
pub member_public_id: String,
pub member_display_name: String,
pub member_status: crate::data::platoon::MemberStatus,
}
impl PlatoonMemberStatusUpdate {
pub const CODE: u8 = 18;
pub fn as_event_params<C>(&self) -> polariton::operation::ParameterTable<C> {
let mut params = std::collections::HashMap::with_capacity(2);
params.insert(1, polariton::operation::Typed::Str(self.member_public_id.clone().into()));
params.insert(75, polariton::operation::Typed::Str(self.member_display_name.clone().into()));
params.insert(3, polariton::operation::Typed::Int(self.member_status.as_u8() as i32));
params.into()
}
}
impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for PlatoonMemberStatusUpdate {
const CHANNEL: u8 = 0;
const ENCRYPT: bool = true;
const RELIABLE: bool = true;
fn into_event(self) -> polariton::operation::Event<C> {
polariton::operation::Event {
code: Self::CODE,
params: self.as_event_params(),
}
}
}
@@ -0,0 +1,27 @@
#[derive(Clone)]
pub struct PlatoonDisbanded {
pub platoon_id: String,
}
impl PlatoonDisbanded {
pub const CODE: u8 = 13;
pub fn as_event_params(&self) -> polariton::operation::ParameterTable<crate::data::custom::CustomType> {
let mut params = std::collections::HashMap::with_capacity(1);
params.insert(16, polariton::operation::Typed::Str(self.platoon_id.clone().into()));
params.into()
}
}
impl polariton_server::events::IntoEvent<crate::data::custom::CustomType> for PlatoonDisbanded {
const CHANNEL: u8 = 0;
const ENCRYPT: bool = true;
const RELIABLE: bool = true;
fn into_event(self) -> polariton::operation::Event<crate::data::custom::CustomType> {
polariton::operation::Event {
code: Self::CODE,
params: self.as_event_params(),
}
}
}