Skip to content

Commit

Permalink
Merge pull request #344 from Wieku/dev
Browse files Browse the repository at this point in the history
0.9.1
  • Loading branch information
Wieku authored Sep 18, 2023
2 parents 59350ce + 5407724 commit 0518d83
Show file tree
Hide file tree
Showing 10 changed files with 261 additions and 135 deletions.
2 changes: 1 addition & 1 deletion app/beatmap/beatmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (beatMap *BeatMap) Reset() {

func (beatMap *BeatMap) Clear() {
beatMap.HitObjects = make([]objects.IHitObject, 0)
beatMap.Timings = objects.NewTimings()
beatMap.Timings.Clear()
}

func (beatMap *BeatMap) Update(time float64) {
Expand Down
7 changes: 7 additions & 0 deletions app/beatmap/objects/timing.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ func (tim *Timings) HasPoints() bool {
return len(tim.points) > 0
}

func (tim *Timings) Clear() {
tim.originalPoints = tim.originalPoints[:0]
tim.points = tim.points[:0]

tim.Current = tim.defaultTimingPoint
}

func (tim *Timings) Reset() {
tim.Current = tim.points[0]
}
7 changes: 4 additions & 3 deletions app/beatmap/parser.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package beatmap

import (
"cmp"
"errors"
"github.com/wieku/danser-go/app/beatmap/objects"
"github.com/wieku/danser-go/app/settings"
Expand All @@ -10,7 +11,7 @@ import (
"math"
"os"
"path/filepath"
"sort"
"slices"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -342,8 +343,8 @@ func ParseObjects(beatMap *BeatMap, diffCalcOnly, parseColors bool) {
}
}

sort.SliceStable(beatMap.HitObjects, func(i, j int) bool {
return beatMap.HitObjects[i].GetStartTime() < beatMap.HitObjects[j].GetStartTime()
slices.SortStableFunc(beatMap.HitObjects, func(a, b objects.IHitObject) int {
return cmp.Compare(a.GetStartTime(), b.GetStartTime())
})

if parseColors {
Expand Down
13 changes: 12 additions & 1 deletion app/rulesets/osu/healthprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ func (hp *HealthProcessor) CalculateRate() { //nolint:gocyclo
break
}

hp.Increase(-hp.PassiveDrain*(o.GetEndTime()-o.GetStartTime()), false)
decr := hp.PassiveDrain * (o.GetEndTime() - o.GetStartTime())
hpUnder := min(0, hp.Health-decr)

hp.Increase(-decr, false)

if s, ok := o.(*objects.Slider); ok {
for j := 0; j < len(s.TickReverse)+1; j++ {
Expand All @@ -143,6 +146,14 @@ func (hp *HealthProcessor) CalculateRate() { //nolint:gocyclo
}
}

//noinspection GoBoolExpressions - false positive
if hpUnder < 0 && hp.Health+hpUnder <= lowestHpEver {
fail = true
hp.PassiveDrain *= 0.96

break
}

if i == len(hp.beatMap.HitObjects)-1 || hp.beatMap.HitObjects[i+1].IsNewCombo() {
hp.AddResult(Hit300g)

Expand Down
10 changes: 3 additions & 7 deletions app/rulesets/osu/slider.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func (slider *Slider) UpdatePostFor(player *difficultyPlayer, time int64, proces
state := slider.state[player]

if time > int64(slider.hitSlider.GetStartTime())+player.diff.Hit50 && !state.isStartHit {
if len(slider.players) == 1 {
if len(slider.players) == 1 && !state.isHit { //don't fade if slider already ended (and armed the start)
slider.hitSlider.ArmStart(false, float64(time))
}

Expand All @@ -313,12 +313,8 @@ func (slider *Slider) UpdatePostFor(player *difficultyPlayer, time int64, proces
}

if (time >= int64(slider.hitSlider.GetEndTime()) || (processSliderEndsAhead && int64(slider.hitSlider.GetEndTime())-time == 1)) && !state.isHit {
if !state.isStartHit {
if len(slider.players) == 1 {
slider.hitSlider.ArmStart(false, float64(time))
}

state.isStartHit = true
if len(slider.players) == 1 && !state.isStartHit {
slider.hitSlider.ArmStart(false, float64(time))
}

if state.startResult != Miss {
Expand Down
72 changes: 38 additions & 34 deletions app/rulesets/osu/spinner.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type spinnerstate struct {
rotationCount int64
lastRotationCount int64
scoringRotationCount int64
rotationCountF float64
rotationCountF float32
rotationCountFD float64
frameVariance float64
theoreticalVelocity float64
Expand Down Expand Up @@ -80,6 +80,36 @@ func (spinner *Spinner) UpdateFor(player *difficultyPlayer, time int64, _ bool)
numFinishedTotal++

if player.cursor.IsReplayFrame && time > int64(spinner.hitSpinner.GetStartTime()) && time < int64(spinner.hitSpinner.GetEndTime()) {
maxAccelThisFrame := player.diff.GetModifiedTime(spinner.maxAcceleration * timeDiff)

if player.diff.CheckModActive(difficulty.SpunOut) || player.diff.CheckModActive(difficulty.Relax2) {
state.currentVelocity = 0.03
} else if state.theoreticalVelocity > state.currentVelocity {
accel := maxAccelThisFrame
if state.currentVelocity < 0 && player.diff.CheckModActive(difficulty.Relax) {
accel /= 4
}

state.currentVelocity += min(state.theoreticalVelocity-state.currentVelocity, accel)
} else {
accel := -maxAccelThisFrame
if state.currentVelocity > 0 && player.diff.CheckModActive(difficulty.Relax) {
accel /= 4
}

state.currentVelocity += max(state.theoreticalVelocity-state.currentVelocity, accel)
}

state.currentVelocity = max(-0.05, min(state.currentVelocity, 0.05))

if len(spinner.players) == 1 {
if state.currentVelocity == 0 {
spinner.hitSpinner.PauseSpinSample()
} else {
spinner.hitSpinner.StartSpinSample()
}
}

decay1 := math.Pow(0.9, timeDiff/FrameTime)
state.rpm = state.rpm*decay1 + (1.0-decay1)*(math.Abs(state.currentVelocity)*1000)/(math.Pi*2)*60

Expand Down Expand Up @@ -118,7 +148,11 @@ func (spinner *Spinner) UpdateFor(player *difficultyPlayer, time int64, _ bool)

if math.Abs(angleDiff) < math.Pi {
if player.diff.GetModifiedTime(state.frameVariance) > FrameTime*1.04 {
state.theoreticalVelocity = angleDiff / player.diff.GetModifiedTime(timeDiff)
if timeDiff > 0 {
state.theoreticalVelocity = angleDiff / player.diff.GetModifiedTime(timeDiff)
} else {
state.theoreticalVelocity = 0
}
} else {
state.theoreticalVelocity = angleDiff / FrameTime
}
Expand All @@ -129,45 +163,15 @@ func (spinner *Spinner) UpdateFor(player *difficultyPlayer, time int64, _ bool)

state.lastAngle = mouseAngle

maxAccelThisFrame := player.diff.GetModifiedTime(spinner.maxAcceleration * timeDiff)

if player.diff.CheckModActive(difficulty.SpunOut) || player.diff.CheckModActive(difficulty.Relax2) {
state.currentVelocity = 0.03
} else if state.theoreticalVelocity > state.currentVelocity {
accel := maxAccelThisFrame
if state.currentVelocity < 0 && player.diff.CheckModActive(difficulty.Relax) {
accel /= 4
}

state.currentVelocity += min(state.theoreticalVelocity-state.currentVelocity, accel)
} else {
accel := -maxAccelThisFrame
if state.currentVelocity > 0 && player.diff.CheckModActive(difficulty.Relax) {
accel /= 4
}

state.currentVelocity += max(state.theoreticalVelocity-state.currentVelocity, accel)
}

state.currentVelocity = max(-0.05, min(state.currentVelocity, 0.05))

if len(spinner.players) == 1 {
if state.currentVelocity == 0 {
spinner.hitSpinner.PauseSpinSample()
} else {
spinner.hitSpinner.StartSpinSample()
}
}

rotationAddition := state.currentVelocity * timeDiff

state.rotationCountFD += rotationAddition
state.rotationCountF += math.Abs(rotationAddition / math.Pi)
state.rotationCountF += float32(math.Abs(float64(float32(rotationAddition)) / math.Pi))

if len(spinner.players) == 1 {
spinner.hitSpinner.SetRotation(player.diff.GetModifiedTime(state.rotationCountFD))
spinner.hitSpinner.SetRPM(state.rpm)
spinner.hitSpinner.UpdateCompletion(state.rotationCountF / float64(state.requirement))
spinner.hitSpinner.UpdateCompletion(float64(state.rotationCountF) / float64(state.requirement))
}

state.rotationCount = int64(state.rotationCountF)
Expand Down
Loading

0 comments on commit 0518d83

Please sign in to comment.