Skip to content

Commit 6ef755f

Browse files
committed
pre 1.24 support
1 parent c03d970 commit 6ef755f

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

src/main/kotlin/file/CoreJassProvider.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff 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()) {

src/main/kotlin/file/SetupApp.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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")

0 commit comments

Comments
 (0)