1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 20:47:26 +08:00

Fix possible nullref.

This commit is contained in:
smoogipooo 2017-03-29 16:20:54 +09:00
parent 475c865968
commit c5f9c4cac9

View File

@ -4,6 +4,7 @@
using osu.Game.Modes.Taiko.Objects; using osu.Game.Modes.Taiko.Objects;
using osu.Game.Modes.Objects.Types; using osu.Game.Modes.Objects.Types;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using System;
namespace osu.Game.Modes.Taiko namespace osu.Game.Modes.Taiko
{ {
@ -34,13 +35,16 @@ namespace osu.Game.Modes.Taiko
IHasEndTime endTimeData = h as IHasEndTime; IHasEndTime endTimeData = h as IHasEndTime;
double endTime = endTimeData?.EndTime ?? h.StartTime; double endTime = endTimeData?.EndTime ?? h.StartTime;
Swell sp = h as Swell; Swell swell = h as Swell;
if (sp != null) DrumRoll drumRoll = h as DrumRoll;
Hit hit = h as Hit;
if (swell != null)
{ {
int d = 0; int d = 0;
int count = 0; int count = 0;
int req = sp.RequiredHits; int req = swell.RequiredHits;
double hitRate = sp.Duration / req; double hitRate = swell.Duration / req;
for (double j = h.StartTime; j < endTime; j += hitRate) for (double j = h.StartTime; j < endTime; j += hitRate)
{ {
switch (d) switch (d)
@ -65,25 +69,21 @@ namespace osu.Game.Modes.Taiko
break; break;
} }
} }
else if (h is DrumRoll) else if (drumRoll != null)
{ {
DrumRoll d = h as DrumRoll; double delay = drumRoll.TickTimeDistance;
double delay = d.TickTimeDistance; double time = drumRoll.StartTime;
double time = d.StartTime; for (int j = 0; j < drumRoll.TotalTicks; j++)
for (int j = 0; j < d.TotalTicks; j++)
{ {
Frames.Add(new LegacyReplayFrame((int)time, 0, 0, hitButton ? LegacyButtonState.Left1 : LegacyButtonState.Left2)); Frames.Add(new LegacyReplayFrame((int)time, 0, 0, hitButton ? LegacyButtonState.Left1 : LegacyButtonState.Left2));
time += delay; time += delay;
hitButton = !hitButton; hitButton = !hitButton;
} }
} }
else else if (hit != null)
{ {
Hit hit = h as Hit;
if (hit.Type == HitType.Centre) if (hit.Type == HitType.Centre)
{ {
if (h.IsStrong) if (h.IsStrong)
@ -101,6 +101,8 @@ namespace osu.Game.Modes.Taiko
Frames.Add(new LegacyReplayFrame(h.StartTime, 0, 0, button)); Frames.Add(new LegacyReplayFrame(h.StartTime, 0, 0, button));
} }
else
throw new Exception("Unknown hit object type.");
Frames.Add(new LegacyReplayFrame(endTime + 1, 0, 0, LegacyButtonState.None)); Frames.Add(new LegacyReplayFrame(endTime + 1, 0, 0, LegacyButtonState.None));
@ -113,9 +115,6 @@ namespace osu.Game.Modes.Taiko
hitButton = !hitButton; hitButton = !hitButton;
} }
//Player.currentScore.Replay = InputManager.ReplayScore.Replay;
//Player.currentScore.PlayerName = "mekkadosu!";
} }
} }
} }