make orbs harder to dupe, sync less chunks in a single frame, sync pos data less oftern

This commit is contained in:
bgkillas 2024-08-31 05:53:55 -04:00
parent d329c318c0
commit 96d32007b2
2 changed files with 17 additions and 11 deletions

View file

@ -49,10 +49,9 @@ local function send_orbs()
end end
function module.on_world_update() function module.on_world_update()
if GameGetFrameNum() % 10 == 0 then if GameGetFrameNum() % 3 == 0 then
local found_local = orbs_found_this_run() local found_local = orbs_found_this_run()
local x, y = EntityGetTransform(ctx.my_player.entity) for _, orb_ent in ipairs(EntityGetWithTag("hittable") or {}) do
for _, orb_ent in ipairs(EntityGetInRadiusWithTag(x, y, 300, "hittable") or {}) do
local comp = EntityGetFirstComponent(orb_ent, "OrbComponent") local comp = EntityGetFirstComponent(orb_ent, "OrbComponent")
if comp ~= nil then if comp ~= nil then
local orb = ComponentGetValue2(comp, "orb_id") local orb = ComponentGetValue2(comp, "orb_id")

View file

@ -20,7 +20,7 @@ local CHUNK_SIZE = 128
local iter_cam = false local iter_cam = false
local iter_fast = false local iter_fast = 0
local iter_slow = 0 local iter_slow = 0
@ -68,21 +68,28 @@ local function get_all_chunks(ocx, ocy, pos_data, priority)
send_chunks(cx, cy, chunk_map) send_chunks(cx, cy, chunk_map)
end end
end end
net.proxy_bin_send(KEY_WORLD_END, string.char(priority) .. pos_data) net.proxy_bin_send(KEY_WORLD_END, string.char(priority))
elseif GameGetFrameNum() % (int * 2) == 1 then elseif GameGetFrameNum() % (int * 2) == 1 then
local nx = ocx local nx = ocx
if iter_fast then if iter_fast == 1 or iter_fast == 2 then
nx = nx - 2 nx = nx - 2
end end
for cx = nx, nx + 1 do for cx = nx, nx + 1 do
for cy = ocy - 2, ocy + 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 if cx < ocx - 1 or cx > ocx or cy < ocy - 1 or cy > ocy then
send_chunks(cx, cy, chunk_map) send_chunks(cx, cy, chunk_map)
end end
end end
end end
net.proxy_bin_send(KEY_WORLD_END, string.char(priority + 1)) net.proxy_bin_send(KEY_WORLD_END, string.char(priority + 1) .. pos_data)
iter_fast = not iter_fast iter_fast = iter_fast + 1
if iter_fast == 4 then
iter_fast = 0
end
elseif priority == 0 and GameGetFrameNum() % (int * 4) == 4 then elseif priority == 0 and GameGetFrameNum() % (int * 4) == 4 then
local nx = ocx local nx = ocx
if iter_slow == 1 or iter_slow == 2 then if iter_slow == 1 or iter_slow == 2 then
@ -90,7 +97,7 @@ local function get_all_chunks(ocx, ocy, pos_data, priority)
end end
for cx = nx, nx + 2 do for cx = nx, nx + 2 do
local ny = ocy local ny = ocy
if iter_slow == 0 or iter_slow == 1 then if iter_slow == 2 or iter_slow == 3 then
ny = ny - 3 ny = ny - 3
end end
for cy = ny, ny + 2 do for cy = ny, ny + 2 do
@ -126,7 +133,7 @@ function world_sync.on_world_update()
get_all_chunks(ocx, ocy, pos_data, 32) get_all_chunks(ocx, ocy, pos_data, 32)
end end
local int = 3 -- ctx.proxy_opt.world_sync_interval local int = 3 -- ctx.proxy_opt.world_sync_interval
if GameGetFrameNum() % (int * 4) == 0 then if GameGetFrameNum() % (int * 8) == 0 then
iter_cam = not iter_cam iter_cam = not iter_cam
end end
else else