JurkerKunde Posted March 6, 2015 Share Posted March 6, 2015 Bug Submission:Category: GeneralIssue Title: mainfunctions.lua:SetDebugEntity breaks when debug-entity is set to an "non-entity" (missing member-check)Issue Description:Version: 129194Don't Starve Together: 129194 LINUXBuild Date: 2015-03-05_11-21-22I was tempering around with the console of my dedicated server, when I accidentally issued c_select(). After that, every attempt to c_select anything, crashed with[string "scripts/mainfunctions.lua"]:364: attempt to index upvalue 'debug_entity' (a number value)So did calling SetDebugEntity directly.Investigation revealed that SetDebugEntity just checks for local debug_entity and tries to execute the member function .entity:SetSelected(false). The check should be extended toif debug_entity and type(debug_entity) == "table" and debug_entity.entity thenThis is not directly a bug, but since I had to reset the server, implementing this check would be very convenient.Steps to Reproduce: c_select(123)ConsoleInput: "c_select(123)"[string "scripts/mainfunctions.lua"]:368: attempt to index local 'inst' (a number value)c_select(AllPlayers[1])ConsoleInput: "c_select(AllPlayers[1])"[string "scripts/mainfunctions.lua"]:364: attempt to index upvalue 'debug_entity' (a number value)-or- SetDebugEntity(123)ConsoleInput: "SetDebugEntity(123)"[string "scripts/mainfunctions.lua"]:368: attempt to index local 'inst' (a number value)SetDebugEntity(AllPlayers[1])ConsoleInput: "SetDebugEntity(AllPlayers[1])"[string "scripts/mainfunctions.lua"]:364: attempt to index upvalue 'debug_entity' (a number value) Link to comment Share on other sites More sharing options...
JurkerKunde Posted March 6, 2015 Author Share Posted March 6, 2015 Sorry, it should be "when I accidentally issued c_select(123)". Link to comment Share on other sites More sharing options...
JurkerKunde Posted March 6, 2015 Author Share Posted March 6, 2015 Thinking about it, it would also be good, if the check would be made before the call to inst.entity:SetSelected(true), as this fails, too.function SetDebugEntity(inst) if debug_entity and type(debug_entity) == table and debug_entity.entity then debug_entity.entity:SetSelected(false) end debug_entity = inst if inst and type(inst) == "table" and inst.entity then inst.entity:SetSelected(true) endend If you dont want to have anything else in debug_value then an "entity" or nil, one could do something likefunction SetDebugEntity(inst) if debug_entity then debug_entity.entity:SetSelected(false) end if type(inst) == "table" and inst.entity then debug_entity = inst else debug_entity = nil end if inst then inst.entity:SetSelected(true) endendThat depends on whether you want to allow other types then "entity" to be allowed to get saved. I think, this isnt really necessary, but one could use this to store a no-the-fly function or something else, which one wouldn't have to store in a local variable. On the other hand other functions could rely an the fact, that there is an "entity" stored, too. Link to comment 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.