Skip to content

Commit 6152656

Browse files
committed
🐛 fix flags & flags2 status fields causing i32 overflow
semver: patch
1 parent cc514ab commit 6152656

3 files changed

Lines changed: 30 additions & 4 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"timestamp": "2025-12-22T21:29:37Z",
3+
"event": "Status",
4+
"Flags": 2350956814,
5+
"Flags2": 0,
6+
"Pips": [
7+
4,
8+
7,
9+
1
10+
],
11+
"FireGroup": 0,
12+
"GuiFocus": 0,
13+
"Fuel": {
14+
"FuelMain": 0.000000,
15+
"FuelReservoir": 0.499512
16+
},
17+
"Cargo": 0.000000,
18+
"LegalState": "Allied",
19+
"Latitude": -45.529053,
20+
"Longitude": -26.269121,
21+
"Heading": 64,
22+
"Altitude": 0,
23+
"BodyName": "Nokomishi A 1",
24+
"PlanetRadius": 1483876.125000,
25+
"Balance": 2168298530
26+
}

EliteAPI/Journals/JournalUtils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ public static List<EventPath> ToPaths(string json)
2727

2828
// expand flags
2929
var flagsPath = paths.FirstOrDefault(p => p.Path == "Flags");
30-
var flagsValue = flagsPath.Equals(default(EventPath)) ? 0 : Convert.ToInt32(flagsPath.Value);
30+
var flagsValue = flagsPath.Equals(default(EventPath)) ? 0u : Convert.ToUInt32(flagsPath.Value);
3131
foreach (var flag in StatusUtils.GetFlags(flagsValue))
3232
paths.Add(new EventPath(flag.Key, flag.Value, EventValueType.Boolean));
3333

3434
// expand flags2
3535
var flags2Path = paths.FirstOrDefault(p => p.Path == "Flags2");
36-
var flags2Value = flags2Path.Equals(default(EventPath)) ? 0 : Convert.ToInt32(flags2Path.Value);
36+
var flags2Value = flags2Path.Equals(default(EventPath)) ? 0u : Convert.ToUInt32(flags2Path.Value);
3737
foreach (var flag in StatusUtils.GetFlags2(flags2Value))
3838
paths.Add(new EventPath(flag.Key, flag.Value, EventValueType.Boolean));
3939

EliteAPI/Journals/StatusUtils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace EliteAPI.Journals
44
{
55
public static class StatusUtils
66
{
7-
public static Dictionary<string, bool> GetFlags(int flags) => new()
7+
public static Dictionary<string, bool> GetFlags(uint flags) => new()
88
{
99
{ "Available", flags != 0 },
1010
{ "Docked", (flags & 1) != 0 },
@@ -38,7 +38,7 @@ public static class StatusUtils
3838
{ "NightVision", (flags & (1 << 28)) != 0 }
3939
};
4040

41-
public static Dictionary<string, bool> GetFlags2(int flags2) => new()
41+
public static Dictionary<string, bool> GetFlags2(uint flags2) => new()
4242
{
4343
{ "OnFoot", (flags2 & 1) != 0 },
4444
{ "InTaxi", (flags2 & (1 << 1)) != 0 },

0 commit comments

Comments
 (0)