File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -114,6 +114,28 @@ object CoreJassProvider {
114114 return PATCH_TO_JASS_HISTORY_FOLDER .containsKey(normalized) || looksLikeJassHistoryFolder(normalized)
115115 }
116116
117+ /* *
118+ * Whether the patch targets a version before 1.24. These legacy patches ship Blizzard
119+ * common.j/blizzard.j with return-type mismatches the Jass VM tolerates, so the compiler
120+ * must relax Jass type checks and skip PJass for them.
121+ */
122+ fun isPre124 (patch : String? ): Boolean {
123+ val normalized = normalizePatchInput(patch)
124+ val gameVersion = Wc3PatchTarget .parse(normalized).orElse(null )?.gameVersion() ? : return false
125+ return compareVersionStrings(gameVersion, " 1.24" ) < 0
126+ }
127+
128+ private fun compareVersionStrings (a : String , b : String ): Int {
129+ val pa = a.split(" ." )
130+ val pb = b.split(" ." )
131+ for (i in 0 until maxOf(pa.size, pb.size)) {
132+ val na = pa.getOrNull(i)?.takeWhile { it.isDigit() }?.toIntOrNull() ? : 0
133+ val nb = pb.getOrNull(i)?.takeWhile { it.isDigit() }?.toIntOrNull() ? : 0
134+ if (na != nb) return na - nb
135+ }
136+ return 0
137+ }
138+
117139 fun normalizePatchInput (input : String? ): String {
118140 val patch = input?.trim().orEmpty()
119141 val normalizedAlias = when (patch.lowercase()) {
Original file line number Diff line number Diff line change @@ -919,6 +919,11 @@ object SetupApp {
919919 if (setup.noPJass) {
920920 args.add(" -noPJass" )
921921 }
922+ // Pre-1.24 targets ship Blizzard common.j/blizzard.j with return-type mismatches
923+ // the Jass VM tolerates. Tell the compiler to relax Jass type checks and skip PJass.
924+ if (CoreJassProvider .isPre124(configData.wc3Patch)) {
925+ args.add(" -legacyJassChecks" )
926+ }
922927
923928 configData.dependencies.stream().forEach {
924929 args.add(" -lib" )
You can’t perform that action at this time.
0 commit comments