Extend varp array to support cases where a server has >2500

This commit is contained in:
Pazaz 2022-04-27 11:35:48 -04:00
parent 1523a94221
commit aa72ec12d2
15 changed files with 28 additions and 29 deletions

View file

@ -576,8 +576,8 @@ public class ClientProt {
local693 = InterfaceList.getComponent(local19); local693 = InterfaceList.getComponent(local19);
if (local693.anIntArrayArray4 != null && local693.anIntArrayArray4[0][0] == 5) { if (local693.anIntArrayArray4 != null && local693.anIntArrayArray4[0][0] == 5) {
local1955 = local693.anIntArrayArray4[0][1]; local1955 = local693.anIntArrayArray4[0][1];
if (VarpDomain.varps[local1955] != local693.anIntArray48[0]) { if (VarpDomain.activeVarps[local1955] != local693.anIntArray48[0]) {
VarpDomain.varps[local1955] = local693.anIntArray48[0]; VarpDomain.activeVarps[local1955] = local693.anIntArray48[0];
Static85.refreshMagicVarp(local1955); Static85.refreshMagicVarp(local1955);
} }
} }
@ -603,7 +603,7 @@ public class ClientProt {
local693 = InterfaceList.getComponent(local19); local693 = InterfaceList.getComponent(local19);
if (local693.anIntArrayArray4 != null && local693.anIntArrayArray4[0][0] == 5) { if (local693.anIntArrayArray4 != null && local693.anIntArrayArray4[0][0] == 5) {
local1955 = local693.anIntArrayArray4[0][1]; local1955 = local693.anIntArrayArray4[0][1];
VarpDomain.varps[local1955] = 1 - VarpDomain.varps[local1955]; VarpDomain.activeVarps[local1955] = 1 - VarpDomain.activeVarps[local1955];
Static85.refreshMagicVarp(local1955); Static85.refreshMagicVarp(local1955);
} }
} }

View file

