Skip to content

Commit

Permalink
Fix a crash when toggling auto-overcharge for units that do not suppo…
Browse files Browse the repository at this point in the history
…rt it (FAForever#6364)
  • Loading branch information
lL1l1 authored Jul 28, 2024
1 parent 71f5a0e commit 6f33ad6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/snippets/fix.6364.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- (#6364) Fix the game crashing when enabling auto-overcharge with a non-Seraphim SACU selected.
3 changes: 2 additions & 1 deletion lua/sim/units/CommandUnit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ CommandUnit = ClassUnit(WalkingLandUnit) {
---@param auto boolean
SetAutoOvercharge = function(self, auto)
local wep = self:GetWeaponByLabel('AutoOverCharge')
if wep.NeedsUpgrade then return end
-- non-OC SACU can get here if auto OC is ordered along with an OC capable ACU/SACU, so wep will be nil
if not wep or wep.NeedsUpgrade then return end

wep:SetAutoOvercharge(auto)
self:UpdateStat("AutoOC", auto and 1 or 0)
Expand Down

0 comments on commit 6f33ad6

Please sign in to comment.