Move engine messages into separate lib for reuse
authorunc0rr
Tue, 13 Nov 2018 07:43:36 +0100
changeset 14210 a8fe9cd51154
parent 14209 4b418709b1cf
child 14211 257b296169a8
Move engine messages into separate lib for reuse
rust/hedgewars-engine-messages/Cargo.toml
rust/hedgewars-engine-messages/src/lib.rs
rust/lib-hedgewars-engine/src/engine_message.rs
rust/lib-hedgewars-engine/src/lib.rs
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rust/hedgewars-engine-messages/Cargo.toml	Tue Nov 13 07:43:36 2018 +0100
@@ -0,0 +1,7 @@
+[package]
+name = "hedgewars-engine-messages"
+version = "0.1.0"
+authors = ["Andrey Korotaev <a.korotaev@hedgewars.org>"]
+
+[dependencies]
+nom = "4.1.1"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rust/hedgewars-engine-messages/src/lib.rs	Tue Nov 13 07:43:36 2018 +0100
@@ -0,0 +1,134 @@
+use crate::command::Command;
+
+pub enum KeystrokeAction {
+    Press,
+    Release,
+}
+
+pub enum SyncedEngineMessage {
+    Left(KeystrokeAction),
+    Right(KeystrokeAction),
+    Up(KeystrokeAction),
+    Down(KeystrokeAction),
+    Precise(KeystrokeAction),
+    Attack(KeystrokeAction),
+    NextTurn,
+    Switch,
+    Empty,
+    Timer(u8),
+    Slot(u8),
+    SetWeapon(u8),
+    Put(i32, i32),
+    HighJump,
+    LowJump,
+    Skip,
+    TeamControlGained(String),
+    TeamControlLost(String),
+}
+
+pub enum UnsyncedEngineMessage {
+    Ping,
+    Pong,
+    Say(String),
+    Taunt(u8),
+    GameType(u8),
+    Warning(String),
+    StopSyncing,
+    GameOver,
+    GameInterrupted,
+    GameSetupChecksum(String),
+}
+
+pub enum ConfigEngineMessage {
+    ConfigRequest,
+    SetAmmo(String),
+    SetScript(String),
+    SetScriptParam(String),
+    Spectate,
+    TeamLocality(bool),
+    SetMap(String),
+    SetTheme(String),
+    SetSeed(String),
+    SetTemplateFilter(String),
+    SetMapGenerator(String),
+    SetFeatureSize(u8),
+    SetDelay(u32),
+    SetReadyDelay(u32),
+    SetCratesFrequency(u8),
+    SetHealthCrateProbability(u8),
+    SetHealthCratesNumber(u8),
+    SetRoundsTilSuddenDeath(u8),
+    SetSuddenDeathWaterRiseSpeed(u8),
+    SetSuddenDeathHealthDecreaseRate(u8),
+    SetDamageMultiplier(u32),
+    SetRopeLength(u32),
+    SetGetawayTime(u32),
+    SetDudMinesPercent(u8),
+    SetMinesNumber(u32),
+    SetAirMinesNumber(u32),
+    SetBarrelsNumber(u32),
+    SetTurnTime(u32),
+    SetMinesTime(u32),
+    SetWorldEdge(u8),
+    Draw, // TODO
+    SetVoicePack(String),
+    AddHedgehog(String, u8, u32),
+    AddTeam(String, u8),
+    SetHedgehogCoordinates(i32, i32),
+    SetFort(String),
+    SetGrave(String),
+    SetHat(String),
+    SetFlag(String),
+    SetOwner(String),
+    SetOneClanMode(bool),
+    SetMultishootMode(bool),
+    SetSolidLand(bool),
+    SetBorders(bool),
+    SetDivideTeams(bool),
+    SetLowGravity(bool),
+    SetLaserSight(bool),
+    SetInvulnerability(bool),
+    SetHealthReset(bool),
+    SetVampiric(bool),
+    SetKarma(bool),
+    SetArtilleryMode(bool),
+    SetHedgehogSwitch(bool),
+    SetRandomOrder(bool),
+    SetKingMode(bool),
+    SetPlaceHedgehog(bool),
+    SetSharedAmmo(bool),
+    SetGirdersEnabled(bool),
+    SetLandObjectsEnabled(bool),
+    SetAISurvivalMode(bool),
+    SetInfiniteAttack(bool),
+    SetResetWeapons(bool),
+    SetAmmoPerHedgehog(bool),
+    SetWindMode(u8),
+    SetTagTeam(bool),
+    SetBottomBorder(bool),
+    SetShoppaBorder(bool),
+}
+
+pub enum EngineMessage {
+    Synced(SyncedEngineMessage, u32),
+    Unsynced(UnsyncedEngineMessage),
+    Config(ConfigEngineMessage),
+}
+
+impl EngineMessage {
+    fn from_bytes(buf: &[u8]) -> Self {
+        unimplemented!()
+    }
+
+    fn to_bytes(&self) -> Vec<u8> {
+        unimplemented!()
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    #[test]
+    fn it_works() {
+        assert_eq!(2 + 2, 4);
+    }
+}
--- a/rust/lib-hedgewars-engine/src/engine_message.rs	Tue Nov 13 08:11:31 2018 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-use crate::command::Command;
-
-pub enum KeystrokeAction {
-    Press,
-    Release,
-}
-
-pub enum SyncedEngineMessage {
-    Left(KeystrokeAction),
-    Right(KeystrokeAction),
-    Up(KeystrokeAction),
-    Down(KeystrokeAction),
-    Precise(KeystrokeAction),
-    Attack(KeystrokeAction),
-    NextTurn,
-    Switch,
-    Empty,
-    Timer(u8),
-    Slot(u8),
-    SetWeapon(u8),
-    Put(i32, i32),
-    HighJump,
-    LowJump,
-    Skip,
-    TeamControlGained(String),
-    TeamControlLost(String),
-}
-
-pub enum UnsyncedEngineMessage {
-    Ping,
-    Pong,
-    Say(String),
-    Taunt(u8),
-    GameType(u8),
-    Warning(String),
-    StopSyncing,
-    GameOver,
-    GameInterrupted,
-    GameSetupChecksum(String),
-}
-
-pub enum ConfigEngineMessage {
-    ConfigRequest,
-    SetAmmo(String),
-    SetScript(String),
-    SetScriptParam(String),
-    Spectate,
-    TeamLocality(bool),
-    SetMap(String),
-    SetTheme(String),
-    SetSeed(String),
-    SetTemplateFilter(String),
-    SetMapGenerator(String),
-    SetFeatureSize(u8),
-    SetDelay(u32),
-    SetReadyDelay(u32),
-    SetCratesFrequency(u8),
-    SetHealthCrateProbability(u8),
-    SetHealthCratesNumber(u8),
-    SetRoundsTilSuddenDeath(u8),
-    SetSuddenDeathWaterRiseSpeed(u8),
-    SetSuddenDeathHealthDecreaseRate(u8),
-    SetDamageMultiplier(u32),
-    SetRopeLength(u32),
-    SetGetawayTime(u32),
-    SetDudMinesPercent(u8),
-    SetMinesNumber(u32),
-    SetAirMinesNumber(u32),
-    SetBarrelsNumber(u32),
-    SetTurnTime(u32),
-    SetMinesTime(u32),
-    SetWorldEdge(u8),
-    Draw, // TODO
-    SetVoicePack(String),
-    AddHedgehog(String, u8, u32),
-    AddTeam(String, u8),
-    SetHedgehogCoordinates(i32, i32),
-    SetFort(String),
-    SetGrave(String),
-    SetHat(String),
-    SetFlag(String),
-    SetOwner(String),
-    SetOneClanMode(bool),
-    SetMultishootMode(bool),
-    SetSolidLand(bool),
-    SetBorders(bool),
-    SetDivideTeams(bool),
-    SetLowGravity(bool),
-    SetLaserSight(bool),
-    SetInvulnerability(bool),
-    SetHealthReset(bool),
-    SetVampiric(bool),
-    SetKarma(bool),
-    SetArtilleryMode(bool),
-    SetHedgehogSwitch(bool),
-    SetRandomOrder(bool),
-    SetKingMode(bool),
-    SetPlaceHedgehog(bool),
-    SetSharedAmmo(bool),
-    SetGirdersEnabled(bool),
-    SetLandObjectsEnabled(bool),
-    SetAISurvivalMode(bool),
-    SetInfiniteAttack(bool),
-    SetResetWeapons(bool),
-    SetAmmoPerHedgehog(bool),
-    SetWindMode(u8),
-    SetTagTeam(bool),
-    SetBottomBorder(bool),
-    SetShoppaBorder(bool),
-}
-
-pub enum EngineMessage {
-    Synced(SyncedEngineMessage, u32),
-    Unsynced(UnsyncedEngineMessage),
-    Config(ConfigEngineMessage),
-}
-
-impl EngineMessage {
-    fn from_bytes(buf: &[u8]) -> Self {
-        unimplemented!()
-    }
-
-    fn to_bytes(&self) -> Vec<u8> {
-        unimplemented!()
-    }
-}
--- a/rust/lib-hedgewars-engine/src/lib.rs	Tue Nov 13 08:11:31 2018 +0300
+++ b/rust/lib-hedgewars-engine/src/lib.rs	Tue Nov 13 07:43:36 2018 +0100
@@ -6,7 +6,6 @@
 extern crate gfx_device_gl;
 
 mod world;
-mod engine_message;
 mod command;
 
 #[repr(C)]