@ -213,7 +213,7 @@ public final class LocType {
if (this.multiLocVarbit != -1) { if (this.multiLocVarbit != -1) {
local26 = Static155.getVarbit(this.multiLocVarbit); local26 = Static155.getVarbit(this.multiLocVarbit);
} else if (this.multiLocVarp != -1) { } else if (this.multiLocVarp != -1) {
local26 = VarpDomain.varps[this.multiLocVarp]; local26 = VarpDomain.activeVarps[this.multiLocVarp];
} }
if (local26 < 0 || local26 >= this.multiLocs.length - 1 || this.multiLocs[local26] == -1) { if (local26 < 0 || local26 >= this.multiLocs.length - 1 || this.multiLocs[local26] == -1) {
@Pc(84) int local84 = this.multiLocs[this.multiLocs.length - 1]; @Pc(84) int local84 = this.multiLocs[this.multiLocs.length - 1];

View file

@ -161,7 +161,7 @@ public final class NpcType {
if (this.multiNpcVarbit != -1) { if (this.multiNpcVarbit != -1) {
local5 = Static155.getVarbit(this.multiNpcVarbit); local5 = Static155.getVarbit(this.multiNpcVarbit);
} else if (this.multiNpcVarp != -1) { } else if (this.multiNpcVarp != -1) {
local5 = VarpDomain.varps[this.multiNpcVarp]; local5 = VarpDomain.activeVarps[this.multiNpcVarp];
} }
if (local5 < 0 || local5 >= this.multiNpcs.length - 1 || this.multiNpcs[local5] == -1) { if (local5 < 0 || local5 >= this.multiNpcs.length - 1 || this.multiNpcs[local5] == -1) {
@Pc(55) int local55 = this.multiNpcs[this.multiNpcs.length - 1]; @Pc(55) int local55 = this.multiNpcs[this.multiNpcs.length - 1];
@ -180,7 +180,7 @@ public final class NpcType {
if (this.multiNpcVarbit != -1) { if (this.multiNpcVarbit != -1) {
local16 = Static155.getVarbit(this.multiNpcVarbit); local16 = Static155.getVarbit(this.multiNpcVarbit);
} else if (this.multiNpcVarp != -1) { } else if (this.multiNpcVarp != -1) {
local16 = VarpDomain.varps[this.multiNpcVarp]; local16 = VarpDomain.activeVarps[this.multiNpcVarp];
} }
if (local16 < 0 || local16 >= this.multiNpcs.length - 1 || this.multiNpcs[local16] == -1) { if (local16 < 0 || local16 >= this.multiNpcs.length - 1 || this.multiNpcs[local16] == -1) {
@Pc(62) int local62 = this.multiNpcs[this.multiNpcs.length - 1]; @Pc(62) int local62 = this.multiNpcs[this.multiNpcs.length - 1];

View file

@ -1568,9 +1568,9 @@ public class Protocol {
opcode = -1; opcode = -1;
return true; return true;
} else if (opcode == ServerProt.FORCE_VARP_REFRESH) { } else if (opcode == ServerProt.FORCE_VARP_REFRESH) {
for (int i = 0; i < VarpDomain.varps.length; i++) { for (int i = 0; i < VarpDomain.activeVarps.length; i++) {
if (Static106.varp[i] != VarpDomain.varps[i]) { if (VarpDomain.varp[i] != VarpDomain.activeVarps[i]) {
VarpDomain.varps[i] = Static106.varp[i]; VarpDomain.activeVarps[i] = VarpDomain.varp[i];
Static85.refreshMagicVarp(i); Static85.refreshMagicVarp(i);
VarpDomain.updatedVarps[VarpDomain.updatedVarpsWriterIndex++ & 0x1F] = i; VarpDomain.updatedVarps[VarpDomain.updatedVarpsWriterIndex++ & 0x1F] = i;
} }

View file

@ -98,7 +98,7 @@ public final class ScriptRunner {
} }
if (opcode == 1) { if (opcode == 1) {
id = intOperands[pc]; id = intOperands[pc];
intStack[isp++] = VarpDomain.varps[id]; intStack[isp++] = VarpDomain.activeVarps[id];
continue; continue;
} }
if (opcode == 2) { if (opcode == 2) {

View file

@ -7,7 +7,4 @@ public final class Static106 {
@OriginalMember(owner = "client!ic", name = "a", descriptor = "Lclient!qf;") @OriginalMember(owner = "client!ic", name = "a", descriptor = "Lclient!qf;")
public static Sprite compass; public static Sprite compass;
@OriginalMember(owner = "client!ic", name = "e", descriptor = "[I")
public static final int[] varp = new int[2500];
} }

View file

@ -20,7 +20,7 @@ public final class Static148 {
@OriginalMember(owner = "client!li", name = "a", descriptor = "(III)V") @OriginalMember(owner = "client!li", name = "a", descriptor = "(III)V")
public static void method2766(@OriginalArg(0) int arg0, @OriginalArg(2) int arg1) { public static void method2766(@OriginalArg(0) int arg0, @OriginalArg(2) int arg1) {
VarpDomain.varps[arg0] = arg1; VarpDomain.activeVarps[arg0] = arg1;
@Pc(21) LongNode local21 = (LongNode) Static199.aClass133_20.get((long) arg0); @Pc(21) LongNode local21 = (LongNode) Static199.aClass133_20.get((long) arg0);
if (local21 == null) { if (local21 == null) {
local21 = new LongNode(MonotonicClock.currentTimeMillis() + 500L); local21 = new LongNode(MonotonicClock.currentTimeMillis() + 500L);

View file

@ -52,6 +52,6 @@ public final class Static155 {
@Pc(19) int local19 = local13.endBit; @Pc(19) int local19 = local13.endBit;
@Pc(22) int local22 = local13.startBit; @Pc(22) int local22 = local13.startBit;
@Pc(29) int local29 = Class3_Sub9.anIntArray135[local19 - local22]; @Pc(29) int local29 = Class3_Sub9.anIntArray135[local19 - local22];
return VarpDomain.varps[local16] >> local22 & local29; return VarpDomain.activeVarps[local16] >> local22 & local29;
} }
} }

View file

@ -93,7 +93,7 @@ public final class Static202 {
arg1 = 0; arg1 = 0;
} }
local25 <<= local16; local25 <<= local16;
Static148.method2766(local19, local25 & arg1 << local16 | VarpDomain.varps[local19] & ~local25); Static148.method2766(local19, local25 & arg1 << local16 | VarpDomain.activeVarps[local19] & ~local25);
} }
@OriginalMember(owner = "client!qg", name = "a", descriptor = "([Lclient!na;[SI)V") @OriginalMember(owner = "client!qg", name = "a", descriptor = "([Lclient!na;[SI)V")

View file

@ -20,6 +20,6 @@ public final class Static272 {
arg0 = 0; arg0 = 0;
} }
local29 <<= local23; local29 <<= local23;
VarpDomain.set(arg0 << local23 & local29 | ~local29 & Static106.varp[local17], local17); VarpDomain.set(arg0 << local23 & local29 | ~local29 & VarpDomain.varp[local17], local17);
} }
} }

View file

@ -73,13 +73,13 @@ public final class Static273 {
} }
} }
if (local46 == 5) { if (local46 == 5) {
local41 = VarpDomain.varps[local33[local39++]]; local41 = VarpDomain.activeVarps[local33[local39++]];
} }
if (local46 == 6) { if (local46 == 6) {
local41 = PlayerSkillXpTable.xpLevelLookup[PlayerSkillXpTable.baseLevels[local33[local39++]] - 1]; local41 = PlayerSkillXpTable.xpLevelLookup[PlayerSkillXpTable.baseLevels[local33[local39++]] - 1];
} }
if (local46 == 7) { if (local46 == 7) {
local41 = VarpDomain.varps[local33[local39++]] * 100 / 46875; local41 = VarpDomain.activeVarps[local33[local39++]] * 100 / 46875;
} }
if (local46 == 8) { if (local46 == 8) {
local41 = PlayerList.self.combatLevel; local41 = PlayerList.self.combatLevel;
@ -112,7 +112,7 @@ public final class Static273 {
local41 = Player.weight; local41 = Player.weight;
} }
if (local46 == 13) { if (local46 == 13) {
local124 = VarpDomain.varps[local33[local39++]]; local124 = VarpDomain.activeVarps[local33[local39++]];
@Pc(353) int local353 = local33[local39++]; @Pc(353) int local353 = local33[local39++];
local41 = (0x1 << local353 & local124) == 0 ? 0 : 1; local41 = (0x1 << local353 & local124) == 0 ? 0 : 1;
} }

View file

@ -144,7 +144,7 @@ public final class Static38 {
if ((local28.value & 0x3FFFFFFFFFFFFFFFL) < local4) { if ((local28.value & 0x3FFFFFFFFFFFFFFFL) < local4) {
if ((local28.value & 0x4000000000000000L) != 0L) { if ((local28.value & 0x4000000000000000L) != 0L) {
@Pc(58) int local58 = (int) local28.key; @Pc(58) int local58 = (int) local28.key;
VarpDomain.varps[local58] = Static106.varp[local58]; VarpDomain.activeVarps[local58] = VarpDomain.varp[local58];
local28.unlink(); local28.unlink();
return local58; return local58;
} }

View file

@ -116,8 +116,8 @@ public final class Static8 {
for (@Pc(3) int local3 = 0; local3 < VarpTypeList.anInt4043; local3++) { for (@Pc(3) int local3 = 0; local3 < VarpTypeList.anInt4043; local3++) {
@Pc(19) VarpType local19 = VarpTypeList.get(local3); @Pc(19) VarpType local19 = VarpTypeList.get(local3);
if (local19 != null && local19.clientCode == 0) { if (local19 != null && local19.clientCode == 0) {
Static106.varp[local3] = 0; VarpDomain.varp[local3] = 0;
VarpDomain.varps[local3] = 0; VarpDomain.activeVarps[local3] = 0;
} }
} }
Static199.aClass133_20 = new HashTable(16); Static199.aClass133_20 = new HashTable(16);

View file

@ -20,7 +20,7 @@ public final class Static85 {
if (local17 == 0) { if (local17 == 0) {
return; return;
} }
@Pc(25) int local25 = VarpDomain.varps[arg0]; @Pc(25) int local25 = VarpDomain.activeVarps[arg0];
if (local17 == 6) { if (local17 == 6) {
Static79.anInt2157 = local25; Static79.anInt2157 = local25;
} }

View file

@ -7,18 +7,20 @@ import org.openrs2.deob.annotation.Pc;
public class VarpDomain { public class VarpDomain {
@OriginalMember(owner = "client!gj", name = "q", descriptor = "[I") @OriginalMember(owner = "client!gj", name = "q", descriptor = "[I")
public static final int[] updatedVarps = new int[32]; public static final int[] updatedVarps = new int[32];
@OriginalMember(owner = "client!ic", name = "e", descriptor = "[I")
public static final int[] varp = new int[3500];
@OriginalMember(owner = "client!ah", name = "j", descriptor = "[I") @OriginalMember(owner = "client!ah", name = "j", descriptor = "[I")
public static final int[] varps = new int[2500]; public static final int[] activeVarps = new int[3500];
@OriginalMember(owner = "client!fi", name = "n", descriptor = "I") @OriginalMember(owner = "client!fi", name = "n", descriptor = "I")
public static int updatedVarpsWriterIndex = 0; public static int updatedVarpsWriterIndex = 0;
@OriginalMember(owner = "client!nh", name = "a", descriptor = "(BII)V") @OriginalMember(owner = "client!nh", name = "a", descriptor = "(BII)V")
public static void set(@OriginalArg(1) int arg0, @OriginalArg(2) int arg1) { public static void set(@OriginalArg(1) int value, @OriginalArg(2) int id) {
Static106.varp[arg1] = arg0; varp[id] = value;
@Pc(20) LongNode local20 = (LongNode) Static199.aClass133_20.get((long) arg1); @Pc(20) LongNode local20 = (LongNode) Static199.aClass133_20.get((long) id);
if (local20 == null) { if (local20 == null) {
local20 = new LongNode(4611686018427387905L); local20 = new LongNode(4611686018427387905L);
Static199.aClass133_20.put(local20, (long) arg1); Static199.aClass133_20.put(local20, (long) id);
} else if (local20.value != 4611686018427387905L) { } else if (local20.value != 4611686018427387905L) {
local20.value = MonotonicClock.currentTimeMillis() + 500L | 0x4000000000000000L; local20.value = MonotonicClock.currentTimeMillis() + 500L | 0x4000000000000000L;
} }