@@ -205,6 +205,30 @@ public void patchComplianceRequiresKnownMatchingClientWhenPinned() throws Except
205205 assertFalse (isPatchCompliant (Optional .of (WurstBuildConfig .Wc3Patch .PRE_129 ), Optional .empty ()));
206206 }
207207
208+ @ Test
209+ public void retryLaunchSelectionRechecksPatchCompliance () throws Exception {
210+ Path project = projectWithPatch ("v1.27b" );
211+ W3InstallationData reforgedRetry = installationData ("warcraft-reforged-retry" , "Warcraft III.exe" , GameVersion .VERSION_1_32 );
212+ W3InstallationData legacySelection = installationData ("warcraft-legacy-selection" , "war3.exe" , new GameVersion ("1.27" ));
213+ Path fakeInitialExe = Files .writeString (Files .createTempFile ("not-warcraft-initial" , ".exe" ), "not a PE file" );
214+
215+ PatchComplianceRunMap request = new PatchComplianceRunMap (project , legacySelection , fakeInitialExe .toString ());
216+
217+ W3InstallationData resolved = request .resolveAfterRetry (reforgedRetry );
218+
219+ assertEquals (request .mismatchPrompts , 1 );
220+ assertEquals (
221+ resolved .getGameExe ().orElseThrow ().getAbsoluteFile (),
222+ legacySelection .getGameExe ().orElseThrow ().getAbsoluteFile ()
223+ );
224+ }
225+
226+ private static W3InstallationData installationData (String folderPrefix , String exeName , GameVersion version ) throws IOException {
227+ Path install = Files .createTempDirectory (folderPrefix );
228+ Path exe = Files .writeString (install .resolve (exeName ), "not a PE file" );
229+ return new W3InstallationData (Optional .of (exe .toFile ()), Optional .of (version ));
230+ }
231+
208232 private static boolean isPatchCompliant (Optional <WurstBuildConfig .Wc3Patch > projectKind ,
209233 Optional <GameVersion > clientVersion ) throws Exception {
210234 Method method = RunMap .class .getDeclaredMethod ("isPatchCompliant" , Optional .class , Optional .class );
@@ -274,4 +298,29 @@ Optional<File> gameExe() {
274298 return w3data .getGameExe ();
275299 }
276300 }
301+
302+ private static final class PatchComplianceRunMap extends RunMap {
303+ private final W3InstallationData alternateSelection ;
304+ private int mismatchPrompts = 0 ;
305+
306+ PatchComplianceRunMap (Path projectRoot , W3InstallationData alternateSelection , String gameExePath ) {
307+ super (null , WFile .create (projectRoot ), Optional .empty (), Optional .empty (), List .of (), Optional .of (gameExePath ));
308+ this .alternateSelection = alternateSelection ;
309+ }
310+
311+ W3InstallationData resolveAfterRetry (W3InstallationData retrySelection ) {
312+ return resolveLaunchData (retrySelection );
313+ }
314+
315+ @ Override
316+ protected MismatchChoice chooseMismatchAction (String message ) {
317+ mismatchPrompts ++;
318+ return MismatchChoice .CHOOSE_OTHER ;
319+ }
320+
321+ @ Override
322+ protected Optional <W3InstallationData > chooseAlternateGamePath () {
323+ return Optional .of (alternateSelection );
324+ }
325+ }
277326}
0 commit comments