mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
Should fix host crash when throwing items on clients.
This commit is contained in:
parent
1fdb8da46c
commit
a35e899029
2 changed files with 20 additions and 6 deletions
4
Justfile
4
Justfile
|
@ -12,3 +12,7 @@ run2:
|
|||
|
||||
release:
|
||||
python prepare_release.py
|
||||
|
||||
noita:
|
||||
cd /home/quant/.local/share/Steam/steamapps/common/Noita/ && NP_NOITA_ADDR=127.0.0.1:21252 wine noita.exe -gamemode 0
|
||||
|
|
@ -66,9 +66,15 @@ function item_sync.host_localize_item(gid, peer_id)
|
|||
ctx.lib.net.send_localize(peer_id, gid)
|
||||
end
|
||||
|
||||
function item_sync.make_item_global(item)
|
||||
function item_sync.make_item_global(item, instant)
|
||||
async(function()
|
||||
wait(1) -- Wait 1 frame so that game sets proper velocity.
|
||||
if not instant then
|
||||
wait(1) -- Wait 1 frame so that game sets proper velocity.
|
||||
end
|
||||
if not EntityGetIsAlive(item) then
|
||||
GamePrint("Thrown item vanished before we could send it")
|
||||
return
|
||||
end
|
||||
local g_id = EntityGetFirstComponentIncludingDisabled(item, "VariableStorageComponent", "ew_global_item_id")
|
||||
local id = ComponentGetValue2(g_id, "value_int")
|
||||
if g_id == nil then
|
||||
|
@ -134,9 +140,13 @@ function item_sync.on_world_update_client()
|
|||
local thrown_item = get_global_ent("ew_thrown")
|
||||
if thrown_item ~= nil and not EntityHasTag(thrown_item, "ew_client_item") then
|
||||
async(function ()
|
||||
wait(1) -- Wait 1 frame so that game sets proper velocity.
|
||||
ctx.lib.net.send_item_upload(inventory_helper.serialize_single_item(thrown_item))
|
||||
EntityKill(thrown_item)
|
||||
wait(1) -- Wait 1 frame so that game sets proper velocity.
|
||||
if not EntityGetIsAlive(thrown_item) then
|
||||
GamePrint("Thrown item vanished before we could send it")
|
||||
return
|
||||
end
|
||||
ctx.lib.net.send_item_upload(inventory_helper.serialize_single_item(thrown_item))
|
||||
EntityKill(thrown_item)
|
||||
end)
|
||||
end
|
||||
|
||||
|
@ -152,7 +162,7 @@ function item_sync.upload(item_data)
|
|||
local item = inventory_helper.deserialize_single_item(item_data)
|
||||
EntityAddTag(item, "ew_global_item")
|
||||
item_sync.ensure_notify_component(item)
|
||||
item_sync.make_item_global(item)
|
||||
item_sync.make_item_global(item, true)
|
||||
end
|
||||
|
||||
return item_sync
|
Loading…
Add table
Add a link
Reference in a new issue