diff --git a/Server/src/main/core/api/ContentAPI.kt b/Server/src/main/core/api/ContentAPI.kt index 9de96075b..aabc95bcc 100644 --- a/Server/src/main/core/api/ContentAPI.kt +++ b/Server/src/main/core/api/ContentAPI.kt @@ -1012,7 +1012,7 @@ fun getVarp (player: Player, varpIndex: Int) : Int { fun getVarbit (player: Player, def: VarbitDefinition) : Int { val mask = def.mask val current = getVarp (player, def.varpId) - return (current and mask) shr def.startBit + return (current shr def.startBit) and mask } fun getVarbit (player: Player, varbitId: Int) : Int { @@ -1030,8 +1030,8 @@ fun setVarp (player: Player, varpIndex: Int, value: Int, save: Boolean = false) @JvmOverloads fun setVarbit (player: Player, def: VarbitDefinition, value: Int, save: Boolean = false) { val mask = def.mask - val current = getVarp (player, def.varpId) and mask.inv() - val newValue = (value shl def.startBit) and mask + val current = getVarp (player, def.varpId) and (mask shl def.startBit).inv() + val newValue = (value and mask) shl def.startBit setVarp (player, def.varpId, current or newValue, save) } diff --git a/Server/src/main/core/cache/def/impl/VarbitDefinition.java b/Server/src/main/core/cache/def/impl/VarbitDefinition.java index fa3d94ddc..9fb4f6b15 100644 --- a/Server/src/main/core/cache/def/impl/VarbitDefinition.java +++ b/Server/src/main/core/cache/def/impl/VarbitDefinition.java @@ -162,7 +162,7 @@ public final class VarbitDefinition { public int getMask() { int mask = 0; for (int i = startBit; i <= endBit; i++) - mask |= (1 << i); + mask |= (1 << (i - startBit)); return mask; }