Closed sprunk closed 2 weeks ago
@sprunk Can you clarify, maybe pointing out how this is set somewhere else?
All other unit-related callins' implementations consist of passing their name to UnitCallIn()
, for example:
https://github.com/beyond-all-reason/spring/blob/fd7de2625116007a28eab9af9e06bd0066c92617/rts/Lua/LuaHandle.cpp#L1373-L1377
https://github.com/beyond-all-reason/spring/blob/fd7de2625116007a28eab9af9e06bd0066c92617/rts/Lua/LuaHandle.cpp#L1621-L1625
UnitCallIn
pushes the relevant Lua function on top of the Lua stack via GetGlobalFunc
:
https://github.com/beyond-all-reason/spring/blob/fd7de2625116007a28eab9af9e06bd0066c92617/rts/Lua/LuaHandle.cpp#L968-L976
UnitArrivedAtGoal()
differs from all other callins implemented via UnitCallIn
in that it manually calls GetGlobalFunc
first, which puts a second copy of the Lua function on the Lua stack.
https://github.com/beyond-all-reason/spring/blob/fd7de2625116007a28eab9af9e06bd0066c92617/rts/Lua/LuaHandle.cpp#L1852-L1861
This extra copy on the stack does not get cleaned up and is what causes the "stack-top = 1" warning.
UnitCallIn
already puts the function on the stack. Fixes #1523