FAForever / faf-coop-maps

Coop maps for FAF
8 stars 21 forks source link

UEF M5 Fix SMD check bug #441

Closed maudlin27 closed 4 months ago

maudlin27 commented 6 months ago

Fix bug when checking for units with SMD: -Previous code would error out if no units in the rectangle -Also included unnecessary logic to get local units before replacing local units immediately after -also didn't appear to actually check for the categories wanted

Error that prompted this change: WARNING: Error running lua script: ...alliance\maps\scca_coop_e05\scca_coop_e05_script.lua(485): attempt to loop over local `units' (a nil value) stack traceback: ...alliance\maps\scca_coop_e05\scca_coop_e05_script.lua(485): in function <...alliance\maps\scca_coop_e05\scca_coop_e05_script.lua:477>

speed2CZ commented 6 months ago

You should keep the first way of getting the units, you dont need to change the if condition then

maudlin27 commented 6 months ago

I'd still be changing the if condition to add the check that the unit has GetTacticalSiloAmmoCount, otherwise it could error out. This way also minimises the changes made to the original code approach (I don't think it ends up mattering in this case since ultimately it's just a case of whether a check is made re if the SMD are built by players 1-4 or not, but as a general approach I find the risk of unexpected consequences is lower if trying to follow the original code approach, unless there's a good reason not to)