Closed Craxy closed 7 years ago
Further logging from Boehrsi:
Message: [TrafficLights] Level loading [Modding]
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
Message: [TrafficLights] Level loaded [Modding]
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
GfxDevice: creating device client; threaded=1
GfxDevice: creating device client; threaded=1
GfxDevice: creating device client; threaded=1
GfxDevice: creating device client; threaded=1
GfxDevice: creating device client; threaded=1
GfxDevice: creating device client; threaded=1
GfxDevice: creating device client; threaded=1
GfxDevice: creating device client; threaded=1
Error: [TrafficLights] SetTool returned null.
Collected tools: System.Collections.Generic.KeyValuePair`2[[System.Type, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[ToolBase, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Collections.Generic.KeyValuePair`2[[System.Type, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[ToolBase, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Collections.Generic.KeyValuePair`2[[System.Type, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[ToolBase, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Collections.Generic.KeyValuePair`2[[System.Type, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[ToolBase, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Collections.Generic.KeyValuePair`2[[System.Type, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[ToolBase, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Collections.Generic.KeyValuePair`2[[System.Type, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[ToolBase, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Collections.Generic.KeyValuePair`2[[System.Type, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[ToolBase, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Collections.Generic.KeyValuePair`2[[System.Type, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[ToolBase, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Collections.Generic.KeyValuePair`2[[System.Type, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[ToolBase, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Collections.Generic.KeyValuePair`2[[System.Type, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[ToolBase, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Collections.Generic.KeyValuePair`2[[System.Type, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[ToolBase, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Collections.Generic.KeyValuePair`2[[System.Type, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[ToolBase, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Collections.Generic.KeyValuePair`2[[System.Type, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[ToolBase, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Collections.Generic.KeyValuePair`2[[System.Type, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[ToolBase, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Collections.Generic.KeyValuePair`2[[System.Type, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[ToolBase, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Collections.Generic.KeyValuePair`2[[System.Type, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[ToolBase, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Collections.Generic.KeyValuePair`2[[System.Type, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[ToolBase, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Collections.Generic.KeyValuePair`2[[System.Type, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[ToolBase, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]
Added Components: DefaultTool, NetTool, BulldozeTool, ZoneTool, BuildingTool, PropTool, TreeTool, TransportTool, DistrictTool, GameAreaTool, CameraTool, IdleTool, TerrainTool, DisasterTool, PropLineTool.PropLineTool, MoveIt.MoveItTool, WaterTool, ResourceTool, SurfacePainter.InGameSurfaceTool, Craxy.CitiesSkylines.ToggleTrafficLights.Tools.JunctionTool [Modding]
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
NullReferenceException: Object reference not set to an instance of an object
at Craxy.CitiesSkylines.ToggleTrafficLights.Game.Behaviours.MainMachine.ActivateIntersectionTool (Boolean keepInfoMode, Elevation elevation) [0x00000] in <filename unknown>:0
at Craxy.CitiesSkylines.ToggleTrafficLights.Game.Behaviours.MainMachine.OnMessage (Message message) [0x00000] in <filename unknown>:0
at Craxy.CitiesSkylines.ToggleTrafficLights.Game.Behaviours.MainMachine.Send (Message message) [0x00000] in <filename unknown>:0
at Craxy.CitiesSkylines.ToggleTrafficLights.Game.Behaviours.ToggleTrafficLightsButton.OnButtonClick (ColossalFramework.UI.UIComponent _, ColossalFramework.UI.UIMouseEventParameter e) [0x00000] in <filename unknown>:0
at ColossalFramework.UI.UIComponent.OnClick (ColossalFramework.UI.UIMouseEventParameter p) [0x00000] in <filename unknown>:0
at ColossalFramework.UI.UIButton.OnClick (ColossalFramework.UI.UIMouseEventParameter p) [0x00000] in <filename unknown>:0
at ColossalFramework.UI.UIInput+MouseHandler.ProcessInput (IInputTranslator translator, Ray ray, ColossalFramework.UI.UIComponent component, Boolean retainFocusSetting) [0x00000] in <filename unknown>:0
at ColossalFramework.UI.UIInput.ProcessMouseInput () [0x00000] in <filename unknown>:0
at ColossalFramework.UI.UIInput.Update () [0x00000] in <filename unknown>:0
(Filename: Line: -1)
(yes -- I forgot that Dictionary returns KeyValuePair ... intended was of course Values -> GetType()
instead of KeyValuePairs -> GetType()
...)
The used mods are:
PropLineTool.PropLineTool
: https://github.com/Alterran/CS-PropLineToolMoveIt.MoveItTool
: https://github.com/SamsamTS/CS-MoveItWaterTool
, ResourceTool
: https://github.com/earalov/Skylines-NaturalResourcesBrushSurfacePainter.InGameSurfaceTool
: https://github.com/earalov/Skylines-SurfacePainterCraxy.CitiesSkylines.ToggleTrafficLights.Tools.JunctionTool
: https://github.com/Craxy/ToggleTrafficLightsPropLineTool and NaturalResourcesBrush both add their tools not only to ToolsModifierControl.m_Tools
(dictionary) but to ToolsModifierControl.toolController.m_tools
(array) too. TTL only adds the Junction Tool to ToolsModifierControl.m_Tools
. Probably one of these tools fill the dictionary with the tools from the array. So if TTL is loaded before (most likely) PropLineTool, the Junction Tool doesn't get added again and is therefore practically removed.
Changes in 8f6d388:
Instead of using ToolsModifierControl.m_Tools
and ToolsModifierControl.toolController.m_tools
, the Junction Tool isn't added to any of these lists any more. Therefore a special SetTool
for junction tool is used that searches in ToolsModifierControl.toolController.GetComponent<>
for the JunctionTool. The activation doesn't interfere with any of the internal lists any more. As a result the NullReferenceException
should occur for Boehrsi any more, and this issue is (hopefully) fixed.
Issue is kept open until feedback from Boehrsi.
Reported by Boehrsi: (23 Jul @ 2:56pm and 24 Jul @ 9:18am in TTL Comments)
Linked Stack Traces:
(source: https://gist.github.com/anonymous/44bb2c31e8cece76b7201f23d2533123 )
(source: https://gist.github.com/anonymous/027a64a62ddf8e66440b4a870949c623 )
Issue is:
ActivateAndReturnTool<JunctionTool>()
returnsnull
(and in the function:ToolsModifierControl.SetTool<T>()
returnsnull
). Thereforetool.CurrentElevation
throws aNullReferenceException
. That happens whenJunctionTool
isn't inToolsModifierControl.m_Tools
.JunctionTool
is added inMainMachine.Awake()->Setup()->SetupTool()
. ThereforeJunctionTool
should be inToolsModifierControl.m_Tools
-- but isn't for Boehrsi.Two ideas why that might be the case:
ToolsModifierControl.m_Tools
, probably by callingToolsModifierControl.CollectTools()
.JunctionTool
is added before C:S fillsToolsModifierControl.m_Tools
(by callingToolsModifierControl.CollectTools()
). Though in that case it's rather strange it's working for some, but not for others. Probably because of different loading behavior/speed? However, if it's because of C:S not collected the tools yet, it should be fixed by 54000e9. It adds aToolsModifierControl.GetCurrentTool()
which should invokeToolsModifierControl.CollectTools()
(unlessToolsModifierControl.toolController
isnull
).