1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use enums::{FlagCode, GameType, PlaneType, PlayerStatus};
use types::{Level, Player, Position, Rotation, Team, Upgrades};

/// Initial data passed in for a
/// player when the server starts.
///
/// This is an element of the `players`
/// array within the [`Login`] packet.
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct LoginPlayer {
	pub id: Player,
	pub status: PlayerStatus,
	pub level: Level,
	pub name: String,
	#[cfg_attr(feature = "serde", serde(rename = "type"))]
	pub ty: PlaneType,
	pub team: Team,
	pub pos: Position,
	pub rot: Rotation,
	pub flag: FlagCode,
	pub upgrades: Upgrades,
}

/// Initial Login packet sent to the server
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Login {
	pub success: bool,
	pub id: Player,
	pub team: Team,
	pub clock: u32,
	pub token: String,
	#[cfg_attr(feature = "serde", serde(rename = "type"))]
	pub ty: GameType,
	pub room: String,
	pub players: Vec<LoginPlayer>,
}