Skip to content

Commit

Permalink
Merge pull request #117 from replay-id-comparison-fix
Browse files Browse the repository at this point in the history
Replay id comparison fix
  • Loading branch information
NSGolova authored Jan 7, 2024
2 parents 970ae12 + d6d013a commit 68d3a7f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,10 @@ private bool TryFindNoteData(NoteEvent noteEvent, out NoteData? noteData) {
var prevNode = _startNodeForLastProcessedTime;
for (var node = startNode; node != null; node = node.Next) {
noteData = node.Value;
if (Mathf.Abs(_startNodeForLastProcessedTime?
.Value.time ?? 0 - noteData.time) < 1e-6) {
if (Mathf.Abs(_startNodeForLastProcessedTime?.Value.time ?? 0 - noteData.time) < 1e-3) {
_startNodeForLastProcessedTime = node;
}
if (Mathf.Abs(noteEvent.spawnTime - noteData.time) < 1e-6
if (Mathf.Abs(noteEvent.spawnTime - noteData.time) < 1e-3
&& _comparator.Compare(noteEvent, noteData)) {
return true;
}
Expand Down
12 changes: 6 additions & 6 deletions Source/7_Utils/ReplayDataUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ public static int ComputeObstacleId(this ObstacleData obstacleData) {

public static int ComputeNoteId(this NoteData noteData, bool noScoring = false, bool altBomb = false) {
// Bombs may have both correct values as well as default.
var colorType = altBomb && noteData.colorType == ColorType.None ? 0 : (int)noteData.colorType;
var cutDirection = altBomb && noteData.colorType == ColorType.None ? 3 : (int)noteData.cutDirection;

var colorType = altBomb && noteData.colorType == ColorType.None ? 3 : (int)noteData.colorType;
// Pre 1.20 replays has no scoring in ID
var scoringPart = noScoring ? 0 : ((int)noteData.scoringType + 2) * 10000;

return scoringPart + noteData.lineIndex
* 1000 + (int)noteData.noteLineLayer * 100 + colorType
* 10 + cutDirection;
return scoringPart
+ noteData.lineIndex * 1000
+ (int)noteData.noteLineLayer * 100
+ colorType * 10
+ (int)noteData.cutDirection;
}

public static bool Compare(NoteEvent noteEvent, NoteData noteData) {
Expand Down

0 comments on commit 68d3a7f

Please sign in to comment.