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
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
use crate::Stream;
/// Messages that consists only of primitives and string and can be derived
use bitbuffer::{BitRead, LittleEndian};

#[derive(BitRead, Debug)]
pub struct FileMessage {
    pub transfer_id: u32,
    pub file_name: String,
    pub requested: bool,
}

#[derive(BitRead, Debug)]
pub struct NetTickMessage {
    pub tick: u32,
    pub frame_time: u16,
    pub std_dev: u16,
}

#[derive(BitRead, Debug)]
pub struct StringCmdMessage {
    pub command: String,
}

#[derive(BitRead, Debug)]
pub struct SigOnStateMessage {
    pub state: u8,
    pub count: u32,
}

#[derive(BitRead, Debug)]
pub struct PrintMessage {
    pub value: String,
}

#[derive(BitRead, Debug)]
pub struct ServerInfoMessage {
    pub version: u16,
    pub server_count: u32,
    pub stv: bool,
    pub dedicated: bool,
    pub max_crc: u32,
    pub max_classes: u16,
    pub map_hash: u128,
    pub player_count: u8,
    pub max_player_count: u8,
    pub interval_per_tick: f32,
    #[size = 1]
    pub platform: String,
    pub game: String,
    pub map: String,
    pub skybox: String,
    pub server_name: String,
    pub replay: bool,
}

#[derive(BitRead, Debug)]
pub struct SetPauseMessage {
    pub pause: bool,
}

#[derive(BitRead, Debug)]
pub struct SetViewMessage {
    #[size = 11]
    pub index: u16,
}

#[derive(BitRead, Debug)]
pub struct FixAngleMessage {
    pub relative: bool,
    pub x: u16,
    pub y: u16,
    pub z: u16,
}

#[derive(BitRead, Debug)]
#[endianness = "LittleEndian"]
pub struct EntityMessage {
    #[size = 11]
    pub index: u16,
    #[size = 9]
    pub class_id: u16,
    #[size = 11]
    pub length: u16,
    #[size = "length"]
    pub data: Stream,
}

#[derive(BitRead, Debug)]
pub struct PreFetchMessage {
    #[size = 14]
    pub index: u16,
}

#[derive(BitRead, Debug)]
#[endianness = "LittleEndian"]
pub struct MenuMessage {
    pub kind: u16,
    pub length: u16,
    #[size = "length.saturating_mul(8)"]
    pub index: Stream,
}

#[derive(BitRead, Debug)]
pub struct GetCvarValueMessage {
    pub cookie: u32,
    pub value: String,
}

#[derive(BitRead, Debug)]
#[endianness = "LittleEndian"]
pub struct CmdKeyValuesMessage {
    pub length: u32,
    #[size = "length.saturating_mul(8)"]
    pub data: Stream,
}