Skip to content

Commit

Permalink
Fix[JNA]: use bitshift for packing version number
Browse files Browse the repository at this point in the history
When using a char array, a non-zero patch version will break the check.
Changed it to bitshift.
  • Loading branch information
khanhduytran0 committed Feb 5, 2025
1 parent 6aacf3a commit 7d8203b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Natives/MinecraftResourceUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ + (void)tweakVersionJson:(NSMutableDictionary *)json {
if ([library[@"name"] hasPrefix:@"net.java.dev.jna:jna:"]) {
// Special handling for LabyMod 1.8.9 and Forge 1.12.2(?)
// we have libjnidispatch 5.13.0 in Frameworks directory
char bundledVer[4] = {5, 13, 0, 0};
char requiredVer[4] = {(char)version[0].intValue, (char)version[1].intValue, (char)version[2].intValue, 0};
if (*(uint32_t *)requiredVer > *(uint32_t*)bundledVer) {
uint32_t bundledVer = 5 << 16 | 13 << 8 | 0;
uint32_t requiredVer = (char)version[0].intValue << 16 | (char)version[1].intValue << 8 | (char)version[2].intValue;
if (requiredVer > bundledVer) {
NSLog(@"[MCDL] Warning: JNA version required by %@ is %@ > 5.13.0, skipping JNA replacement.", json[@"id"], versionStr);
continue;
}
Expand Down

0 comments on commit 7d8203b

Please sign in to comment.