Skip to content

Commit

Permalink
Check LoGetMagneticYaw for nil (#1016)
Browse files Browse the repository at this point in the history
  • Loading branch information
charliefoxtwo authored Nov 24, 2024
1 parent dd0012b commit 3d2db8a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Scripts/DCS-BIOS/lib/modules/common_modules/CommonData.lua
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ end, angular_max_length, "Speed", "Angular Z Velocity")

CommonData:defineIntegerFromGetter("HDG_DEG_MAG", function()
local magnetic_heading_rad = LoGetMagneticYaw()

if not magnetic_heading_rad then
return 0
end

local heading = Module.round(magnetic_heading_rad * 180 / math.pi) % 360
if heading < 0 then -- you'd think this would always be positive, but sometimes radians is negative!
heading = heading + 360
Expand Down

0 comments on commit 3d2db8a

Please sign in to comment.