Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ private static String calculateProjectConfigHash(WurstProjectConfigData projectC
.append(",").append(force.getFlags().getSharedControl())
.append(",").append(force.getFlags().getSharedControlAdvanced())
.append("players:");
for (int id : force.getPlayerIds()) {
sb.append(id).append(",");
}
sb.append("\n");
for (int id : force.getPlayerIds()) {
sb.append(id).append(",");
}
sb.append("\n");
}

// Option flags
Expand All @@ -175,20 +175,22 @@ private static void applyBuildMapData(WurstProjectConfigData projectConfig, File
prepareW3I(projectConfig, w3I);
result.script = new File(buildDir, "war3mapj_with_config.j.txt");

FileInputStream inputStream = new FileInputStream(mapScript);
StringWriter sw = new StringWriter();

if (w3data.getWc3PatchVersion().isPresent()) {
w3I.injectConfigsInJassScript(inputStream, sw, w3data.getWc3PatchVersion().get());
} else {
GameVersion version = GameVersion.VERSION_1_32;
WLogger.info(
"Failed to determine installed game version. Falling back to " + version
);
w3I.injectConfigsInJassScript(inputStream, sw, version);
try (FileInputStream inputStream = new FileInputStream(mapScript)) {
StringWriter sw = new StringWriter();

if (w3data.getWc3PatchVersion().isPresent()) {
w3I.injectConfigsInJassScript(inputStream, sw, w3data.getWc3PatchVersion().get());
} else {
GameVersion version = GameVersion.VERSION_1_32;
WLogger.info(
"Failed to determine installed game version. Falling back to " + version
);
w3I.injectConfigsInJassScript(inputStream, sw, version);
}

byte[] scriptBytes = sw.toString().getBytes(StandardCharsets.UTF_8);
Files.write(scriptBytes, result.script);
}
byte[] scriptBytes = sw.toString().getBytes(StandardCharsets.UTF_8);
Files.write(scriptBytes, result.script);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,24 @@ public static String getLog() {
}

private static String getLast100Lines(File file) throws IOException {
FileInputStream fileInputStream = new FileInputStream(file);
FileChannel channel = fileInputStream.getChannel();
ByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
buffer.position((int) channel.size());
int count = 0;
StringBuilder builder = new StringBuilder();
for (long i = channel.size() - 1; i >= 0; i--) {
char c = (char) buffer.get((int) i);
builder.append(c);
if (c == '\n') {
if (count == 100) break;
count++;
FileChannel channel;
try (FileInputStream fileInputStream = new FileInputStream(file)) {
channel = fileInputStream.getChannel();
ByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
buffer.position((int) channel.size());
int count = 0;
StringBuilder builder = new StringBuilder();
for (long i = channel.size() - 1; i >= 0; i--) {
char c = (char) buffer.get((int) i);
builder.append(c);
if (c == '\n') {
if (count == 100) break;
count++;
}
}
return builder.toString();
}
channel.close();
return builder.toString();

}


Expand Down
Loading