/// </summary>
GameDestroyed,
+ /// <summary>
+ /// The host has a newer version of the game and the client should update.
+ /// </summary>
+ ClientOutdated,
+
+ /// <summary>
+ /// The host has an older version of the game and the client should downgrade.
+ /// </summary>
+ ClientTooNew,
+
/// <summary>
/// Custom error by a plugin.
/// </summary>
"Check the server console for more information. " +
"Please report the issue on the Impostor GitHub if it keeps happening.";
+ public const string ClientOutdated = "Please update your game to play in this lobby.";
+
+ public const string ClientTooNew = "Your game version is too new for this lobby. " +
+ "If you want to join this lobby you need to downgrade your client.";
+
public const string Destroyed = "The game you tried to join is being destroyed. " +
"Please create a new game.";
case GameJoinError.GameDestroyed:
await DisconnectAsync(DisconnectReason.Custom, DisconnectMessages.Destroyed);
break;
+ case GameJoinError.ClientOutdated:
+ await DisconnectAsync(DisconnectReason.Custom, DisconnectMessages.ClientOutdated);
+ break;
+ case GameJoinError.ClientTooNew:
+ await DisconnectAsync(DisconnectReason.Custom, DisconnectMessages.ClientTooNew);
+ break;
case GameJoinError.Custom:
await DisconnectAsync(DisconnectReason.Custom, result.Message);
break;
{
using var message = MessageWriter.Get(MessageType.Reliable);
- var games = _gameManager.FindListings((MapFlags)options.Map, options.NumImpostors, options.Keywords);
+ var games = _gameManager.FindListings((MapFlags)options.Map, options.NumImpostors, options.Keywords, this.GameVersion);
Message16GetGameListS2C.Serialize(message, games);
return game;
}
- public IEnumerable<Game> FindListings(MapFlags map, int impostorCount, GameKeywords language, int count = 10)
+ public IEnumerable<Game> FindListings(MapFlags map, int impostorCount, GameKeywords language, int gameVersion, int count = 10)
{
var results = 0;
foreach (var (_, game) in _games.Where(x =>
x.Value.IsPublic &&
x.Value.GameState == GameStates.NotStarted &&
- x.Value.PlayerCount < x.Value.Options.MaxPlayers))
+ x.Value.PlayerCount < x.Value.Options.MaxPlayers &&
+ 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 (client.GameVersion < this.Host.Client.GameVersion)
+ {
+ return GameJoinResult.FromError(GameJoinError.ClientOutdated);
+ }
+ else
+ {
+ return GameJoinResult.FromError(GameJoinError.ClientTooNew);
+ }
+ }
+
// Check if;
// - The player is already in this game.
// - The game is full.