CF: Treat versions with no loader as equal in loader comparison

This commit is contained in:
comp500 2023-05-31 16:08:10 +01:00
parent 7b380f23df
commit cbd38b3b73

View File

@ -305,9 +305,14 @@ func findLatestFile(modInfoData modInfo, mcVersions []string, packLoaders []stri
// Compare first by Minecraft version (prefer higher indexes of mcVersions)
compare := int32(mcVerIdx - bestMcVer)
if compare == 0 {
// Treat unmarked versions as neutral (i.e. same as others)
if bestLoaderType == modloaderTypeAny || loaderIdx == modloaderTypeAny {
compare = 0
} else {
// Prefer higher loader indexes
compare = int32(loaderIdx) - int32(bestLoaderType)
}
}
if compare == 0 {
// Other comparisons are equal, compare by ID instead
compare = int32(int64(v.ID) - int64(fileID))
@ -332,9 +337,14 @@ func findLatestFile(modInfoData modInfo, mcVersions []string, packLoaders []stri
// Compare first by Minecraft version (prefer higher indexes of mcVersions)
compare := int32(mcVerIdx - bestMcVer)
if compare == 0 {
// Treat unmarked versions as neutral (i.e. same as others)
if bestLoaderType == modloaderTypeAny || loaderIdx == modloaderTypeAny {
compare = 0
} else {
// Prefer higher loader indexes
compare = int32(loaderIdx) - int32(bestLoaderType)
}
}
if compare == 0 {
// Other comparisons are equal, compare by ID instead
compare = int32(int64(v.ID) - int64(fileID))