Ethos | Eek - Too many npcs
Before you kill me, I've seen this error on here a couple times and I've tried their solutions but I can't seem to get the issue resolved. I tried changing the bits from 14 to 16, among other things.
The player will dc and can't login for a few login attempts. This happens randomly when you try to login while at home.
Client Error:
Code:
[NPC] Size mismatch : returning
Error: astra Too many npcs
java.lang.RuntimeException: eek
at com.client.Client.method139(Client.java:15355)
at com.client.Client.updateNPCs(Client.java:2703)
at com.client.Client.parsePacket(Client.java:16815)
java.lang.ArrayIndexOutOfBoundsException: 16940
at com.client.definitions.NpcDefinition.forID(NpcDefinition.java:34)
at com.client.Client.method46(Client.java:3812)
at com.client.Client.updateNPCs(Client.java:2704)
at com.client.Client.parsePacket(Client.java:16815)
Error: T2 - Incoming packet: 65, Previous packet: 81, Previous packet 2:99 - Packet size: 268, Player x:3092, Player y:349827,-110,73,36,-110,73,36,-110,73,36,-110,0,-101,-50,-126,17,96,40,30,0,19,121,109,-46,32,6,70,91,124,72,1,-110,-106,-31,2,0,101,102,6,-117,65,-52,-119,-13,-62,-48,103,-93,-1,-8,
Server Error:
Always throws an indexOutOfBounds for the stream.writeBits method. Sometimes gives information saying 512 outofbounds for stream.writeBits, other times it doesn't show any information
Server Methods
Code:
public void addNewNPC(NPC npc, Stream str, Stream updateBlock) {
// synchronized(this) {
int id = npc.getIndex();
npcInListBitmap[id >> 3] |= 1 << (id & 7);
npcList[npcListSize++] = npc;
str.writeBits(14, id);
int z = npc.getY() - getY();
if (z < 0)
z += 32;
str.writeBits(5, z);
z = npc.getX() - getX();
if (z < 0)
z += 32;
str.writeBits(5, z);
str.writeBits(1, 0);
str.writeBits(16, npc.npcType);
boolean savedUpdateRequired = npc.updateRequired;
npc.updateRequired = true;
npc.appendNPCUpdateBlock(updateBlock);
npc.updateRequired = savedUpdateRequired;
str.writeBits(1, 1);
}
Code:
public void updateNPC(Player plr, Stream str) {
// synchronized(plr) {
updateBlock.currentOffset = 0;
str.createFrameVarSizeWord(65);
str.initBitAccess();
str.writeBits(8, plr.npcListSize);
int size = plr.npcListSize;
plr.npcListSize = 0;
for (int i = 0; i < size; i++) {
if (!plr.rebuildNPCList && plr.withinDistance(plr.npcList[i]) && !plr.npcList[i].teleporting) {
plr.npcList[i].updateNPCMovement(str);
plr.npcList[i].appendNPCUpdateBlock(updateBlock);
plr.npcList[plr.npcListSize++] = plr.npcList[i];
} else {
int id = plr.npcList[i].getIndex();
plr.npcInListBitmap[id >> 3] &= ~(1 << (id & 7));
str.writeBits(1, 1);
str.writeBits(2, 3);
}
}
for (int i = 0; i < NPCHandler.maxNPCs; i++) {
if (NPCHandler.npcs[i] != null) {
int id = NPCHandler.npcs[i].getIndex();
if (!plr.rebuildNPCList && (plr.npcInListBitmap[id >> 3] & (1 << (id & 7))) != 0) {
} else if (!plr.withinDistance(NPCHandler.npcs[i])) {
} else {
plr.addNewNPC(NPCHandler.npcs[i], str, updateBlock);
}
}
}
plr.rebuildNPCList = false;
if (updateBlock.currentOffset > 0) {
str.writeBits(14, 16383);
str.finishBitAccess();
str.writeBytes(updateBlock.buffer, updateBlock.currentOffset, 0);
} else {
str.finishBitAccess();
}
str.endFrameVarSizeWord();
// }
}
Client methods:
Code:
private void method46(int i, Stream stream) {
while (stream.bitPosition + 21 < i * 8) {
int k = stream.readBits(14);
if (k == 16383) {
break;
}
if (npcArray[k] == null)
npcArray[k] = new NPC();
NPC npc = npcArray[k];
npcIndices[npcCount++] = k;
npc.anInt1537 = loopCycle;
int l = stream.readBits(5);
if (l > 15)
l -= 32;
int i1 = stream.readBits(5);
if (i1 > 15)
i1 -= 32;
int j1 = stream.readBits(1);
int npcId = stream.readBits(16);
npc.desc = NpcDefinition.forID(npcId);
if (npc.desc.floatingText != null)
npc.floatingText = npc.desc.floatingText;
if (npc.floatingSprite != null)
npc.floatingSprite = npc.floatingSprite;
int k1 = stream.readBits(1);
if (k1 == 1)
anIntArray894[anInt893++] = k;
npc.anInt1540 = npc.desc.boundDim;
npc.anInt1504 = npc.desc.getDegreesToTurn;
npc.anInt1554 = npc.desc.walkAnim;
npc.anInt1555 = npc.desc.anInt58;
npc.anInt1556 = npc.desc.anInt83;
npc.anInt1557 = npc.desc.anInt55;
npc.anInt1511 = npc.desc.standAnim;
npc.setPos(myPlayer.smallX[0] + i1, myPlayer.smallY[0] + l, j1 == 1);
}
stream.finishBitAccess();
}
Code:
if (k > npcCount) {
Signlink.reporterror(myUsername + " Too many npcs");
throw new RuntimeException("eek");
}
This comment is on the updateNpcs client method. I'm wondering if anyone has the real fix rather than the cheaphax fix that someone else did?
Code:
/**
* NPC Updating
* <p>
* There is a crash at random npcs so i did some sort of cheap fix to stop it
* from throwing runtime exception which will ultimately log a player out, even
* regardless of where and when they are in the game, causes to many issues.
*
* @[Only registered and activated users can see links. Click Here To Register...] stream
* @[Only registered and activated users can see links. Click Here To Register...] i
*/
public void updateNPCs(Stream stream, int i) {
Any help is appreciated. Willing to accept help over anydesk if anyone knows the solution!