Program: 44251
Project: 44251
Buggy source:
protected final void handleIncomingPacket(int command,int length,byte data[]){
  try {
    if (command == 254) {
      int bar=DataOperations.getUnsigned4Bytes(data,1);
      if (bar == -1) {
        smithingscreen.isVisible=false;
      }
 else {
        SmithingScreen.changeItems(smithingscreen,bar);
        smithingscreen.isVisible=true;
      }
    }
    if (command == 231) {
      return;
    }
    if (command == 233) {
      questPoints=DataOperations.getUnsignedByte(data[1]);
      int k=DataOperations.getUnsignedByte(data[2]);
      int r=3;
      newQuestNames=new String[k];
      questStage=new byte[k];
      for (int i=0; i < k; i++) {
        int uid=DataOperations.getUnsignedByte(data[r]);
        r++;
        newQuestNames[i]=questName[uid];
        questStage[i]=(byte)DataOperations.getUnsignedByte(data[r]);
        r++;
      }
    }
    if (command == 110) {
      int i=1;
      serverStartTime=DataOperations.getUnsigned8Bytes(data,i);
      i+=8;
      serverLocation=new String(data,i,length - i);
      return;
    }
    if (command == 145) {
      if (!hasWorldInfo) {
        return;
      }
      loading=true;
      lastPlayerCount=playerCount;
      for (int k=0; k < lastPlayerCount; k++)       lastPlayerArray[k]=playerArray[k];
      int currentOffset=8;
      setSectionX(DataOperations.getIntFromByteArray(data,currentOffset,11));
      currentOffset+=11;
      setSectionY(DataOperations.getIntFromByteArray(data,currentOffset,13));
      currentOffset+=13;
      int mobSprite=DataOperations.getIntFromByteArray(data,currentOffset,4);
      currentOffset+=4;
      boolean sectionLoaded=loadSection(getSectionX(),getSectionY());
      setSectionX(getSectionX() - getAreaX());
      setSectionY(getSectionY() - getAreaY());
      int mapEnterX=getSectionX() * magicLoc + 64;
      int mapEnterY=getSectionY() * magicLoc + 64;
      if (sectionLoaded) {
        ourPlayer.waypointCurrent=0;
        ourPlayer.waypointEndSprite=0;
        ourPlayer.currentX=ourPlayer.waypointsX[0]=mapEnterX;
        ourPlayer.currentY=ourPlayer.waypointsY[0]=mapEnterY;
      }
      playerCount=0;
      ourPlayer=makePlayer(serverIndex,mapEnterX,mapEnterY,mobSprite);
      int newPlayerCount=DataOperations.getIntFromByteArray(data,currentOffset,8);
      currentOffset+=8;
      for (int currentNewPlayer=0; currentNewPlayer < newPlayerCount; currentNewPlayer++) {
        Mob lastMob=getLastPlayer(DataOperations.getIntFromByteArray(data,currentOffset,16));
        currentOffset+=16;
        int nextPlayer=DataOperations.getIntFromByteArray(data,currentOffset,1);
        currentOffset++;
        if (nextPlayer != 0) {
          int waypointsLeft=DataOperations.getIntFromByteArray(data,currentOffset,1);
          currentOffset++;
          if (waypointsLeft == 0) {
            int currentNextSprite=DataOperations.getIntFromByteArray(data,currentOffset,3);
            currentOffset+=3;
            int currentWaypoint=lastMob.waypointCurrent;
            int newWaypointX=lastMob.waypointsX[currentWaypoint];
            int newWaypointY=lastMob.waypointsY[currentWaypoint];
            if (currentNextSprite == 2 || currentNextSprite == 1 || currentNextSprite == 3)             newWaypointX+=magicLoc;
            if (currentNextSprite == 6 || currentNextSprite == 5 || currentNextSprite == 7)             newWaypointX-=magicLoc;
            if (currentNextSprite == 4 || currentNextSprite == 3 || currentNextSprite == 5)             newWaypointY+=magicLoc;
            if (currentNextSprite == 0 || currentNextSprite == 1 || currentNextSprite == 7)             newWaypointY-=magicLoc;
            lastMob.nextSprite=currentNextSprite;
            lastMob.waypointCurrent=currentWaypoint=(currentWaypoint + 1) % 10;
            lastMob.waypointsX[currentWaypoint]=newWaypointX;
            lastMob.waypointsY[currentWaypoint]=newWaypointY;
          }
 else {
            int needsNextSprite=DataOperations.getIntFromByteArray(data,currentOffset,4);
            currentOffset+=4;
            if ((needsNextSprite & 0xc) == 12) {
              continue;
            }
            lastMob.nextSprite=needsNextSprite;
          }
        }
        playerArray[playerCount++]=lastMob;
      }
      int mobCount=0;
      while (currentOffset + 24 < length * 8) {
        int mobIndex=DataOperations.getIntFromByteArray(data,currentOffset,16);
        currentOffset+=16;
        int areaMobX=DataOperations.getIntFromByteArray(data,currentOffset,5);
        currentOffset+=5;
        if (areaMobX > 15)         areaMobX-=32;
        int areaMobY=DataOperations.getIntFromByteArray(data,currentOffset,5);
        currentOffset+=5;
        if (areaMobY > 15)         areaMobY-=32;
        int mobArrayMobID=DataOperations.getIntFromByteArray(data,currentOffset,4);
        currentOffset+=4;
        int addIndex=DataOperations.getIntFromByteArray(data,currentOffset,1);
        currentOffset++;
        int mobX=(getSectionX() + areaMobX) * magicLoc + 64;
        int mobY=(getSectionY() + areaMobY) * magicLoc + 64;
        makePlayer(mobIndex,mobX,mobY,mobArrayMobID);
        if (addIndex == 0)         mobArrayIndexes[mobCount++]=mobIndex;
      }
      if (mobCount > 0) {
        super.streamClass.createPacket(83);
        super.streamClass.add2ByteInt(mobCount);
        for (int currentMob=0; currentMob < mobCount; currentMob++) {
          Mob dummyMob=mobArray[mobArrayIndexes[currentMob]];
          super.streamClass.add2ByteInt(dummyMob.serverIndex);
          super.streamClass.add2ByteInt(dummyMob.mobIntUnknown);
        }
        super.streamClass.formatPacket();
        mobCount=0;
      }
      loading=false;
      return;
    }
    if (command == 109) {
      for (int l=1; l < length; )       if (DataOperations.getUnsignedByte(data[l]) == 255) {
        int newCount=0;
        int newSectionX=getSectionX() + data[l + 1] >> 3;
        int newSectionY=getSectionY() + data[l + 2] >> 3;
        l+=3;
        for (int groundItem=0; groundItem < groundItemCount; groundItem++) {
          int newX=(groundItemX[groundItem] >> 3) - newSectionX;
          int newY=(groundItemY[groundItem] >> 3) - newSectionY;
          if (newX != 0 || newY != 0) {
            if (groundItem != newCount) {
              groundItemX[newCount]=groundItemX[groundItem];
              groundItemY[newCount]=groundItemY[groundItem];
              groundItemType[newCount]=groundItemType[groundItem];
              groundItemObjectVar[newCount]=groundItemObjectVar[groundItem];
            }
            newCount++;
          }
        }
        groundItemCount=newCount;
      }
 else {
        int i8=DataOperations.getUnsigned2Bytes(data,l);
        l+=2;
        int k14=getSectionX() + data[l++];
        int j19=getSectionY() + data[l++];
        if ((i8 & 0x8000) == 0) {
          groundItemX[groundItemCount]=k14;
          groundItemY[groundItemCount]=j19;
          groundItemType[groundItemCount]=i8;
          groundItemObjectVar[groundItemCount]=0;
          for (int k23=0; k23 < objectCount; k23++) {
            if (objectX[k23] != k14 || objectY[k23] != j19)             continue;
            groundItemObjectVar[groundItemCount]=EntityHandler.getObjectDef(objectType[k23]).getGroundItemVar();
            break;
          }
          groundItemCount++;
        }
 else {
          i8&=0x7fff;
          int l23=0;
          for (int k26=0; k26 < groundItemCount; k26++) {
            if (groundItemX[k26] != k14 || groundItemY[k26] != j19 || groundItemType[k26] != i8) {
              if (k26 != l23) {
                groundItemX[l23]=groundItemX[k26];
                groundItemY[l23]=groundItemY[k26];
                groundItemType[l23]=groundItemType[k26];
                groundItemObjectVar[l23]=groundItemObjectVar[k26];
              }
              l23++;
            }
 else {
              i8=-123;
            }
          }
          groundItemCount=l23;
        }
      }
      return;
    }
    if (command == 27) {
      for (int i1=1; i1 < length; )       if (DataOperations.getUnsignedByte(data[i1]) == 255) {
        int j8=0;
        int l14=getSectionX() + data[i1 + 1] >> 3;
        int k19=getSectionY() + data[i1 + 2] >> 3;
        i1+=3;
        for (int i24=0; i24 < objectCount; i24++) {
          int l26=(objectX[i24] >> 3) - l14;
          int k29=(objectY[i24] >> 3) - k19;
          if (l26 != 0 || k29 != 0) {
            if (i24 != j8) {
              objectModelArray[j8]=objectModelArray[i24];
              objectModelArray[j8].anInt257=j8;
              objectX[j8]=objectX[i24];
              objectY[j8]=objectY[i24];
              objectType[j8]=objectType[i24];
              objectID[j8]=objectID[i24];
            }
            j8++;
          }
 else {
            gameCamera.removeModel(objectModelArray[i24]);
            engineHandle.updateObject(objectX[i24],objectY[i24],objectType[i24],objectID[i24]);
          }
        }
        objectCount=j8;
      }
 else {
        int k8=DataOperations.getUnsigned2Bytes(data,i1);
        i1+=2;
        int i15=getSectionX() + data[i1++];
        int l19=getSectionY() + data[i1++];
        int l29=data[i1++];
        int j24=0;
        for (int i27=0; i27 < objectCount; i27++)         if (objectX[i27] != i15 || objectY[i27] != l19 || objectID[i27] != l29) {
          if (i27 != j24) {
            objectModelArray[j24]=objectModelArray[i27];
            objectModelArray[j24].anInt257=j24;
            objectX[j24]=objectX[i27];
            objectY[j24]=objectY[i27];
            objectType[j24]=objectType[i27];
            objectID[j24]=objectID[i27];
          }
          j24++;
        }
 else {
          gameCamera.removeModel(objectModelArray[i27]);
          engineHandle.updateObject(objectX[i27],objectY[i27],objectType[i27],objectID[i27]);
        }
        objectCount=j24;
        if (k8 != 60000) {
          engineHandle.registerObjectDir(i15,l19,l29);
          int i34;
          int j37;
          if (l29 == 0 || l29 == 4) {
            i34=EntityHandler.getObjectDef(k8).getWidth();
            j37=EntityHandler.getObjectDef(k8).getHeight();
          }
 else {
            j37=EntityHandler.getObjectDef(k8).getWidth();
            i34=EntityHandler.getObjectDef(k8).getHeight();
          }
          int j40=((i15 + i15 + i34) * magicLoc) / 2;
          int i42=((l19 + l19 + j37) * magicLoc) / 2;
          int k43=EntityHandler.getObjectDef(k8).modelID;
          Model model_1=gameDataModels[k43].method203();
          gameCamera.addModel(model_1);
          model_1.anInt257=objectCount;
          model_1.method188(0,l29 * 32,0);
          model_1.method190(j40,-engineHandle.getAveragedElevation(j40,i42),i42);
          model_1.method184(true,48,48,-50,-10,-50);
          engineHandle.method412(i15,l19,k8,l29);
          if (k8 == 74)           model_1.method190(0,-480,0);
          objectX[objectCount]=i15;
          objectY[objectCount]=l19;
          objectType[objectCount]=k8;
          objectID[objectCount]=l29;
          objectModelArray[objectCount++]=model_1;
        }
      }
      return;
    }
    if (command == 114) {
      int invOffset=1;
      inventoryCount=data[invOffset++] & 0xff;
      for (int invItem=0; invItem < inventoryCount; invItem++) {
        int j15=DataOperations.getUnsigned2Bytes(data,invOffset);
        invOffset+=2;
        getInventoryItems()[invItem]=(j15 & 0x7fff);
        wearing[invItem]=j15 / 32768;
        if (EntityHandler.getItemDef(j15 & 0x7fff).isStackable()) {
          inventoryItemsCount[invItem]=DataOperations.readInt(data,invOffset);
          invOffset+=4;
        }
 else {
          inventoryItemsCount[invItem]=1;
        }
      }
      return;
    }
    if (command == 53) {
      int mobCount=DataOperations.getUnsigned2Bytes(data,1);
      int mobUpdateOffset=3;
      for (int currentMob=0; currentMob < mobCount; currentMob++) {
        int mobArrayIndex=DataOperations.getUnsigned2Bytes(data,mobUpdateOffset);
        mobUpdateOffset+=2;
        if (mobArrayIndex < 0 || mobArrayIndex > mobArray.length) {
          return;
        }
        Mob mob=mobArray[mobArrayIndex];
        if (mob == null) {
          return;
        }
        byte mobUpdateType=data[mobUpdateOffset++];
        if (mobUpdateType == 0) {
          int i30=DataOperations.getUnsigned2Bytes(data,mobUpdateOffset);
          mobUpdateOffset+=2;
          if (mob != null) {
            mob.anInt163=150;
            mob.anInt162=i30;
          }
        }
 else         if (mobUpdateType == 1) {
          byte byte7=data[mobUpdateOffset++];
          if (mob != null) {
            String s2=DataConversions.byteToString(data,mobUpdateOffset,byte7);
            mob.lastMessageTimeout=150;
            mob.lastMessage=s2;
            displayMessage(mob.name + "String_Node_Str" + mob.lastMessage,2,mob.admin);
          }
          mobUpdateOffset+=byte7;
        }
 else         if (mobUpdateType == 2) {
          int j30=DataOperations.getUnsignedByte(data[mobUpdateOffset++]);
          int hits=DataOperations.getUnsignedByte(data[mobUpdateOffset++]);
          int hitsBase=DataOperations.getUnsignedByte(data[mobUpdateOffset++]);
          if (mob != null) {
            mob.anInt164=j30;
            mob.hitPointsCurrent=hits;
            mob.hitPointsBase=hitsBase;
            mob.combatTimer=200;
            if (mob == ourPlayer) {
              playerStatCurrent[3]=hits;
              playerStatBase[3]=hitsBase;
              showWelcomeBox=false;
            }
          }
        }
 else         if (mobUpdateType == 3) {
          int k30=DataOperations.getUnsigned2Bytes(data,mobUpdateOffset);
          mobUpdateOffset+=2;
          int k34=DataOperations.getUnsigned2Bytes(data,mobUpdateOffset);
          mobUpdateOffset+=2;
          if (mob != null) {
            mob.attackingCameraInt=k30;
            mob.attackingNpcIndex=k34;
            mob.attackingMobIndex=-1;
            mob.anInt176=attackingInt40;
          }
        }
 else         if (mobUpdateType == 4) {
          int l30=DataOperations.getUnsigned2Bytes(data,mobUpdateOffset);
          mobUpdateOffset+=2;
          int l34=DataOperations.getUnsigned2Bytes(data,mobUpdateOffset);
          mobUpdateOffset+=2;
          if (mob != null) {
            mob.attackingCameraInt=l30;
            mob.attackingMobIndex=l34;
            mob.attackingNpcIndex=-1;
            mob.anInt176=attackingInt40;
          }
        }
 else         if (mobUpdateType == 5) {
          if (mob != null) {
            mob.mobIntUnknown=DataOperations.getUnsigned2Bytes(data,mobUpdateOffset);
            mobUpdateOffset+=2;
            mob.nameLong=DataOperations.getUnsigned8Bytes(data,mobUpdateOffset);
            mobUpdateOffset+=8;
            mob.name=DataOperations.longToString(mob.nameLong);
            int i31=DataOperations.getUnsignedByte(data[mobUpdateOffset]);
            mobUpdateOffset++;
            for (int i35=0; i35 < i31; i35++) {
              mob.animationCount[i35]=DataOperations.getUnsignedByte(data[mobUpdateOffset]);
              mobUpdateOffset++;
            }
            for (int l37=i31; l37 < 12; l37++)             mob.animationCount[l37]=0;
            mob.colourHairType=data[mobUpdateOffset++] & 0xff;
            mob.colourTopType=data[mobUpdateOffset++] & 0xff;
            mob.colourBottomType=data[mobUpdateOffset++] & 0xff;
            mob.colourSkinType=data[mobUpdateOffset++] & 0xff;
            mob.level=data[mobUpdateOffset++] & 0xff;
            mob.anInt179=data[mobUpdateOffset++] & 0xff;
            mob.admin=data[mobUpdateOffset++] & 0xff;
          }
 else {
            mobUpdateOffset+=14;
            int j31=DataOperations.getUnsignedByte(data[mobUpdateOffset]);
            mobUpdateOffset+=j31 + 1;
          }
        }
 else         if (mobUpdateType == 6) {
          byte byte8=data[mobUpdateOffset];
          mobUpdateOffset++;
          if (mob != null) {
            String s3=DataConversions.byteToString(data,mobUpdateOffset,byte8);
            mob.lastMessageTimeout=150;
            mob.lastMessage=s3;
            if (mob == ourPlayer)             displayMessage(mob.name + "String_Node_Str" + mob.lastMessage,5,mob.admin);
          }
          mobUpdateOffset+=byte8;
        }
      }
      return;
    }
    if (command == 129) {
      combatStyle=DataOperations.getUnsignedByte(data[1]);
      return;
    }
    if (command == 95) {
      for (int l1=1; l1 < length; )       if (DataOperations.getUnsignedByte(data[l1]) == 255) {
        int j9=0;
        int l15=getSectionX() + data[l1 + 1] >> 3;
        int j20=getSectionY() + data[l1 + 2] >> 3;
        l1+=3;
        for (int currentDoor=0; currentDoor < doorCount; currentDoor++) {
          int j27=(doorX[currentDoor] >> 3) - l15;
          int k31=(doorY[currentDoor] >> 3) - j20;
          if (j27 != 0 || k31 != 0) {
            if (currentDoor != j9) {
              doorModel[j9]=doorModel[currentDoor];
              doorModel[j9].anInt257=j9 + 10000;
              doorX[j9]=doorX[currentDoor];
              doorY[j9]=doorY[currentDoor];
              doorDirection[j9]=doorDirection[currentDoor];
              doorType[j9]=doorType[currentDoor];
            }
            j9++;
          }
 else {
            gameCamera.removeModel(doorModel[currentDoor]);
            engineHandle.updateDoor(doorX[currentDoor],doorY[currentDoor],doorDirection[currentDoor],doorType[currentDoor]);
          }
        }
        doorCount=j9;
      }
 else {
        int k9=DataOperations.getUnsigned2Bytes(data,l1);
        l1+=2;
        int i16=getSectionX() + data[l1++];
        int k20=getSectionY() + data[l1++];
        byte byte5=data[l1++];
        int k27=0;
        for (int l31=0; l31 < doorCount; l31++)         if (doorX[l31] != i16 || doorY[l31] != k20 || doorDirection[l31] != byte5) {
          if (l31 != k27) {
            doorModel[k27]=doorModel[l31];
            doorModel[k27].anInt257=k27 + 10000;
            doorX[k27]=doorX[l31];
            doorY[k27]=doorY[l31];
            doorDirection[k27]=doorDirection[l31];
            doorType[k27]=doorType[l31];
          }
          k27++;
        }
 else {
          gameCamera.removeModel(doorModel[l31]);
          engineHandle.updateDoor(doorX[l31],doorY[l31],doorDirection[l31],doorType[l31]);
        }
        doorCount=k27;
        if (k9 != 60000) {
          engineHandle.method408(i16,k20,byte5,k9);
          Model model=makeModel(i16,k20,byte5,k9,doorCount);
          doorModel[doorCount]=model;
          doorX[doorCount]=i16;
          doorY[doorCount]=k20;
          doorType[doorCount]=k9;
          doorDirection[doorCount++]=byte5;
        }
      }
      return;
    }
    if (command == 77) {
      lastNpcCount=npcCount;
      npcCount=0;
      for (int lastNpcIndex=0; lastNpcIndex < lastNpcCount; lastNpcIndex++)       lastNpcArray[lastNpcIndex]=npcArray[lastNpcIndex];
      int newNpcOffset=8;
      int newNpcCount=DataOperations.getIntFromByteArray(data,newNpcOffset,8);
      newNpcOffset+=8;
      for (int newNpcIndex=0; newNpcIndex < newNpcCount; newNpcIndex++) {
        Mob newNPC=getLastNpc(DataOperations.getIntFromByteArray(data,newNpcOffset,16));
        newNpcOffset+=16;
        int npcNeedsUpdate=DataOperations.getIntFromByteArray(data,newNpcOffset,1);
        newNpcOffset++;
        if (npcNeedsUpdate != 0) {
          int i32=DataOperations.getIntFromByteArray(data,newNpcOffset,1);
          newNpcOffset++;
          if (i32 == 0) {
            int nextSprite=DataOperations.getIntFromByteArray(data,newNpcOffset,3);
            newNpcOffset+=3;
            int waypointCurrent=newNPC.waypointCurrent;
            int waypointX=newNPC.waypointsX[waypointCurrent];
            int waypointY=newNPC.waypointsY[waypointCurrent];
            if (nextSprite == 2 || nextSprite == 1 || nextSprite == 3)             waypointX+=magicLoc;
            if (nextSprite == 6 || nextSprite == 5 || nextSprite == 7)             waypointX-=magicLoc;
            if (nextSprite == 4 || nextSprite == 3 || nextSprite == 5)             waypointY+=magicLoc;
            if (nextSprite == 0 || nextSprite == 1 || nextSprite == 7)             waypointY-=magicLoc;
            newNPC.nextSprite=nextSprite;
            newNPC.waypointCurrent=waypointCurrent=(waypointCurrent + 1) % 10;
            newNPC.waypointsX[waypointCurrent]=waypointX;
            newNPC.waypointsY[waypointCurrent]=waypointY;
          }
 else {
            int nextSpriteOffset=DataOperations.getIntFromByteArray(data,newNpcOffset,4);
            newNpcOffset+=4;
            if ((nextSpriteOffset & 0xc) == 12) {
              continue;
            }
            newNPC.nextSprite=nextSpriteOffset;
          }
        }
        npcArray[npcCount++]=newNPC;
      }
      while (newNpcOffset + 34 < length * 8) {
        int serverIndex=DataOperations.getIntFromByteArray(data,newNpcOffset,16);
        newNpcOffset+=16;
        int i28=DataOperations.getIntFromByteArray(data,newNpcOffset,5);
        newNpcOffset+=5;
        if (i28 > 15)         i28-=32;
        int j32=DataOperations.getIntFromByteArray(data,newNpcOffset,5);
        newNpcOffset+=5;
        if (j32 > 15)         j32-=32;
        int nextSprite=DataOperations.getIntFromByteArray(data,newNpcOffset,4);
        newNpcOffset+=4;
        int x=(getSectionX() + i28) * magicLoc + 64;
        int y=(getSectionY() + j32) * magicLoc + 64;
        int type=DataOperations.getIntFromByteArray(data,newNpcOffset,10);
        newNpcOffset+=10;
        if (type >= EntityHandler.npcCount())         type=24;
        addNPC(serverIndex,x,y,nextSprite,type);
      }
      return;
    }
    if (command == 190) {
      int j2=DataOperations.getUnsigned2Bytes(data,1);
      int i10=3;
      for (int k16=0; k16 < j2; k16++) {
        int i21=DataOperations.getUnsigned2Bytes(data,i10);
        i10+=2;
        Mob mob_2=npcRecordArray[i21];
        int j28=DataOperations.getUnsignedByte(data[i10]);
        i10++;
        if (j28 == 1) {
          int k32=DataOperations.getUnsigned2Bytes(data,i10);
          i10+=2;
          byte byte9=data[i10];
          i10++;
          if (mob_2 != null) {
            String s4=DataConversions.byteToString(data,i10,byte9);
            mob_2.lastMessageTimeout=150;
            mob_2.lastMessage=s4;
            if (k32 == ourPlayer.serverIndex)             displayMessage("String_Node_Str" + EntityHandler.getNpcDef(mob_2.type).getName() + "String_Node_Str"+ mob_2.lastMessage,5,0);
          }
          i10+=byte9;
        }
 else         if (j28 == 2) {
          int l32=DataOperations.getUnsignedByte(data[i10]);
          i10++;
          int i36=DataOperations.getUnsignedByte(data[i10]);
          i10++;
          int k38=DataOperations.getUnsignedByte(data[i10]);
          i10++;
          if (mob_2 != null) {
            mob_2.anInt164=l32;
            mob_2.hitPointsCurrent=i36;
            mob_2.hitPointsBase=k38;
            mob_2.combatTimer=200;
          }
        }
      }
      return;
    }
    if (command == 223) {
      showQuestionMenu=true;
      int newQuestionMenuCount=DataOperations.getUnsignedByte(data[1]);
      questionMenuCount=newQuestionMenuCount;
      int newQuestionMenuOffset=2;
      for (int l16=0; l16 < newQuestionMenuCount; l16++) {
        int newQuestionMenuQuestionLength=DataOperations.getUnsignedByte(data[newQuestionMenuOffset]);
        newQuestionMenuOffset++;
        questionMenuAnswer[l16]=new String(data,newQuestionMenuOffset,newQuestionMenuQuestionLength);
        newQuestionMenuOffset+=newQuestionMenuQuestionLength;
      }
      return;
    }
    if (command == 127) {
      showQuestionMenu=false;
      return;
    }
    if (command == 131) {
      needsClear=true;
      notInWilderness=true;
      hasWorldInfo=true;
      serverIndex=DataOperations.getUnsigned2Bytes(data,1);
      wildX=DataOperations.getUnsigned2Bytes(data,3);
      wildY=DataOperations.getUnsigned2Bytes(data,5);
      wildYSubtract=DataOperations.getUnsigned2Bytes(data,7);
      wildYMultiplier=DataOperations.getUnsigned2Bytes(data,9);
      wildY-=wildYSubtract * wildYMultiplier;
      return;
    }
    if (command == 180) {
      int l2=1;
      for (int k10=0; k10 < 18; k10++) {
        playerStatCurrent[k10]=DataOperations.getUnsignedByte(data[l2++]);
      }
      for (int i17=0; i17 < 18; i17++) {
        playerStatBase[i17]=DataOperations.getUnsignedByte(data[l2++]);
      }
      for (int k21=0; k21 < 18; k21++) {
        playerStatExperience[k21]=DataOperations.readInt(data,l2);
        l2+=4;
      }
      expGained=0;
      return;
    }
    if (command == 177) {
      int i3=1;
      for (int x=0; x < 6; x++) {
        equipmentStatus[x]=DataOperations.getSigned2Bytes(data,i3);
        i3+=2;
      }
      return;
    }
    if (command == 165) {
      playerAliveTimeout=250;
      return;
    }
    if (command == 115) {
      int thingLength=(length - 1) / 4;
      for (int currentThing=0; currentThing < thingLength; currentThing++) {
        int currentItemSectionX=getSectionX() + DataOperations.getSigned2Bytes(data,1 + currentThing * 4) >> 3;
        int currentItemSectionY=getSectionY() + DataOperations.getSigned2Bytes(data,3 + currentThing * 4) >> 3;
        int currentCount=0;
        for (int currentItem=0; currentItem < groundItemCount; currentItem++) {
          int currentItemOffsetX=(groundItemX[currentItem] >> 3) - currentItemSectionX;
          int currentItemOffsetY=(groundItemY[currentItem] >> 3) - currentItemSectionY;
          if (currentItemOffsetX != 0 || currentItemOffsetY != 0) {
            if (currentItem != currentCount) {
              groundItemX[currentCount]=groundItemX[currentItem];
              groundItemY[currentCount]=groundItemY[currentItem];
              groundItemType[currentCount]=groundItemType[currentItem];
              groundItemObjectVar[currentCount]=groundItemObjectVar[currentItem];
            }
            currentCount++;
          }
        }
        groundItemCount=currentCount;
        currentCount=0;
        for (int j33=0; j33 < objectCount; j33++) {
          int k36=(objectX[j33] >> 3) - currentItemSectionX;
          int l38=(objectY[j33] >> 3) - currentItemSectionY;
          if (k36 != 0 || l38 != 0) {
            if (j33 != currentCount) {
              objectModelArray[currentCount]=objectModelArray[j33];
              objectModelArray[currentCount].anInt257=currentCount;
              objectX[currentCount]=objectX[j33];
              objectY[currentCount]=objectY[j33];
              objectType[currentCount]=objectType[j33];
              objectID[currentCount]=objectID[j33];
            }
            currentCount++;
          }
 else {
            gameCamera.removeModel(objectModelArray[j33]);
            engineHandle.updateObject(objectX[j33],objectY[j33],objectType[j33],objectID[j33]);
          }
        }
        objectCount=currentCount;
        currentCount=0;
        for (int l36=0; l36 < doorCount; l36++) {
          int i39=(doorX[l36] >> 3) - currentItemSectionX;
          int j41=(doorY[l36] >> 3) - currentItemSectionY;
          if (i39 != 0 || j41 != 0) {
            if (l36 != currentCount) {
              doorModel[currentCount]=doorModel[l36];
              doorModel[currentCount].anInt257=currentCount + 10000;
              doorX[currentCount]=doorX[l36];
              doorY[currentCount]=doorY[l36];
              doorDirection[currentCount]=doorDirection[l36];
              doorType[currentCount]=doorType[l36];
            }
            currentCount++;
          }
 else {
            gameCamera.removeModel(doorModel[l36]);
            engineHandle.updateDoor(doorX[l36],doorY[l36],doorDirection[l36],doorType[l36]);
          }
        }
        doorCount=currentCount;
      }
      return;
    }
    if (command == 230) {
      showDrawPointsScreen=true;
      int pkbytes=1;
      pkatk=DataOperations.readInt(data,pkbytes);
      pkbytes+=4;
      pkdef=DataOperations.readInt(data,pkbytes);
      pkbytes+=4;
      pkstr=DataOperations.readInt(data,pkbytes);
      pkbytes+=4;
      pkrange=DataOperations.readInt(data,pkbytes);
      pkbytes+=4;
      pkmagic=DataOperations.readInt(data,pkbytes);
    }
    if (command == 207) {
      showCharacterLookScreen=true;
      return;
    }
    if (command == 4) {
      int currentMob=DataOperations.getUnsigned2Bytes(data,1);
      if (mobArray[currentMob] != null)       tradeOtherPlayerName=mobArray[currentMob].name;
      showTradeWindow=true;
      tradeOtherAccepted=false;
      tradeWeAccepted=false;
      tradeMyItemCount=0;
      tradeOtherItemCount=0;
      return;
    }
    if (command == 187) {
      showTradeWindow=false;
      showTradeConfirmWindow=false;
      return;
    }
    if (command == 250) {
      tradeOtherItemCount=data[1] & 0xff;
      int l3=2;
      for (int i11=0; i11 < tradeOtherItemCount; i11++) {
        tradeOtherItems[i11]=DataOperations.getUnsigned2Bytes(data,l3);
        l3+=2;
        tradeOtherItemsCount[i11]=DataOperations.readInt(data,l3);
        l3+=4;
      }
      tradeOtherAccepted=false;
      tradeWeAccepted=false;
      return;
    }
    if (command == 92) {
      tradeOtherAccepted=data[1] == 1;
    }
    if (command == 253) {
      showShop=true;
      int i4=1;
      int j11=data[i4++] & 0xff;
      byte byte4=data[i4++];
      shopItemSellPriceModifier=data[i4++] & 0xff;
      shopItemBuyPriceModifier=data[i4++] & 0xff;
      for (int i22=0; i22 < 40; i22++)       shopItems[i22]=-1;
      for (int j25=0; j25 < j11; j25++) {
        shopItems[j25]=DataOperations.getUnsigned2Bytes(data,i4);
        i4+=2;
        shopItemCount[j25]=DataOperations.getUnsigned2Bytes(data,i4);
        i4+=2;
        shopItemsBuyPrice[j25]=DataOperations.getUnsigned4Bytes(data,i4);
        i4+=4;
        shopItemsSellPrice[j25]=DataOperations.getUnsigned4Bytes(data,i4);
        i4+=4;
      }
      if (byte4 == 1) {
        int l28=39;
        for (int k33=0; k33 < inventoryCount; k33++) {
          if (l28 < j11)           break;
          boolean flag2=false;
          for (int j39=0; j39 < 40; j39++) {
            if (shopItems[j39] != getInventoryItems()[k33])             continue;
            flag2=true;
            break;
          }
          if (getInventoryItems()[k33] == 10)           flag2=true;
          if (!flag2) {
            shopItems[l28]=getInventoryItems()[k33] & 0x7fff;
            shopItemsSellPrice[l28]=EntityHandler.getItemDef(shopItems[l28]).basePrice - (int)(EntityHandler.getItemDef(shopItems[l28]).basePrice / 2.5);
            shopItemsSellPrice[l28]=shopItemsSellPrice[l28] - (int)(shopItemsSellPrice[l28] * 0.10);
            shopItemCount[l28]=0;
            l28--;
          }
        }
      }
      if (selectedShopItemIndex >= 0 && selectedShopItemIndex < 40 && shopItems[selectedShopItemIndex] != selectedShopItemType) {
        selectedShopItemIndex=-1;
        selectedShopItemType=-2;
      }
      return;
    }
    if (command == 220) {
      showShop=false;
      return;
    }
    if (command == 18) {
      tradeWeAccepted=data[1] == 1;
    }
    if (command == 152) {
      configAutoCameraAngle=DataOperations.getUnsignedByte(data[1]) == 1;
      configMouseButtons=DataOperations.getUnsignedByte(data[2]) == 1;
      configSoundEffects=DataOperations.getUnsignedByte(data[3]) == 1;
      showRoof=DataOperations.getUnsignedByte(data[4]) == 1;
      autoScreenshot=DataOperations.getUnsignedByte(data[5]) == 1;
      combatWindow=DataOperations.getUnsignedByte(data[6]) == 1;
      return;
    }
    if (command == 209) {
      for (int currentPrayer=0; currentPrayer < length - 1; currentPrayer++) {
        boolean prayerOff=data[currentPrayer + 1] == 1;
        if (!prayerOn[currentPrayer] && prayerOff)         playSound("String_Node_Str");
        if (prayerOn[currentPrayer] && !prayerOff)         playSound("String_Node_Str");
        prayerOn[currentPrayer]=prayerOff;
      }
      return;
    }
    if (command == 93) {
      showBank=true;
      int l4=1;
      newBankItemCount=data[l4++] & 0xff;
      bankItemsMax=data[l4++] & 0xff;
      for (int k11=0; k11 < newBankItemCount; k11++) {
        newBankItems[k11]=DataOperations.getUnsigned2Bytes(data,l4);
        l4+=2;
        newBankItemsCount[k11]=DataOperations.getUnsigned4Bytes(data,l4);
        l4+=4;
      }
      updateBankItems();
      return;
    }
    if (command == 171) {
      showBank=false;
      return;
    }
    if (command == 211) {
      int idx=data[1] & 0xFF;
      int oldExp=playerStatExperience[idx];
      playerStatExperience[idx]=DataOperations.readInt(data,2);
      if (playerStatExperience[idx] > oldExp) {
        expGained+=(playerStatExperience[idx] - oldExp);
      }
      return;
    }
    if (command == 229) {
      int j5=DataOperations.getUnsigned2Bytes(data,1);
      if (mobArray[j5] != null) {
        duelOpponentName=mobArray[j5].name;
      }
      showDuelWindow=true;
      duelMyItemCount=0;
      duelOpponentItemCount=0;
      duelOpponentAccepted=false;
      duelMyAccepted=false;
      duelNoRetreating=false;
      duelNoMagic=false;
      duelNoPrayer=false;
      duelNoWeapons=false;
      return;
    }
    if (command == 160) {
      showDuelWindow=false;
      showDuelConfirmWindow=false;
      return;
    }
    if (command == 251) {
      showTradeConfirmWindow=true;
      tradeConfirmAccepted=false;
      showTradeWindow=false;
      int k5=1;
      tradeConfirmOtherNameLong=DataOperations.getUnsigned8Bytes(data,k5);
      k5+=8;
      tradeConfirmOtherItemCount=data[k5++] & 0xff;
      for (int l11=0; l11 < tradeConfirmOtherItemCount; l11++) {
        tradeConfirmOtherItems[l11]=DataOperations.getUnsigned2Bytes(data,k5);
        k5+=2;
        tradeConfirmOtherItemsCount[l11]=DataOperations.readInt(data,k5);
        k5+=4;
      }
      tradeConfirmItemCount=data[k5++] & 0xff;
      for (int k17=0; k17 < tradeConfirmItemCount; k17++) {
        tradeConfirmItems[k17]=DataOperations.getUnsigned2Bytes(data,k5);
        k5+=2;
        tradeConfirmItemsCount[k17]=DataOperations.readInt(data,k5);
        k5+=4;
      }
      return;
    }
    if (command == 63) {
      duelOpponentItemCount=data[1] & 0xff;
      int l5=2;
      for (int i12=0; i12 < duelOpponentItemCount; i12++) {
        duelOpponentItems[i12]=DataOperations.getUnsigned2Bytes(data,l5);
        l5+=2;
        duelOpponentItemsCount[i12]=DataOperations.readInt(data,l5);
        l5+=4;
      }
      duelOpponentAccepted=false;
      duelMyAccepted=false;
      return;
    }
    if (command == 198) {
      duelNoRetreating=data[1] == 1;
      duelNoMagic=data[2] == 1;
      duelNoPrayer=data[3] == 1;
      duelNoWeapons=data[4] == 1;
      duelOpponentAccepted=false;
      duelMyAccepted=false;
      return;
    }
    if (command == 139) {
      int bankDataOffset=1;
      int bankSlot=data[bankDataOffset++] & 0xff;
      int bankItemId=DataOperations.getUnsigned2Bytes(data,bankDataOffset);
      bankDataOffset+=2;
      int bankItemCount=DataOperations.getUnsigned4Bytes(data,bankDataOffset);
      bankDataOffset+=4;
      if (bankItemCount == 0) {
        newBankItemCount--;
        for (int currentBankSlot=bankSlot; currentBankSlot < newBankItemCount; currentBankSlot++) {
          newBankItems[currentBankSlot]=newBankItems[currentBankSlot + 1];
          newBankItemsCount[currentBankSlot]=newBankItemsCount[currentBankSlot + 1];
        }
      }
 else {
        newBankItems[bankSlot]=bankItemId;
        newBankItemsCount[bankSlot]=bankItemCount;
        if (bankSlot >= newBankItemCount)         newBankItemCount=bankSlot + 1;
      }
      updateBankItems();
      return;
    }
    if (command == 228) {
      int j6=1;
      int k12=1;
      int i18=data[j6++] & 0xff;
      int k22=DataOperations.getUnsigned2Bytes(data,j6);
      j6+=2;
      if (EntityHandler.getItemDef(k22 & 0x7fff).isStackable()) {
        k12=DataOperations.readInt(data,j6);
        j6+=4;
      }
      getInventoryItems()[i18]=k22 & 0x7fff;
      wearing[i18]=k22 / 32768;
      inventoryItemsCount[i18]=k12;
      if (i18 >= inventoryCount)       inventoryCount=i18 + 1;
      return;
    }
    if (command == 191) {
      int k6=data[1] & 0xff;
      inventoryCount--;
      for (int l12=k6; l12 < inventoryCount; l12++) {
        getInventoryItems()[l12]=getInventoryItems()[l12 + 1];
        inventoryItemsCount[l12]=inventoryItemsCount[l12 + 1];
        wearing[l12]=wearing[l12 + 1];
      }
      return;
    }
    if (command == 208) {
      int pointer=1;
      int idx=data[pointer++] & 0xff;
      int oldExp=playerStatExperience[idx];
      playerStatCurrent[idx]=DataOperations.getUnsignedByte(data[pointer++]);
      playerStatBase[idx]=DataOperations.getUnsignedByte(data[pointer++]);
      playerStatExperience[idx]=DataOperations.readInt(data,pointer);
      pointer+=4;
      if (playerStatExperience[idx] > oldExp) {
        expGained+=(playerStatExperience[idx] - oldExp);
      }
      return;
    }
    if (command == 65) {
      duelOpponentAccepted=data[1] == 1;
    }
    if (command == 197) {
      duelMyAccepted=data[1] == 1;
    }
    if (command == 147) {
      showDuelConfirmWindow=true;
      duelWeAccept=false;
      showDuelWindow=false;
      int i7=1;
      duelOpponentNameLong=DataOperations.getUnsigned8Bytes(data,i7);
      i7+=8;
      duelConfirmOpponentItemCount=data[i7++] & 0xff;
      for (int j13=0; j13 < duelConfirmOpponentItemCount; j13++) {
        duelConfirmOpponentItems[j13]=DataOperations.getUnsigned2Bytes(data,i7);
        i7+=2;
        duelConfirmOpponentItemsCount[j13]=DataOperations.readInt(data,i7);
        i7+=4;
      }
      duelConfirmMyItemCount=data[i7++] & 0xff;
      for (int j18=0; j18 < duelConfirmMyItemCount; j18++) {
        duelConfirmMyItems[j18]=DataOperations.getUnsigned2Bytes(data,i7);
        i7+=2;
        duelConfirmMyItemsCount[j18]=DataOperations.readInt(data,i7);
        i7+=4;
      }
      duelCantRetreat=data[i7++] & 0xff;
      duelUseMagic=data[i7++] & 0xff;
      duelUsePrayer=data[i7++] & 0xff;
      duelUseWeapons=data[i7++] & 0xff;
      return;
    }
    if (command == 11) {
      String s=new String(data,1,length - 1);
      playSound(s);
      return;
    }
    if (command == 23) {
      if (anInt892 < 50) {
        int j7=data[1] & 0xff;
        int k13=data[2] + getSectionX();
        int k18=data[3] + getSectionY();
        anIntArray782[anInt892]=j7;
        anIntArray923[anInt892]=0;
        anIntArray944[anInt892]=k13;
        anIntArray757[anInt892]=k18;
        anInt892++;
      }
      return;
    }
    if (command == 248) {
      if (!hasReceivedWelcomeBoxDetails) {
        lastLoggedInDays=DataOperations.getUnsigned2Bytes(data,1);
        subscriptionLeftDays=DataOperations.getUnsigned2Bytes(data,3);
        lastLoggedInAddress=new String(data,5,length - 5);
        showWelcomeBox=true;
        hasReceivedWelcomeBoxDetails=true;
      }
      return;
    }
    if (command == 148) {
      serverMessage=new String(data,1,length - 1);
      showServerMessageBox=true;
      serverMessageBoxTop=false;
      return;
    }
    if (command == 64) {
      serverMessage=new String(data,1,length - 1);
      showServerMessageBox=true;
      serverMessageBoxTop=true;
      return;
    }
    if (command == 126) {
      fatigue=DataOperations.getUnsigned2Bytes(data,1);
      return;
    }
    if (command == 206) {
      if (!sleeping) {
      }
      sleeping=true;
      gameMenu.updateText(chatHandle,"String_Node_Str");
      super.inputText="String_Node_Str";
      super.enteredText="String_Node_Str";
      sleepEquation=DataOperations.getImage(data,1,length);
      return;
    }
    if (command == 182) {
      int offset=1;
      questPoints=DataOperations.getUnsigned2Bytes(data,offset);
      offset+=2;
      for (int i=0; i < questName.length; i++)       questStage[i]=data[offset + i];
      return;
    }
    if (command == 224) {
      sleeping=false;
      sleepMessage=null;
      return;
    }
    if (command == 225) {
      sleepMessage="String_Node_Str";
      return;
    }
    if (command == 174) {
      DataOperations.getUnsigned2Bytes(data,1);
      return;
    }
    if (command == 181) {
      if (autoScreenshot) {
        takeScreenshot(false);
      }
      return;
    }
    if (command == 172) {
      systemUpdate=DataOperations.getUnsigned2Bytes(data,1) * 32;
      return;
    }
  }
 catch (  Exception e) {
  }
}

