fix replay hit results
This commit is contained in:
parent
35769b31c7
commit
408c162741
|
@ -85,7 +85,9 @@ public class Circle extends GameObject {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameObject clone(GameData data) {
|
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
|
@Override
|
||||||
|
@ -170,12 +172,13 @@ public class Circle extends GameObject {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isreplay;
|
||||||
@Override
|
@Override
|
||||||
public boolean update(boolean overlap, int delta, int mouseX, int mouseY, boolean keyPressed, int trackPosition) {
|
public boolean update(boolean overlap, int delta, int mouseX, int mouseY, boolean keyPressed, int trackPosition) {
|
||||||
int time = hitObject.getTime();
|
int time = hitObject.getTime();
|
||||||
|
|
||||||
int[] hitResultOffset = game.getHitResultOffsets();
|
int[] hitResultOffset = game.getHitResultOffsets();
|
||||||
boolean isAutoMod = GameMod.AUTO.isActive();
|
boolean isAutoMod = !isreplay && GameMod.AUTO.isActive();
|
||||||
|
|
||||||
if (trackPosition > time + hitResultOffset[GameData.HIT_50]) {
|
if (trackPosition > time + hitResultOffset[GameData.HIT_50]) {
|
||||||
if (isAutoMod) {// "auto" mod: catch any missed notes due to lag
|
if (isAutoMod) {// "auto" mod: catch any missed notes due to lag
|
||||||
|
|
|
@ -191,7 +191,9 @@ public class Slider extends GameObject {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameObject clone(GameData data) {
|
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
|
@Override
|
||||||
|
@ -627,11 +629,12 @@ public class Slider extends GameObject {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isreplay;
|
||||||
@Override
|
@Override
|
||||||
public boolean update(boolean overlap, int delta, int mouseX, int mouseY, boolean keyPressed, int trackPosition) {
|
public boolean update(boolean overlap, int delta, int mouseX, int mouseY, boolean keyPressed, int trackPosition) {
|
||||||
int repeatCount = hitObject.getRepeatCount();
|
int repeatCount = hitObject.getRepeatCount();
|
||||||
int[] hitResultOffset = game.getHitResultOffsets();
|
int[] hitResultOffset = game.getHitResultOffsets();
|
||||||
boolean isAutoMod = GameMod.AUTO.isActive();
|
boolean isAutoMod = !isreplay && GameMod.AUTO.isActive();
|
||||||
|
|
||||||
if (!sliderClickedInitial) {
|
if (!sliderClickedInitial) {
|
||||||
int time = hitObject.getTime();
|
int time = hitObject.getTime();
|
||||||
|
|
|
@ -1558,6 +1558,9 @@ public class Game extends ComplexOpsuState {
|
||||||
}
|
}
|
||||||
|
|
||||||
gameObjects = new GameObject[beatmap.objects.length];
|
gameObjects = new GameObject[beatmap.objects.length];
|
||||||
|
for (ReplayPlayback replayPlayback : replays) {
|
||||||
|
replayPlayback.gameObjects = new GameObject[gameObjects.length];
|
||||||
|
}
|
||||||
playbackSpeed = PlaybackSpeed.NORMAL;
|
playbackSpeed = PlaybackSpeed.NORMAL;
|
||||||
|
|
||||||
// reset game data
|
// reset game data
|
||||||
|
@ -1604,6 +1607,9 @@ public class Game extends ComplexOpsuState {
|
||||||
} else if (hitObject.isSpinner()) {
|
} else if (hitObject.isSpinner()) {
|
||||||
gameObjects[i] = new Spinner(hitObject, this, data);
|
gameObjects[i] = new Spinner(hitObject, this, data);
|
||||||
}
|
}
|
||||||
|
for (ReplayPlayback replayPlayback : replays) {
|
||||||
|
replayPlayback.gameObjects[i] = gameObjects[i].clone(replayPlayback.gdata);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String message = String.format("Failed to create %s at index %d:\n%s", hitObject.getTypeName(), i, hitObject.toString());
|
String message = String.format("Failed to create %s at index %d:\n%s", hitObject.getTypeName(), i, hitObject.toString());
|
||||||
Log.error(message, e);
|
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);
|
Dancer.instance.setGameObjects(gameObjects);
|
||||||
storyboardOverlay.setGameObjects(gameObjects);
|
storyboardOverlay.setGameObjects(gameObjects);
|
||||||
if (!skippedToCheckpoint) {
|
if (!skippedToCheckpoint) {
|
||||||
|
|
|
@ -45,11 +45,12 @@ public class ReplayPlayback {
|
||||||
private boolean hr;
|
private boolean hr;
|
||||||
private String player;
|
private String player;
|
||||||
|
|
||||||
private GameObject[] gameObjects;
|
public GameObject[] gameObjects;
|
||||||
private int objectIndex = 0;
|
private int objectIndex = 0;
|
||||||
private int lastkeys = 0;
|
private int lastkeys = 0;
|
||||||
private Image hitImage;
|
private Image hitImage;
|
||||||
private int hitImageTimer = 0;
|
private int hitImageTimer = 0;
|
||||||
|
public GData gdata = new GData();
|
||||||
|
|
||||||
public ReplayPlayback(DisplayContainer container, Replay replay, Color color) {
|
public ReplayPlayback(DisplayContainer container, Replay replay, Color color) {
|
||||||
this.container = container;
|
this.container = container;
|
||||||
|
@ -101,10 +102,6 @@ public class ReplayPlayback {
|
||||||
this.player = replay.playerName + this.player;
|
this.player = replay.playerName + this.player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGameObjects(GameObject[] gameObjects) {
|
|
||||||
this.gameObjects = gameObjects;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetFrameIndex() {
|
public void resetFrameIndex() {
|
||||||
frameIndex = 0;
|
frameIndex = 0;
|
||||||
currentFrame = replay.frames[frameIndex++];
|
currentFrame = replay.frames[frameIndex++];
|
||||||
|
@ -115,12 +112,6 @@ public class ReplayPlayback {
|
||||||
if (objectIndex >= gameObjects.length) // nothing to do here
|
if (objectIndex >= gameObjects.length) // nothing to do here
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int deltakeys = (currentFrame.getKeys() & ~this.lastkeys);
|
|
||||||
if (deltakeys == ReplayFrame.KEY_NONE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.lastkeys = currentFrame.getKeys();
|
|
||||||
|
|
||||||
HitObject hitObject = beatmap.objects[objectIndex];
|
HitObject hitObject = beatmap.objects[objectIndex];
|
||||||
|
|
||||||
// circles
|
// circles
|
||||||
|
@ -154,8 +145,17 @@ public class ReplayPlayback {
|
||||||
|
|
||||||
while (nextFrame != null && nextFrame.getTime() < time) {
|
while (nextFrame != null && nextFrame.getTime() < time) {
|
||||||
currentFrame = nextFrame;
|
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();
|
processKeys();
|
||||||
sendKeys(beatmap, time);
|
|
||||||
frameIndex++;
|
frameIndex++;
|
||||||
if (frameIndex >= replay.frames.length) {
|
if (frameIndex >= replay.frames.length) {
|
||||||
nextFrame = null;
|
nextFrame = null;
|
||||||
|
@ -163,9 +163,6 @@ public class ReplayPlayback {
|
||||||
}
|
}
|
||||||
nextFrame = replay.frames[frameIndex];
|
nextFrame = replay.frames[frameIndex];
|
||||||
}
|
}
|
||||||
processKeys();
|
|
||||||
sendKeys(beatmap, time);
|
|
||||||
update(time, beatmap, hitResultOffset, renderdelta);
|
|
||||||
g.setColor(color);
|
g.setColor(color);
|
||||||
ypos *= (SQSIZE + 5);
|
ypos *= (SQSIZE + 5);
|
||||||
for (int i = 0; i < 4; i++) {
|
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);
|
Fonts.SMALLBOLD.drawString(SQSIZE * 5, ypos, this.player + " " + this.objectIndex, color);
|
||||||
int namewidth = Fonts.SMALLBOLD.getWidth(this.player);
|
int namewidth = Fonts.SMALLBOLD.getWidth(this.player);
|
||||||
if (hitImage != null) {
|
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();
|
int y = currentFrame.getScaledY();
|
||||||
if (hr) {
|
if (hr) {
|
||||||
|
@ -204,13 +201,11 @@ public class ReplayPlayback {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private GData _data;
|
|
||||||
public class GData extends GameData {
|
public class GData extends GameData {
|
||||||
|
|
||||||
public GData() {
|
public GData() {
|
||||||
super();
|
super();
|
||||||
this.loadImages();
|
this.loadImages();
|
||||||
_data = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -237,20 +232,13 @@ public class ReplayPlayback {
|
||||||
|
|
||||||
@Override
|
@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) {
|
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 ((result == HIT_300)) {
|
||||||
|
//return;
|
||||||
if (handleResult) {
|
|
||||||
hitResult = handleHitResult(time, result, x, y, color, end, hitObject,
|
|
||||||
hitResultType, repeat, (curve != null && !sliderHeldToEnd));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((hitResult == HIT_300 || hitResult == HIT_300G || hitResult == HIT_300K)) {
|
if (result < hitResults.length) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hitResult < hitResults.length) {
|
|
||||||
hitImageTimer = 0;
|
hitImageTimer = 0;
|
||||||
hitImage = hitResults[hitResult].getScaledCopy(SQSIZE, SQSIZE);
|
hitImage = hitResults[result].getScaledCopy(SQSIZE, SQSIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user