Skip to content

Commit

Permalink
Bugfix: Gracefully handle invalid RFBand request
Browse files Browse the repository at this point in the history
Don't throw if the band isn't in the dictionary, assign a default instead.
  • Loading branch information
DRVeyl committed Dec 24, 2019
1 parent 27a59d0 commit 6149698
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/RealAntennasProject/Antenna/BandInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

namespace RealAntennas.Antenna
Expand All @@ -18,6 +19,11 @@ public static BandInfo Get(string band)
{
if (!initialized && GameDatabase.Instance.GetConfigNode("RealAntennas/RealAntennasCommNetParams/RealAntennasCommNetParams") is ConfigNode node)
Init(node);
if (!All.ContainsKey(band))
{
Debug.LogError($"{ModTag} Band \"{band}\" not defined, defaulting to {All.Keys.FirstOrDefault()}");
band = All.Keys.FirstOrDefault();
}
return All[band];
}
public static void Init(ConfigNode config)
Expand Down

0 comments on commit 6149698

Please sign in to comment.