From b1145272d1c7cc3d7dc51ef178cd2df700102e5c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 14 Sep 2017 12:58:32 +0900 Subject: [PATCH] Update code to support new inspectcode analysis rules --- appveyor.yml | 1 + osu-framework | 2 +- osu.Game/Beatmaps/WorkingBeatmap.cs | 7 +++++-- osu.Game/Overlays/Settings/Sections/Debug/GCSettings.cs | 2 +- .../Overlays/Settings/Sections/General/UpdateSettings.cs | 2 +- .../Overlays/Settings/Sections/Input/KeyboardSettings.cs | 2 +- osu.Game/Screens/Menu/MainMenu.cs | 2 +- osu.Game/Screens/Play/SongProgressGraph.cs | 8 ++++++-- osu.Game/Screens/Select/SongSelect.cs | 2 +- osu.Game/Screens/Tournament/Drawings.cs | 2 +- osu.Game/Users/Avatar.cs | 2 +- osu.sln.DotSettings | 3 +++ 12 files changed, 23 insertions(+), 12 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index b26a895788..21c15724e6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,3 +1,4 @@ +# 2017-09-14 clone_depth: 1 version: '{branch}-{build}' configuration: Debug diff --git a/osu-framework b/osu-framework index b060218232..7347c386dc 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit b060218232fcd6f24d4922d05160616db0195bd4 +Subproject commit 7347c386dcd10eb799b1ce1512536879328109f9 diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index df8e7f5e3b..bb3122489e 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -100,8 +100,11 @@ namespace osu.Game.Beatmaps public void TransferTo(WorkingBeatmap other) { - if (track != null && BeatmapInfo.AudioEquals(other.BeatmapInfo)) - other.track = track; + lock (trackLock) + { + if (track != null && BeatmapInfo.AudioEquals(other.BeatmapInfo)) + other.track = track; + } if (background != null && BeatmapInfo.BackgroundEquals(other.BeatmapInfo)) other.background = background; diff --git a/osu.Game/Overlays/Settings/Sections/Debug/GCSettings.cs b/osu.Game/Overlays/Settings/Sections/Debug/GCSettings.cs index 0a32b50809..495a2543d1 100644 --- a/osu.Game/Overlays/Settings/Sections/Debug/GCSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Debug/GCSettings.cs @@ -28,7 +28,7 @@ namespace osu.Game.Overlays.Settings.Sections.Debug { RelativeSizeAxes = Axes.X, Text = "Force garbage collection", - Action = () => GC.Collect() + Action = GC.Collect }, }; } diff --git a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index 01e32b5a1b..833a5ff966 100644 --- a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -27,7 +27,7 @@ namespace osu.Game.Overlays.Settings.Sections.General { RelativeSizeAxes = Axes.X, Text = "Open osu! folder", - Action = () => storage.OpenInNativeExplorer(), + Action = storage.OpenInNativeExplorer, } }; } diff --git a/osu.Game/Overlays/Settings/Sections/Input/KeyboardSettings.cs b/osu.Game/Overlays/Settings/Sections/Input/KeyboardSettings.cs index 01e73d0168..b68fd4bc04 100644 --- a/osu.Game/Overlays/Settings/Sections/Input/KeyboardSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Input/KeyboardSettings.cs @@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input { RelativeSizeAxes = Axes.X, Text = "Key Configuration", - Action = () => keyConfig.ToggleVisibility() + Action = keyConfig.ToggleVisibility }, }; } diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 2544cc2837..1c82d15f50 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -50,7 +50,7 @@ namespace osu.Game.Screens.Menu OnEdit = delegate { Push(new Editor()); }, OnSolo = delegate { Push(consumeSongSelect()); }, OnMulti = delegate { Push(new Lobby()); }, - OnExit = delegate { Exit(); }, + OnExit = Exit, } } }, diff --git a/osu.Game/Screens/Play/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs index 541065e532..dc4deaaefc 100644 --- a/osu.Game/Screens/Play/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -1,8 +1,10 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using System.Linq; using System.Collections.Generic; +using System.Diagnostics; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects; @@ -34,10 +36,12 @@ namespace osu.Game.Screens.Play foreach (var h in objects) { - IHasEndTime end = h as IHasEndTime; + var endTime = Math.Max((h as IHasEndTime)?.EndTime ?? h.StartTime, h.StartTime); + + Debug.Assert(endTime > h.StartTime); int startRange = (int)((h.StartTime - firstHit) / interval); - int endRange = (int)(((end?.EndTime > 0 ? end.EndTime : h.StartTime) - firstHit) / interval); + int endRange = (int)((endTime - firstHit) / interval); for (int i = startRange; i <= endRange; i++) Values[i]++; } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index f97c4fe420..84457b77a7 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -106,7 +106,7 @@ namespace osu.Game.Screens.Select Origin = Anchor.CentreRight, SelectionChanged = carouselSelectionChanged, BeatmapsChanged = carouselBeatmapsLoaded, - DeleteRequested = b => promptDelete(b), + DeleteRequested = promptDelete, RestoreRequested = s => { foreach (var b in s.Beatmaps) manager.Restore(b); }, HideDifficultyRequested = b => manager.Hide(b), StartRequested = () => carouselRaisedStart(), diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index 7cd81a924d..3d27552212 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -237,7 +237,7 @@ namespace osu.Game.Screens.Tournament RelativeSizeAxes = Axes.X, Text = "Reset", - Action = () => reset(false) + Action = () => reset() } } } diff --git a/osu.Game/Users/Avatar.cs b/osu.Game/Users/Avatar.cs index 5d518f1780..111c901ca0 100644 --- a/osu.Game/Users/Avatar.cs +++ b/osu.Game/Users/Avatar.cs @@ -26,7 +26,7 @@ namespace osu.Game.Users private void load(TextureStore textures) { Texture texture = null; - if (user?.Id > 1) texture = textures.Get($@"https://a.ppy.sh/{user.Id}"); + if (user != null && user.Id > 1) texture = textures.Get($@"https://a.ppy.sh/{user.Id}"); if (texture == null) texture = textures.Get(@"Online/avatar-guest"); Add(new Sprite diff --git a/osu.sln.DotSettings b/osu.sln.DotSettings index 0b8c196ec8..8988908ee2 100644 --- a/osu.sln.DotSettings +++ b/osu.sln.DotSettings @@ -56,6 +56,8 @@ WARNING HINT HINT + HINT + HINT HINT WARNING WARNING @@ -617,6 +619,7 @@ Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-frame <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> <Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />