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 (x, y) = my_pos;
|
||||||
let (cx, cy) = cam_pos;
|
let (cx, cy) = cam_pos;
|
||||||
if (x - cx).abs() <= 2 && (y - cy).abs() <= 2 {
|
if (x - cx).abs() <= 2 && (y - cy).abs() <= 2 {
|
||||||
!(chx <= x + 2 && chx >= x - 3
|
!(chx <= x + 3 && chx >= x - 3
|
||||||
&& chy <= y + 2 && chy >= y - 3)
|
&& chy <= y + 3 && chy >= y - 3)
|
||||||
} else {
|
} else {
|
||||||
!(chx <= x + 1 && chx >= x - 2
|
!(chx <= x + 2 && chx >= x - 2
|
||||||
&& chy <= y + 1 && chy >= y - 2)
|
&& chy <= y + 2 && chy >= y - 2)
|
||||||
&& !(chx <= cx + 1 && chx >= cx - 2
|
&& !(chx <= cx + 2 && chx >= cx - 2
|
||||||
&& chy <= cy + 1 && chy >= cy - 2)
|
&& chy <= cy + 2 && chy >= cy - 2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut emit_queue = Vec::new();
|
let mut emit_queue = Vec::new();
|
||||||
|
@ -503,15 +503,10 @@ impl WorldManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WorldNetMessage::ListenUpdate { delta, priority } => {
|
WorldNetMessage::ListenUpdate { delta, priority } => {
|
||||||
let Some(ChunkState::Listening { priority: pri, .. }) = self.chunk_state.get_mut(&delta.chunk_coord)
|
if let Some(ChunkState::Listening { priority: pri, .. }) = self.chunk_state.get_mut(&delta.chunk_coord)
|
||||||
else {
|
{
|
||||||
/*warn!(
|
*pri = priority;
|
||||||
"Can't handle ListenUpdate for {:?} - not a listener",
|
}
|
||||||
delta.chunk_coord
|
|
||||||
);*/
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
*pri = priority;
|
|
||||||
self.inbound_model.apply_chunk_delta(&delta);
|
self.inbound_model.apply_chunk_delta(&delta);
|
||||||
}
|
}
|
||||||
WorldNetMessage::ListenAuthorityRelinquished { chunk } => {
|
WorldNetMessage::ListenAuthorityRelinquished { chunk } => {
|
||||||
|
|
|
@ -74,7 +74,7 @@ local function get_potions_of_type(type)
|
||||||
if children_items == nil then
|
if children_items == nil then
|
||||||
return potions
|
return potions
|
||||||
end
|
end
|
||||||
for _, item in ipairs(children_items) do
|
for _, item in ipairs(children_items or {}) do
|
||||||
if EntityHasTag(item, "potion") then
|
if EntityHasTag(item, "potion") then
|
||||||
local mat = EntityGetFirstComponent(item, "MaterialInventoryComponent")
|
local mat = EntityGetFirstComponent(item, "MaterialInventoryComponent")
|
||||||
local materials = ComponentGetValue2(mat, "count_per_material_type")
|
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 materials = ComponentGetValue2(mat, "count_per_material_type")
|
||||||
local other = 0
|
local other = 0
|
||||||
local water = 0
|
local water = 0
|
||||||
for id, amt in pairs(materials) do
|
for id, amt in pairs(materials or {}) do
|
||||||
if amt ~= 0 then
|
if amt ~= 0 then
|
||||||
local name = CellFactory_GetName(id - 1)
|
local name = CellFactory_GetName(id - 1)
|
||||||
local use = false
|
local use = false
|
||||||
|
@ -145,7 +145,7 @@ local function find_new_wand()
|
||||||
else
|
else
|
||||||
local bad_mod = false
|
local bad_mod = false
|
||||||
local is_any_not_empty = 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_proj = false
|
||||||
local is_bad_proj = false
|
local is_bad_proj = false
|
||||||
local sprites = EntityGetComponentIncludingDisabled(child, "SpriteComponent")
|
local sprites = EntityGetComponentIncludingDisabled(child, "SpriteComponent")
|
||||||
|
|
|
@ -24,9 +24,7 @@ local iter_fast = 0
|
||||||
|
|
||||||
local iter_slow = 0
|
local iter_slow = 0
|
||||||
|
|
||||||
function round(x)
|
local iter_slow_2 = 0
|
||||||
return x >= 0 and math.floor(x + 0.5) or math.ceil(x - 0.5)
|
|
||||||
end
|
|
||||||
|
|
||||||
function world_sync.on_world_initialized()
|
function world_sync.on_world_initialized()
|
||||||
local c = 0
|
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 grid_world = world_ffi.get_grid_world()
|
||||||
local chunk_map = grid_world.vtable.get_chunk_map(grid_world)
|
local chunk_map = grid_world.vtable.get_chunk_map(grid_world)
|
||||||
--local thread_impl = grid_world.mThreadImpl
|
--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
|
if GameGetFrameNum() % int == 0 then
|
||||||
for cx = ocx - 1, ocx do
|
send_chunks(ocx, ocy, chunk_map)
|
||||||
for cy = ocy - 1, ocy do
|
|
||||||
send_chunks(cx, cy, chunk_map)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
net.proxy_bin_send(KEY_WORLD_END, string.char(priority))
|
net.proxy_bin_send(KEY_WORLD_END, string.char(priority))
|
||||||
elseif GameGetFrameNum() % (int * 2) == 1 then
|
elseif GameGetFrameNum() % int == 2 then
|
||||||
local nx = ocx
|
if iter_fast == 0 then
|
||||||
if iter_fast == 1 or iter_fast == 2 then
|
send_chunks(ocx + 1, ocy, chunk_map)
|
||||||
nx = nx - 2
|
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
|
end
|
||||||
for cx = nx, nx + 1 do
|
net.proxy_bin_send(KEY_WORLD_END, string.char(math.min(priority + 1, 16)))
|
||||||
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)
|
|
||||||
iter_fast = iter_fast + 1
|
iter_fast = iter_fast + 1
|
||||||
if iter_fast == 4 then
|
if iter_fast == 4 then
|
||||||
iter_fast = 0
|
iter_fast = 0
|
||||||
end
|
end
|
||||||
elseif priority == 0 and GameGetFrameNum() % (int * 4) == 4 then
|
elseif GameGetFrameNum() % (int * 4) == 3 then
|
||||||
local nx = ocx
|
if iter_slow == 0 then
|
||||||
if iter_slow == 1 or iter_slow == 2 then
|
send_chunks(ocx + 2, ocy - 1, chunk_map)
|
||||||
nx = nx - 3
|
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
|
end
|
||||||
for cx = nx, nx + 2 do
|
net.proxy_bin_send(KEY_WORLD_END, string.char(math.min(priority + 2, 16)) .. pos_data)
|
||||||
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]]))
|
|
||||||
iter_slow = iter_slow + 1
|
iter_slow = iter_slow + 1
|
||||||
if iter_slow == 4 then
|
if iter_slow == 4 then
|
||||||
iter_slow = 0
|
iter_slow = 0
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function world_sync.on_world_update()
|
function world_sync.on_world_update()
|
||||||
local cx, cy = GameGetCameraPos()
|
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
|
local player_data = ctx.my_player
|
||||||
if not EntityGetIsAlive(player_data.entity) then
|
if not EntityGetIsAlive(player_data.entity) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local px, py = EntityGetTransform(player_data.entity)
|
local px, py = EntityGetTransform(player_data.entity)
|
||||||
-- Original Chunk x/y
|
-- 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
|
local pos_data = ocx..":"..ocy..":"..cx..":"..cy
|
||||||
if math.abs(cx - ocx) > 2 or math.abs(cy - ocy) > 2 then
|
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)
|
get_all_chunks(cx, cy, pos_data, 16)
|
||||||
else
|
else
|
||||||
get_all_chunks(ocx, ocy, pos_data, 16)
|
get_all_chunks(ocx, ocy, pos_data, 16)
|
||||||
end
|
end
|
||||||
local int = 3 -- ctx.proxy_opt.world_sync_interval
|
|
||||||
if GameGetFrameNum() % (int * 8) == 0 then
|
|
||||||
iter_cam = not iter_cam
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
local pri = 0
|
local pri = 0
|
||||||
if EntityHasTag(ctx.my_player.entity, "ew_notplayer") then
|
if EntityHasTag(ctx.my_player.entity, "ew_notplayer") then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue