diff --git a/Refresh.GameServer/Endpoints/Game/MatchingEndpoints.cs b/Refresh.GameServer/Endpoints/Game/MatchingEndpoints.cs index 22f1ae49..1376e681 100644 --- a/Refresh.GameServer/Endpoints/Game/MatchingEndpoints.cs +++ b/Refresh.GameServer/Endpoints/Game/MatchingEndpoints.cs @@ -50,7 +50,7 @@ public Response Match( [GameEndpoint("enterLevel/{slotType}/{id}", HttpMethods.Post)] public Response EnterLevel(RequestContext context, Token token, MatchService matchService, string slotType, int id) { - GameRoom room = matchService.GetOrCreateRoomByPlayer(token.User, token.TokenPlatform, token.TokenGame, NatType.Strict, null, false); + GameRoom room = matchService.GetOrCreateRoomByPlayer(token.User, token.TokenPlatform, token.TokenGame, NatType.Strict, false); // User slot ID of 0 means pod/moon level if (id == 0 && slotType == "user") diff --git a/Refresh.GameServer/Services/MatchService.cs b/Refresh.GameServer/Services/MatchService.cs index 0ecd9601..7e6e9685 100644 --- a/Refresh.GameServer/Services/MatchService.cs +++ b/Refresh.GameServer/Services/MatchService.cs @@ -26,15 +26,14 @@ public GameRoom GetOrCreateRoomByPlayer( GameUser player, TokenPlatform platform, TokenGame game, - NatType natType, - int? buildVersion, + NatType natType, bool? passedNoJoinPoint = null) { GameRoom? room = this.RoomAccessor.GetRoomByUser(player, platform, game); // ReSharper disable once ConvertIfStatementToNullCoalescingExpression if (room == null) - room = this.CreateRoomByPlayer(player, platform, game, natType, buildVersion, passedNoJoinPoint); + room = this.CreateRoomByPlayer(player, platform, game, natType, passedNoJoinPoint); return room; } @@ -43,11 +42,10 @@ public GameRoom CreateRoomByPlayer( GameUser player, TokenPlatform platform, TokenGame game, - NatType natType, - int? buildVersion, + NatType natType, bool? passedNoJoinPoint = null) { - GameRoom room = new(player, platform, game, natType, buildVersion, passedNoJoinPoint); + GameRoom room = new(player, platform, game, natType, passedNoJoinPoint); this.RoomAccessor.AddRoom(room); return room; } @@ -56,14 +54,13 @@ public GameRoom SplitUserIntoNewRoom( GameUser player, TokenPlatform platform, TokenGame game, - NatType natType, - int? buildVersion, + NatType natType, bool? passedNoJoinPoint = null) { GameRoom? room = this.RoomAccessor.GetRoomByUser(player, platform, game); if (room == null) { - return this.CreateRoomByPlayer(player, platform, game, natType, buildVersion, passedNoJoinPoint); + return this.CreateRoomByPlayer(player, platform, game, natType, passedNoJoinPoint); } // Remove player from old room @@ -71,7 +68,7 @@ public GameRoom SplitUserIntoNewRoom( // Update the room on the room accessor this.RoomAccessor.UpdateRoom(room); - return this.CreateRoomByPlayer(player, platform, game, natType, buildVersion, passedNoJoinPoint); + return this.CreateRoomByPlayer(player, platform, game, natType, passedNoJoinPoint); } public int GetPlayerCountForLevel(RoomSlotType type, int id) diff --git a/Refresh.GameServer/Types/Matching/GameRoom.cs b/Refresh.GameServer/Types/Matching/GameRoom.cs index 14e5581a..c7dced30 100644 --- a/Refresh.GameServer/Types/Matching/GameRoom.cs +++ b/Refresh.GameServer/Types/Matching/GameRoom.cs @@ -8,13 +8,12 @@ namespace Refresh.GameServer.Types.Matching; public class GameRoom { - public GameRoom(GameUser host, TokenPlatform platform, TokenGame game, NatType natType, int? buildVersion, bool? passedNoJoinPoint) + public GameRoom(GameUser host, TokenPlatform platform, TokenGame game, NatType natType, bool? passedNoJoinPoint) { this.PlayerIds.Add(new GameRoomPlayer(host.Username, host.UserId)); this.Platform = platform; this.Game = game; this.NatType = natType; - this.BuildVersion = buildVersion; this.PassedNoJoinPoint = passedNoJoinPoint ?? false; } @@ -29,8 +28,7 @@ public GameRoom(GameUser host, TokenPlatform platform, TokenGame game, NatType n public readonly NatType NatType; public DateTimeOffset LastContact; - - public int? BuildVersion; + public bool PassedNoJoinPoint; public List GetPlayers(GameDatabaseContext database) => diff --git a/Refresh.GameServer/Types/Matching/IRoomAccessor.cs b/Refresh.GameServer/Types/Matching/IRoomAccessor.cs index 9f0ebf0e..984408c7 100644 --- a/Refresh.GameServer/Types/Matching/IRoomAccessor.cs +++ b/Refresh.GameServer/Types/Matching/IRoomAccessor.cs @@ -98,17 +98,17 @@ public IEnumerable GetRoomsInLevel(GameLevel level) => this.GetRoomsIn /// The platform to check for /// The game to check for /// The found room, or null if not found - public GameRoom? GetRoomByUser(GameUser user, TokenPlatform? platform = null, TokenGame? game = null, int? buildVersion = null) => this.GetRoomByUserUuid(user.UserId, platform, game, buildVersion); + public GameRoom? GetRoomByUser(GameUser user, TokenPlatform? platform = null, TokenGame? game = null) => this.GetRoomByUserUuid(user.UserId, platform, game); /// /// Gets a room by a user's UUID. /// /// The user UUID to search for /// The found room, or null if not found - public GameRoom? GetRoomByUserUuid(ObjectId uuid, TokenPlatform? platform = null, TokenGame? game = null, int? buildVersion = null); + public GameRoom? GetRoomByUserUuid(ObjectId uuid, TokenPlatform? platform = null, TokenGame? game = null); /// /// Gets a room by a user's username. /// /// The username to search for /// The found room, or null if not found - public GameRoom? GetRoomByUsername(string username, TokenPlatform? platform = null, TokenGame? game = null, int? buildVersion = null); + public GameRoom? GetRoomByUsername(string username, TokenPlatform? platform = null, TokenGame? game = null); } \ No newline at end of file diff --git a/Refresh.GameServer/Types/Matching/MatchMethods/CreateRoomMethod.cs b/Refresh.GameServer/Types/Matching/MatchMethods/CreateRoomMethod.cs index 7e0fe2b6..ed7487bc 100644 --- a/Refresh.GameServer/Types/Matching/MatchMethods/CreateRoomMethod.cs +++ b/Refresh.GameServer/Types/Matching/MatchMethods/CreateRoomMethod.cs @@ -12,10 +12,10 @@ public class CreateRoomMethod : IMatchMethod public Response Execute(DataContext dataContext, SerializedRoomData body, GameServerConfig gameServerConfig) { NatType natType = body.NatType == null ? NatType.Open : body.NatType[0]; - GameRoom room = dataContext.Match.GetOrCreateRoomByPlayer(dataContext.User!, dataContext.Platform, dataContext.Game, natType, body.BuildVersion, body.PassedNoJoinPoint); + GameRoom room = dataContext.Match.GetOrCreateRoomByPlayer(dataContext.User!, dataContext.Platform, dataContext.Game, natType, body.PassedNoJoinPoint); if (room.HostId.Id != dataContext.User!.UserId) { - room = dataContext.Match.SplitUserIntoNewRoom(dataContext.User, dataContext.Platform, dataContext.Game, natType, body.BuildVersion, body.PassedNoJoinPoint); + room = dataContext.Match.SplitUserIntoNewRoom(dataContext.User, dataContext.Platform, dataContext.Game, natType, body.PassedNoJoinPoint); } if (body.RoomState != null) room.RoomState = body.RoomState.Value; diff --git a/Refresh.GameServer/Types/Matching/MatchMethods/FindRoomMethod.cs b/Refresh.GameServer/Types/Matching/MatchMethods/FindRoomMethod.cs index 236ae677..572eafc6 100644 --- a/Refresh.GameServer/Types/Matching/MatchMethods/FindRoomMethod.cs +++ b/Refresh.GameServer/Types/Matching/MatchMethods/FindRoomMethod.cs @@ -69,9 +69,7 @@ public Response Execute(DataContext dataContext, SerializedRoomData body, GameSe (userLevelIds.Count == 0 || r.LevelType != RoomSlotType.Online || userLevelIds.Contains(r.LevelId)) && (developerLevelIds.Count == 0 || r.LevelType != RoomSlotType.Story || developerLevelIds.Contains(r.LevelId)) && // Make sure that we don't try to match the player into a full room, or a room which won't fit the user's current room - usersRoom.PlayerIds.Count + r.PlayerIds.Count <= 4 && - // Match the build version of the rooms, or dont match build versions if the game doesnt specify it - (body.BuildVersion == null || (r.BuildVersion ?? 0) == body.BuildVersion)) + usersRoom.PlayerIds.Count + r.PlayerIds.Count <= 4) // Shuffle the rooms around before sorting, this is because the selection is based on a weighted average towards the top of the range, // so there would be a bias towards longer lasting rooms without this shuffle .OrderBy(r => Random.Shared.Next()) @@ -117,9 +115,8 @@ public Response Execute(DataContext dataContext, SerializedRoomData body, GameSe foreach (GameRoom logRoom in allRooms) dataContext.Logger.LogInfo(BunkumCategory.Matching, - "Room {0}: Nat Type {1}, Level {2} ({3}), Build Version {4}", - logRoom.RoomId, logRoom.NatType, logRoom.LevelId, logRoom.LevelType, - logRoom.BuildVersion ?? 0); + "Room {0}: Nat Type {1}, Level {2} ({3})", + logRoom.RoomId, logRoom.NatType, logRoom.LevelId, logRoom.LevelType); } else { diff --git a/Refresh.GameServer/Types/Matching/MatchMethods/UpdatePlayersInRoomMethod.cs b/Refresh.GameServer/Types/Matching/MatchMethods/UpdatePlayersInRoomMethod.cs index dbb79c28..88bbef6d 100644 --- a/Refresh.GameServer/Types/Matching/MatchMethods/UpdatePlayersInRoomMethod.cs +++ b/Refresh.GameServer/Types/Matching/MatchMethods/UpdatePlayersInRoomMethod.cs @@ -12,7 +12,7 @@ public class UpdatePlayersInRoomMethod : IMatchMethod public Response Execute(DataContext dataContext, SerializedRoomData body, GameServerConfig gameServerConfig) { if (body.Players == null) return BadRequest; - GameRoom room = dataContext.Match.GetOrCreateRoomByPlayer(dataContext.User!, dataContext.Platform, dataContext.Game, body.NatType == null ? NatType.Open : body.NatType[0], body.BuildVersion, body.PassedNoJoinPoint); + GameRoom room = dataContext.Match.GetOrCreateRoomByPlayer(dataContext.User!, dataContext.Platform, dataContext.Game, body.NatType == null ? NatType.Open : body.NatType[0], body.PassedNoJoinPoint); foreach (string playerUsername in body.Players) { diff --git a/Refresh.GameServer/Types/Matching/MatchMethods/UpdateRoomDataMethod.cs b/Refresh.GameServer/Types/Matching/MatchMethods/UpdateRoomDataMethod.cs index c1d8ccdf..b2eae087 100644 --- a/Refresh.GameServer/Types/Matching/MatchMethods/UpdateRoomDataMethod.cs +++ b/Refresh.GameServer/Types/Matching/MatchMethods/UpdateRoomDataMethod.cs @@ -11,7 +11,7 @@ public class UpdateRoomDataMethod : IMatchMethod public Response Execute(DataContext dataContext, SerializedRoomData body, GameServerConfig gameServerConfig) { - GameRoom room = dataContext.Match.GetOrCreateRoomByPlayer(dataContext.User!, dataContext.Platform, dataContext.Game, body.NatType == null ? NatType.Open : body.NatType[0], body.BuildVersion, body.PassedNoJoinPoint); + GameRoom room = dataContext.Match.GetOrCreateRoomByPlayer(dataContext.User!, dataContext.Platform, dataContext.Game, body.NatType == null ? NatType.Open : body.NatType[0], body.PassedNoJoinPoint); if (room.HostId.Id != dataContext.User!.UserId) return Unauthorized; if (body.RoomState != null) room.RoomState = body.RoomState.Value; diff --git a/Refresh.GameServer/Types/Matching/RoomAccessors/InMemoryRoomAccessor.cs b/Refresh.GameServer/Types/Matching/RoomAccessors/InMemoryRoomAccessor.cs index 695ec41c..eb29bef4 100644 --- a/Refresh.GameServer/Types/Matching/RoomAccessors/InMemoryRoomAccessor.cs +++ b/Refresh.GameServer/Types/Matching/RoomAccessors/InMemoryRoomAccessor.cs @@ -149,7 +149,7 @@ public IEnumerable GetRoomsByGameAndPlatform(TokenGame game, TokenPlat } /// - public GameRoom? GetRoomByUserUuid(ObjectId uuid, TokenPlatform? platform = null, TokenGame? game = null, int? buildVersion = null) + public GameRoom? GetRoomByUserUuid(ObjectId uuid, TokenPlatform? platform = null, TokenGame? game = null) { lock (this._rooms) { @@ -157,13 +157,12 @@ public IEnumerable GetRoomsByGameAndPlatform(TokenGame game, TokenPlat return this._rooms.FirstOrDefault(r => r.PlayerIds.Any(p => p.Id == uuid) && (platform == null || r.Platform == platform) && - (game == null || r.Game == game) && - (buildVersion == null || r.BuildVersion == buildVersion)); + (game == null || r.Game == game)); } } /// - public GameRoom? GetRoomByUsername(string username, TokenPlatform? platform = null, TokenGame? game = null, int? buildVersion = null) + public GameRoom? GetRoomByUsername(string username, TokenPlatform? platform = null, TokenGame? game = null) { lock (this._rooms) { @@ -171,8 +170,7 @@ public IEnumerable GetRoomsByGameAndPlatform(TokenGame game, TokenPlat return this._rooms.FirstOrDefault(r => r.PlayerIds.Any(p => p.Username == username) && (platform == null || r.Platform == platform) && - (game == null || r.Game == game) && - (buildVersion == null || r.BuildVersion == buildVersion)); + (game == null || r.Game == game)); } } } \ No newline at end of file diff --git a/Refresh.GameServer/Types/Matching/SerializedRoomData.cs b/Refresh.GameServer/Types/Matching/SerializedRoomData.cs index e1300a94..b43decc2 100644 --- a/Refresh.GameServer/Types/Matching/SerializedRoomData.cs +++ b/Refresh.GameServer/Types/Matching/SerializedRoomData.cs @@ -47,8 +47,8 @@ public class SerializedRoomData [JsonProperty("Language")] public byte? Language { get; set; } - [JsonProperty("BuildVersion")] - public int? BuildVersion { get; set; } + // [JsonProperty("BuildVersion")] + // public int? BuildVersion { get; set; } [JsonProperty("Search")] public string? Search { get; set; }