fix replay hit results

This commit is contained in:
yugecin 2017-12-21 23:55:16 +01:00
parent 35769b31c7
commit 408c162741
4 changed files with 33 additions and 41 deletions

View File

@ -85,7 +85,9 @@ public class Circle extends GameObject {
@Override
public GameObject clone(GameData data) {
return new Circle(hitObject, game, data, comboColorIndex, comboEnd);
Circle c = new Circle(hitObject, game, data, comboColorIndex, comboEnd);
c.isreplay = true;
return c;
}
@Override
@ -170,12 +172,13 @@ public class Circle extends GameObject {
return false;
}
private boolean isreplay;
@Override
public boolean update(boolean overlap, int delta, int mouseX, int mouseY, boolean keyPressed, int trackPosition) {
int time = hitObject.getTime();
int[] hitResultOffset = game.getHitResultOffsets();
boolean isAutoMod = GameMod.AUTO.isActive();
boolean isAutoMod = !isreplay && GameMod.AUTO.isActive();
if (trackPosition > time + hitResultOffset[GameData.HIT_50]) {
if (isAutoMod) {// "auto" mod: catch any missed notes due to lag

View File

@ -191,7 +191,9 @@ public class Slider extends GameObject {
@Override
public GameObject clone(GameData data) {
return new Slider(hitObject, game, data, comboColorIndex, comboEnd);
Slider s = new Slider(hitObject, game, data, comboColorIndex, comboEnd);
s.isreplay = true;
return s;
}
@Override
@ -627,11 +629,12 @@ public class Slider extends GameObject {
return false;
}
boolean isreplay;
@Override
public boolean update(boolean overlap, int delta, int mouseX, int mouseY, boolean keyPressed, int trackPosition) {
int repeatCount = hitObject.getRepeatCount();
int[] hitResultOffset = game.getHitResultOffsets();
boolean isAutoMod = GameMod.AUTO.isActive();
boolean isAutoMod = !isreplay && GameMod.AUTO.isActive();
if (!sliderClickedInitial) {
int time = hitObject.getTime();

View File

@ -1558,6 +1558,9 @@ public class Game extends ComplexOpsuState {
}
gameObjects = new GameObject[beatmap.objects.length];
for (ReplayPlayback replayPlayback : replays) {
replayPlayback.gameObjects = new GameObject[gameObjects.length];
}
playbackSpeed = PlaybackSpeed.NORMAL;
// reset game data
@ -1604,6 +1607,9 @@ public class Game extends ComplexOpsuState {
} else if (hitObject.isSpinner()) {
gameObjects[i] = new Spinner(hitObject, this, data);
}
for (ReplayPlayback replayPlayback : replays) {
replayPlayback.gameObjects[i] = gameObjects[i].clone(replayPlayback.gdata);
}
} catch (Exception e) {
String message = String.format("Failed to create %s at index %d:\n%s", hitObject.getTypeName(), i, hitObject.toString());
Log.error(message, e);
@ -1718,14 +1724,6 @@ public class Game extends ComplexOpsuState {
}
}
for (ReplayPlayback replayPlayback : replays) {
GameObject[] objs = new GameObject[gameObjects.length];
for (int i = 0; i < objs.length; i++) {
objs[i] = gameObjects[i].clone(replayPlayback.new GData());
}
replayPlayback.setGameObjects(objs);
}
Dancer.instance.setGameObjects(gameObjects);
storyboardOverlay.setGameObjects(gameObjects);
if (!skippedToCheckpoint) {

View File

@ -45,11 +45,12 @@ public class ReplayPlayback {
private boolean hr;
private String player;
private GameObject[] gameObjects;
public GameObject[] gameObjects;
private int objectIndex = 0;
private int lastkeys = 0;
private Image hitImage;
private int hitImageTimer = 0;
public GData gdata = new GData();
public ReplayPlayback(DisplayContainer container, Replay replay, Color color) {
this.container = container;
@ -101,10 +102,6 @@ public class ReplayPlayback {
this.player = replay.playerName + this.player;
}
public void setGameObjects(GameObject[] gameObjects) {
this.gameObjects = gameObjects;
}
public void resetFrameIndex() {
frameIndex = 0;
currentFrame = replay.frames[frameIndex++];
@ -115,12 +112,6 @@ public class ReplayPlayback {
if (objectIndex >= gameObjects.length) // nothing to do here
return;
int deltakeys = (currentFrame.getKeys() & ~this.lastkeys);
if (deltakeys == ReplayFrame.KEY_NONE) {
return;
}
this.lastkeys = currentFrame.getKeys();
HitObject hitObject = beatmap.objects[objectIndex];
// circles
@ -154,8 +145,17 @@ public class ReplayPlayback {
while (nextFrame != null && nextFrame.getTime() < time) {
currentFrame = nextFrame;
int keys = currentFrame.getKeys();
int deltaKeys = (keys & ~lastkeys); // keys that turned on
if (deltaKeys != ReplayFrame.KEY_NONE) { // send a key press
sendKeys(beatmap, currentFrame.getTime());
} else if (keys == lastkeys) {
update(time, beatmap, hitResultOffset, currentFrame.getTimeDiff());
}
lastkeys = keys;
processKeys();
sendKeys(beatmap, time);
frameIndex++;
if (frameIndex >= replay.frames.length) {
nextFrame = null;
@ -163,9 +163,6 @@ public class ReplayPlayback {
}
nextFrame = replay.frames[frameIndex];
}
processKeys();
sendKeys(beatmap, time);
update(time, beatmap, hitResultOffset, renderdelta);
g.setColor(color);
ypos *= (SQSIZE + 5);
for (int i = 0; i < 4; i++) {
@ -177,7 +174,7 @@ public class ReplayPlayback {
Fonts.SMALLBOLD.drawString(SQSIZE * 5, ypos, this.player + " " + this.objectIndex, color);
int namewidth = Fonts.SMALLBOLD.getWidth(this.player);
if (hitImage != null) {
hitImage.draw(SQSIZE * 5 + namewidth + SQSIZE * 2, ypos + SQSIZE / 2);
hitImage.draw(SQSIZE * 5 + namewidth + SQSIZE * 2, ypos);
}
int y = currentFrame.getScaledY();
if (hr) {
@ -204,13 +201,11 @@ public class ReplayPlayback {
}
}
private GData _data;
public class GData extends GameData {
public GData() {
super();
this.loadImages();
_data = this;
}
@Override
@ -237,20 +232,13 @@ public class ReplayPlayback {
@Override
public void sendHitResult(int time, int result, float x, float y, Color color, boolean end, HitObject hitObject, HitObjectType hitResultType, boolean expand, int repeat, Curve curve, boolean sliderHeldToEnd, boolean handleResult) {
int hitResult = HIT_300;
if (handleResult) {
hitResult = handleHitResult(time, result, x, y, color, end, hitObject,
hitResultType, repeat, (curve != null && !sliderHeldToEnd));
if ((result == HIT_300)) {
//return;
}
if ((hitResult == HIT_300 || hitResult == HIT_300G || hitResult == HIT_300K)) {
return;
}
if (hitResult < hitResults.length) {
if (result < hitResults.length) {
hitImageTimer = 0;
hitImage = hitResults[hitResult].getScaledCopy(SQSIZE, SQSIZE);
hitImage = hitResults[result].getScaledCopy(SQSIZE, SQSIZE);
}
}