Skip to content

Commit

Permalink
Fix wrapping of toplevel gadget callins returning several parameters. (
Browse files Browse the repository at this point in the history
…#3947)

Fix wrapping of top level callins returning several parameters, this fixes a bug introduced in #3907
Affected methods: GameSetup, AllowWeaponTarget, UnitPreDamaged, FeaturePreDamaged

Likely affected gadgets:
* GameSetup: none, still it can be affecting some engine calls since it will always return newReady nil, although afaics the engine won't accept the nil value so it shouldn't be affecting it.
* AllowWeaponTarget (affects returned priority): unit_aa_targeting_priority.
* UnitPreDamaged (affects impulse only): unit_combomb_full_damage, unit_dgun_behaviour, engine_hotfixes, unit_paralyze_damage_multiplier, map_lava, unit_paralyze_on_off, unit_collision_damage_behavior, unit_timeslow, unit_objectify, unit_evolution, unit_commando_watch, unit_shield_behaviour, unit_single_damage_fire, unit_lightning_splash_dmg, mo_preventcombomb, scav_spawner_defense, unit_no_land_damage.
* FeaturePreDamaged (affects impulse only): gfx_tree_feller.
  • Loading branch information
saurtron authored Nov 21, 2024
1 parent 2d6ba1a commit ac209d4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions luarules/gadgets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ gadgetHandler = {
}



-- these call-ins are set to 'nil' if not used
-- they are setup in UpdateCallIns()
local callInLists = {
Expand Down Expand Up @@ -812,17 +811,18 @@ function gadgetHandler:UpdateCallIn(name)
local selffunc = self[name]

if selffunc ~= nil then
-- max 2 return parameters for top level callins!
_G[name] = function(...)
callinDepth = callinDepth + 1

local res = selffunc(self, ...)
local res1, res2 = selffunc(self, ...)

callinDepth = callinDepth - 1
if reorderNeeded and callinDepth == 0 then
self:PerformReorders()
end

return res
return res1, res2
end
else
Spring.Log(LOG_SECTION, LOG.ERROR, "UpdateCallIn: " .. name .. " is not implemented")
Expand Down

0 comments on commit ac209d4

Please sign in to comment.