diff options
| author | 2024-08-19 09:42:25 +0200 | |
|---|---|---|
| committer | 2024-08-19 08:42:25 +0100 | |
| commit | f6cc1baa74d3f4540a53bc8df4732e7a331800a6 (patch) | |
| tree | 1a08dd2e5b93f0a3b95c224d481f41ca2430020c | |
| parent | Bump version (diff) | |
| download | enigma-f6cc1baa74d3f4540a53bc8df4732e7a331800a6.tar.gz enigma-f6cc1baa74d3f4540a53bc8df4732e7a331800a6.tar.xz enigma-f6cc1baa74d3f4540a53bc8df4732e7a331800a6.zip | |
Fix Enigma dir writer behaving incorrectly after the first write (#546)
* Fix Enigma dir writer behaving incorrectly after first write when using MIO
* Fix checkstyle
* Fix misleading field name
| -rw-r--r-- | enigma/src/main/java/cuchaz/enigma/translation/mapping/serde/MappingFormat.java | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/mapping/serde/MappingFormat.java b/enigma/src/main/java/cuchaz/enigma/translation/mapping/serde/MappingFormat.java index 7daa5d48..c9707b9c 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/mapping/serde/MappingFormat.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/mapping/serde/MappingFormat.java | |||
| @@ -52,7 +52,7 @@ public enum MappingFormat { | |||
| 52 | private final FileType fileType; | 52 | private final FileType fileType; |
| 53 | private final net.fabricmc.mappingio.format.MappingFormat mappingIoCounterpart; | 53 | private final net.fabricmc.mappingio.format.MappingFormat mappingIoCounterpart; |
| 54 | private final boolean hasMappingIoWriter; | 54 | private final boolean hasMappingIoWriter; |
| 55 | private boolean lastUsedMappingIoWriter; | 55 | private boolean usedMappingIoWriterLast; |
| 56 | 56 | ||
| 57 | MappingFormat(MappingsWriter writer, MappingsReader reader, FileType fileType, net.fabricmc.mappingio.format.MappingFormat mappingIoCounterpart, boolean hasMappingIoWriter) { | 57 | MappingFormat(MappingsWriter writer, MappingsReader reader, FileType fileType, net.fabricmc.mappingio.format.MappingFormat mappingIoCounterpart, boolean hasMappingIoWriter) { |
| 58 | this.writer = writer; | 58 | this.writer = writer; |
| @@ -72,14 +72,15 @@ public enum MappingFormat { | |||
| 72 | throw new IllegalStateException(name() + " does not support writing"); | 72 | throw new IllegalStateException(name() + " does not support writing"); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | writer.write(mappings, lastUsedMappingIoWriter ? MappingDelta.added(mappings) : delta, path, progressListener, saveParameters); | 75 | writer.write(mappings, usedMappingIoWriterLast ? MappingDelta.added(mappings) : delta, path, progressListener, saveParameters); |
| 76 | lastUsedMappingIoWriter = false; | 76 | usedMappingIoWriterLast = false; |
| 77 | return; | 77 | return; |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | try { | 80 | try { |
| 81 | if (this == ENIGMA_DIRECTORY) { // TODO: Remove once MIO supports deltas | 81 | if (this == ENIGMA_DIRECTORY) { // TODO: Remove once MIO supports deltas |
| 82 | EnigmaMappingsWriter.DIRECTORY.write(mappings, lastUsedMappingIoWriter ? MappingDelta.added(mappings) : delta, path, progressListener, saveParameters, true); | 82 | EnigmaMappingsWriter.DIRECTORY.write(mappings, usedMappingIoWriterLast ? MappingDelta.added(mappings) : delta, path, progressListener, saveParameters, true); |
| 83 | usedMappingIoWriterLast = false; | ||
| 83 | } else { | 84 | } else { |
| 84 | if (this == PROGUARD) { | 85 | if (this == PROGUARD) { |
| 85 | mappings = MappingOperations.invert(mappings); | 86 | mappings = MappingOperations.invert(mappings); |
| @@ -91,9 +92,8 @@ public enum MappingFormat { | |||
| 91 | 92 | ||
| 92 | tree.accept(MappingWriter.create(path, mappingIoCounterpart), VisitOrder.createByName()); | 93 | tree.accept(MappingWriter.create(path, mappingIoCounterpart), VisitOrder.createByName()); |
| 93 | progressListener.step(1, I18n.translate("progress.done")); | 94 | progressListener.step(1, I18n.translate("progress.done")); |
| 95 | usedMappingIoWriterLast = true; | ||
| 94 | } | 96 | } |
| 95 | |||
| 96 | lastUsedMappingIoWriter = true; | ||
| 97 | } catch (IOException e) { | 97 | } catch (IOException e) { |
| 98 | throw new UncheckedIOException(e); | 98 | throw new UncheckedIOException(e); |
| 99 | } | 99 | } |