mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
Ignore unknown pixels on noita side
This commit is contained in:
parent
3860f48633
commit
b90f0c3f6c
5 changed files with 22 additions and 20 deletions
|
@ -96,12 +96,12 @@ impl NetManager {
|
|||
}
|
||||
|
||||
pub(crate) fn send(&self, peer: omni::OmniPeerId, msg: &NetMsg, reliability: Reliability) {
|
||||
let encoded = bitcode::encode(msg);
|
||||
let encoded = lz4_flex::compress_prepend_size(&bitcode::encode(msg));
|
||||
self.peer.send(peer, encoded.clone(), reliability).ok(); // TODO log
|
||||
}
|
||||
|
||||
pub(crate) fn broadcast(&self, msg: &NetMsg, reliability: Reliability) {
|
||||
let encoded = bitcode::encode(msg);
|
||||
let encoded = lz4_flex::compress_prepend_size(&bitcode::encode(msg));
|
||||
let len = encoded.len();
|
||||
if let Err(err) = self.peer.broadcast(encoded, reliability) {
|
||||
warn!("Error while broadcasting message of len {}: {}", len, err)
|
||||
|
@ -219,8 +219,10 @@ impl NetManager {
|
|||
state.try_ws_write(ws_encode_proxy("leave", id));
|
||||
}
|
||||
omni::OmniNetworkEvent::Message { src, data } => {
|
||||
// TODO move all compression here.
|
||||
let Ok(net_msg) = bitcode::decode::<NetMsg>(&data) else {
|
||||
let Some(net_msg) = lz4_flex::decompress_size_prepended(&data)
|
||||
.ok()
|
||||
.and_then(|decomp| bitcode::decode::<NetMsg>(&decomp).ok())
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
match net_msg {
|
||||
|
@ -276,9 +278,7 @@ impl NetManager {
|
|||
}
|
||||
// Broadcast
|
||||
2 => {
|
||||
// Somewhat arbitrary limit to begin compressing messages.
|
||||
// Messages shorter than this many bytes probably won't be compressed as much
|
||||
let msg_to_send = if msg.len() > 140 {
|
||||
let msg_to_send = if false {
|
||||
let compressed = lz4_flex::compress_prepend_size(&msg[1..]);
|
||||
|
||||
debug!(
|
||||
|
|
|
@ -19,7 +19,11 @@ pub struct Pixel {
|
|||
impl Pixel {
|
||||
pub fn to_raw(self) -> RawPixel {
|
||||
RawPixel {
|
||||
material: self.material,
|
||||
material: if self.flags != PixelFlags::Unknown {
|
||||
self.material
|
||||
} else {
|
||||
u16::MAX
|
||||
},
|
||||
flags: if self.flags == PixelFlags::Normal {
|
||||
0
|
||||
} else {
|
||||
|
|
|
@ -193,6 +193,10 @@ function world.decode(grid_world, header, pixel_runs)
|
|||
|
||||
local current_material = 0
|
||||
|
||||
if new_material == -1 then
|
||||
goto next_pixel
|
||||
end
|
||||
|
||||
if ppixel[0] ~= nil then
|
||||
local pixel = ppixel[0]
|
||||
local cell_type = pixel.vtable.get_cell_type(pixel)
|
||||
|
|
|
@ -106,7 +106,7 @@ function net.init()
|
|||
else
|
||||
print("Could not deserialize: "..item)
|
||||
end
|
||||
elseif string.byte(msg, 1, 1) == 2 then
|
||||
elseif string.byte(msg, 1, 1) == 3 then
|
||||
msg_decoded = {
|
||||
kind = "proxy",
|
||||
peer_id = nil,
|
||||
|
|
|
@ -87,11 +87,7 @@ function world_sync.on_world_update_host()
|
|||
end
|
||||
if area ~= nil then
|
||||
local str = ffi.string(area, world.encoded_size(area))
|
||||
if string.len(str) > bandwidth_bucket_max then
|
||||
GamePrint("Discarding chunk update, as it is too large to be sent")
|
||||
else
|
||||
net.proxy_bin_send(KEY_WORLD_FRAME, str)
|
||||
end
|
||||
net.proxy_bin_send(KEY_WORLD_FRAME, str)
|
||||
end
|
||||
end
|
||||
net.proxy_bin_send(KEY_WORLD_END, "")
|
||||
|
@ -101,14 +97,12 @@ end
|
|||
|
||||
local PixelRun_const_ptr = ffi.typeof("struct PixelRun const*")
|
||||
|
||||
function world_sync.handle_world_data(world_data)
|
||||
function world_sync.handle_world_data(datum)
|
||||
local grid_world = world_ffi.get_grid_world()
|
||||
for i, datum in ipairs(world_data) do
|
||||
-- GamePrint("Decoding world data "..i)
|
||||
local header = ffi.cast("struct EncodedAreaHeader const*", ffi.cast('char const*', datum))
|
||||
local runs = ffi.cast(PixelRun_const_ptr, ffi.cast("const char*", datum) + ffi.sizeof(world.EncodedAreaHeader))
|
||||
world.decode(grid_world, header, runs)
|
||||
end
|
||||
local header = ffi.cast("struct EncodedAreaHeader const*", ffi.cast('char const*', datum))
|
||||
local runs = ffi.cast(PixelRun_const_ptr, ffi.cast("const char*", datum) + ffi.sizeof(world.EncodedAreaHeader))
|
||||
world.decode(grid_world, header, runs)
|
||||
end
|
||||
|
||||
net.net_handling.proxy[0] = function(_, value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue