Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix room logging code and 404 return #566

Merged
merged 2 commits into from
Jul 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions Refresh.GameServer/Types/Matching/MatchMethods/FindRoomMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,26 +99,35 @@ public Response Execute(DataContext dataContext, SerializedRoomData body, GameSe
// Now that we've done all our filtering, lets convert it to a list, so we can index it quickly.
List<GameRoom> foundRooms = rooms.ToList();

// If there's no rooms, dump an "overview" of the global room state, to help debug matching issues
if (foundRooms.Count <= 0 && gameServerConfig.PrintRoomStateWhenNoFoundRooms)
// If there are no rooms, return a 404 status code
if (foundRooms.Count <= 0)
{
if (allRooms.Count == 0)
{
dataContext.Logger.LogDebug(BunkumCategory.Matching,
dataContext.Logger.LogInfo(BunkumCategory.Matching,
"Room search by {0} on {1} ({2}) returned no results due to there being no open rooms on the game/platform.",
dataContext.User.Username, dataContext.Game, dataContext.Platform);
}
else
// If we failed to find a match, but there are other rooms, dump an "overview" of the global room state, to help debug matching issues
else if(gameServerConfig.PrintRoomStateWhenNoFoundRooms)
{
dataContext.Logger.LogDebug(BunkumCategory.Matching,
dataContext.Logger.LogInfo(BunkumCategory.Matching,
"Room search by {0} on {1} ({2}) returned no results, dumping list of possible rooms.",
dataContext.User.Username, dataContext.Game, dataContext.Platform);

foreach (GameRoom logRoom in allRooms)
dataContext.Logger.LogDebug(BunkumCategory.Matching, "Room {0}: Nat Type {1}, Level {2} ({3}), Build Version {4}",
logRoom.RoomId, logRoom.NatType, logRoom.LevelId, logRoom.LevelType, logRoom.BuildVersion ?? 0);
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);
}

else
{
dataContext.Logger.LogInfo(BunkumCategory.Matching,
"Room search by {0} on {1} ({2}) returned no results, could not find a valid room to match the user into.",
dataContext.User.Username, dataContext.Game, dataContext.Platform);
}

// Return a 404 status code if there's no rooms to match them to
return new Response(new List<object> { new SerializedStatusCodeMatchResponse(404), }, ContentType.Json);
}
Expand Down
Loading