Skip to content

Auto Reclaim/Heal/Assist widget causes idle con count to not decrease if con dies #5811

Description

@Petronous

This concerns widgets gui_chili_core_selector.lua and unit_auto_reclaim_heal_assist.lua.

Auto Reclaim/Heal/Assist widget causes idle con count to not decrease if con dies

Steps to reproduce:

  1. Launch a fresh ZK install / have default settings
  2. Start skirmish, enable Auto Reclaim/Heal/Assist widget
  3. place commander, plop factory
  4. Ctrl-K commander

Expected result:

number of idle cons is 0

Actual Result:

number of idle cons ticks to 0 for a moment and immediately goes back to 1

Likely cause:

The auto reclaim widget has a ConController object which keeps track of a given con, and deletes itself when the con dies. The deletion function is ConController.unset, triggered, among other things, by widget:UnitDestroyed:

	unset = function(self)
		-- Echo("IdleConAssist removed: " .. self.unitID)
		GiveOrderToUnit(self.unitID,CMD.STOP, {}, {""},1)
		return nil
	end,

Following liberal use of Spring.Echo, I found that Spring seemingly lets the widget issue an order even to a dead unit, which then triggers the UnitIdle callin (after the order "completes") in the core selector widget, after UnitDestroyed already fired. This creates a ghost idle constructor that will never go away.

Proposed solutions:

a) Make core selector somehow check that the newly idle unit is still alive. (possibly by Spring.GetUnitIsDead?)
b) Stop auto reclaim from issuing orders if unset was called after the unit was destroyed.
c) Engine change to completely block commands to dead units (granted, I'm guessing with this, no idea what really goes on in the engine)

Of these, c) might be cleanest, but i have no idea how difficult that would be, a) is probably more future-proof, and b) seems simplest.

As a) or b) sound like they'd be very simple changes of a few lines, I could do it myself and make a PR, depending on what the preferred solution is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions