Skip to content

Commit bef0b24

Browse files
committed
update(engine): Make ServerIP nullable
1 parent 434be34 commit bef0b24

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

managed/src/SwiftlyS2.Core/Modules/Engine/EngineService.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using SwiftlyS2.Shared.Natives;
66
using SwiftlyS2.Shared.SchemaDefinitions;
77
using SwiftlyS2.Shared.SteamAPI;
8+
using Spectre.Console;
89

910
namespace SwiftlyS2.Core.Services;
1011

@@ -17,7 +18,19 @@ public EngineService( CommandTrackerManager commandTrackedManager )
1718
this._commandTrackedManager = commandTrackedManager;
1819
}
1920

20-
public string ServerIP => SteamGameServer.GetPublicIP().ToString();
21+
public string? ServerIP {
22+
get {
23+
try
24+
{
25+
return SteamGameServer.GetPublicIP().ToString();
26+
}
27+
catch (Exception e)
28+
{
29+
AnsiConsole.WriteException(e);
30+
return null;
31+
}
32+
}
33+
}
2134

2235
public ref CGlobalVars GlobalVars => ref NativeEngineHelpers.GetGlobalVars().AsRef<CGlobalVars>();
2336

managed/src/SwiftlyS2.Shared/Modules/Engine/IEngineService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public interface IEngineService
88
/// <summary>
99
/// The IP address of the server.
1010
/// </summary>
11-
public string ServerIP { get; }
11+
public string? ServerIP { get; }
1212

1313
/// <summary>
1414
/// Gets the map that the server is running

0 commit comments

Comments
 (0)