Send host_id to mod

This commit is contained in:
IQuant 2024-05-17 18:09:50 +03:00
parent 07c98b4f57
commit f5d78f2a5c
3 changed files with 6 additions and 2 deletions

View file

@ -31,6 +31,11 @@ function net_handling.proxy.debug(_, value)
ctx.debug = value == "true"
end
function net_handling.proxy.host_id(_, value)
ctx.host_id = tonumber(value)
ctx.is_host = ctx.my_id == ctx.host_id
end
function net_handling.mod.player(peer_id, value)
local input_data = value.i
local pos_data = value.p

View file

@ -246,6 +246,7 @@ impl NetManager {
"peer_id",
self.peer.my_id().expect("Has peer id at this point"),
));
state.try_ws_write(ws_encode_proxy("host_id", self.peer.host_id()));
state.try_ws_write(ws_encode_proxy("name", "test_name"));
state.try_ws_write(ws_encode_proxy(
"debug",

View file

@ -112,7 +112,6 @@ impl SteamPeer {
};
let networking = self.client.networking();
let res = networking.send_p2p_packet(peer, send_type.clone(), msg);
// info!("Sent a packet to {:?}, st {:?}", peer, send_type);
if !res {
warn!("Couldn't send a packet to {:?}, st {:?}", peer, send_type)
}
@ -165,7 +164,6 @@ impl SteamPeer {
}
let networking = self.client.networking();
while let Some(size) = networking.is_p2p_packet_available() {
info!("Got packet {}", size);
let mut empty_array = vec![0; size];
let mut buffer = empty_array.as_mut_slice();
if let Some((sender, _)) = networking.read_p2p_packet(&mut buffer) {