Thread: Issue with region generation and packet sizing

Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1 Issue with region generation and packet sizing 
    Extreme Donator
    CrazzMC's Avatar
    Join Date
    Sep 2011
    Posts
    41
    Thanks given
    4
    Thanks received
    1
    Discord
    View profile
    Rep Power
    11
    Looked through a few sources to get region generation/construction going. I'm having issues with Packet 241 (ConstructMapRegion). I am currently on vencillio and I've got a little too much time invested to switch sources. The main difference I am noticing compared to other sources is that I have to declare the size server sided where others do not. I match the client side packet size to the server and I still am getting T1/T2 Errors. I'm not really sure if 20 is correct but its what I've seen on a few other really old posts.

    Server Code:
    Code:
            
            StreamBuffer.OutBuffer out = StreamBuffer.newOutBuffer(20);
            out.writeHeader(paramClient.getEncryptor(), 241);
            out.writeShort(paramClient.getPlayer().getLocation().getRegionX() + 6);
            out.writeShort(paramClient.getPlayer().getLocation().getRegionY() + 6);
            out.setAccessType(StreamBuffer.AccessType.BIT_ACCESS);
            for (int z = 0; z < 4; z++) {
                for (int x = 0; x < 13; x++) {
                    for (int y = 0; y < 13; y++) {
                        Palette.PaletteTile tile = palette.getTile(x, y, z);
                        boolean b = false;
                        if (x < 2 || x > 10 || y < 2 || y > 10) {
                            b = true;
                        }
                        int toWrite = !b && tile != null ? 1 : 0;
                        out.writeBits(1, toWrite);
                        if (toWrite == 1) {
                            int val = tile.getX() << 14 | tile.getY() << 3 | tile.getZ() << 24 | tile.getRotation() << 1;
                            out.writeBits(26, val);
                        }
                    }
                }
            }
            out.setAccessType(StreamBuffer.AccessType.BYTE_ACCESS);
            paramClient.send(out.getBuffer());
    Client Code: (I've cross referenced this code to about 3 other sources as well and it seems fairly consistent.)
    Code:
    				case 73:
    				case 241:
    					int regionX = mapRegionsX;
    					int regionY = mapRegionsY;
    					if (pktType == 73) {
    						regionX = MapX = inStream.method435();
    						regionY = MapY = inStream.readUShort();
    						dynamicRegion = false;
    					}
    					if (pktType == 241) {
    						System.out.println("241 packet size: " + pktSize);
    						regionX = MapX = inStream.readUShort();
    						regionY = MapY = inStream.readUShort();
    						inStream.initBitAccess();
    						for (int j16 = 0; j16 < 4; j16++) {
    							for (int l20 = 0; l20 < 13; l20++) {
    								for (int j23 = 0; j23 < 13; j23++) {
    									int i26 = inStream.readBits(1);
    									if (i26 == 1) {
    										anIntArrayArrayArray1129[j16][l20][j23] = inStream.readBits(26);
    									} else {
    										anIntArrayArrayArray1129[j16][l20][j23] = -1;
    									}
    								}
    							}
    						}
    						inStream.finishBitAccess();
    						dynamicRegion = true;
    					}
    					if (pktType != 241 && mapRegionsX == regionX && mapRegionsY == regionY && loadingStage == 2) {
    						pktType = -1;
    						return true;
    					}
    					mapRegionsX = regionX;
    					mapRegionsY = regionY;
    					regionBaseX = (mapRegionsX - 6) * 8;
    					regionBaseY = (mapRegionsY - 6) * 8;
    					aBoolean1141 = (mapRegionsX / 8 == 48 || mapRegionsX / 8 == 49) && mapRegionsY / 8 == 48;
    					if (mapRegionsX / 8 == 48 && mapRegionsY / 8 == 148)
    						aBoolean1141 = true;
    					loadingStage = 1;
    					aLong824 = System.currentTimeMillis();
    					aRSImageProducer_1165.initDrawingArea();
    					drawLoadingMessages(1, "Loading - please wait.", null);
    					aRSImageProducer_1165.drawGraphics(frameMode == ScreenMode.FIXED ? 4 : 0, super.graphics,
    							frameMode == ScreenMode.FIXED ? 4 : 0);
    					if (pktType == 73) {
    						int k16 = 0;
    						for (int i21 = (mapRegionsX - 6) / 8; i21 <= (mapRegionsX + 6) / 8; i21++) {
    							for (int k23 = (mapRegionsY - 6) / 8; k23 <= (mapRegionsY + 6) / 8; k23++)
    								k16++;
    						}
    						aByteArrayArray1183 = new byte[k16][];
    						aByteArrayArray1247 = new byte[k16][];
    						mapCoordinates = new int[k16];
    						anIntArray1235 = new int[k16];
    						anIntArray1236 = new int[k16];
    						k16 = 0;
    						for (int l23 = (mapRegionsX - 6) / 8; l23 <= (mapRegionsX + 6) / 8; l23++) {
    							for (int j26 = (mapRegionsY - 6) / 8; j26 <= (mapRegionsY + 6) / 8; j26++) {
    								mapCoordinates[k16] = (l23 << 8) + j26;
    								if (aBoolean1141
    										&& (j26 == 49 || j26 == 149 || j26 == 147 || l23 == 50 || l23 == 49 && j26 == 47)) {
    									anIntArray1235[k16] = -1;
    									anIntArray1236[k16] = -1;
    									k16++;
    								} else {
    									int k28 = anIntArray1235[k16] = onDemandFetcher.method562(0, j26, l23);
    									if (k28 != -1)
    										onDemandFetcher.method558(3, k28);
    									int j30 = anIntArray1236[k16] = onDemandFetcher.method562(1, j26, l23);
    									if (j30 != -1)
    										onDemandFetcher.method558(3, j30);
    									k16++;
    								}
    							}
    						}
    					}
    					if (pktType == 241) {
    						int l16 = 0;
    						int ai[] = new int[676];
    						for (int i24 = 0; i24 < 4; i24++) {
    							for (int k26 = 0; k26 < 13; k26++) {
    								for (int l28 = 0; l28 < 13; l28++) {
    									int k30 = anIntArrayArrayArray1129[i24][k26][l28];
    									if (k30 != -1) {
    										int k31 = k30 >> 14 & 0x3ff;
    										int i32 = k30 >> 3 & 0x7ff;
    										int k32 = (k31 / 8 << 8) + i32 / 8;
    										for (int j33 = 0; j33 < l16; j33++) {
    											if (ai[j33] != k32)
    												continue;
    											k32 = -1;
    
    										}
    										if (k32 != -1)
    											ai[l16++] = k32;
    									}
    								}
    							}
    						}
    						aByteArrayArray1183 = new byte[l16][];
    						aByteArrayArray1247 = new byte[l16][];
    						mapCoordinates = new int[l16];
    						anIntArray1235 = new int[l16];
    						anIntArray1236 = new int[l16];
    						for (int l26 = 0; l26 < l16; l26++) {
    							int i29 = mapCoordinates[l26] = ai[l26];
    							int l30 = i29 >> 8 & 0xff;
    							int l31 = i29 & 0xff;
    							int j32 = anIntArray1235[l26] = onDemandFetcher.method562(0, l31, l30);
    							if (j32 != -1)
    								onDemandFetcher.method558(3, j32);
    							int i33 = anIntArray1236[l26] = onDemandFetcher.method562(1, l31, l30);
    							if (i33 != -1)
    								onDemandFetcher.method558(3, i33);
    						}
    					}
    					int i17 = regionBaseX - anInt1036;
    					int j21 = regionBaseY - anInt1037;
    					anInt1036 = regionBaseX;
    					anInt1037 = regionBaseY;
    					for (int j24 = 0; j24 < 16384; j24++) {
    						Npc npc = npcArray[j24];
    						if (npc != null) {
    							for (int j29 = 0; j29 < 10; j29++) {
    								npc.smallX[j29] -= i17;
    								npc.smallY[j29] -= j21;
    							}
    							npc.x -= i17 * 128;
    							npc.y -= j21 * 128;
    						}
    					}
    					for (int i27 = 0; i27 < maxPlayers; i27++) {
    						Player player = playerArray[i27];
    						if (player != null) {
    							for (int i31 = 0; i31 < 10; i31++) {
    								player.smallX[i31] -= i17;
    								player.smallY[i31] -= j21;
    							}
    							player.x -= i17 * 128;
    							player.y -= j21 * 128;
    						}
    					}
    					aBoolean1080 = true;
    					byte byte1 = 0;
    					byte byte2 = 104;
    					byte byte3 = 1;
    					if (i17 < 0) {
    						byte1 = 103;
    						byte2 = -1;
    						byte3 = -1;
    					}
    					byte byte4 = 0;
    					byte byte5 = 104;
    					byte byte6 = 1;
    					if (j21 < 0) {
    						byte4 = 103;
    						byte5 = -1;
    						byte6 = -1;
    					}
    					for (int k33 = byte1; k33 != byte2; k33 += byte3) {
    						for (int l33 = byte4; l33 != byte5; l33 += byte6) {
    							int i34 = k33 + i17;
    							int j34 = l33 + j21;
    							for (int k34 = 0; k34 < 4; k34++)
    								if (i34 >= 0 && j34 >= 0 && i34 < 104 && j34 < 104)
    									groundArray[k34][k33][l33] = groundArray[k34][i34][j34];
    								else
    									groundArray[k34][k33][l33] = null;
    						}
    					}
    					for (Class30_Sub1 class30_sub1_1 = (Class30_Sub1) aClass19_1179
    							.reverseGetFirst(); class30_sub1_1 != null; class30_sub1_1 = (Class30_Sub1) aClass19_1179
    							.reverseGetNext()) {
    						class30_sub1_1.anInt1297 -= i17;
    						class30_sub1_1.anInt1298 -= j21;
    						if (class30_sub1_1.anInt1297 < 0 || class30_sub1_1.anInt1298 < 0 || class30_sub1_1.anInt1297 >= 104
    								|| class30_sub1_1.anInt1298 >= 104)
    							class30_sub1_1.unlink();
    					}
    					if (destX != 0) {
    						destX -= i17;
    						destY -= j21;
    					}
    					aBoolean1160 = false;
    					pktType = -1;
    					return true;

    Packet Size: (I've tried -1 and -2 to try to read it from the actual inStream but that fails as well - I either get 0, or 239 not 100% sure why either)
    Code:
    		2, 19, 0, 0, 0, 0, 6, 0, 4, 3, // 240
    The reason why its 19 (I've tried 20) is because a few of the other packets I have are 1 less in the packetSizes array than in the newOutBuffer(size) code.

    Console: (Prints are pretty much every time it loops through)
    Code:
    PACKET IS : 241
    About to check packets
    241 packet size: 19
    PACKET IS : 34
    About to check packets
    PACKET IS : 231
    About to check packets
    Error: T1 - Packet Type 231, Size0 - 34,241
    PACKET IS : 56
    About to check packets
    Error: T1 - Packet Type 56, Size0 - 231,34
    Thanks in advance,

    Crazz
    Reply With Quote  
     

  2. #2  
    Registered Member

    Join Date
    Feb 2010
    Posts
    3,187
    Thanks given
    1,124
    Thanks received
    834
    Discord
    View profile
    Rep Power
    1514
    referencing hyperion the psize client sided is -2 opcode header should be a short, for whatever reason hyperion writes the y before bit access as short a and the x after bit access

    e.g

    send 241 (short header)
    shorta (ry)
    do bit shit
    short (rx)

    give it ago and see if it works

    and change your client side to -2

    fyi consulting a refactored 317 looks like some knob cheese changed your client side code, hyperions order is correct, you may have to change it back

    also you should send y before x
    Reply With Quote  
     

  3. #3  
    Extreme Donator
    CrazzMC's Avatar
    Join Date
    Sep 2011
    Posts
    41
    Thanks given
    4
    Thanks received
    1
    Discord
    View profile
    Rep Power
    11
    Quote Originally Posted by Fire Cape View Post
    referencing hyperion the psize client sided is -2 opcode header should be a short, for whatever reason hyperion writes the y before bit access as short a and the x after bit access

    e.g

    send 241 (short header)
    shorta (ry)
    do bit shit
    short (rx)

    give it ago and see if it works

    and change your client side to -2

    fyi consulting a refactored 317 looks like some knob cheese changed your client side code, hyperions order is correct, you may have to change it back

    also you should send y before x
    Alright I gave it a shot but unfortunately It still throws T1/2 Errors and kicks me off. It did send the size this time and it was 111 (when i set my newOutBuffer to size 20).

    Current updated Client Sided Code after suggestions:
    Code:
    PacketConstants
    		2, -2, 0, 0, 0, 0, 6, 0, 4, 3, // 240
    
    Client
    				case 73:
    				case 241:
    					int regionX = mapRegionsX;
    					int regionY = mapRegionsY;
    					if (pktType == 73) {
    						regionX = MapX = inStream.readUShortA();
    						regionY = MapY = inStream.readUShort();
    						dynamicRegion = false;
    					}
    					if (pktType == 241) {
    						System.out.println("241 packet size: " + pktSize);
    						regionY = MapY = inStream.readUShortA();
    						inStream.initBitAccess();
    						for (int j16 = 0; j16 < 4; j16++) {
    							for (int l20 = 0; l20 < 13; l20++) {
    								for (int j23 = 0; j23 < 13; j23++) {
    									int i26 = inStream.readBits(1);
    									if (i26 == 1) {
    //										int val = Integer.parseInt(inStream.readString());
    //										anIntArrayArrayArray1129[j16][l20][j23] = val;
    										anIntArrayArrayArray1129[j16][l20][j23] = inStream.readBits(26);
    									} else {
    										anIntArrayArrayArray1129[j16][l20][j23] = -1;
    									}
    								}
    							}
    						}
    						inStream.finishBitAccess();
    						regionX = MapX = inStream.readUShort();
    						dynamicRegion = true;
    ...rest is the same					}
    Updated server sided code after suggestion:
    Code:
        public void execute(Client paramClient) {
            StreamBuffer.OutBuffer out = StreamBuffer.newOutBuffer(20);
    //        out.writeHeader(paramClient.getEncryptor(), 241); - tried with both this commented and uncommented made no difference
            out.writeShort(paramClient.getPlayer().getLocation().getRegionY() + 6, StreamBuffer.ValueType.A);
            out.setAccessType(StreamBuffer.AccessType.BIT_ACCESS);
            for (int z = 0; z < 4; z++) {
                for (int x = 0; x < 13; x++) {
                    for (int y = 0; y < 13; y++) {
                        Palette.PaletteTile tile = palette.getTile(x, y, z);
                        boolean b = false;
                        if (x < 2 || x > 10 || y < 2 || y > 10) {
                            b = true;
                        }
                        int toWrite = !b && tile != null ? 1 : 0;
                        out.writeBits(1, toWrite);
                        if (toWrite == 1) {
                            int val = tile.getX() << 14 | tile.getY() << 3 | tile.getZ() << 24 | tile.getRotation() << 1;
                            out.writeBits(26, val);
                        }
                    }
                }
            }
            out.setAccessType(StreamBuffer.AccessType.BYTE_ACCESS);
            out.writeShort(paramClient.getPlayer().getLocation().getRegionX() + 6);
            paramClient.send(out.getBuffer());
    EDIT:

    So I added these 2 lines server sided before regionY and after my regionX code respectively:
    Code:
            out.writeVariablePacketHeader(paramClient.getEncryptor(), 241);
            out.finishVariablePacketHeader();
    I don't get T1/2 errors but I am getting an error where i < packetSize:
    Code:
    
    			if (i < pktSize) {
    				System.out.println("I is less than packetsize so returning false");
    				return false;
    			}
    I just realized that you said to use shortHeaders so I will try that tomorrow morning. Hope that fixes it. Been a stressful few days with this one
    Reply With Quote  
     

  4. #4  
    Registered Member

    Join Date
    Feb 2010
    Posts
    3,187
    Thanks given
    1,124
    Thanks received
    834
    Discord
    View profile
    Rep Power
    1514
    Quote Originally Posted by CrazzMC View Post
    Alright I gave it a shot but unfortunately It still throws T1/2 Errors and kicks me off. It did send the size this time and it was 111 (when i set my newOutBuffer to size 20).

    Current updated Client Sided Code after suggestions:
    Code:
    PacketConstants
    		2, -2, 0, 0, 0, 0, 6, 0, 4, 3, // 240
    
    Client
    				case 73:
    				case 241:
    					int regionX = mapRegionsX;
    					int regionY = mapRegionsY;
    					if (pktType == 73) {
    						regionX = MapX = inStream.readUShortA();
    						regionY = MapY = inStream.readUShort();
    						dynamicRegion = false;
    					}
    					if (pktType == 241) {
    						System.out.println("241 packet size: " + pktSize);
    						regionY = MapY = inStream.readUShortA();
    						inStream.initBitAccess();
    						for (int j16 = 0; j16 < 4; j16++) {
    							for (int l20 = 0; l20 < 13; l20++) {
    								for (int j23 = 0; j23 < 13; j23++) {
    									int i26 = inStream.readBits(1);
    									if (i26 == 1) {
    //										int val = Integer.parseInt(inStream.readString());
    //										anIntArrayArrayArray1129[j16][l20][j23] = val;
    										anIntArrayArrayArray1129[j16][l20][j23] = inStream.readBits(26);
    									} else {
    										anIntArrayArrayArray1129[j16][l20][j23] = -1;
    									}
    								}
    							}
    						}
    						inStream.finishBitAccess();
    						regionX = MapX = inStream.readUShort();
    						dynamicRegion = true;
    ...rest is the same					}
    Updated server sided code after suggestion:
    Code:
        public void execute(Client paramClient) {
            StreamBuffer.OutBuffer out = StreamBuffer.newOutBuffer(20);
    //        out.writeHeader(paramClient.getEncryptor(), 241); - tried with both this commented and uncommented made no difference
            out.writeShort(paramClient.getPlayer().getLocation().getRegionY() + 6, StreamBuffer.ValueType.A);
            out.setAccessType(StreamBuffer.AccessType.BIT_ACCESS);
            for (int z = 0; z < 4; z++) {
                for (int x = 0; x < 13; x++) {
                    for (int y = 0; y < 13; y++) {
                        Palette.PaletteTile tile = palette.getTile(x, y, z);
                        boolean b = false;
                        if (x < 2 || x > 10 || y < 2 || y > 10) {
                            b = true;
                        }
                        int toWrite = !b && tile != null ? 1 : 0;
                        out.writeBits(1, toWrite);
                        if (toWrite == 1) {
                            int val = tile.getX() << 14 | tile.getY() << 3 | tile.getZ() << 24 | tile.getRotation() << 1;
                            out.writeBits(26, val);
                        }
                    }
                }
            }
            out.setAccessType(StreamBuffer.AccessType.BYTE_ACCESS);
            out.writeShort(paramClient.getPlayer().getLocation().getRegionX() + 6);
            paramClient.send(out.getBuffer());
    EDIT:

    So I added these 2 lines server sided before regionY and after my regionX code respectively:
    Code:
            out.writeVariablePacketHeader(paramClient.getEncryptor(), 241);
            out.finishVariablePacketHeader();
    I don't get T1/2 errors but I am getting an error where i < packetSize:
    Code:
    
    			if (i < pktSize) {
    				System.out.println("I is less than packetsize so returning false");
    				return false;
    			}
    I just realized that you said to use shortHeaders so I will try that tomorrow morning. Hope that fixes it. Been a stressful few days with this one
    If the length is variable it means it can change everytime it is sent, explicitly setting it at 20 might be too small for the outgoing stream
    Reply With Quote  
     

  5. #5  
    Extreme Donator
    CrazzMC's Avatar
    Join Date
    Sep 2011
    Posts
    41
    Thanks given
    4
    Thanks received
    1
    Discord
    View profile
    Rep Power
    11
    Quote Originally Posted by Fire Cape View Post
    If the length is variable it means it can change every time it is sent, explicitly setting it at 20 might be too small for the outgoing stream
    Okay so after adding changing the header to a short and changing the buffer size from 20 all the way up to 1024 I still am getting errors. Currently this is how my packets are sent; it uses ChannelBuffers class.
    Code:
    		/**
    		 * Creates a new OutBuffer.
    		 *
    		 *  @[Only registered and activated users can see links. ] size
    		 *            the size
    		 */
    		private OutBuffer(int size) {
    			buffer = ChannelBuffers.buffer(size);
    		}
    I did however see this method so I'll give it a shot.
    Code:
        public static ChannelBuffer dynamicBuffer() {
            return dynamicBuffer(BIG_ENDIAN, 256);
        }
    Reply With Quote  
     

  6. #6  
    Registered Member

    Join Date
    Feb 2010
    Posts
    3,187
    Thanks given
    1,124
    Thanks received
    834
    Discord
    View profile
    Rep Power
    1514
    mind showing me how your player updating is done ? that is another example of a variable short message that uses bit access so will give me an idea of if you're doing anything wrong (should be packet 81 in 317)

    the errors you are getting now is it complaining about psize, still getting t1/t2?
    Reply With Quote  
     

  7. #7  
    Extreme Donator
    CrazzMC's Avatar
    Join Date
    Sep 2011
    Posts
    41
    Thanks given
    4
    Thanks received
    1
    Discord
    View profile
    Rep Power
    11
    Quote Originally Posted by Fire Cape View Post
    mind showing me how your player updating is done ? that is another example of a variable short message that uses bit access so will give me an idea of if you're doing anything wrong (should be packet 81 in 317)

    the errors you are getting now is it complaining about psize, still getting t1/t2?
    No luck from the dynamic buffer, but I don't think it hurt (as of right now).


    Player Updating:
    Code:
    	private final PlayerUpdateFlags[] pFlags;
    
    	public SendPlayerUpdate(PlayerUpdateFlags[] pFlags) {
    		super();
    		this.pFlags = pFlags;
    	}
    
    	@Override
    	public void execute(Client client) {
    		PlayerUpdating.update(client.getPlayer(), pFlags);
    	}
    
    	@Override
    	public int getOpcode() {
    		return 81;
    	}
    PlayerUpdating.update(client.getPlayer(), pFlags) method
    Code:
    	public static void update(Player player, PlayerUpdateFlags[] pFlags) {
    
    		StreamBuffer.OutBuffer out = StreamBuffer.newOutBuffer(12228);
    		StreamBuffer.OutBuffer block = StreamBuffer.newOutBuffer(8192);
    
    		out.writeVariableShortPacketHeader(player.getClient().getEncryptor(), 81);
    		out.setAccessType(StreamBuffer.AccessType.BIT_ACCESS);
    
    		PlayerUpdateFlags local = pFlags[player.getIndex()];
    
    		updateLocalPlayerMovement(local, out);
    		if (local.isUpdateRequired()) {
    			updateState(local, block, false, true);
    		}
    
    		out.writeBits(8, player.getPlayers().size());
    		for (Iterator<Player> i = player.getPlayers().iterator(); i.hasNext();) {
    			PlayerUpdateFlags flags = pFlags[i.next().getIndex()];
    
    			if ((flags != null) && (flags.getLocation().isViewableFrom(local.getLocation())) && (flags.isActive()) && (!flags.isPlacement()) && (flags.isVisible())) {
    				updateOtherPlayerMovement(flags, out);
    				if (flags.isUpdateRequired())
    					updateState(flags, block, false, player.getPrivateMessaging().ignored(flags.getUsername()));
    			} else {
    				out.writeBit(true);
    				out.writeBits(2, 3);
    				i.remove();
    			}
    		}
    
    		int added = 0;
    
    		for (int i = 0; i < World.getPlayers().length; i++) {
    			if ((player.getPlayers().size() >= 255) || (added >= 15)) {
    				break;
    			}
    
    			PlayerUpdateFlags flags = pFlags[i];
    
    			if (flags != null && !flags.getUsername().equals(local.getUsername()) && flags.isActive()) {
    
    				if (flags != null) {
    					if (!doesLocalListContainPlayer(player, flags.getUsernameToLong()) && flags.getLocation().isViewableFrom(player.getLocation())) {
    						player.getPlayers().add(World.getPlayers()[i]);
    						addPlayer(out, local, flags, i);
    						updateState(flags, block, true, player.getPrivateMessaging().ignored(flags.getUsername()));
    						added++;
    					}
    				}
    			}
    		}
    		if (block.getBuffer().writerIndex() > 0) {
    			out.writeBits(11, 2047);
    			out.setAccessType(StreamBuffer.AccessType.BYTE_ACCESS);
    			out.writeBytes(block.getBuffer());
    		} else {
    			out.setAccessType(StreamBuffer.AccessType.BYTE_ACCESS);
    		}
    
    		out.finishVariableShortPacketHeader();
    		player.getClient().send(out.getBuffer());
    	}
    EDIT: T1/2 Errors btw

    Console
    Code:
    About to check packets
    PACKET IS : 241
    packet 241 size reading from -2: 352
    About to check packets
    241 packet size: 352
    PACKET IS : 71
    About to check packets
    Error: T2 - 71,241,73 - 3,1827,3170 - 1,96,2,
    PACKET IS : 4
    About to check packets
    Method 137 check implement 4
    PACKET IS : 0
    About to check packets
    java.lang.ArrayIndexOutOfBoundsException: Index 130 out of bounds for length 18
    	at Client.parsePacket(Client.java:13764)
    	at Client.mainGameProcessor(Client.java:4105)
    	at Client.processGameLoop(Client.java:3483)
    	at ClientEngine.run(ClientEngine.java:246)
    	at Client.run(Client.java:5993)
    	at java.base/java.lang.Thread.run(Thread.java:834)
    Reply With Quote  
     

  8. #8  
    Registered Member

    Join Date
    Feb 2010
    Posts
    3,187
    Thanks given
    1,124
    Thanks received
    834
    Discord
    View profile
    Rep Power
    1514
    Quote Originally Posted by CrazzMC View Post
    No luck from the dynamic buffer, but I don't think it hurt (as of right now).


    Player Updating:
    Code:
    	private final PlayerUpdateFlags[] pFlags;
    
    	public SendPlayerUpdate(PlayerUpdateFlags[] pFlags) {
    		super();
    		this.pFlags = pFlags;
    	}
    
    	@Override
    	public void execute(Client client) {
    		PlayerUpdating.update(client.getPlayer(), pFlags);
    	}
    
    	@Override
    	public int getOpcode() {
    		return 81;
    	}
    PlayerUpdating.update(client.getPlayer(), pFlags) method
    Code:
    	public static void update(Player player, PlayerUpdateFlags[] pFlags) {
    
    		StreamBuffer.OutBuffer out = StreamBuffer.newOutBuffer(12228);
    		StreamBuffer.OutBuffer block = StreamBuffer.newOutBuffer(8192);
    
    		out.writeVariableShortPacketHeader(player.getClient().getEncryptor(), 81);
    		out.setAccessType(StreamBuffer.AccessType.BIT_ACCESS);
    
    		PlayerUpdateFlags local = pFlags[player.getIndex()];
    
    		updateLocalPlayerMovement(local, out);
    		if (local.isUpdateRequired()) {
    			updateState(local, block, false, true);
    		}
    
    		out.writeBits(8, player.getPlayers().size());
    		for (Iterator<Player> i = player.getPlayers().iterator(); i.hasNext();) {
    			PlayerUpdateFlags flags = pFlags[i.next().getIndex()];
    
    			if ((flags != null) && (flags.getLocation().isViewableFrom(local.getLocation())) && (flags.isActive()) && (!flags.isPlacement()) && (flags.isVisible())) {
    				updateOtherPlayerMovement(flags, out);
    				if (flags.isUpdateRequired())
    					updateState(flags, block, false, player.getPrivateMessaging().ignored(flags.getUsername()));
    			} else {
    				out.writeBit(true);
    				out.writeBits(2, 3);
    				i.remove();
    			}
    		}
    
    		int added = 0;
    
    		for (int i = 0; i < World.getPlayers().length; i++) {
    			if ((player.getPlayers().size() >= 255) || (added >= 15)) {
    				break;
    			}
    
    			PlayerUpdateFlags flags = pFlags[i];
    
    			if (flags != null && !flags.getUsername().equals(local.getUsername()) && flags.isActive()) {
    
    				if (flags != null) {
    					if (!doesLocalListContainPlayer(player, flags.getUsernameToLong()) && flags.getLocation().isViewableFrom(player.getLocation())) {
    						player.getPlayers().add(World.getPlayers()[i]);
    						addPlayer(out, local, flags, i);
    						updateState(flags, block, true, player.getPrivateMessaging().ignored(flags.getUsername()));
    						added++;
    					}
    				}
    			}
    		}
    		if (block.getBuffer().writerIndex() > 0) {
    			out.writeBits(11, 2047);
    			out.setAccessType(StreamBuffer.AccessType.BYTE_ACCESS);
    			out.writeBytes(block.getBuffer());
    		} else {
    			out.setAccessType(StreamBuffer.AccessType.BYTE_ACCESS);
    		}
    
    		out.finishVariableShortPacketHeader();
    		player.getClient().send(out.getBuffer());
    	}
    EDIT: T1/2 Errors btw

    Console
    Code:
    About to check packets
    PACKET IS : 241
    packet 241 size reading from -2: 352
    About to check packets
    241 packet size: 352
    PACKET IS : 71
    About to check packets
    Error: T2 - 71,241,73 - 3,1827,3170 - 1,96,2,
    PACKET IS : 4
    About to check packets
    Method 137 check implement 4
    PACKET IS : 0
    About to check packets
    java.lang.ArrayIndexOutOfBoundsException: Index 130 out of bounds for length 18
    	at Client.parsePacket(Client.java:13764)
    	at Client.mainGameProcessor(Client.java:4105)
    	at Client.processGameLoop(Client.java:3483)
    	at ClientEngine.run(ClientEngine.java:246)
    	at Client.run(Client.java:5993)
    	at java.base/java.lang.Thread.run(Thread.java:834)
    cheers I downloaded the source to have a look for u too my god is it massive and a bit of a design mindfield lol

    err I notice writeVariableShortPacketHeader did you try that ?
    Reply With Quote  
     

  9. #9  
    Extreme Donator
    CrazzMC's Avatar
    Join Date
    Sep 2011
    Posts
    41
    Thanks given
    4
    Thanks received
    1
    Discord
    View profile
    Rep Power
    11
    Quote Originally Posted by Fire Cape View Post
    cheers I downloaded the source to have a look for u too my god is it massive and a bit of a design mindfield lol

    err I notice writeVariableShortPacketHeader did you try that ?
    Appreciate all the help! My discord is crazzmc#1439 if thats easier to communicate. Mine isn't too big, but I got it from a friend about a year ago just been working on it overtime where I can.

    And yes I tried both short and non-short versions of the header.
    Reply With Quote  
     

  10. #10  
    Registered Member

    Join Date
    Feb 2010
    Posts
    3,187
    Thanks given
    1,124
    Thanks received
    834
    Discord
    View profile
    Rep Power
    1514
    Quote Originally Posted by CrazzMC View Post
    Appreciate all the help! My discord is crazzmc#1439 if thats easier to communicate. Mine isn't too big, but I got it from a friend about a year ago just been working on it overtime where I can.

    And yes I tried both short and non-short versions of the header.
    I'll try add ya, when are you sending this btw ? You making sure the actual map loads properly first right ?
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 9
    Last Post: 03-23-2016, 01:52 AM
  2. Issues with my sideicons and modicons.
    By Lawless in forum Help
    Replies: 0
    Last Post: 07-24-2014, 06:41 AM
  3. Replies: 37
    Last Post: 03-25-2010, 09:06 PM
  4. Replies: 4
    Last Post: 02-24-2010, 01:03 PM
  5. 521 deob with mapdata and packet logging!!!!
    By Clienthax in forum Downloads
    Replies: 22
    Last Post: 11-21-2008, 03:20 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •