Skip to content

Commit

Permalink
15.1: record file consistency (#210)
Browse files Browse the repository at this point in the history
* fix disconnectCheck not toggling when joining from seedqueue wall screen

* bump version to 15.1

* write global file when leaving world
  • Loading branch information
tildejustin authored Aug 10, 2024
1 parent f675c72 commit 1225cfc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ yarn_mappings=1.16.1.build.19
loader_version=0.14.25

# Mod Properties
mod_version=15.0
mod_version=15.1
maven_group=com.redlimerl.speedrunigt
archives_base_name=SpeedRunIGT
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public abstract class MinecraftClientMixin {

@Shadow @Final public TextRenderer textRenderer;
@Shadow @Final private Window window;
private boolean disconnectCheck = false;

@Inject(at = @At("HEAD"), method = "createWorld")
public void onCreate(String worldName, LevelInfo levelInfo, RegistryTracker.Modifiable registryTracker, GeneratorOptions generatorOptions, CallbackInfo ci) {
Expand All @@ -86,7 +85,6 @@ public void onCreate(String worldName, LevelInfo levelInfo, RegistryTracker.Modi
InGameTimer.getInstance().setCheatAvailable(levelInfo.areCommandsAllowed());
InGameTimer.getInstance().checkDifficulty(levelInfo.getDifficulty());
InGameTimerUtils.IS_CHANGING_DIMENSION = true;
this.disconnectCheck = false;
}

@Inject(at = @At("HEAD"), method = "startIntegratedServer(Ljava/lang/String;)V")
Expand All @@ -100,14 +98,10 @@ public void onWorldOpen(String worldName, CallbackInfo ci) {
e.printStackTrace();
}
InGameTimerUtils.IS_CHANGING_DIMENSION = true;
this.disconnectCheck = false;
}

@Inject(method = "openScreen", at = @At("RETURN"))
public void onSetScreen(Screen screen, CallbackInfo ci) {
if (screen instanceof LevelLoadingScreen) {
this.disconnectCheck = true;
}
if (InGameTimerClientUtils.FAILED_CATEGORY_INIT_SCREEN != null) {
Screen screen1 = InGameTimerClientUtils.FAILED_CATEGORY_INIT_SCREEN;
InGameTimerClientUtils.FAILED_CATEGORY_INIT_SCREEN = null;
Expand Down Expand Up @@ -293,15 +287,18 @@ private static void onCrash(CrashReport crashReport, CallbackInfo ci) {
}

// Record save
@Inject(method = "stop", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;close()V", shift = At.Shift.BEFORE))
@Inject(method = "stop", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;close()V"))
public void onStop(CallbackInfo ci) {
InGameTimer.getInstance().writeRecordFile(false);
}

// Disconnecting fix
@Inject(at = @At("HEAD"), method = "disconnect(Lnet/minecraft/client/gui/screen/Screen;)V")
public void disconnect(CallbackInfo ci) {
if (InGameTimer.getInstance().getStatus() != TimerStatus.NONE && this.disconnectCheck) {
// seedqueue suppresses disconnect calls for worlds in queue,
// and the client world is set after starting the server,
// which where the stray disconnect calls come from.
if (InGameTimer.getInstance().getStatus() != TimerStatus.NONE && this.world != null) {
GameInstance.getInstance().callEvents("leave_world");
InGameTimer.leave();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,9 @@ public void setPause(boolean toPause, TimerStatus toStatus, String reason) {
//if ((toStatus == TimerStatus.IDLE || toStatus == TimerStatus.PAUSED) && !isCompleted()) TheRunRequestHelper.updateTimerData(this, TheRunTimer.PacketType.PAUSE);
if (this.isStarted()) {
if (SpeedRunOption.getOption(SpeedRunOptions.TIMER_DATA_AUTO_SAVE) == SpeedRunOptions.TimerSaveInterval.PAUSE && this.status != TimerStatus.LEAVE) save();
this.writeRecordFile(true);
// writes the global file on leaving the world.
// otherwise with seedqueue, the global record is only updated upon joining the next world.
this.writeRecordFile(toStatus != TimerStatus.LEAVE);
}
}
} else {
Expand Down

0 comments on commit 1225cfc

Please sign in to comment.