Add OnlineMode to session settings. Only allow admins to join an Offline game.

This commit is contained in:
Brant Martin
2018-08-20 20:06:32 -04:00
parent 016203d2bc
commit 355375e9db
2 changed files with 7 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ using Torch.Managers;
using Torch.Utils;
using Torch.ViewModels;
using VRage.Game;
using VRage.Game.ModAPI;
using VRage.GameServices;
using VRage.Network;
using VRage.Steam;
@@ -153,7 +154,9 @@ namespace Torch.Server.Managers
//SteamNetworking.GetP2PSessionState(new CSteamID(steamId), out P2PSessionState_t state);
var ip = "0"; //state.GetRemoteIP();
_log.Debug($"ValidateAuthTicketResponse(user={steamId}, response={response}, owner={steamOwner})");
Torch.CurrentSession.KeenSession.PromotedUsers.TryGetValue(steamId, out MyPromoteLevel promoteLevel);
_log.Debug($"ValidateAuthTicketResponse(user={steamId}, response={response}, owner={steamOwner}, permissions={promoteLevel})");
_log.Info($"Connection attempt by {steamId} from {ip}");
// TODO implement IP bans
@@ -164,7 +167,7 @@ namespace Torch.Server.Managers
UserRejected(steamId, JoinResult.NotInGroup);
}
else if (Torch.CurrentSession.KeenSession.OnlineMode == MyOnlineModeEnum.OFFLINE &&
!Torch.CurrentSession.KeenSession.IsUserAdmin(steamId))
promoteLevel < MyPromoteLevel.Admin)
{
_log.Warn($"Rejecting user {steamId}, world is set to offline and user is not admin.");
UserRejected(steamId, JoinResult.TicketCanceled);

View File

@@ -18,6 +18,8 @@ namespace Torch.Server.ViewModels
[Torch.Views.Display(Description = "The type of the game mode.", Name = "Game Mode", GroupName = "Others")]
public MyGameModeEnum GameMode { get => _settings.GameMode; set => SetValue(ref _settings.GameMode, value); }
[Torch.Views.Display(Description = "The type of the game online mode.", Name = "Online Mode", GroupName = "Others")]
public MyOnlineModeEnum OnlineMode { get => _settings.OnlineMode; set => SetValue(ref _settings.OnlineMode, value); }
[Torch.Views.Display(Description = "The multiplier for inventory size.", Name = "Inventory Size", GroupName = "Multipliers")]
public float InventorySizeMultiplier { get => _settings.InventorySizeMultiplier; set => SetValue(ref _settings.InventorySizeMultiplier, value); }