--- /dev/null
+namespace Impostor.Server.Config
+{
+ public class CompatibilityConfig
+ {
+ public const string Section = "Compatibility";
+
+ public bool AllowVersionMixing { get; set; } = false;
+ }
+}
private readonly INodeLocator _nodeLocator;
private readonly IPEndPoint _publicIp;
private readonly ConcurrentDictionary<int, Game> _games;
+ private readonly CompatibilityConfig _compatibilityConfig;
private readonly IServiceProvider _serviceProvider;
private readonly IEventManager _eventManager;
private readonly IGameCodeFactory _gameCodeFactory;
- public GameManager(ILogger<GameManager> logger, IOptions<ServerConfig> config, INodeLocator nodeLocator, IServiceProvider serviceProvider, IEventManager eventManager, IGameCodeFactory gameCodeFactory)
+ public GameManager(ILogger<GameManager> logger, IOptions<ServerConfig> config, INodeLocator nodeLocator, IServiceProvider serviceProvider, IEventManager eventManager, IGameCodeFactory gameCodeFactory, IOptions<CompatibilityConfig> compatibilityConfig)
{
_logger = logger;
_nodeLocator = nodeLocator;
_gameCodeFactory = gameCodeFactory;
_publicIp = new IPEndPoint(IPAddress.Parse(config.Value.ResolvePublicIp()), config.Value.PublicPort);
_games = new ConcurrentDictionary<int, Game>();
+ _compatibilityConfig = compatibilityConfig.Value;
}
IEnumerable<IGame> IGameManager.Games => _games.Select(kv => kv.Value);
x.Value.IsPublic &&
x.Value.GameState == GameStates.NotStarted &&
x.Value.PlayerCount < x.Value.Options.MaxPlayers &&
- x.Value.Host?.Client.GameVersion == gameVersion))
+ (_compatibilityConfig.AllowVersionMixing == true || x.Value.Host?.Client.GameVersion == gameVersion)))
{
// Check for options.
if (!map.HasFlag((MapFlags)(1 << (byte)game.Options.Map)))
var player = client.Player;
// Check if the player is running the same version as the host
- if (this.Host != null && client.GameVersion != this.Host.Client.GameVersion)
+ if (_compatibilityConfig.AllowVersionMixing == false &&
+ this.Host != null && client.GameVersion != this.Host.Client.GameVersion)
{
if (client.GameVersion < this.Host.Client.GameVersion)
{
using Impostor.Api.Net;
using Impostor.Api.Net.Messages;
using Impostor.Api.Net.Messages.S2C;
+using Impostor.Server.Config;
using Impostor.Server.Events;
using Impostor.Server.Net.Manager;
using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
namespace Impostor.Server.Net.State
{
private readonly ConcurrentDictionary<int, ClientPlayer> _players;
private readonly HashSet<IPAddress> _bannedIps;
private readonly IEventManager _eventManager;
+ private readonly CompatibilityConfig _compatibilityConfig;
public Game(
ILogger<Game> logger,
GameCode code,
GameOptionsData options,
ClientManager clientManager,
- IEventManager eventManager)
+ IEventManager eventManager,
+ IOptions<CompatibilityConfig> compatibilityConfig)
{
_logger = logger;
_serviceProvider = serviceProvider;
Options = options;
_clientManager = clientManager;
_eventManager = eventManager;
+ _compatibilityConfig = compatibilityConfig.Value;
Items = new ConcurrentDictionary<object, object>();
}
services.Configure<DebugConfig>(host.Configuration.GetSection(DebugConfig.Section));
services.Configure<AntiCheatConfig>(host.Configuration.GetSection(AntiCheatConfig.Section));
+ services.Configure<CompatibilityConfig>(host.Configuration.GetSection(CompatibilityConfig.Section));
services.Configure<ServerConfig>(host.Configuration.GetSection(ServerConfig.Section));
services.Configure<ServerRedirectorConfig>(host.Configuration.GetSection(ServerRedirectorConfig.Section));