mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Add support for matchmaker sending clients off to game server
This commit is contained in:
@@ -72,3 +72,32 @@ pub enum SingleplayerErrorCode {
|
||||
MaintenanceMode = 4,
|
||||
DuplicateLogin = 5,
|
||||
}
|
||||
|
||||
#[repr(i16)]
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
pub enum LobbyReasonCode {
|
||||
UnexpectedError = -1,
|
||||
Ok = 0,
|
||||
MaintenanceMode = 1,
|
||||
RobotValidationError = 2,
|
||||
LoggedInOtherLocation = 3,
|
||||
GroupFailedChecks = 4,
|
||||
ConnectionTestFailed = 5,
|
||||
WrongGameModeForParty = 6,
|
||||
BrawlConnectionTestFailed = 7,
|
||||
PartyNotAllowed = 8,
|
||||
NoSuitableLobbyFound = 9,
|
||||
EventSystemExpired = 10
|
||||
}
|
||||
|
||||
impl LobbyReasonCode {
|
||||
pub(crate) fn from_service_error(err: i16) -> Self {
|
||||
match err {
|
||||
0 /* None */ => Self::Ok,
|
||||
125 => Self::MaintenanceMode,
|
||||
140 => Self::RobotValidationError,
|
||||
_ => Self::UnexpectedError,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ impl GameMap {
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Hash, Eq, PartialEq)]
|
||||
pub enum GameMode {
|
||||
BattleArena = 0,
|
||||
SuddenDeath = 1,
|
||||
@@ -121,7 +121,7 @@ impl GameMode {
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Hash, Eq, PartialEq)]
|
||||
pub enum MapVisibility {
|
||||
Good = 0,
|
||||
Poor = 1,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use polariton::operation::Typed;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct PlayerData {
|
||||
pub name: String,
|
||||
pub display_name: String,
|
||||
@@ -12,6 +13,7 @@ pub struct PlayerData {
|
||||
pub has_premium: bool,
|
||||
pub robot_uuid: String,
|
||||
pub cpu: i32,
|
||||
pub avatar_id: Option<i32>,
|
||||
pub weapon_order: Vec<i32>,
|
||||
pub colour_map: Vec<u8>,
|
||||
pub is_ai: bool,
|
||||
@@ -52,6 +54,41 @@ impl PlayerData {
|
||||
}
|
||||
Ok(42 + self.robot_map.len() + (self.weapon_order.len() * 4) + self.colour_map.len() + (self.weapon_rank.len() * 8) + total_len)
|
||||
}
|
||||
|
||||
pub fn as_transmissible<C>(&self) -> Typed<C> {
|
||||
let weapon_ranks = Typed::Dict(polariton::operation::Dict {
|
||||
key_ty: polariton::serdes::TypePrefix::Int,
|
||||
val_ty: polariton::serdes::TypePrefix::Int,
|
||||
items: self.weapon_rank.clone().into_iter().map(|(k, v)| (Typed::Int(k), Typed::Int(v))).collect(),
|
||||
});
|
||||
Typed::HashMap(vec![
|
||||
(Typed::Str("name".into()), Typed::Str(self.name.clone().into())),
|
||||
(Typed::Str("displayName".into()), Typed::Str(self.display_name.clone().into())),
|
||||
(Typed::Str("robotName".into()), Typed::Str(self.robot_name.clone().into())),
|
||||
(Typed::Str("cubeMap".into()), Typed::Bytes(self.robot_map.clone().into())),
|
||||
(Typed::Str("colourMap".into()), Typed::Bytes(self.colour_map.clone().into())),
|
||||
(Typed::Str("spawnEffect".into()), Typed::Str(self.spawn_effect.clone().into())),
|
||||
(Typed::Str("deathEffect".into()), Typed::Str(self.death_effect.clone().into())),
|
||||
//(Typed::Str("groupId".into()), Typed::Int(self.group)), // FIXME
|
||||
(Typed::Str("groupId".into()), Typed::Int(self.team)), // not strongly enforced in EnterBattleEventListener
|
||||
(Typed::Str("team".into()), Typed::Int(self.team)), // not strongly enforced in EnterBattleEventListener (but has to be parsable into an i32)
|
||||
(Typed::Str("hasPremium".into()), Typed::Bool(self.has_premium)),
|
||||
(Typed::Str("weaponOrder".into()), Typed::IntArr(self.weapon_order.clone().into())),
|
||||
(Typed::Str("robotUniqueID".into()), Typed::Str(self.robot_uuid.clone().into())),
|
||||
(Typed::Str("cpu".into()), Typed::Int(self.cpu)), // not strongly enforced in EnterBattleEventListener
|
||||
(Typed::Str("useCustomAvatar".into()), Typed::Bool(self.avatar_id.is_none())),
|
||||
(Typed::Str("avatarId".into()), Typed::Int(self.avatar_id.unwrap_or(0))),
|
||||
(Typed::Str("masteryLevel".into()), Typed::Int(self.mastery)),
|
||||
(Typed::Str("tier".into()), Typed::Int(self.tier)),
|
||||
(Typed::Str("playerRank".into()), Typed::Int(self.player_rank)),
|
||||
(Typed::Str("weaponRanks".into()), weapon_ranks),
|
||||
(Typed::Str("isAI".into()), Typed::Bool(self.is_ai)),
|
||||
// only required if clanName exists
|
||||
/*(Typed::Str("clanName".into()), Typed::Str(todo!())),
|
||||
(Typed::Str("clanUseCustomAvatar".into()), Typed::Bool(todo!())),
|
||||
(Typed::Str("clanDefaultAvatarID".into()), Typed::Int(todo!())),*/
|
||||
].into())
|
||||
}
|
||||
}
|
||||
|
||||
pub struct PlayerDatas {
|
||||
|
||||
Reference in New Issue
Block a user