Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetInt16Config()

static short System.AppContextConfigHelper.GetInt16Config ( string configName,
short defaultValue,
bool allowNegative = true )
inlinestaticpackage

Definition at line 59 of file AppContextConfigHelper.cs.

60 {
61 try
62 {
63 object data = AppContext.GetData(configName);
64 short num = defaultValue;
65 if (!(data is uint num2))
66 {
67 if (data is string text)
68 {
69 num = (text.StartsWith("0x") ? Convert.ToInt16(text, 16) : ((!text.StartsWith("0")) ? short.Parse(text, NumberStyles.AllowLeadingSign, NumberFormatInfo.InvariantInfo) : Convert.ToInt16(text, 8)));
70 }
71 else if (data is IConvertible convertible)
72 {
73 num = convertible.ToInt16(NumberFormatInfo.InvariantInfo);
74 }
75 }
76 else
77 {
78 num = (short)num2;
79 if ((uint)num != num2)
80 {
81 return defaultValue;
82 }
83 }
84 return (!allowNegative && num < 0) ? defaultValue : num;
85 }
86 catch (FormatException)
87 {
88 return defaultValue;
89 }
90 catch (OverflowException)
91 {
92 return defaultValue;
93 }
94 }

References System.AppContext.GetData(), System.Globalization.NumberFormatInfo.InvariantInfo, System.text, and System.Convert.ToInt16().