Skip to content

Commit

Permalink
Fix Enigma dir writer behaving incorrectly after the first write (#546)
Browse files Browse the repository at this point in the history
* Fix Enigma dir writer behaving incorrectly after first write when using MIO

* Fix checkstyle

* Fix misleading field name
  • Loading branch information
NebelNidas authored Aug 19, 2024
1 parent 6fd510c commit f6cc1ba
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public enum MappingFormat {
private final FileType fileType;
private final net.fabricmc.mappingio.format.MappingFormat mappingIoCounterpart;
private final boolean hasMappingIoWriter;
private boolean lastUsedMappingIoWriter;
private boolean usedMappingIoWriterLast;

MappingFormat(MappingsWriter writer, MappingsReader reader, FileType fileType, net.fabricmc.mappingio.format.MappingFormat mappingIoCounterpart, boolean hasMappingIoWriter) {
this.writer = writer;
Expand All @@ -72,14 +72,15 @@ public void write(EntryTree<EntryMapping> mappings, MappingDelta<EntryMapping> d
throw new IllegalStateException(name() + " does not support writing");
}

writer.write(mappings, lastUsedMappingIoWriter ? MappingDelta.added(mappings) : delta, path, progressListener, saveParameters);
lastUsedMappingIoWriter = false;
writer.write(mappings, usedMappingIoWriterLast ? MappingDelta.added(mappings) : delta, path, progressListener, saveParameters);
usedMappingIoWriterLast = false;
return;
}

try {
if (this == ENIGMA_DIRECTORY) { // TODO: Remove once MIO supports deltas
EnigmaMappingsWriter.DIRECTORY.write(mappings, lastUsedMappingIoWriter ? MappingDelta.added(mappings) : delta, path, progressListener, saveParameters, true);
EnigmaMappingsWriter.DIRECTORY.write(mappings, usedMappingIoWriterLast ? MappingDelta.added(mappings) : delta, path, progressListener, saveParameters, true);
usedMappingIoWriterLast = false;
} else {
if (this == PROGUARD) {
mappings = MappingOperations.invert(mappings);
Expand All @@ -91,9 +92,8 @@ public void write(EntryTree<EntryMapping> mappings, MappingDelta<EntryMapping> d

tree.accept(MappingWriter.create(path, mappingIoCounterpart), VisitOrder.createByName());
progressListener.step(1, I18n.translate("progress.done"));
usedMappingIoWriterLast = true;
}

lastUsedMappingIoWriter = true;
} catch (IOException e) {
throw new UncheckedIOException(e);
}
Expand Down

0 comments on commit f6cc1ba

Please sign in to comment.