rust/hedgewars-engine-messages/src/messages.rs
author unC0Rr
Wed, 14 Nov 2018 16:58:22 +0100
changeset 14211 0f7b92397b9e
parent 14210 1c55c54013c4
child 14214 77b95406631e
permissions -rw-r--r--
Parse some synced messages, tests
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14209
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
     1
#[derive(Debug, PartialEq)]
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
     2
pub enum KeystrokeAction {
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
     3
    Press,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
     4
    Release,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
     5
}
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
     6
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
     7
#[derive(Debug, PartialEq)]
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
     8
pub enum SyncedEngineMessage {
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
     9
    Left(KeystrokeAction),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    10
    Right(KeystrokeAction),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    11
    Up(KeystrokeAction),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    12
    Down(KeystrokeAction),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    13
    Precise(KeystrokeAction),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    14
    Attack(KeystrokeAction),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    15
    NextTurn,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    16
    Switch,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    17
    Timer(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    18
    Slot(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    19
    SetWeapon(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    20
    Put(i32, i32),
14211
0f7b92397b9e Parse some synced messages, tests
unC0Rr
parents: 14210
diff changeset
    21
    CursorMove(i32, i32),
14209
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    22
    HighJump,
14211
0f7b92397b9e Parse some synced messages, tests
unC0Rr
parents: 14210
diff changeset
    23
    LongJump,
14209
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    24
    Skip,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    25
    TeamControlGained(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    26
    TeamControlLost(String),
14210
1c55c54013c4 Recognize timestamps
unC0Rr
parents: 14209
diff changeset
    27
    TimeWrap,
14209
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    28
}
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    29
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    30
#[derive(Debug, PartialEq)]
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    31
pub enum UnsyncedEngineMessage {
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    32
    Ping,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    33
    Pong,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    34
    Say(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    35
    Taunt(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    36
    GameType(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    37
    Warning(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    38
    StopSyncing,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    39
    GameOver,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    40
    GameInterrupted,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    41
    GameSetupChecksum(String),
14211
0f7b92397b9e Parse some synced messages, tests
unC0Rr
parents: 14210
diff changeset
    42
    TeamControlGained(String),
0f7b92397b9e Parse some synced messages, tests
unC0Rr
parents: 14210
diff changeset
    43
    TeamControlLost(String),
14209
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    44
}
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    45
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    46
#[derive(Debug, PartialEq)]
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    47
pub enum ConfigEngineMessage {
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    48
    ConfigRequest,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    49
    SetAmmo(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    50
    SetScript(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    51
    SetScriptParam(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    52
    Spectate,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    53
    TeamLocality(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    54
    SetMap(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    55
    SetTheme(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    56
    SetSeed(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    57
    SetTemplateFilter(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    58
    SetMapGenerator(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    59
    SetFeatureSize(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    60
    SetDelay(u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    61
    SetReadyDelay(u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    62
    SetCratesFrequency(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    63
    SetHealthCrateProbability(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    64
    SetHealthCratesNumber(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    65
    SetRoundsTilSuddenDeath(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    66
    SetSuddenDeathWaterRiseSpeed(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    67
    SetSuddenDeathHealthDecreaseRate(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    68
    SetDamageMultiplier(u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    69
    SetRopeLength(u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    70
    SetGetawayTime(u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    71
    SetDudMinesPercent(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    72
    SetMinesNumber(u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    73
    SetAirMinesNumber(u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    74
    SetBarrelsNumber(u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    75
    SetTurnTime(u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    76
    SetMinesTime(u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    77
    SetWorldEdge(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    78
    Draw,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    79
    // TODO
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    80
    SetVoicePack(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    81
    AddHedgehog(String, u8, u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    82
    AddTeam(String, u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    83
    SetHedgehogCoordinates(i32, i32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    84
    SetFort(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    85
    SetGrave(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    86
    SetHat(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    87
    SetFlag(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    88
    SetOwner(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    89
    SetOneClanMode(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    90
    SetMultishootMode(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    91
    SetSolidLand(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    92
    SetBorders(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    93
    SetDivideTeams(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    94
    SetLowGravity(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    95
    SetLaserSight(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    96
    SetInvulnerability(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    97
    SetHealthReset(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    98
    SetVampiric(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    99
    SetKarma(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   100
    SetArtilleryMode(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   101
    SetHedgehogSwitch(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   102
    SetRandomOrder(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   103
    SetKingMode(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   104
    SetPlaceHedgehog(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   105
    SetSharedAmmo(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   106
    SetGirdersEnabled(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   107
    SetLandObjectsEnabled(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   108
    SetAISurvivalMode(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   109
    SetInfiniteAttack(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   110
    SetResetWeapons(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   111
    SetAmmoPerHedgehog(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   112
    SetWindMode(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   113
    SetTagTeam(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   114
    SetBottomBorder(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   115
    SetShoppaBorder(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   116
}
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   117
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   118
#[derive(Debug, PartialEq)]
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   119
pub enum EngineMessage {
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   120
    Synced(SyncedEngineMessage, u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   121
    Unsynced(UnsyncedEngineMessage),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   122
    Config(ConfigEngineMessage),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   123
    Unknown,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   124
    Empty,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   125
}
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   126
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   127
impl EngineMessage {
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   128
    fn from_bytes(buf: &[u8]) -> Self {
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   129
        unimplemented!()
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   130
    }
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   131
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   132
    fn to_bytes(&self) -> Vec<u8> {
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   133
        unimplemented!()
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   134
    }
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   135
}