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