M client/src/gateway.ts => client/src/gateway.ts +1 -1
@@ 68,7 68,7 @@ export async function gateway_connect(gateway_url: string, username: string): Ga
client.ping_timeout = setTimeout(ping_fn, 5 * 1000);
let handshake_start_msg = MessageC2SHello.encode({
- version: 1,
+ version: 3,
requestedUsername: username,
nextState: State.Play
}).finish();
M protocol/build.rs => protocol/build.rs +2 -1
@@ 9,5 9,6 @@ fn main() {
.input("src/pbuf/player.proto")
.input("src/pbuf/state.proto")
.input("src/pbuf/goodbye_reason.proto")
+ .input("src/pbuf/module.proto")
.run_from_script();
-}>
\ No newline at end of file
+}
M protocol/src/lib.rs => protocol/src/lib.rs +11 -4
@@ 1,12 1,12 @@
use std::error::Error;
use protobuf::{Enum, Message};
use crate::message_c2s::{MessageC2SAuthenticateAndBeamOut, MessageC2SChat, MessageC2SGoodbye, MessageC2SHello, MessageC2SInput, MessageC2SPing};
-use crate::message_s2c::{MessageS2CChat, MessageS2CGoodbye, MessageS2CHello, MessageS2CPlanetData, MessageS2CPlayersUpdate, MessageS2CPong};
+use crate::message_s2c::{MessageS2CChat, MessageS2CGoodbye, MessageS2CHello, MessageS2CPlanetData, MessageS2CPlayersUpdate, MessageS2CPong, MessageS2CModulesUpdate};
use crate::planet::PlanetType;
use crate::starkingdoms_protocol::PacketWrapper;
include!(concat!(env!("OUT_DIR"), "/protos/mod.rs"));
-pub const PROTOCOL_VERSION: u32 = 2;
+pub const PROTOCOL_VERSION: u32 = 3;
pub mod api;
@@ 27,7 27,8 @@ pub enum MessageS2C {
Chat(MessageS2CChat),
Pong(MessageS2CPong),
PlayersUpdate(MessageS2CPlayersUpdate),
- PlanetData(MessageS2CPlanetData)
+ PlanetData(MessageS2CPlanetData),
+ ModulesUpdate(MessageS2CModulesUpdate),
}
impl TryFrom<&[u8]> for MessageC2S {
@@ 122,6 123,9 @@ impl TryFrom<&[u8]> for MessageS2C {
_id if _id == message_s2c::message_s2cplanet_data::Packet_info::type_.value() as i64 => {
MessageS2C::PlanetData(MessageS2CPlanetData::parse_from_bytes(&pkt.packet_data)?)
},
+ _id if _id == message_s2c::message_s2cmodules_update::Packet_info::type_.value() as i64 => {
+ MessageS2C::ModulesUpdate(MessageS2CModulesUpdate::parse_from_bytes(&pkt.packet_data)?)
+ },
_ => { return Err("Not a S2C packet".into()); }
};
@@ 152,6 156,9 @@ impl TryInto<Vec<u8>> for MessageS2C {
MessageS2C::PlanetData(p) => {
(message_s2c::message_s2cplanet_data::Packet_info::type_.value(), p.write_to_bytes()?)
}
+ MessageS2C::ModulesUpdate(p) => {
+ (message_s2c::message_s2cmodules_update::Packet_info::type_.value(), p.write_to_bytes()?)
+ }
};
let pkt = PacketWrapper {
@@ 171,4 178,4 @@ impl planet::PlanetType {
PlanetType::Moon => "moon".to_string()
}
}
-}>
\ No newline at end of file
+}
M protocol/src/pbuf/message_s2c.proto => protocol/src/pbuf/message_s2c.proto +8 -1
@@ 5,6 5,7 @@ import "state.proto";
import "goodbye_reason.proto";
import "player.proto";
import "planet.proto";
+import "module.proto";
message MessageS2CHello {
enum packet_info { unknown = 0; type = 0x05; }
@@ 41,4 42,10 @@ message MessageS2CPlanetData {
enum packet_info { unknown = 0; type = 0x0a; }
repeated protocol.planet.Planet planets = 1; // List of all planets on the server
-}>
\ No newline at end of file
+}
+
+message MessageS2CModulesUpdate {
+ enum packet_info { unknown = 0; type = 0x0b; }
+
+ repeated protocol.module.Module modules = 1;
+}
A protocol/src/pbuf/module.proto => protocol/src/pbuf/module.proto +15 -0
@@ 0,0 1,15 @@
+syntax = "proto3";
+package protocol.module;
+
+message Module {
+ ModuleType module_type = 1;
+ float rotation = 2;
+ float x = 3;
+ float y = 4;
+}
+
+enum ModuleType {
+ Cargo = 0;
+ LandingThruster = 1;
+ Hub = 2;
+}