rust/hedgewars-server/src/protocol/test.rs
author alfadur
Fri, 12 Apr 2019 22:36:54 +0300
changeset 14816 add191d825f4
parent 14804 b3adc030104b
child 15095 c5a6e8566425
permissions -rw-r--r--
add parser error handling
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13419
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
     1
use proptest::{
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
     2
    arbitrary::{any, any_with, Arbitrary, StrategyFor},
14478
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
     3
    strategy::{BoxedStrategy, Just, Map, Strategy},
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
     4
    test_runner::{Reason, TestRunner},
13419
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
     5
};
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
     6
14804
b3adc030104b implement server vars
alfadur
parents: 14478
diff changeset
     7
use crate::server::coretypes::{GameCfg, HedgehogInfo, ServerVar, ServerVar::*, TeamInfo};
13439
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
     8
14478
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
     9
use super::messages::{HWProtocolMessage, HWProtocolMessage::*};
13419
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    10
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    11
// Due to inability to define From between Options
14478
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    12
trait Into2<T>: Sized {
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    13
    fn into2(self) -> T;
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    14
}
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    15
impl<T> Into2<T> for T {
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    16
    fn into2(self) -> T {
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    17
        self
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    18
    }
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    19
}
13433
fb104e150878 Implement to_raw_protocol for Rnd and enable tests. Add cargo/rls build artifacts to .gitignore
Marcin Mielniczuk <marmistrz.dev@zoho.eu>
parents: 13432
diff changeset
    20
impl Into2<Vec<String>> for Vec<Ascii> {
fb104e150878 Implement to_raw_protocol for Rnd and enable tests. Add cargo/rls build artifacts to .gitignore
Marcin Mielniczuk <marmistrz.dev@zoho.eu>
parents: 13432
diff changeset
    21
    fn into2(self) -> Vec<String> {
fb104e150878 Implement to_raw_protocol for Rnd and enable tests. Add cargo/rls build artifacts to .gitignore
Marcin Mielniczuk <marmistrz.dev@zoho.eu>
parents: 13432
diff changeset
    22
        self.into_iter().map(|x| x.0).collect()
fb104e150878 Implement to_raw_protocol for Rnd and enable tests. Add cargo/rls build artifacts to .gitignore
Marcin Mielniczuk <marmistrz.dev@zoho.eu>
parents: 13432
diff changeset
    23
    }
fb104e150878 Implement to_raw_protocol for Rnd and enable tests. Add cargo/rls build artifacts to .gitignore
Marcin Mielniczuk <marmistrz.dev@zoho.eu>
parents: 13432
diff changeset
    24
}
14478
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    25
impl Into2<String> for Ascii {
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    26
    fn into2(self) -> String {
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    27
        self.0
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    28
    }
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    29
}
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    30
impl Into2<Option<String>> for Option<Ascii> {
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    31
    fn into2(self) -> Option<String> {
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    32
        self.map(|x| x.0)
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    33
    }
13419
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    34
}
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    35
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    36
macro_rules! proto_msg_case {
14478
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    37
    ($val: ident()) => {
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    38
        Just($val)
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    39
    };
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    40
    ($val: ident($arg: ty)) => {
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    41
        any::<$arg>().prop_map(|v| $val(v.into2()))
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    42
    };
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    43
    ($val: ident($arg1: ty, $arg2: ty)) => {
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    44
        any::<($arg1, $arg2)>().prop_map(|v| $val(v.0.into2(), v.1.into2()))
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    45
    };
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    46
    ($val: ident($arg1: ty, $arg2: ty, $arg3: ty)) => {
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    47
        any::<($arg1, $arg2, $arg3)>().prop_map(|v| $val(v.0.into2(), v.1.into2(), v.2.into2()))
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    48
    };
13419
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    49
}
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    50
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    51
macro_rules! proto_msg_match {
13439
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
    52
    ($var: expr, def = $default: expr, $($num: expr => $constr: ident $res: tt),*) => (
13419
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    53
        match $var {
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    54
            $($num => (proto_msg_case!($constr $res)).boxed()),*,
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    55
            _ => Just($default).boxed()
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    56
        }
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    57
    )
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    58
}
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    59
13432
ee3fa3b8809d Fix cmd parsing & update tests
alfadur
parents: 13421
diff changeset
    60
/// Wrapper type for generating non-empty strings
13419
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    61
#[derive(Debug)]
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    62
struct Ascii(String);
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    63
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    64
impl Arbitrary for Ascii {
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    65
    type Parameters = <String as Arbitrary>::Parameters;
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    66
13666
09f4a30e50cc Rust 2018 conversion
alfadur
parents: 13528
diff changeset
    67
    fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
13462
7f3289a239dd Optimize test string generation
alfadur
parents: 13450
diff changeset
    68
        "[a-zA-Z0-9]+".prop_map(Ascii).boxed()
13419
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    69
    }
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    70
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    71
    type Strategy = BoxedStrategy<Ascii>;
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    72
}
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
    73