Fixed version (ground truth):
protected final void handleIncomingPacket(int command,int length,byte data[]){
  try {
    if (command == 254) {
      int bar=DataOperations.getUnsigned4Bytes(data,1);
      if (bar == -1) {
        smithingscreen.isVisible=false;
      }
 else {
        SmithingScreen.changeItems(smithingscreen,bar);
        smithingscreen.isVisible=true;
      }
    }
    if (command == 231) {
      return;
    }
    if (command == 233) {
      questPoints=DataOperations.getUnsignedByte(data[1]);
      int k=DataOperations.getUnsignedByte(data[2]);
      int r=3;
      newQuestNames=new String[k];
      questStage=new byte[k];
      for (int i=0; i < k; i++) {
        int uid=DataOperations.getUnsignedByte(data[r]);
        r++;
        newQuestNames[i]=questName[uid];
        questStage[i]=(byte)DataOperations.getUnsignedByte(data[r]);
        r++;
      }
    }
    if (command == 110) {
      int i=1;
      serverStartTime=DataOperations.getUnsigned8Bytes(data,i);
      i+=8;
      serverLocation=new String(data,i,length - i);
      return;
    }
    if (command == 145) {
      if (!hasWorldInfo) {
        return;
      }
      loading=true;
      lastPlayerCount=playerCount;
      for (int k=0; k < lastPlayerCount; k++)       lastPlayerArray[k]=playerArray[k];
      int currentOffset=8;
      setSectionX(DataOperations.getIntFromByteArray(data,currentOffset,11));
      currentOffset+=11;
      setSectionY(DataOperations.getIntFromByteArray(data,currentOffset,13));
      currentOffset+=13;
      int mobSprite=DataOperations.getIntFromByteArray(data,currentOffset,4);
      currentOffset+=4;
      boolean sectionLoaded=loadSection(getSectionX(),getSectionY());
      setSectionX(getSectionX() - getAreaX());
      setSectionY(getSectionY() - getAreaY());
      int mapEnterX=getSectionX() * magicLoc + 64;
      int mapEnterY=getSectionY() * magicLoc + 64;
      if (sectionLoaded) {
        ourPlayer.waypointCurrent=0;
        ourPlayer.waypointEndSprite=0;
        ourPlayer.currentX=ourPlayer.waypointsX[0]=mapEnterX;
        ourPlayer.currentY=ourPlayer.waypointsY[0]=mapEnterY;
      }
      playerCount=0;
      ourPlayer=makePlayer(serverIndex,mapEnterX,mapEnterY,mobSprite);
      int newPlayerCount=DataOperations.getIntFromByteArray(data,currentOffset,8);
      currentOffset+=8;
      for (int currentNewPlayer=0; currentNewPlayer < newPlayerCount; currentNewPlayer++) {
        Mob lastMob=getLastPlayer(DataOperations.getIntFromByteArray(data,currentOffset,16));
        currentOffset+=16;
        int nextPlayer=DataOperations.getIntFromByteArray(data,currentOffset,1);
        currentOffset++;
        if (nextPlayer != 0) {
          int waypointsLeft=DataOperations.getIntFromByteArray(data,currentOffset,1);
          currentOffset++;
          if (waypointsLeft == 0) {
            int currentNextSprite=DataOperations.getIntFromByteArray(data,currentOffset,3);
            currentOffset+=3;
            int currentWaypoint=lastMob.waypointCurrent;
            int newWaypointX=lastMob.waypointsX[currentWaypoint];
            int newWaypointY=lastMob.waypointsY[currentWaypoint];
            if (currentNextSprite == 2 || currentNextSprite == 1 || currentNextSprite == 3)             newWaypointX+=magicLoc;
            if (currentNextSprite == 6 || currentNextSprite == 5 || currentNextSprite == 7)             newWaypointX-=magicLoc;
            if (currentNextSprite == 4 || currentNextSprite == 3 || currentNextSprite == 5)             newWaypointY+=magicLoc;
            if (currentNextSprite == 0 || currentNextSprite == 1 || currentNextSprite == 7)             newWaypointY-=magicLoc;
            lastMob.nextSprite=currentNextSprite;
            lastMob.waypointCurrent=currentWaypoint=(currentWaypoint + 1) % 10;
            lastMob.waypointsX[currentWaypoint]=newWaypointX;
            lastMob.waypointsY[currentWaypoint]=newWaypointY;
          }
 else {
            int needsNextSprite=DataOperations.getIntFromByteArray(data,currentOffset,4);
            currentOffset+=4;
            if ((needsNextSprite & 0xc) == 12) {
              continue;
            }
            lastMob.nextSprite=needsNextSprite;
          }
        }
        playerArray[playerCount++]=lastMob;
      }
      int mobCount=0;
      while (currentOffset + 24 < length * 8) {
        int mobIndex=DataOperations.getIntFromByteArray(data,currentOffset,16);
        currentOffset+=16;
        int areaMobX=DataOperations.getIntFromByteArray(data,currentOffset,5);
        currentOffset+=5;
        if (areaMobX > 15)         areaMobX-=32;
        int areaMobY=DataOperations.getIntFromByteArray(data,currentOffset,5);
        currentOffset+=5;
        if (areaMobY > 15)         areaMobY-=32;
        int mobArrayMobID=DataOperations.getIntFromByteArray(data,currentOffset,4);
        currentOffset+=4;
        int addIndex=DataOperations.getIntFromByteArray(data,currentOffset,1);
        currentOffset++;
        int mobX=(getSectionX() + areaMobX) * magicLoc + 64;
        int mobY=(getSectionY() + areaMobY) * magicLoc + 64;
        makePlayer(mobIndex,mobX,mobY,mobArrayMobID);
        if (addIndex == 0)         mobArrayIndexes[mobCount++]=mobIndex;
      }
      if (mobCount > 0) {
        super.streamClass.createPacket(83);
        super.streamClass.add2ByteInt(mobCount);
        for (int currentMob=0; currentMob < mobCount; currentMob++) {
          Mob dummyMob=mobArray[mobArrayIndexes[currentMob]];
          super.streamClass.add2ByteInt(dummyMob.serverIndex);
          super.streamClass.add2ByteInt(dummyMob.mobIntUnknown);
        }
        super.streamClass.formatPacket();
        mobCount=0;
      }
      loading=false;
      return;
    }
    if (command == 109) {
      if (needsClear) {
        for (int i=0; i < groundItemType.length; i++) {
          groundItemType[i]=-1;
          groundItemX[i]=-1;
          groundItemY[i]=-1;
          groundItemObjectVar[i]=-1;
        }
        groundItemCount=0;
        needsClear=false;
      }
      for (int l=1; l < length; )       if (DataOperations.getUnsignedByte(data[l]) == 255) {
        int newCount=0;
        int newSectionX=getSectionX() + data[l + 1] >> 3;
        int newSectionY=getSectionY() + data[l + 2] >> 3;
        l+=3;
        for (int groundItem=0; groundItem < groundItemCount; groundItem++) {
          int newX=(groundItemX[groundItem] >> 3) - newSectionX;
          int newY=(groundItemY[groundItem] >> 3) - newSectionY;
          if (newX != 0 || newY != 0) {
            if (groundItem != newCount) {
              groundItemX[newCount]=groundItemX[groundItem];
              groundItemY[newCount]=groundItemY[groundItem];
              groundItemType[newCount]=groundItemType[groundItem];
              groundItemObjectVar[newCount]=groundItemObjectVar[groundItem];
            }
            newCount++;
          }
        }
        groundItemCount=newCount;
      }
 else {
        int i8=DataOperations.getUnsigned2Bytes(data,l);
        l+=2;
        int k14=getSectionX() + data[l++];
        int j19=getSectionY() + data[l++];
        if ((i8 & 0x8000) == 0) {
          groundItemX[groundItemCount]=k14;
          groundItemY[groundItemCount]=j19;
          groundItemType[groundItemCount]=i8;
          groundItemObjectVar[groundItemCount]=0;
          for (int k23=0; k23 < objectCount; k23++) {
            if (objectX[k23] != k14 || objectY[k23] != j19)             continue;
            groundItemObjectVar[groundItemCount]=EntityHandler.getObjectDef(objectType[k23]).getGroundItemVar();
            break;
          }
          groundItemCount++;
        }
 else {
          i8&=0x7fff;
          int l23=0;
          for (int k26=0; k26 < groundItemCount; k26++) {
            if (groundItemX[k26] != k14 || groundItemY[k26] != j19 || groundItemType[k26] != i8) {
              if (k26 != l23) {
                groundItemX[l23]=groundItemX[k26];
                groundItemY[l23]=groundItemY[k26];
                groundItemType[l23]=groundItemType[k26];
                groundItemObjectVar[l23]=groundItemObjectVar[k26];
              }
              l23++;
            }
 else {
              i8=-123;
            }
          }
          groundItemCount=l23;
        }
      }
      return;
    }
    if (command == 27) {
      for (int i1=1; i1 < length; )       if (DataOperations.getUnsignedByte(data[i1]) == 255) {
        int j8=0;
        int l14=getSectionX() + data[i1 + 1] >> 3;
        int k19=getSectionY() + data[i1 + 2] >> 3;
        i1+=3;
        for (int i24=0; i24 < objectCount; i24++) {
          int l26=(objectX[i24] >> 3) - l14;
          int k29=(objectY[i24] >> 3) - k19;
          if (l26 != 0 || k29 != 0) {
            if (i24 != j8) {
              objectModelArray[j8]=objectModelArray[i24];
              objectModelArray[j8].anInt257=j8;
              objectX[j8]=objectX[i24];
              objectY[j8]=objectY[i24];
              objectType[j8]=objectType[i24];
              objectID[j8]=objectID[i24];
            }
            j8++;
          }
 else {
            gameCamera.removeModel(objectModelArray[i24]);
            engineHandle.updateObject(objectX[i24],objectY[i24],objectType[i24],objectID[i24]);
          }
        }
        objectCount=j8;
      }
 else {
        int k8=DataOperations.getUnsigned2Bytes(data,i1);
        i1+=2;
        int i15=getSectionX() + data[i1++];
        int l19=getSectionY() + data[i1++];
        int l29=data[i1++];
        int j24=0;
        for (int i27=0; i27 < objectCount; i27++)         if (objectX[i27] != i15 || objectY[i27] != l19 || objectID[i27] != l29) {
          if (i27 != j24) {
            objectModelArray[j24]=objectModelArray[i27];
            objectModelArray[j24].anInt257=j24;
            objectX[j24]=objectX[i27];
            objectY[j24]=objectY[i27];
            objectType[j24]=objectType[i27];
            objectID[j24]=objectID[i27];
          }
          j24++;
        }
 else {
          gameCamera.removeModel(objectModelArray[i27]);
          engineHandle.updateObject(objectX[i27],objectY[i27],objectType[i27],objectID[i27]);
        }
        objectCount=j24;
        if (k8 != 60000) {
          engineHandle.registerObjectDir(i15,l19,l29);
          int i34;
          int j37;
          if (l29 == 0 || l29 == 4) {
            i34=EntityHandler.getObjectDef(k8).getWidth();
            j37=EntityHandler.getObjectDef(k8).getHeight();
          }
 else {
            j37=EntityHandler.getObjectDef(k8).getWidth();
            i34=EntityHandler.getObjectDef(k8).getHeight();
          }
          int j40=((i15 + i15 + i34) * magicLoc) / 2;
          int i42=((l19 + l19 + j37) * magicLoc) / 2;
          int k43=EntityHandler.getObjectDef(k8).modelID;
          Model model_1=gameDataModels[k43].method203();
          gameCamera.addModel(model_1);
          model_1.anInt257=objectCount;
          model_1.method188(0,l29 * 32,0);
          model_1.method190(j40,-engineHandle.getAveragedElevation(j40,i42),i42);
          model_1.method184(true,48,48,-50,-10,-50);
          engineHandle.method412(i15,l19,k8,l29);
          if (k8 == 74)           model_1.method190(0,-480,0);
          objectX[objectCount]=i15;
          objectY[objectCount]=l19;
          objectType[objectCount]=k8;
          objectID[objectCount]=l29;
          objectModelArray[objectCount++]=model_1;
        }
      }
      return;
    }
    if (command == 114) {
      int invOffset=1;
      inventoryCount=data[invOffset++] & 0xff;
      for (int invItem=0; invItem < inventoryCount; invItem++) {
        int j15=DataOperations.getUnsigned2Bytes(data,invOffset);
        invOffset+=2;
        getInventoryItems()[invItem]=(j15 & 0x7fff);
        wearing[invItem]=j15 / 32768;
        if (EntityHandler.getItemDef(j15 & 0x7fff).isStackable()) {
          inventoryItemsCount[invItem]=DataOperations.readInt(data,invOffset);
          invOffset+=4;
        }
 else {
          inventoryItemsCount[invItem]=1;
        }
      }
      return;
    }
    if (command == 53) {
      int mobCount=DataOperations.getUnsigned2Bytes(data,1);
      int mobUpdateOffset=3;
      for (int currentMob=0; currentMob < mobCount; currentMob++) {
        int mobArrayIndex=DataOperations.getUnsigned2Bytes(data,mobUpdateOffset);
        mobUpdateOffset+=2;
        if (mobArrayIndex < 0 || mobArrayIndex > mobArray.length) {
          return;
        }
        Mob mob=mobArray[mobArrayIndex];
        if (mob == null) {
          return;
        }
        byte mobUpdateType=data[mobUpdateOffset++];
        if (mobUpdateType == 0) {
          int i30=DataOperations.getUnsigned2Bytes(data,mobUpdateOffset);
          mobUpdateOffset+=2;
          if (mob != null) {
            mob.anInt163=150;
            mob.anInt162=i30;
          }
        }
 else         if (mobUpdateType == 1) {
          byte byte7=data[mobUpdateOffset++];
          if (mob != null) {
            String s2=DataConversions.byteToString(data,mobUpdateOffset,byte7);
            mob.lastMessageTimeout=150;
            mob.lastMessage=s2;
            displayMessage(mob.name + "String_Node_Str" + mob.lastMessage,2,mob.admin);
          }
          mobUpdateOffset+=byte7;
        }
 else         if (mobUpdateType == 2) {
          int j30=DataOperations.getUnsignedByte(data[mobUpdateOffset++]);
          int hits=DataOperations.getUnsignedByte(data[mobUpdateOffset++]);
          int hitsBase=DataOperations.getUnsignedByte(data[mobUpdateOffset++]);
          if (mob != null) {
            mob.anInt164=j30;
            mob.hitPointsCurrent=hits;
            mob.hitPointsBase=hitsBase;
            mob.combatTimer=200;
            if (mob == ourPlayer) {
              playerStatCurrent[3]=hits;
              playerStatBase[3]=hitsBase;
              showWelcomeBox=false;
            }
          }
        }
 else         if (mobUpdateType == 3) {
          int k30=DataOperations.getUnsigned2Bytes(data,mobUpdateOffset);
          mobUpdateOffset+=2;
          int k34=DataOperations.getUnsigned2Bytes(data,mobUpdateOffset);
          mobUpdateOffset+=2;
          if (mob != null) {
            mob.attackingCameraInt=k30;
            mob.attackingNpcIndex=k34;
            mob.attackingMobIndex=-1;
            mob.anInt176=attackingInt40;
          }
        }
 else         if (mobUpdateType == 4) {
          int l30=DataOperations.getUnsigned2Bytes(data,mobUpdateOffset);
          mobUpdateOffset+=2;
          int l34=DataOperations.getUnsigned2Bytes(data,mobUpdateOffset);
          mobUpdateOffset+=2;
          if (mob != null) {
            mob.attackingCameraInt=l30;
            mob.attackingMobIndex=l34;
            mob.attackingNpcIndex=-1;
            mob.anInt176=attackingInt40;
          }
        }
 else         if (mobUpdateType == 5) {
          if (mob != null) {
            mob.mobIntUnknown=DataOperations.getUnsigned2Bytes(data,mobUpdateOffset);
            mobUpdateOffset+=2;
            mob.nameLong=DataOperations.getUnsigned8Bytes(data,mobUpdateOffset);
            mobUpdateOffset+=8;
            mob.name=DataOperations.longToString(mob.nameLong);
            int i31=DataOperations.getUnsignedByte(data[mobUpdateOffset]);
            mobUpdateOffset++;
            for (int i35=0; i35 < i31; i35++) {
              mob.animationCount[i35]=DataOperations.getUnsignedByte(data[mobUpdateOffset]);
              mobUpdateOffset++;
            }
            for (int l37=i31; l37 < 12; l37++)             mob.animationCount[l37]=0;
            mob.colourHairType=data[mobUpdateOffset++] & 0xff;
            mob.colourTopType=data[mobUpdateOffset++] & 0xff;
            mob.colourBottomType=data[mobUpdateOffset++] & 0xff;
            mob.colourSkinType=data[mobUpdateOffset++] & 0xff;
            mob.level=data[mobUpdateOffset++] & 0xff;
            mob.anInt179=data[mobUpdateOffset++] & 0xff;
            mob.admin=data[mobUpdateOffset++] & 0xff;
          }
 else {
            mobUpdateOffset+=14;
            int j31=DataOperations.getUnsignedByte(data[mobUpdateOffset]);
            mobUpdateOffset+=j31 + 1;
          }
        }
 else         if (mobUpdateType == 6) {
          byte byte8=data[mobUpdateOffset];
          mobUpdateOffset++;
          if (mob != null) {
            String s3=DataConversions.byteToString(data,mobUpdateOffset,byte8);
            mob.lastMessageTimeout=150;
            mob.lastMessage=s3;
            if (mob == ourPlayer)             displayMessage(mob.name + "String_Node_Str" + mob.lastMessage,5,mob.admin);
          }
          mobUpdateOffset+=byte8;
        }
      }
      return;
    }
    if (command == 129) {
      combatStyle=DataOperations.getUnsignedByte(data[1]);
      return;
    }
    if (command == 95) {
      for (int l1=1; l1 < length; )       if (DataOperations.getUnsignedByte(data[l1]) == 255) {
        int j9=0;
        int l15=getSectionX() + data[l1 + 1] >> 3;
        int j20=getSectionY() + data[l1 + 2] >> 3;
        l1+=3;
        for (int currentDoor=0; currentDoor < doorCount; currentDoor++) {
          int j27=(doorX[currentDoor] >> 3) - l15;
          int k31=(doorY[currentDoor] >> 3) - j20;
          if (j27 != 0 || k31 != 0) {
            if (currentDoor != j9) {
              doorModel[j9]=doorModel[currentDoor];
              doorModel[j9].anInt257=j9 + 10000;
              doorX[j9]=doorX[currentDoor];
              doorY[j9]=doorY[currentDoor];
              doorDirection[j9]=doorDirection[currentDoor];
              doorType[j9]=doorType[currentDoor];
            }
            j9++;
          }
 else {
            gameCamera.removeModel(doorModel[currentDoor]);
            engineHandle.updateDoor(doorX[currentDoor],doorY[currentDoor],doorDirection[currentDoor],doorType[currentDoor]);
          }
        }
        doorCount=j9;
      }
 else {
        int k9=DataOperations.getUnsigned2Bytes(data,l1);
        l1+=2;
        int i16=getSectionX() + data[l1++];
        int k20=getSectionY() + data[l1++];
        byte byte5=data[l1++];
        int k27=0;
        for (int l31=0; l31 < doorCount; l31++)         if (doorX[l31] != i16 || doorY[l31] != k20 || doorDirection[l31] != byte5) {
          if (l31 != k27) {
            doorModel[k27]=doorModel[l31];
            doorModel[k27].anInt257=k27 + 10000;
            doorX[k27]=doorX[l31];
            doorY[k27]=doorY[l31];
            doorDirection[k27]=doorDirection[l31];
            doorType[k27]=doorType[l31];
          }
          k27++;
        }
 else {
          gameCamera.removeModel(doorModel[l31]);
          engineHandle.updateDoor(doorX[l31],doorY[l31],doorDirection[l31],doorType[l31]);
        }
        doorCount=k27;
        if (k9 != 60000) {
          engineHandle.method408(i16,k20,byte5,k9);
          Model model=makeModel(i16,k20,byte5,k9,doorCount);
          doorModel[doorCount]=model;
          doorX[doorCount]=i16;
          doorY[doorCount]=k20;
          doorType[doorCount]=k9;
          doorDirection[doorCount++]=byte5;
        }
      }
      return;
    }
    if (command == 77) {
      lastNpcCount=npcCount;
      npcCount=0;
      for (int lastNpcIndex=0; lastNpcIndex < lastNpcCount; lastNpcIndex++)       lastNpcArray[lastNpcIndex]=npcArray[lastNpcIndex];
      int newNpcOffset=8;
      int newNpcCount=DataOperations.getIntFromByteArray(data,newNpcOffset,8);
      newNpcOffset+=8;
      for (int newNpcIndex=0; newNpcIndex < newNpcCount; newNpcIndex++) {
        Mob newNPC=getLastNpc(DataOperations.getIntFromByteArray(data,newNpcOffset,16));
        newNpcOffset+=16;
        int npcNeedsUpdate=DataOperations.getIntFromByteArray(data,newNpcOffset,1);
        newNpcOffset++;
        if (npcNeedsUpdate != 0) {
          int i32=DataOperations.getIntFromByteArray(data,newNpcOffset,1);
          newNpcOffset++;
          if (i32 == 0) {
            int nextSprite=DataOperations.getIntFromByteArray(data,newNpcOffset,3);
            newNpcOffset+=3;
            int waypointCurrent=newNPC.waypointCurrent;
            int waypointX=newNPC.waypointsX[waypointCurrent];
            int waypointY=newNPC.waypointsY[waypointCurrent];
            if (nextSprite == 2 || nextSprite == 1 || nextSprite == 3)             waypointX+=magicLoc;
            if (nextSprite == 6 || nextSprite == 5 || nextSprite == 7)             waypointX-=magicLoc;
            if (nextSprite == 4 || nextSprite == 3 || nextSprite == 5)             waypointY+=magicLoc;
            if (nextSprite == 0 || nextSprite == 1 || nextSprite == 7)             waypointY-=magicLoc;
            newNPC.nextSprite=nextSprite;
            newNPC.waypointCurrent=waypointCurrent=(waypointCurrent + 1) % 10;
            newNPC.waypointsX[waypointCurrent]=waypointX;
            newNPC.waypointsY[waypointCurrent]=waypointY;
          }
 else {
            int nextSpriteOffset=DataOperations.getIntFromByteArray(data,newNpcOffset,4);
            newNpcOffset+=4;
            if ((nextSpriteOffset & 0xc) == 12) {
              continue;
            }
            newNPC.nextSprite=nextSpriteOffset;
          }
        }
        npcArray[npcCount++]=newNPC;
      }
      while (newNpcOffset + 34 < length * 8) {
        int serverIndex=DataOperations.getIntFromByteArray(data,newNpcOffset,16);
        newNpcOffset+=16;
        int i28=DataOperations.getIntFromByteArray(data,newNpcOffset,5);
        newNpcOffset+=5;
        if (i28 > 15)         i28-=32;
        int j32=DataOperations.getIntFromByteArray(data,newNpcOffset,5);
        newNpcOffset+=5;
        if (j32 > 15)         j32-=32;
        int nextSprite=DataOperations.getIntFromByteArray(data,newNpcOffset,4);
        newNpcOffset+=4;
        int x=(getSectionX() + i28) * magicLoc + 64;
        int y=(getSectionY() + j32) * magicLoc + 64;
        int type=DataOperations.getIntFromByteArray(data,newNpcOffset,10);
        newNpcOffset+=10;
        if (type >= EntityHandler.npcCount())         type=24;
        addNPC(serverIndex,x,y,nextSprite,type);
      }
      return;
    }
    if (command == 190) {
      int j2=DataOperations.getUnsigned2Bytes(data,1);
      int i10=3;
      for (int k16=0; k16 < j2; k16++) {
        int i21=DataOperations.getUnsigned2Bytes(data,i10);
        i10+=2;
        Mob mob_2=npcRecordArray[i21];
        int j28=DataOperations.getUnsignedByte(data[i10]);
        i10++;
        if (j28 == 1) {
          int k32=DataOperations.getUnsigned2Bytes(data,i10);
          i10+=2;
          byte byte9=data[i10];
          i10++;
          if (mob_2 != null) {
            String s4=DataConversions.byteToString(data,i10,byte9);
            mob_2.lastMessageTimeout=150;
            mob_2.lastMessage=s4;
            if (k32 == ourPlayer.serverIndex)             displayMessage("String_Node_Str" + EntityHandler.getNpcDef(mob_2.type).getName() + "String_Node_Str"+ mob_2.lastMessage,5,0);
          }
          i10+=byte9;
        }
 else         if (j28 == 2) {
          int l32=DataOperations.getUnsignedByte(data[i10]);
          i10++;
          int i36=DataOperations.getUnsignedByte(data[i10]);
          i10++;
          int k38=DataOperations.getUnsignedByte(data[i10]);
          i10++;
          if (mob_2 != null) {
            mob_2.anInt164=l32;
            mob_2.hitPointsCurrent=i36;
            mob_2.hitPointsBase=k38;
            mob_2.combatTimer=200;
          }
        }
      }
      return;
    }
    if (command == 223) {
      showQuestionMenu=true;
      int newQuestionMenuCount=DataOperations.getUnsignedByte(data[1]);
      questionMenuCount=newQuestionMenuCount;
      int newQuestionMenuOffset=2;
      for (int l16=0; l16 < newQuestionMenuCount; l16++) {
        int newQuestionMenuQuestionLength=DataOperations.getUnsignedByte(data[newQuestionMenuOffset]);
        newQuestionMenuOffset++;
        questionMenuAnswer[l16]=new String(data,newQuestionMenuOffset,newQuestionMenuQuestionLength);
        newQuestionMenuOffset+=newQuestionMenuQuestionLength;
      }
      return;
    }
    if (command == 127) {
      showQuestionMenu=false;
      return;
    }
    if (command == 131) {
      needsClear=true;
      notInWilderness=true;
      hasWorldInfo=true;
      serverIndex=DataOperations.getUnsigned2Bytes(data,1);
      wildX=DataOperations.getUnsigned2Bytes(data,3);
      wildY=DataOperations.getUnsigned2Bytes(data,5);
      wildYSubtract=DataOperations.getUnsigned2Bytes(data,7);
      wildYMultiplier=DataOperations.getUnsigned2Bytes(data,9);
      wildY-=wildYSubtract * wildYMultiplier;
      return;
    }
    if (command == 180) {
      int l2=1;
      for (int k10=0; k10 < 18; k10++) {
        playerStatCurrent[k10]=DataOperations.getUnsignedByte(data[l2++]);
      }
      for (int i17=0; i17 < 18; i17++) {
        playerStatBase[i17]=DataOperations.getUnsignedByte(data[l2++]);
      }
      for (int k21=0; k21 < 18; k21++) {
        playerStatExperience[k21]=DataOperations.readInt(data,l2);
        l2+=4;
      }
      expGained=0;
      return;
    }
    if (command == 177) {
      int i3=1;
      for (int x=0; x < 6; x++) {
        equipmentStatus[x]=DataOperations.getSigned2Bytes(data,i3);
        i3+=2;
      }
      return;
    }
    if (command == 165) {
      playerAliveTimeout=250;
      return;
    }
    if (command == 115) {
      int thingLength=(length - 1) / 4;
      for (int currentThing=0; currentThing < thingLength; currentThing++) {
        int currentItemSectionX=getSectionX() + DataOperations.getSigned2Bytes(data,1 + currentThing * 4) >> 3;
        int currentItemSectionY=getSectionY() + DataOperations.getSigned2Bytes(data,3 + currentThing * 4) >> 3;
        int currentCount=0;
        for (int currentItem=0; currentItem < groundItemCount; currentItem++) {
          int currentItemOffsetX=(groundItemX[currentItem] >> 3) - currentItemSectionX;
          int currentItemOffsetY=(groundItemY[currentItem] >> 3) - currentItemSectionY;
          if (currentItemOffsetX != 0 || currentItemOffsetY != 0) {
            if (currentItem != currentCount) {
              groundItemX[currentCount]=groundItemX[currentItem];
              groundItemY[currentCount]=groundItemY[currentItem];
              groundItemType[currentCount]=groundItemType[currentItem];
              groundItemObjectVar[currentCount]=groundItemObjectVar[currentItem];
            }
            currentCount++;
          }
        }
        groundItemCount=currentCount;
        currentCount=0;
        for (int j33=0; j33 < objectCount; j33++) {
          int k36=(objectX[j33] >> 3) - currentItemSectionX;
          int l38=(objectY[j33] >> 3) - currentItemSectionY;
          if (k36 != 0 || l38 != 0) {
            if (j33 != currentCount) {
              objectModelArray[currentCount]=objectModelArray[j33];
              objectModelArray[currentCount].anInt257=currentCount;
              objectX[currentCount]=objectX[j33];
              objectY[currentCount]=objectY[j33];
              objectType[currentCount]=objectType[j33];
              objectID[currentCount]=objectID[j33];
            }
            currentCount++;
          }
 else {
            gameCamera.removeModel(objectModelArray[j33]);
            engineHandle.updateObject(objectX[j33],objectY[j33],objectType[j33],objectID[j33]);
          }
        }
        objectCount=currentCount;
        currentCount=0;
        for (int l36=0; l36 < doorCount; l36++) {
          int i39=(doorX[l36] >> 3) - currentItemSectionX;
          int j41=(doorY[l36] >> 3) - currentItemSectionY;
          if (i39 != 0 || j41 != 0) {
            if (l36 != currentCount) {
              doorModel[currentCount]=doorModel[l36];
              doorModel[currentCount].anInt257=currentCount + 10000;
              doorX[currentCount]=doorX[l36];
              doorY[currentCount]=doorY[l36];
              doorDirection[currentCount]=doorDirection[l36];
              doorType[currentCount]=doorType[l36];
            }
            currentCount++;
          }
 else {
            gameCamera.removeModel(doorModel[l36]);
            engineHandle.updateDoor(doorX[l36],doorY[l36],doorDirection[l36],doorType[l36]);
          }
        }
        doorCount=currentCount;
      }
      return;
    }
    if (command == 230) {
      showDrawPointsScreen=true;
      int pkbytes=1;
      pkatk=DataOperations.readInt(data,pkbytes);
      pkbytes+=4;
      pkdef=DataOperations.readInt(data,pkbytes);
      pkbytes+=4;
      pkstr=DataOperations.readInt(data,pkbytes);
      pkbytes+=4;
      pkrange=DataOperations.readInt(data,pkbytes);
      pkbytes+=4;
      pkmagic=DataOperations.readInt(data,pkbytes);
    }
    if (command == 207) {
      showCharacterLookScreen=true;
      return;
    }
    if (command == 4) {
      int currentMob=DataOperations.getUnsigned2Bytes(data,1);
      if (mobArray[currentMob] != null)       tradeOtherPlayerName=mobArray[currentMob].name;
      showTradeWindow=true;
      tradeOtherAccepted=false;
      tradeWeAccepted=false;
      tradeMyItemCount=0;
      tradeOtherItemCount=0;
      return;
    }
    if (command == 187) {
      showTradeWindow=false;
      showTradeConfirmWindow=false;
      return;
    }
    if (command == 250) {
      tradeOtherItemCount=data[1] & 0xff;
      int l3=2;
      for (int i11=0; i11 < tradeOtherItemCount; i11++) {
        tradeOtherItems[i11]=DataOperations.getUnsigned2Bytes(data,l3);
        l3+=2;
        tradeOtherItemsCount[i11]=DataOperations.readInt(data,l3);
        l3+=4;
      }
      tradeOtherAccepted=false;
      tradeWeAccepted=false;
      return;
    }
    if (command == 92) {
      tradeOtherAccepted=data[1] == 1;
    }
    if (command == 253) {
      showShop=true;
      int i4=1;
      int j11=data[i4++] & 0xff;
      byte byte4=data[i4++];
      shopItemSellPriceModifier=data[i4++] & 0xff;
      shopItemBuyPriceModifier=data[i4++] & 0xff;
      for (int i22=0; i22 < 40; i22++)       shopItems[i22]=-1;
      for (int j25=0; j25 < j11; j25++) {
        shopItems[j25]=DataOperations.getUnsigned2Bytes(data,i4);
        i4+=2;
        shopItemCount[j25]=DataOperations.getUnsigned2Bytes(data,i4);
        i4+=2;
        shopItemsBuyPrice[j25]=DataOperations.getUnsigned4Bytes(data,i4);
        i4+=4;
        shopItemsSellPrice[j25]=DataOperations.getUnsigned4Bytes(data,i4);
        i4+=4;
      }
      if (byte4 == 1) {
        int l28=39;
        for (int k33=0; k33 < inventoryCount; k33++) {
          if (l28 < j11)           break;
          boolean flag2=false;
          for (int j39=0; j39 < 40; j39++) {
            if (shopItems[j39] != getInventoryItems()[k33])             continue;
            flag2=true;
            break;
          }
          if (getInventoryItems()[k33] == 10)           flag2=true;
          if (!flag2) {
            shopItems[l28]=getInventoryItems()[k33] & 0x7fff;
            shopItemsSellPrice[l28]=EntityHandler.getItemDef(shopItems[l28]).basePrice - (int)(EntityHandler.getItemDef(shopItems[l28]).basePrice / 2.5);
            shopItemsSellPrice[l28]=shopItemsSellPrice[l28] - (int)(shopItemsSellPrice[l28] * 0.10);
            shopItemCount[l28]=0;
            l28--;
          }
        }
      }
      if (selectedShopItemIndex >= 0 && selectedShopItemIndex < 40 && shopItems[selectedShopItemIndex] != selectedShopItemType) {
        selectedShopItemIndex=-1;
        selectedShopItemType=-2;
      }
      return;
    }
    if (command == 220) {
      showShop=false;
      return;
    }
    if (command == 18) {
      tradeWeAccepted=data[1] == 1;
    }
    if (command == 152) {
      configAutoCameraAngle=DataOperations.getUnsignedByte(data[1]) == 1;
      configMouseButtons=DataOperations.getUnsignedByte(data[2]) == 1;
      configSoundEffects=DataOperations.getUnsignedByte(data[3]) == 1;
      showRoof=DataOperations.getUnsignedByte(data[4]) == 1;
      autoScreenshot=DataOperations.getUnsignedByte(data[5]) == 1;
      combatWindow=DataOperations.getUnsignedByte(data[6]) == 1;
      return;
    }
    if (command == 209) {
      for (int currentPrayer=0; currentPrayer < length - 1; currentPrayer++) {
        boolean prayerOff=data[currentPrayer + 1] == 1;
        if (!prayerOn[currentPrayer] && prayerOff)         playSound("String_Node_Str");
        if (prayerOn[currentPrayer] && !prayerOff)         playSound("String_Node_Str");
        prayerOn[currentPrayer]=prayerOff;
      }
      return;
    }
    if (command == 93) {
      showBank=true;
      int l4=1;
      newBankItemCount=data[l4++] & 0xff;
      bankItemsMax=data[l4++] & 0xff;
      for (int k11=0; k11 < newBankItemCount; k11++) {
        newBankItems[k11]=DataOperations.getUnsigned2Bytes(data,l4);
        l4+=2;
        newBankItemsCount[k11]=DataOperations.getUnsigned4Bytes(data,l4);
        l4+=4;
      }
      updateBankItems();
      return;
    }
    if (command == 171) {
      showBank=false;
      return;
    }
    if (command == 211) {
      int idx=data[1] & 0xFF;
      int oldExp=playerStatExperience[idx];
      playerStatExperience[idx]=DataOperations.readInt(data,2);
      if (playerStatExperience[idx] > oldExp) {
        expGained+=(playerStatExperience[idx] - oldExp);
      }
      return;
    }
    if (command == 229) {
      int j5=DataOperations.getUnsigned2Bytes(data,1);
      if (mobArray[j5] != null) {
        duelOpponentName=mobArray[j5].name;
      }
      showDuelWindow=true;
      duelMyItemCount=0;
      duelOpponentItemCount=0;
      duelOpponentAccepted=false;
      duelMyAccepted=false;
      duelNoRetreating=false;
      duelNoMagic=false;
      duelNoPrayer=false;
      duelNoWeapons=false;
      return;
    }
    if (command == 160) {
      showDuelWindow=false;
      showDuelConfirmWindow=false;
      return;
    }
    if (command == 251) {
      showTradeConfirmWindow=true;
      tradeConfirmAccepted=false;
      showTradeWindow=false;
      int k5=1;
      tradeConfirmOtherNameLong=DataOperations.getUnsigned8Bytes(data,k5);
      k5+=8;
      tradeConfirmOtherItemCount=data[k5++] & 0xff;
      for (int l11=0; l11 < tradeConfirmOtherItemCount; l11++) {
        tradeConfirmOtherItems[l11]=DataOperations.getUnsigned2Bytes(data,k5);
        k5+=2;
        tradeConfirmOtherItemsCount[l11]=DataOperations.readInt(data,k5);
        k5+=4;
      }
      tradeConfirmItemCount=data[k5++] & 0xff;
      for (int k17=0; k17 < tradeConfirmItemCount; k17++) {
        tradeConfirmItems[k17]=DataOperations.getUnsigned2Bytes(data,k5);
        k5+=2;
        tradeConfirmItemsCount[k17]=DataOperations.readInt(data,k5);
        k5+=4;
      }
      return;
    }
    if (command == 63) {
      duelOpponentItemCount=data[1] & 0xff;
      int l5=2;
      for (int i12=0; i12 < duelOpponentItemCount; i12++) {
        duelOpponentItems[i12]=DataOperations.getUnsigned2Bytes(data,l5);
        l5+=2;
        duelOpponentItemsCount[i12]=DataOperations.readInt(data,l5);
        l5+=4;
      }
      duelOpponentAccepted=false;
      duelMyAccepted=false;
      return;
    }
    if (command == 198) {
      duelNoRetreating=data[1] == 1;
      duelNoMagic=data[2] == 1;
      duelNoPrayer=data[3] == 1;
      duelNoWeapons=data[4] == 1;
      duelOpponentAccepted=false;
      duelMyAccepted=false;
      return;
    }
    if (command == 139) {
      int bankDataOffset=1;
      int bankSlot=data[bankDataOffset++] & 0xff;
      int bankItemId=DataOperations.getUnsigned2Bytes(data,bankDataOffset);
      bankDataOffset+=2;
      int bankItemCount=DataOperations.getUnsigned4Bytes(data,bankDataOffset);
      bankDataOffset+=4;
      if (bankItemCount == 0) {
        newBankItemCount--;
        for (int currentBankSlot=bankSlot; currentBankSlot < newBankItemCount; currentBankSlot++) {
          newBankItems[currentBankSlot]=newBankItems[currentBankSlot + 1];
          newBankItemsCount[currentBankSlot]=newBankItemsCount[currentBankSlot + 1];
        }
      }
 else {
        newBankItems[bankSlot]=bankItemId;
        newBankItemsCount[bankSlot]=bankItemCount;
        if (bankSlot >= newBankItemCount)         newBankItemCount=bankSlot + 1;
      }
      updateBankItems();
      return;
    }
    if (command == 228) {
      int j6=1;
      int k12=1;
      int i18=data[j6++] & 0xff;
      int k22=DataOperations.getUnsigned2Bytes(data,j6);
      j6+=2;
      if (EntityHandler.getItemDef(k22 & 0x7fff).isStackable()) {
        k12=DataOperations.readInt(data,j6);
        j6+=4;
      }
      getInventoryItems()[i18]=k22 & 0x7fff;
      wearing[i18]=k22 / 32768;
      inventoryItemsCount[i18]=k12;
      if (i18 >= inventoryCount)       inventoryCount=i18 + 1;
      return;
    }
    if (command == 191) {
      int k6=data[1] & 0xff;
      inventoryCount--;
      for (int l12=k6; l12 < inventoryCount; l12++) {
        getInventoryItems()[l12]=getInventoryItems()[l12 + 1];
        inventoryItemsCount[l12]=inventoryItemsCount[l12 + 1];
        wearing[l12]=wearing[l12 + 1];
      }
      return;
    }
    if (command == 208) {
      int pointer=1;
      int idx=data[pointer++] & 0xff;
      int oldExp=playerStatExperience[idx];
      playerStatCurrent[idx]=DataOperations.getUnsignedByte(data[pointer++]);
      playerStatBase[idx]=DataOperations.getUnsignedByte(data[pointer++]);
      playerStatExperience[idx]=DataOperations.readInt(data,pointer);
      pointer+=4;
      if (playerStatExperience[idx] > oldExp) {
        expGained+=(playerStatExperience[idx] - oldExp);
      }
      return;
    }
    if (command == 65) {
      duelOpponentAccepted=data[1] == 1;
    }
    if (command == 197) {
      duelMyAccepted=data[1] == 1;
    }
    if (command == 147) {
      showDuelConfirmWindow=true;
      duelWeAccept=false;
      showDuelWindow=false;
      int i7=1;
      duelOpponentNameLong=DataOperations.getUnsigned8Bytes(data,i7);
      i7+=8;
      duelConfirmOpponentItemCount=data[i7++] & 0xff;
      for (int j13=0; j13 < duelConfirmOpponentItemCount; j13++) {
        duelConfirmOpponentItems[j13]=DataOperations.getUnsigned2Bytes(data,i7);
        i7+=2;
        duelConfirmOpponentItemsCount[j13]=DataOperations.readInt(data,i7);
        i7+=4;
      }
      duelConfirmMyItemCount=data[i7++] & 0xff;
      for (int j18=0; j18 < duelConfirmMyItemCount; j18++) {
        duelConfirmMyItems[j18]=DataOperations.getUnsigned2Bytes(data,i7);
        i7+=2;
        duelConfirmMyItemsCount[j18]=DataOperations.readInt(data,i7);
        i7+=4;
      }
      duelCantRetreat=data[i7++] & 0xff;
      duelUseMagic=data[i7++] & 0xff;
      duelUsePrayer=data[i7++] & 0xff;
      duelUseWeapons=data[i7++] & 0xff;
      return;
    }
    if (command == 11) {
      String s=new String(data,1,length - 1);
      playSound(s);
      return;
    }
    if (command == 23) {
      if (anInt892 < 50) {
        int j7=data[1] & 0xff;
        int k13=data[2] + getSectionX();
        int k18=data[3] + getSectionY();
        anIntArray782[anInt892]=j7;
        anIntArray923[anInt892]=0;
        anIntArray944[anInt892]=k13;
        anIntArray757[anInt892]=k18;
        anInt892++;
      }
      return;
    }
    if (command == 248) {
      if (!hasReceivedWelcomeBoxDetails) {
        lastLoggedInDays=DataOperations.getUnsigned2Bytes(data,1);
        subscriptionLeftDays=DataOperations.getUnsigned2Bytes(data,3);
        lastLoggedInAddress=new String(data,5,length - 5);
        showWelcomeBox=true;
        hasReceivedWelcomeBoxDetails=true;
      }
      return;
    }
    if (command == 148) {
      serverMessage=new String(data,1,length - 1);
      showServerMessageBox=true;
      serverMessageBoxTop=false;
      return;
    }
    if (command == 64) {
      serverMessage=new String(data,1,length - 1);
      showServerMessageBox=true;
      serverMessageBoxTop=true;
      return;
    }
    if (command == 126) {
      fatigue=DataOperations.getUnsigned2Bytes(data,1);
      return;
    }
    if (command == 206) {
      if (!sleeping) {
      }
      sleeping=true;
      gameMenu.updateText(chatHandle,"String_Node_Str");
      super.inputText="String_Node_Str";
      super.enteredText="String_Node_Str";
      sleepEquation=DataOperations.getImage(data,1,length);
      return;
    }
    if (command == 182) {
      int offset=1;
      questPoints=DataOperations.getUnsigned2Bytes(data,offset);
      offset+=2;
      for (int i=0; i < questName.length; i++)       questStage[i]=data[offset + i];
      return;
    }
    if (command == 224) {
      sleeping=false;
      sleepMessage=null;
      return;
    }
    if (command == 225) {
      sleepMessage="String_Node_Str";
      return;
    }
    if (command == 174) {
      DataOperations.getUnsigned2Bytes(data,1);
      return;
    }
    if (command == 181) {
      if (autoScreenshot) {
        takeScreenshot(false);
      }
      return;
    }
    if (command == 172) {
      systemUpdate=DataOperations.getUnsigned2Bytes(data,1) * 32;
      return;
    }
  }
 catch (  Exception e) {
  }
}