@@ -147,10 +147,10 @@ private static String calculateProjectConfigHash(WurstProjectConfigData projectC
147147 .append ("," ).append (force .getFlags ().getSharedControl ())
148148 .append ("," ).append (force .getFlags ().getSharedControlAdvanced ())
149149 .append ("players:" );
150- for (int id : force .getPlayerIds ()) {
151- sb .append (id ).append ("," );
152- }
153- sb .append ("\n " );
150+ for (int id : force .getPlayerIds ()) {
151+ sb .append (id ).append ("," );
152+ }
153+ sb .append ("\n " );
154154 }
155155
156156 // Option flags
@@ -175,20 +175,22 @@ private static void applyBuildMapData(WurstProjectConfigData projectConfig, File
175175 prepareW3I (projectConfig , w3I );
176176 result .script = new File (buildDir , "war3mapj_with_config.j.txt" );
177177
178- FileInputStream inputStream = new FileInputStream (mapScript );
179- StringWriter sw = new StringWriter ();
180-
181- if (w3data .getWc3PatchVersion ().isPresent ()) {
182- w3I .injectConfigsInJassScript (inputStream , sw , w3data .getWc3PatchVersion ().get ());
183- } else {
184- GameVersion version = GameVersion .VERSION_1_32 ;
185- WLogger .info (
186- "Failed to determine installed game version. Falling back to " + version
187- );
188- w3I .injectConfigsInJassScript (inputStream , sw , version );
178+ try (FileInputStream inputStream = new FileInputStream (mapScript )) {
179+ StringWriter sw = new StringWriter ();
180+
181+ if (w3data .getWc3PatchVersion ().isPresent ()) {
182+ w3I .injectConfigsInJassScript (inputStream , sw , w3data .getWc3PatchVersion ().get ());
183+ } else {
184+ GameVersion version = GameVersion .VERSION_1_32 ;
185+ WLogger .info (
186+ "Failed to determine installed game version. Falling back to " + version
187+ );
188+ w3I .injectConfigsInJassScript (inputStream , sw , version );
189+ }
190+
191+ byte [] scriptBytes = sw .toString ().getBytes (StandardCharsets .UTF_8 );
192+ Files .write (scriptBytes , result .script );
189193 }
190- byte [] scriptBytes = sw .toString ().getBytes (StandardCharsets .UTF_8 );
191- Files .write (scriptBytes , result .script );
192194 }
193195
194196
0 commit comments