13439
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
    74
impl Arbitrary for GameCfg {
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
    75
    type Parameters = ();
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
    76
13666
09f4a30e50cc Rust 2018 conversion
alfadur
parents: 13528
diff changeset
    77
    fn arbitrary_with(_args: <Self as Arbitrary>::Parameters) -> <Self as Arbitrary>::Strategy {
09f4a30e50cc Rust 2018 conversion
alfadur
parents: 13528
diff changeset
    78
        use crate::server::coretypes::GameCfg::*;
14478
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    79
        (0..10)
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    80
            .no_shrink()
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    81
            .prop_flat_map(|i| {
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    82
                proto_msg_match!(i, def = FeatureSize(0),
13439
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
    83
            0 => FeatureSize(u32),
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
    84
            1 => MapType(Ascii),
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
    85
            2 => MapGenerator(u32),
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
    86
            3 => MazeSize(u32),
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
    87
            4 => Seed(Ascii),
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
    88
            5 => Template(u32),
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
    89
            6 => Ammo(Ascii, Option<Ascii>),
13775
5fb40c8e5542 port some legacy protocol support
alfadur
parents: 13771
diff changeset
    90
            7 => Scheme(Ascii, Vec<Ascii>),
13439
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
    91
            8 => Script(Ascii),
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
    92
            9 => Theme(Ascii),
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
    93
            10 => DrawnMap(Ascii))
14478
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    94
            })
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
    95
            .boxed()
13439
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
    96
    }
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
    97
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
    98
    type Strategy = BoxedStrategy<GameCfg>;
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
    99
}
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
   100
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
   101
impl Arbitrary for TeamInfo {
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
   102
    type Parameters = ();
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
   103
13666
09f4a30e50cc Rust 2018 conversion
alfadur
parents: 13528
diff changeset
   104
    fn arbitrary_with(_args: <Self as Arbitrary>::Parameters) -> <Self as Arbitrary>::Strategy {
14478
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   105
        (
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   106
            "[a-z]+",
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   107
            0u8..127u8,
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   108
            "[a-z]+",
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   109
            "[a-z]+",
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   110
            "[a-z]+",
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   111
            "[a-z]+",
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   112
            0u8..127u8,
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   113
        )
13439
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
   114
            .prop_map(|(name, color, grave, fort, voice_pack, flag, difficulty)| {
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
   115
                fn hog(n: u8) -> HedgehogInfo {
14478
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   116
                    HedgehogInfo {
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   117
                        name: format!("hog{}", n),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   118
                        hat: format!("hat{}", n),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   119
                    }
13439
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
   120
                }
14478
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   121
                let hedgehogs = [
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   122
                    hog(1),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   123
                    hog(2),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   124
                    hog(3),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   125
                    hog(4),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   126
                    hog(5),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   127
                    hog(6),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   128
                    hog(7),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   129
                    hog(8),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   130
                ];
13439
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
   131
                TeamInfo {
14816
add191d825f4 add parser error handling
alfadur
parents: 14804
diff changeset
   132
                    owner: String::new(),
14478
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   133
                    name,
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   134
                    color,
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   135
                    grave,
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   136
                    fort,
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   137
                    voice_pack,
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   138
                    flag,
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   139
                    difficulty,
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   140
                    hedgehogs,
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   141
                    hedgehogs_number: 0,
13439
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
   142
                }
14478
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   143
            })
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   144
            .boxed()
13439
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
   145
    }
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
   146
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
   147
    type Strategy = BoxedStrategy<TeamInfo>;
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
   148
}
c4f917c6be51 add missing message tests
alfadur
parents: 13437
diff changeset
   149
14804
b3adc030104b implement server vars
alfadur
parents: 14478
diff changeset
   150
