Dwarf Multicannon, logout on firing
I can build and pick up the dwarf multicannon with no issues but soon as I fire it, it causes the client to logout.
Code:
k: 51 l: 502 j: 53 i1: 1073846709
java.lang.ArrayIndexOutOfBoundsException: 63
Error: T2 - 101,85,65 - 2,3205,3859 - 2,0,
at com.client.Client.method137(Client.java:15263)
at com.client.Client.parsePacket(Client.java:16960)
at com.client.Client.mainGameProcessor(Client.java:4054)
at com.client.Client.processGameLoop(Client.java:3339)
at com.client.RSApplet.run(RSApplet.java:275)
at com.client.Client.run(Client.java:6284)
at java.lang.Thread.run(Unknown Source)
When I checked what was triggering it came down to the rotate method.
Code:
private void rotate(GlobalObject cannon) {
switch (rotation) {
case NORTH:
player.getPA().object(cannon.getPosition().getX(), cannon.getPosition().getY(), 516, 10, -1);
break;
case NORTH_EAST:
player.getPA().object(cannon.getPosition().getX(), cannon.getPosition().getY(), 517, 10, -1);
break;
case EAST:
player.getPA().object(cannon.getPosition().getX(), cannon.getPosition().getY(), 518, 10, -1);
break;
case SOUTH_EAST:
player.getPA().object(cannon.getPosition().getX(), cannon.getPosition().getY(), 519, 10, -1);
break;
case SOUTH:
player.getPA().object(cannon.getPosition().getX(), cannon.getPosition().getY(), 520, 10, -1);
break;
case SOUTH_WEST:
player.getPA().object(cannon.getPosition().getX(), cannon.getPosition().getY(), 521, 10, -1);
break;
case WEST:
player.getPA().object(cannon.getPosition().getX(), cannon.getPosition().getY(), 514, 10, -1);
break;
case NORTH_WEST:
player.getPA().object(cannon.getPosition().getX(), cannon.getPosition().getY(), 515, 10, -1);
rotation = null;
break;
}
}
Code:
public void shoot(Position p) {
findCannon();
if (cannon == null) {
return;
}
if (cannon.getPosition().getX() == p.getX() && cannon.getPosition().getY() == p.getY() && cannon.getPosition().getHeight() == p.getHeight()) {
if (shooting) {
player.sendMessage("Your cannon is already firing!");
return;
}
if (balls < 1) {
int amountOfCannonBalls = player.getItems().getItemAmount(2) > 30 ? 30 : player.getItems().getItemAmount(2);
if (amountOfCannonBalls < 1) {
player.sendMessage("You need ammo to shoot this cannon!");
return;
}
balls = amountOfCannonBalls;
player.getItems().deleteItem(2, amountOfCannonBalls);
shooting = true;
CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() {
@Override
public void execute(CycleEventContainer container) {
System.out.println("Break CEC");
if (player.disconnected || !shooting) {
container.stop();
return;
}
if (balls < 1) {
player.sendMessage("Your cannon has run out of ammo!");
shooting = false;
container.stop();
return;
} else {
if (rotation == null) {
reloadNPCs();
rotation = Rotation.NORTH;
rotate(cannon);
fireAtMobs();
return;
}
switch (rotation) {
case NORTH: // north
rotation = Rotation.NORTH_EAST;
break;
case NORTH_EAST: // north-east
rotation = Rotation.EAST;
break;
case EAST: // east
rotation = Rotation.SOUTH_EAST;
break;
case SOUTH_EAST: // south-east
rotation = Rotation.SOUTH;
break;
case SOUTH: // south
rotation = Rotation.SOUTH_WEST;
break;
case SOUTH_WEST: // south-west
rotation = Rotation.WEST;
break;
case WEST: // west
rotation = Rotation.NORTH_WEST;
break;
case NORTH_WEST: // north-west
rotation = null;
break;
}
rotate(cannon);
fireAtMobs();
}
}
}, 1);
}
} else {
player.sendMessage("This is not your cannon to fire!");
}
}
On all the line segments in order:
*Line
Code:
if (j == 101) {
int l2 = stream.method427();
int k5 = l2 >> 2;
int j8 = l2 & 3;
int i11 = anIntArray1177[k5];
int j13 = stream.readUnsignedByte();
int k15 = anInt1268 + (j13 >> 4 & 7);
int l16 = anInt1269 + (j13 & 7);
Line*if (k15 >= 0 && l16 >= 0 && k15 < 104 && l16 < 104)
method130(-1, -1, j8, i11, l16, k5, plane, k15, 0);
return;
}
Code:
Line*case 106:
tabID = inStream.method427();
needDrawTabArea = true;
tabAreaAltered = true;
incomingPacket = -1;
return true;
Code:
if (!loggedIn)
Line*return;
Code:
Line*//handleSounds();
Code:
for (; i1 < 256; i1 += j) {
clickMode3 = clickMode1;
saveClickX = clickX;
saveClickY = clickY;
aLong29 = clickTime;
clickMode1 = 0;
Line*processGameLoop();
readIndex = writeIndex;
}
Code:
Line*private void build3dScreenMenu() {
if (itemSelected == 0 && spellSelected == 0) {
menuActionName[menuActionRow] = "Walk here";
menuActionID[menuActionRow] = 516;
menuActionCmd2[menuActionRow] = super.mouseX;
menuActionCmd3[menuActionRow] = super.mouseY;
menuActionRow++;
}
Help would be so appreciated.