HelicopterRevival


Adds a fully animated attack helicopter to the game. Ideal for getting from A to B quickly, exploring the map, building islands and nuking biters from the sky. Originally forked from Kumpu with fixes for Factorio 0.18.2+, but adding some enhancements of my own as well.

Content
a month ago
0.18 - 2.0
80.2K
Transportation

b Crash if selecting a nonexistant helipad.

2 years ago

Found a bug!

If you open the remote control GUI, remove a helipad and then select the camera showing the now-removed helipad, the server crashes.
(I would imagine this happens in singleplayer, too.)

I think the issue is in "logic/gui/heliPadSelectionGui.lua", line 51.

      local cam = searchInTable(self.guiElems.cams, camID, "ID")
      self.manager:OnChildEvent(self, "selectedPosition", cam.heliPad.baseEnt.position)

I think 'searchInTable' will return nil if the helipad is removed, causing the 'cam' table lookups to error.
Untested, but I think this should prevent the crash:

      local cam = searchInTable(self.guiElems.cams, camID, "ID")
      if cam ~= nil then
          self.manager:OnChildEvent(self, "selectedPosition", cam.heliPad.baseEnt.position)
      end

Although I'm not exactly sure how Factorio's GUI API works, so perhaps there's more to this.

Here's the stacktrace:

133881.684 Info AppManager.cpp:306: Saving to _autosave4 (blocking).
133883.006 Info AppManagerStates.cpp:1943: Saving finished
descend OnUp
134312.584 Error MainLoop.cpp:1284: Exception at tick 33469776: The mod HelicopterRevival (0.2.1) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event HelicopterRevival::on_gui_click (ID 1)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
        [C]: in function '__index'
        __HelicopterRevival__/logic/gui/heliPadSelectionGui.lua:51: in function 'OnCamClicked'
        __HelicopterRevival__/logic/gui/heliPadSelectionGui.lua:39: in function 'OnGuiClick'
        __HelicopterRevival__/logic/gui/remoteGui.lua:100: in function 'OnGuiClick'
        __HelicopterRevival__/control.lua:291: in function <__HelicopterRevival__/control.lua:271>
134312.585 Error ServerMultiplayerManager.cpp:91: MultiplayerManager failed: "The mod HelicopterRevival (0.2.1) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event HelicopterRevival::on_gui_click (ID 1)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
        [C]: in function '__index'
        __HelicopterRevival__/logic/gui/heliPadSelectionGui.lua:51: in function 'OnCamClicked'
        __HelicopterRevival__/logic/gui/heliPadSelectionGui.lua:39: in function 'OnGuiClick'
        __HelicopterRevival__/logic/gui/remoteGui.lua:100: in function 'OnGuiClick'
        __HelicopterRevival__/control.lua:291: in function <__HelicopterRevival__/control.lua:271>"
134312.585 Info ServerMultiplayerManager.cpp:794: updateTick(33469776) changing state from(InGame) to(Failed)
134312.600 Quitting: multiplayer error.

New response