Skip to content

Commit

Permalink
Change anonymous type properties to use explicit names
Browse files Browse the repository at this point in the history
  • Loading branch information
smoogipoo committed Dec 16, 2020
1 parent 54a6802 commit 49d3be8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
1 change: 1 addition & 0 deletions osu.Server.Spectator.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PossibleMultipleEnumeration/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PrivateVariableCanBeMadeReadonly/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PublicConstructorInAbstractClass/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantAnonymousTypePropertyName/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantArgumentDefaultValue/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantArrayCreationExpression/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantAttributeParentheses/@EntryIndexedValue">WARNING</s:String>
Expand Down
44 changes: 37 additions & 7 deletions osu.Server.Spectator/Hubs/MultiplayerHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ protected virtual async Task<MultiplayerRoom> RetrieveRoom(long roomId)
{
using (var conn = Database.GetConnection())
{
var databaseRoom = await conn.QueryFirstOrDefaultAsync<multiplayer_room>("SELECT * FROM multiplayer_rooms WHERE category = 'realtime' AND id = @roomId", new { roomId });
var databaseRoom = await conn.QueryFirstOrDefaultAsync<multiplayer_room>("SELECT * FROM multiplayer_rooms WHERE category = 'realtime' AND id = @RoomID", new
{
RoomID = roomId
});

if (databaseRoom == null)
throw new InvalidStateException("Specified match does not exist.");

Expand All @@ -110,7 +114,10 @@ protected virtual async Task<MultiplayerRoom> RetrieveRoom(long roomId)
if (databaseRoom.user_id != CurrentContextUserId)
throw new InvalidStateException("Non-host is attempting to join match before host");

var playlistItem = await conn.QuerySingleAsync<multiplayer_playlist_item>("SELECT * FROM multiplayer_playlist_items WHERE room_id = @roomId", new { roomId });
var playlistItem = await conn.QuerySingleAsync<multiplayer_playlist_item>("SELECT * FROM multiplayer_playlist_items WHERE room_id = @RoomID", new
{
RoomID = roomId
});

return new MultiplayerRoom(roomId)
{
Expand Down Expand Up @@ -154,7 +161,12 @@ public async Task LeaveRoom()
}

using (var conn = Database.GetConnection())
await conn.ExecuteAsync("UPDATE multiplayer_rooms SET ends_at = NOW() WHERE id = @RoomID", new { room.RoomID });
{
await conn.ExecuteAsync("UPDATE multiplayer_rooms SET ends_at = NOW() WHERE id = @RoomID", new
{
RoomID = room.RoomID
});
}

return;
}
Expand Down Expand Up @@ -275,7 +287,12 @@ public async Task ChangeSettings(MultiplayerRoomSettings settings)
{
var dbPlaylistItem = new multiplayer_playlist_item(room);

await conn.ExecuteAsync("UPDATE multiplayer_rooms SET name = @Name WHERE id = @RoomID", new { room.Settings.Name, room.RoomID });
await conn.ExecuteAsync("UPDATE multiplayer_rooms SET name = @Name WHERE id = @RoomID", new
{
RoomID = room.RoomID,
Name = room.Settings.Name
});

await conn.ExecuteAsync("UPDATE multiplayer_playlist_items SET beatmap_id = @beatmap_id, ruleset_id = @ruleset_id, required_mods = @required_mods, updated_at = NOW() WHERE room_id = @room_id", dbPlaylistItem);
}

Expand Down Expand Up @@ -305,15 +322,28 @@ private async Task updateDatabaseParticipants(MultiplayerRoom room)
using (var transaction = await conn.BeginTransactionAsync())
{
// This should be considered *very* temporary, and for display purposes only!
await conn.ExecuteAsync("DELETE FROM multiplayer_rooms_high WHERE room_id = @RoomID", new { room.RoomID, room.Users.Count }, transaction);
await conn.ExecuteAsync("DELETE FROM multiplayer_rooms_high WHERE room_id = @RoomID", new
{
RoomID = room.RoomID
}, transaction);

foreach (var u in room.Users)
await conn.ExecuteAsync("INSERT INTO multiplayer_rooms_high (room_id, user_id) VALUES (@RoomID, @UserID)", new { room.RoomID, u.UserID }, transaction);
{
await conn.ExecuteAsync("INSERT INTO multiplayer_rooms_high (room_id, user_id) VALUES (@RoomID, @UserID)", new
{
RoomID = room.RoomID,
UserID = u.UserID
}, transaction);
}

await transaction.CommitAsync();
}

await conn.ExecuteAsync("UPDATE multiplayer_rooms SET participant_count = @Count WHERE id = @RoomID", new { room.RoomID, room.Users.Count });
await conn.ExecuteAsync("UPDATE multiplayer_rooms SET participant_count = @Count WHERE id = @RoomID", new
{
RoomID = room.RoomID,
Count = room.Users.Count
});
}
}

Expand Down

0 comments on commit 49d3be8

Please sign in to comment.