mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 15:13:16 +00:00
re-add priority with 7x7 squares instead of 6x6, maybe-probably not fix priority issues
This commit is contained in:
parent
daa7b20739
commit
58171dde0f
3 changed files with 92 additions and 67 deletions
|
@ -246,13 +246,13 @@ impl WorldManager {
|
|||
let (x, y) = my_pos;
|
||||
let (cx, cy) = cam_pos;
|
||||
if (x - cx).abs() <= 2 && (y - cy).abs() <= 2 {
|
||||
!(chx <= x + 2 && chx >= x - 3
|
||||
&& chy <= y + 2 && chy >= y - 3)
|
||||
!(chx <= x + 3 && chx >= x - 3
|
||||
&& chy <= y + 3 && chy >= y - 3)
|
||||
} else {
|
||||
!(chx <= x + 1 && chx >= x - 2
|
||||
&& chy <= y + 1 && chy >= y - 2)
|
||||
&& !(chx <= cx + 1 && chx >= cx - 2
|
||||
&& chy <= cy + 1 && chy >= cy - 2)
|
||||
!(chx <= x + 2 && chx >= x - 2
|
||||
&& chy <= y + 2 && chy >= y - 2)
|
||||
&& !(chx <= cx + 2 && chx >= cx - 2
|
||||
&& chy <= cy + 2 && chy >= cy - 2)
|
||||
}
|
||||
}
|
||||
let mut emit_queue = Vec::new();
|
||||
|
@ -503,15 +503,10 @@ impl WorldManager {
|
|||
}
|
||||
}
|
||||
WorldNetMessage::ListenUpdate { delta, priority } => {
|
||||
let Some(ChunkState::Listening { priority: pri, .. }) = self.chunk_state.get_mut(&delta.chunk_coord)
|
||||
else {
|
||||
/*warn!(
|
||||
"Can't handle ListenUpdate for {:?} - not a listener",
|
||||
delta.chunk_coord
|
||||
);*/
|
||||
return;
|
||||
};
|
||||
*pri = priority;
|
||||
if let Some(ChunkState::Listening { priority: pri, .. }) = self.chunk_state.get_mut(&delta.chunk_coord)
|
||||
{
|
||||
*pri = priority;
|
||||
}
|
||||
self.inbound_model.apply_chunk_delta(&delta);
|
||||
}
|
||||
WorldNetMessage::ListenAuthorityRelinquished { chunk } => {
|
||||
|
|
|
@ -74,7 +74,7 @@ local function get_potions_of_type(type)
|
|||
if children_items == nil then
|
||||
return potions
|
||||
end
|
||||
for _, item in ipairs(children_items) do
|
||||
for _, item in ipairs(children_items or {}) do
|
||||
if EntityHasTag(item, "potion") then
|
||||
local mat = EntityGetFirstComponent(item, "MaterialInventoryComponent")
|
||||
local materials = ComponentGetValue2(mat, "count_per_material_type")
|
||||
|
@ -115,7 +115,7 @@ local function is_potion_of_type(item, type)
|
|||
local materials = ComponentGetValue2(mat, "count_per_material_type")
|
||||
local other = 0
|
||||
local water = 0
|
||||
for id, amt in pairs(materials) do
|
||||
for id, amt in pairs(materials or {}) do
|
||||
if amt ~= 0 then
|
||||
local name = CellFactory_GetName(id - 1)
|
||||
local use = false
|
||||
|
@ -145,7 +145,7 @@ local function find_new_wand()
|
|||
else
|
||||
local bad_mod = false
|
||||
local is_any_not_empty = false
|
||||
for _, child in pairs(children) do
|
||||
for _, child in pairs(children or {}) do
|
||||
local is_proj = false
|
||||
local is_bad_proj = false
|
||||
local sprites = EntityGetComponentIncludingDisabled(child, "SpriteComponent")
|
||||
|
|
|
@ -24,9 +24,7 @@ local iter_fast = 0
|
|||
|
||||
local iter_slow = 0
|
||||
|
||||
function round(x)
|
||||
return x >= 0 and math.floor(x + 0.5) or math.ceil(x - 0.5)
|
||||
end
|
||||
local iter_slow_2 = 0
|
||||
|
||||
function world_sync.on_world_initialized()
|
||||
local c = 0
|
||||
|
@ -61,81 +59,113 @@ local function get_all_chunks(ocx, ocy, pos_data, priority)
|
|||
local grid_world = world_ffi.get_grid_world()
|
||||
local chunk_map = grid_world.vtable.get_chunk_map(grid_world)
|
||||
--local thread_impl = grid_world.mThreadImpl
|
||||
local int = 3 -- ctx.proxy_opt.world_sync_interval
|
||||
local int = 4 -- ctx.proxy_opt.world_sync_interval
|
||||
if GameGetFrameNum() % int == 0 then
|
||||
for cx = ocx - 1, ocx do
|
||||
for cy = ocy - 1, ocy do
|
||||
send_chunks(cx, cy, chunk_map)
|
||||
end
|
||||
end
|
||||
send_chunks(ocx, ocy, chunk_map)
|
||||
net.proxy_bin_send(KEY_WORLD_END, string.char(priority))
|
||||
elseif GameGetFrameNum() % (int * 2) == 1 then
|
||||
local nx = ocx
|
||||
if iter_fast == 1 or iter_fast == 2 then
|
||||
nx = nx - 2
|
||||
elseif GameGetFrameNum() % int == 2 then
|
||||
if iter_fast == 0 then
|
||||
send_chunks(ocx + 1, ocy, chunk_map)
|
||||
send_chunks(ocx + 1, ocy + 1, chunk_map)
|
||||
elseif iter_fast == 1 then
|
||||
send_chunks(ocx, ocy + 1, chunk_map)
|
||||
send_chunks(ocx - 1, ocy + 1, chunk_map)
|
||||
elseif iter_fast == 2 then
|
||||
send_chunks(ocx - 1, ocy, chunk_map)
|
||||
send_chunks(ocx - 1, ocy - 1, chunk_map)
|
||||
else
|
||||
send_chunks(ocx, ocy - 1, chunk_map)
|
||||
send_chunks(ocx + 1, ocy - 1, chunk_map)
|
||||
end
|
||||
for cx = nx, nx + 1 do
|
||||
local ny = ocy
|
||||
if iter_fast == 2 or iter_fast == 3 then
|
||||
ny = ny - 2
|
||||
end
|
||||
for cy = ny, ny + 1 do
|
||||
if cx < ocx - 1 or cx > ocx or cy < ocy - 1 or cy > ocy then
|
||||
send_chunks(cx, cy, chunk_map)
|
||||
end
|
||||
end
|
||||
end
|
||||
net.proxy_bin_send(KEY_WORLD_END, string.char(priority --[[+ 1]]) .. pos_data)
|
||||
net.proxy_bin_send(KEY_WORLD_END, string.char(math.min(priority + 1, 16)))
|
||||
iter_fast = iter_fast + 1
|
||||
if iter_fast == 4 then
|
||||
iter_fast = 0
|
||||
end
|
||||
elseif priority == 0 and GameGetFrameNum() % (int * 4) == 4 then
|
||||
local nx = ocx
|
||||
if iter_slow == 1 or iter_slow == 2 then
|
||||
nx = nx - 3
|
||||
elseif GameGetFrameNum() % (int * 4) == 3 then
|
||||
if iter_slow == 0 then
|
||||
send_chunks(ocx + 2, ocy - 1, chunk_map)
|
||||
send_chunks(ocx + 2, ocy, chunk_map)
|
||||
send_chunks(ocx + 2, ocy + 1, chunk_map)
|
||||
send_chunks(ocx + 2, ocy + 2, chunk_map)
|
||||
elseif iter_slow == 1 then
|
||||
send_chunks(ocx + 1, ocy + 2, chunk_map)
|
||||
send_chunks(ocx, ocy + 2, chunk_map)
|
||||
send_chunks(ocx - 1, ocy + 2, chunk_map)
|
||||
send_chunks(ocx - 2, ocy + 2, chunk_map)
|
||||
elseif iter_slow == 2 then
|
||||
send_chunks(ocx - 2, ocy + 1, chunk_map)
|
||||
send_chunks(ocx - 2, ocy, chunk_map)
|
||||
send_chunks(ocx - 2, ocy - 1, chunk_map)
|
||||
send_chunks(ocx - 2, ocy - 2, chunk_map)
|
||||
else
|
||||
send_chunks(ocx - 1, ocy - 2, chunk_map)
|
||||
send_chunks(ocx, ocy - 2, chunk_map)
|
||||
send_chunks(ocx + 1, ocy - 2, chunk_map)
|
||||
send_chunks(ocx + 2, ocy - 2, chunk_map)
|
||||
end
|
||||
for cx = nx, nx + 2 do
|
||||
local ny = ocy
|
||||
if iter_slow == 2 or iter_slow == 3 then
|
||||
ny = ny - 3
|
||||
end
|
||||
for cy = ny, ny + 2 do
|
||||
if cx < ocx - 2 or cx > ocx + 1 or cy < ocy - 2 or cy > ocy + 1 then
|
||||
send_chunks(cx, cy, chunk_map)
|
||||
end
|
||||
end
|
||||
end
|
||||
net.proxy_bin_send(KEY_WORLD_END, string.char(priority --[[+ 2]]))
|
||||
net.proxy_bin_send(KEY_WORLD_END, string.char(math.min(priority + 2, 16)) .. pos_data)
|
||||
iter_slow = iter_slow + 1
|
||||
if iter_slow == 4 then
|
||||
iter_slow = 0
|
||||
end
|
||||
elseif priority == 0 and GameGetFrameNum() % (int * 3) == 1 then
|
||||
if iter_slow_2 == 0 then
|
||||
send_chunks(ocx + 3, ocy, chunk_map)
|
||||
send_chunks(ocx + 3, ocy + 1, chunk_map)
|
||||
send_chunks(ocx + 3, ocy + 2, chunk_map)
|
||||
send_chunks(ocx + 3, ocy + 3, chunk_map)
|
||||
elseif iter_slow_2 == 1 then
|
||||
send_chunks(ocx + 2, ocy + 3, chunk_map)
|
||||
send_chunks(ocx + 1, ocy + 3, chunk_map)
|
||||
send_chunks(ocx, ocy + 3, chunk_map)
|
||||
send_chunks(ocx - 1, ocy + 3, chunk_map)
|
||||
elseif iter_slow_2 == 2 then
|
||||
send_chunks(ocx - 2, ocy + 3, chunk_map)
|
||||
send_chunks(ocx - 3, ocy + 3, chunk_map)
|
||||
send_chunks(ocx - 3, ocy + 2, chunk_map)
|
||||
send_chunks(ocx - 3, ocy + 1, chunk_map)
|
||||
elseif iter_slow_2 == 3 then
|
||||
send_chunks(ocx - 3, ocy, chunk_map)
|
||||
send_chunks(ocx - 3, ocy - 1, chunk_map)
|
||||
send_chunks(ocx - 3, ocy - 2, chunk_map)
|
||||
send_chunks(ocx - 3, ocy - 3, chunk_map)
|
||||
elseif iter_slow_2 == 4 then
|
||||
send_chunks(ocx - 2, ocy - 3, chunk_map)
|
||||
send_chunks(ocx - 1, ocy - 3, chunk_map)
|
||||
send_chunks(ocx, ocy - 3, chunk_map)
|
||||
send_chunks(ocx + 1, ocy - 3, chunk_map)
|
||||
else
|
||||
send_chunks(ocx + 2, ocy - 3, chunk_map)
|
||||
send_chunks(ocx + 3, ocy - 3, chunk_map)
|
||||
send_chunks(ocx + 3, ocy - 2, chunk_map)
|
||||
send_chunks(ocx + 3, ocy - 1, chunk_map)
|
||||
end
|
||||
net.proxy_bin_send(KEY_WORLD_END, string.char(math.min(priority + 2, 16)))
|
||||
iter_slow_2 = iter_slow_2 + 1
|
||||
if iter_slow_2 == 6 then
|
||||
iter_slow_2 = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function world_sync.on_world_update()
|
||||
local cx, cy = GameGetCameraPos()
|
||||
cx, cy = round(cx / CHUNK_SIZE), round(cy / CHUNK_SIZE)
|
||||
cx, cy = math.floor(cx / CHUNK_SIZE), math.floor(cy / CHUNK_SIZE) + 1
|
||||
local player_data = ctx.my_player
|
||||
if not EntityGetIsAlive(player_data.entity) then
|
||||
return
|
||||
end
|
||||
local px, py = EntityGetTransform(player_data.entity)
|
||||
-- Original Chunk x/y
|
||||
local ocx, ocy = round(px / CHUNK_SIZE), round(py / CHUNK_SIZE)
|
||||
local ocx, ocy = math.floor(px / CHUNK_SIZE), math.floor(py / CHUNK_SIZE) + 1
|
||||
local pos_data = ocx..":"..ocy..":"..cx..":"..cy
|
||||
if math.abs(cx - ocx) > 2 or math.abs(cy - ocy) > 2 then
|
||||
if iter_cam then
|
||||
if GameGetFrameNum() % 3 ~= 2 then
|
||||
get_all_chunks(cx, cy, pos_data, 16)
|
||||
else
|
||||
get_all_chunks(ocx, ocy, pos_data, 16)
|
||||
end
|
||||
local int = 3 -- ctx.proxy_opt.world_sync_interval
|
||||
if GameGetFrameNum() % (int * 8) == 0 then
|
||||
iter_cam = not iter_cam
|
||||
end
|
||||
else
|
||||
local pri = 0
|
||||
if EntityHasTag(ctx.my_player.entity, "ew_notplayer") then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue