Be explicit about when we expect a login phase and when we don't
This commit is contained in:
@@ -42,7 +42,8 @@ public class RestoreReplayGui extends AbstractGuiScreen<RestoreReplayGui> {
|
|||||||
new GuiLabel().setI18nText("replaymod.gui.restorereplay3"));
|
new GuiLabel().setI18nText("replaymod.gui.restorereplay3"));
|
||||||
yesButton.onClick(() -> {
|
yesButton.onClick(() -> {
|
||||||
try {
|
try {
|
||||||
ReplayFile replayFile = new ZipReplayFile(new ReplayStudio(), null, file);
|
ReplayStudio studio = new ReplayStudio();
|
||||||
|
ReplayFile replayFile = new ZipReplayFile(studio, null, file);
|
||||||
// Commit all not-yet-committed files into the main zip file.
|
// Commit all not-yet-committed files into the main zip file.
|
||||||
// If we don't do this, then re-writing packet data below can actually overwrite uncommitted packet data!
|
// If we don't do this, then re-writing packet data below can actually overwrite uncommitted packet data!
|
||||||
replayFile.save();
|
replayFile.save();
|
||||||
@@ -50,8 +51,8 @@ public class RestoreReplayGui extends AbstractGuiScreen<RestoreReplayGui> {
|
|||||||
if (metaData != null && metaData.getDuration() == 0) {
|
if (metaData != null && metaData.getDuration() == 0) {
|
||||||
// Try to restore replay duration
|
// Try to restore replay duration
|
||||||
// We need to re-write the packet data in case there are any incomplete packets dangling at the end
|
// We need to re-write the packet data in case there are any incomplete packets dangling at the end
|
||||||
try (ReplayInputStream in = replayFile.getPacketData();
|
try (ReplayInputStream in = replayFile.getPacketData(studio, true);
|
||||||
ReplayOutputStream out = replayFile.writePacketData()) {
|
ReplayOutputStream out = replayFile.writePacketData(true)) {
|
||||||
PacketData last = null;
|
PacketData last = null;
|
||||||
while ((last = in.readPacket()) != null) {
|
while ((last = in.readPacket()) != null) {
|
||||||
metaData.setDuration((int) last.getTime());
|
metaData.setDuration((int) last.getTime());
|
||||||
|
|||||||
@@ -102,7 +102,8 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
|||||||
this.replayFile = replayFile;
|
this.replayFile = replayFile;
|
||||||
this.metaData = metaData;
|
this.metaData = metaData;
|
||||||
this.resourcePackRecorder = new ResourcePackRecorder(replayFile);
|
this.resourcePackRecorder = new ResourcePackRecorder(replayFile);
|
||||||
this.packetOutputStream = new DataOutputStream(replayFile.writePacketData());
|
// Note: doesn't actually always include the login phase, see `connectionState` field instead.
|
||||||
|
this.packetOutputStream = new DataOutputStream(replayFile.writePacketData(true));
|
||||||
this.startTime = metaData.getDate();
|
this.startTime = metaData.getDate();
|
||||||
|
|
||||||
saveMetaData();
|
saveMetaData();
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ public class QuickReplaySender extends ChannelHandlerAdapter implements ReplaySe
|
|||||||
|
|
||||||
double sysTimeStart = System.currentTimeMillis();
|
double sysTimeStart = System.currentTimeMillis();
|
||||||
double duration;
|
double duration;
|
||||||
try (ReplayInputStream in = replayFile.getPacketData(studio);
|
try (ReplayInputStream in = replayFile.getPacketData(studio, false);
|
||||||
OutputStream cacheOut = replayFile.writeCache(CACHE_ENTRY);
|
OutputStream cacheOut = replayFile.writeCache(CACHE_ENTRY);
|
||||||
OutputStream cacheIndexOut = replayFile.writeCache(CACHE_INDEX_ENTRY)) {
|
OutputStream cacheIndexOut = replayFile.writeCache(CACHE_INDEX_ENTRY)) {
|
||||||
NetOutput out = new StreamNetOutput(cacheOut);
|
NetOutput out = new StreamNetOutput(cacheOut);
|
||||||
|
|||||||
Reference in New Issue
Block a user