impl Arbitrary for ServerVar {
b3adc030104b implement server vars
alfadur
parents: 14478
diff changeset
   151
    type Parameters = ();
b3adc030104b implement server vars
alfadur
parents: 14478
diff changeset
   152
b3adc030104b implement server vars
alfadur
parents: 14478
diff changeset
   153
    fn arbitrary_with(args: Self::Parameters) -> Self::Strategy {
14816
add191d825f4 add parser error handling
alfadur
parents: 14804
diff changeset
   154
        (0..=2)
14804
b3adc030104b implement server vars
alfadur
parents: 14478
diff changeset
   155
            .no_shrink()
b3adc030104b implement server vars
alfadur
parents: 14478
diff changeset
   156
            .prop_flat_map(|i| {
b3adc030104b implement server vars
alfadur
parents: 14478
diff changeset
   157
                proto_msg_match!(i, def = ServerVar::LatestProto(0),
b3adc030104b implement server vars
alfadur
parents: 14478
diff changeset
   158
                    0 => MOTDNew(Ascii),
b3adc030104b implement server vars
alfadur
parents: 14478
diff changeset
   159
                    1 => MOTDOld(Ascii),
b3adc030104b implement server vars
alfadur
parents: 14478
diff changeset
   160
                    2 => LatestProto(u16)
b3adc030104b implement server vars
alfadur
parents: 14478
diff changeset
   161
                )
b3adc030104b implement server vars
alfadur
parents: 14478
diff changeset
   162
            })
b3adc030104b implement server vars
alfadur
parents: 14478
diff changeset
   163
            .boxed()
b3adc030104b implement server vars
alfadur
parents: 14478
diff changeset
   164
    }
b3adc030104b implement server vars
alfadur
parents: 14478
diff changeset
   165
b3adc030104b implement server vars
alfadur
parents: 14478
diff changeset
   166
    type Strategy = BoxedStrategy<ServerVar>;
b3adc030104b implement server vars
alfadur
parents: 14478
diff changeset
   167
}
b3adc030104b implement server vars
alfadur
parents: 14478
diff changeset
   168
13419
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
   169
pub fn gen_proto_msg() -> BoxedStrategy<HWProtocolMessage> where {
14816
add191d825f4 add parser error handling
alfadur
parents: 14804
diff changeset
   170
    let res = (0..=55).no_shrink().prop_flat_map(|i| {
add191d825f4 add parser error handling
alfadur
parents: 14804
diff changeset
   171
        proto_msg_match!(i, def = Ping,
14478
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   172
            0 => Ping(),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   173
            1 => Pong(),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   174
            2 => Quit(Option<Ascii>),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   175
            4 => Global(Ascii),
14816
add191d825f4 add parser error handling
alfadur
parents: 14804
diff changeset
   176
            5 => Watch(u32),
14478
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   177
            6 => ToggleServerRegisteredOnly(),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   178
            7 => SuperPower(),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   179
            8 => Info(Ascii),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   180
            9 => Nick(Ascii),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   181
            10 => Proto(u16),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   182
            11 => Password(Ascii, Ascii),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   183
            12 => Checker(u16, Ascii, Ascii),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   184
            13 => List(),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   185
            14 => Chat(Ascii),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   186
            15 => CreateRoom(Ascii, Option<Ascii>),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   187
            16 => JoinRoom(Ascii, Option<Ascii>),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   188
            17 => Follow(Ascii),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   189
            18 => Rnd(Vec<Ascii>),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   190
            19 => Kick(Ascii),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   191
            20 => Ban(Ascii, Ascii, u32),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   192
            21 => BanIP(Ascii, Ascii, u32),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   193
            22 => BanNick(Ascii, Ascii, u32),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   194
            23 => BanList(),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   195
            24 => Unban(Ascii),
14804
b3adc030104b implement server vars
alfadur
parents: 14478
diff changeset
   196
            25 => SetServerVar(ServerVar),
14478
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   197
            26 => GetServerVar(),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   198
            27 => RestartServer(),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   199
            28 => Stats(),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   200
            29 => Part(Option<Ascii>),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   201
            30 => Cfg(GameCfg),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   202
            31 => AddTeam(Box<TeamInfo>),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   203
            32 => RemoveTeam(Ascii),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   204
            33 => SetHedgehogsNumber(Ascii, u8),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   205
            34 => SetTeamColor(Ascii, u8),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   206
            35 => ToggleReady(),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   207
            36 => StartGame(),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   208
            37 => EngineMessage(Ascii),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   209
            38 => RoundFinished(),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   210
            39 => ToggleRestrictJoin(),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   211
            40 => ToggleRestrictTeams(),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   212
            41 => ToggleRegisteredOnly(),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   213
            42 => RoomName(Ascii),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   214
            43 => Delegate(Ascii),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   215
            44 => TeamChat(Ascii),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   216
            45 => MaxTeams(u8),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   217
            46 => Fix(),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   218
            47 => Unfix(),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   219
            48 => Greeting(Ascii),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   220
            //49 => CallVote(Option<(String, Option<String>)>),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   221
            50 => Vote(bool),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   222
            51 => ForceVote(bool),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   223
            52 => Save(Ascii, Ascii),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   224
            53 => Delete(Ascii),
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   225
            54 => SaveRoom(Ascii),
14816
add191d825f4 add parser error handling
alfadur
parents: 14804
diff changeset
   226
            55 => LoadRoom(Ascii)
14478
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   227
        )
98ef2913ec73 Apply rustfmt to all files
unc0rr
parents: 14436
diff changeset
   228
    });
13419
81e0ed105f5d implementation of team related messages
alfadur
parents:
diff changeset
   229
    res.boxed()
13421
d1368c776a4f Enable all lints from the rust-2018-idioms suite.
marmistrz
parents: 13419
diff changeset
   230
}