Muche Posted January 11, 2016 Share Posted January 11, 2016 Bug Submission: Category: Client Crash Issue Title: Crash after setting invalid entity to net_entity Issue Description: Setting an entity that has been removed (thus is currently invalid) to net_entity causes hard crash. Also removing an entity assigned to net_entity sets the net_entity's value to nil, but dirty event is not fired. Steps to Reproduce: Host a world with following mod enabled: local function getdbgstr(inst) local str = tostring(inst) if inst ~= nil and inst.IsValid ~= nil then str = str .. "; IsValid=" .. tostring(inst:IsValid()) end return str end local function getnetdbgstr(net_var) local str = tostring(net_var) if net_var ~= nil then local val = net_var:value() str = str .. ", value=" .. getdbgstr(val) end return str end local function do3(inst) print("[TestMod:do3]#1 inst.net_testentity=" .. getnetdbgstr(inst.net_testentity)) local axe = inst.testentity print("[TestMod:do3]#2 axe=" .. getdbgstr(axe)) inst.net_testentity:set(axe) print("[TestMod:do3]#3 inst.net_testentity=" .. getnetdbgstr(inst.net_testentity)) print("[TestMod:do3]#4 inst.testentity=" .. getdbgstr(inst.testentity)) end local function do2(inst) print("[TestMod:do2]#1 inst.net_testentity=" .. getnetdbgstr(inst.net_testentity)) local entity = inst.net_testentity:value() if entity ~= nil then entity:Remove() end print("[TestMod:do2]#2 inst.net_testentity=" .. getnetdbgstr(inst.net_testentity)) print("[TestMod:do2]#3 inst.testentity=" .. getdbgstr(inst.testentity)) inst:DoTaskInTime(10, do3) end local function do1(inst) print("[TestMod:do1]#1 inst.net_testentity=" .. getnetdbgstr(inst.net_testentity)) local axe = GLOBAL.SpawnPrefab("axe") inst.net_testentity:set(axe) inst.testentity = axe print("[TestMod:do1]#2 inst.net_testentity=" .. getnetdbgstr(inst.net_testentity)) print("[TestMod:do1]#3 inst.testentity=" .. getdbgstr(inst.testentity)) inst:DoTaskInTime(10, do2) end local function OnTestEntityDirty(inst) print("[TestMod:OnTestEntityDirty]#1 inst.net_testentity=" .. getnetdbgstr(inst.net_testentity)) print("[TestMod:OnTestEntityDirty]#2 inst.testentity=" .. getdbgstr(inst.testentity)) end AddPrefabPostInit("player_classified", function(inst) inst.net_testentity = GLOBAL.net_entity(inst.GUID, "test.entity", "test.entitydirty") print("[TestMod:postinit] inst.net_testentity=" .. getnetdbgstr(inst.net_testentity)) inst:ListenForEvent("test.entitydirty", OnTestEntityDirty) inst:DoTaskInTime(10, do1) end) It produces following log: [00:00:31]: [TestMod:postinit] inst.net_testentity=net_entity (5D737798), value=nil [00:00:41]: [TestMod:do1]#1 inst.net_testentity=net_entity (5D737798), value=nil [00:00:41]: [TestMod:do1]#2 inst.net_testentity=net_entity (5D737798), value=109193 - axe; IsValid=true [00:00:41]: [TestMod:do1]#3 inst.testentity=109193 - axe; IsValid=true [00:00:41]: [TestMod:OnTestEntityDirty]#1 inst.net_testentity=net_entity (5D737798), value=109193 - axe; IsValid=true [00:00:41]: [TestMod:OnTestEntityDirty]#2 inst.testentity=109193 - axe; IsValid=true [00:00:51]: [TestMod:do2]#1 inst.net_testentity=net_entity (5D737798), value=109193 - axe; IsValid=true [00:00:51]: [TestMod:do2]#2 inst.net_testentity=net_entity (5D737798), value=nil [00:00:51]: [TestMod:do2]#3 inst.testentity=109193 - axe; IsValid=false [00:01:01]: [TestMod:do3]#1 inst.net_testentity=net_entity (5D737798), value=nil [00:01:01]: [TestMod:do3]#2 axe=109193 - axe; IsValid=false after that hard crash occurs - dontstarve_steam_162028_crash_2016_1_11T0_26_18C0.zip Also notice that dirty event is fired only once (on change from nil to axe), but not on change from axe to nil. Link to comment https://forums.kleientertainment.com/forums/topic/62264-client-crash-crash-after-setting-invalid-entity-to-net_entity/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.