mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-15 11:00:17 -07:00
Fixed an edge case when working with varbits that encapsulate the 31st bit of a varp
Fixed health check of whiteberry bush
This commit is contained in:
parent
d04302c99f
commit
aab37414c3
2 changed files with 4 additions and 4 deletions
|
|
@ -1012,7 +1012,7 @@ fun getVarp (player: Player, varpIndex: Int) : Int {
|
||||||
fun getVarbit (player: Player, def: VarbitDefinition) : Int {
|
fun getVarbit (player: Player, def: VarbitDefinition) : Int {
|
||||||
val mask = def.mask
|
val mask = def.mask
|
||||||
val current = getVarp (player, def.varpId)
|
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 {
|
fun getVarbit (player: Player, varbitId: Int) : Int {
|
||||||
|
|
@ -1030,8 +1030,8 @@ fun setVarp (player: Player, varpIndex: Int, value: Int, save: Boolean = false)
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun setVarbit (player: Player, def: VarbitDefinition, value: Int, save: Boolean = false) {
|
fun setVarbit (player: Player, def: VarbitDefinition, value: Int, save: Boolean = false) {
|
||||||
val mask = def.mask
|
val mask = def.mask
|
||||||
val current = getVarp (player, def.varpId) and mask.inv()
|
val current = getVarp (player, def.varpId) and (mask shl def.startBit).inv()
|
||||||
val newValue = (value shl def.startBit) and mask
|
val newValue = (value and mask) shl def.startBit
|
||||||
setVarp (player, def.varpId, current or newValue, save)
|
setVarp (player, def.varpId, current or newValue, save)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ public final class VarbitDefinition {
|
||||||
public int getMask() {
|
public int getMask() {
|
||||||
int mask = 0;
|
int mask = 0;
|
||||||
for (int i = startBit; i <= endBit; i++)
|
for (int i = startBit; i <= endBit; i++)
|
||||||
mask |= (1 << i);
|
mask |= (1 << (i - startBit));
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue