Thread: 377 how to correctly use packet 40?

Results 1 to 9 of 9
  1. #1 377 how to correctly use packet 40? 
    Donator
    Mr Sandman's Avatar
    Join Date
    Oct 2011
    Posts
    657
    Thanks given
    176
    Thanks received
    26
    Rep Power
    38
    So I'm currently making a project in apollo which is a 377 revision, and I plan on learning from this project and then continuing on. So I'm currently making a ground item system, and that to spawn ground items a position event must be used which is packet 75. So every ground item is saved in an array and the problem is you can't keep calling packet 75 to position the ground item if you keep doing this you will create clone of that ground item. So I found out that packet 40 (packet 64 in 317) resets every object/item in an 8x8 region which means it deletes it and places it where it is at. So I setup the encoder just like the packet 75. And I don't know what I'm doing wrong, but when I teleport to the region with the items while calling packet 40 it just logs me off and I get T2 errors. Is there anything that I'm doing wrong with calling packet 40?

    Spoiler for Packet 40:
    Code:
    if (packetOpcode == 40) { // #317 64
    				playerPositionY = inputBuffer.getUnsignedByteS();
    				playerPositionX = inputBuffer.getUnsignedByteC();
    				for (int x = playerPositionX; x < playerPositionX + 8; x++)
    					for (int y = playerPositionY; y < playerPositionY + 8; y++)
    						if (groundItemNodes[plane][x][y] != null) {
    							groundItemNodes[plane][x][y] = null;
    							sortGroundItems(x, y);
    						}
    				for (SceneSpawnNode spawnNode = (SceneSpawnNode) spawnObjectNodeList.getBack(); spawnNode != null; spawnNode = (SceneSpawnNode) spawnObjectNodeList
    						.getPrevious())
    					if (spawnNode.x >= playerPositionX && spawnNode.x < playerPositionX + 8 && spawnNode.y >= playerPositionY
    							&& spawnNode.y < playerPositionY + 8 && spawnNode.plane == plane)
    						spawnNode.anInt1390 = 0;
    				packetOpcode = -1;
    				return true;
    			}
    Reply With Quote  
     

  2. #2  
    Banned
    Join Date
    Jan 2011
    Posts
    334
    Thanks given
    20
    Thanks received
    88
    Rep Power
    0
    A T2 error is thrown when the packet size that you send to the client isn't the same size that's read.

    You need to make sure that you're sending the bytes correctly with the correct packet size (if it's hardcoded).
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Donator
    Mr Sandman's Avatar
    Join Date
    Oct 2011
    Posts
    657
    Thanks given
    176
    Thanks received
    26
    Rep Power
    38
    I'm pretty sure I did assign it correctly I got the correct bytes from a list in this forum. If that is not enough information this is how I setup the encoder

    Code:
    GamePacketBuilder builder = new GamePacketBuilder(40);
    		Position base = event.getBase(), pos = event.getPosition();
    
    		builder.put(DataType.BYTE, pos.getLocalY(base) & 0xFFFF);
    		builder.put(DataType.BYTE, DataTransformation.NEGATE, pos.getLocalX(base));
    Quote Originally Posted by Major View Post
    Packet 40 > ??? - Packet 64 in 317
    Something related to Global Objects... mass spawning or something.
    bigRegionY = inStream.getUByteS();
    bigRegionX = inStream.getNegUByte();
    Reply With Quote  
     

  5. #4  
    Registered Member

    Join Date
    Dec 2015
    Posts
    166
    Thanks given
    77
    Thanks received
    87
    Rep Power
    404
    Quote Originally Posted by Mr Sandman View Post
    Code:
    playerPositionY = inputBuffer.getUnsignedByteS();
    Code:
    builder.put(DataType.BYTE, pos.getLocalY(base) & 0xFFFF);
    reading a subtracted byte, writing a normal byte?

    Code:
    builder.put(DataType.BYTE, DataTransformation.SUBTRACT, pos.getLocalY(base));
    "It's all a matter of perspective. There is no single path in life that is right and fair and does no harm."
    Reply With Quote  
     

  6. #5  
    Donator
    Mr Sandman's Avatar
    Join Date
    Oct 2011
    Posts
    657
    Thanks given
    176
    Thanks received
    26
    Rep Power
    38
    Yes I already have that down. But I don't know how to correctly call it. Idk if you know what packet 40 does, but idk if i should call it before the region update process or after, and then call the ground item packet.
    Reply With Quote  
     

  7. #6  
    Author of the first public OSRSPS

    Shadowy's Avatar
    Join Date
    Sep 2009
    Age
    28
    Posts
    1,499
    Thanks given
    490
    Thanks received
    241
    Rep Power
    307
    Quote Originally Posted by Mr Sandman View Post
    I'm pretty sure I did assign it correctly I got the correct bytes from a list in this forum. If that is not enough information this is how I setup the encoder

    Code:
    GamePacketBuilder builder = new GamePacketBuilder(40);
            Position base = event.getBase(), pos = event.getPosition();
    
            builder.put(DataType.BYTE, pos.getLocalY(base) & 0xFFFF);
            builder.put(DataType.BYTE, DataTransformation.NEGATE, pos.getLocalX(base));
    packet 40 377 deob read methods

    Code:
                    anInt990 = buffer.method542(anInt1236);
                    anInt989 = buffer.method541(-34545);
    Code:
        public int method542(int i) {
            i = 77 / i;
            return 128 - array[position++] & 0xff;
        }
    Code:
        public int method541(int i) {
            if (i != -34545) {
                return anInt1436;
            } else {
                return -array[position++] & 0xff;
            }
        }

    haven't tested myself but pretty sure the first byte you're encoding needs the following transformation:

    Code:
            put(DataType.BYTE, DataOrder.BIG, DataTransformation.ADD, value);
    Owner of OS-RSPS, the first Oldschool RuneScape Server (2014)
    Reply With Quote  
     

  8. #7  
    Donator
    Mr Sandman's Avatar
    Join Date
    Oct 2011
    Posts
    657
    Thanks given
    176
    Thanks received
    26
    Rep Power
    38
    Quote Originally Posted by Shadowy View Post
    packet 40 377 deob read methods

    Code:
                    anInt990 = buffer.method542(anInt1236);
                    anInt989 = buffer.method541(-34545);
    Code:
        public int method542(int i) {
            i = 77 / i;
            return 128 - array[position++] & 0xff;
        }
    Code:
        public int method541(int i) {
            if (i != -34545) {
                return anInt1436;
            } else {
                return -array[position++] & 0xff;
            }
        }

    haven't tested myself but pretty sure the first byte you're encoding needs the following transformation:

    Code:
            put(DataType.BYTE, DataOrder.BIG, DataTransformation.ADD, value);

    Nope T2 errors still. Unless I'm calling the packet wrong. Since I'm using apollo I'm calling it in prePlayersyncrhonization, then in the post player syncro I call the groundItemevent packet
    Reply With Quote  
     

  9. #8  
    Registered Member

    Join Date
    Dec 2015
    Posts
    166
    Thanks given
    77
    Thanks received
    87
    Rep Power
    404
    Quote Originally Posted by Shadowy View Post
    packet 40 377 deob read methods

    Code:
                    anInt990 = buffer.method542(anInt1236);
                    anInt989 = buffer.method541(-34545);
    Code:
        public int method542(int i) {
            i = 77 / i;
            return 128 - array[position++] & 0xff;
        }
    Code:
        public int method541(int i) {
            if (i != -34545) {
                return anInt1436;
            } else {
                return -array[position++] & 0xff;
            }
        }

    haven't tested myself but pretty sure the first byte you're encoding needs the following transformation:

    Code:
            put(DataType.BYTE, DataOrder.BIG, DataTransformation.ADD, value);
    Subtracted, not added

    Quote Originally Posted by Mr Sandman View Post
    Nope T2 errors still. Unless I'm calling the packet wrong. Since I'm using apollo I'm calling it in prePlayersyncrhonization, then in the post player syncro I call the groundItemevent packet
    Then the next logical step would be sending it outside of player synchronization. You should actually send it on completion of region change btw. The client sends a packet when region change has completed. Keep in mind that you must validate the packet and ensure a region change had actually occurred
    "It's all a matter of perspective. There is no single path in life that is right and fair and does no harm."
    Reply With Quote  
     

  10. #9  
    Registered Member
    Join Date
    May 2016
    Posts
    35
    Thanks given
    9
    Thanks received
    2
    Rep Power
    11
    Quote Originally Posted by Whis View Post
    Then the next logical step would be sending it outside of player synchronization. You should actually send it on completion of region change btw. The client sends a packet when region change has completed. Keep in mind that you must validate the packet and ensure a region change had actually occurred
    you can do this by flagging a boolean when you send data for the load region packet (packet 73), then verifying if the boolean is flagged when the client responds with the region changed packet (packet 210)
    Reply With Quote  
     


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: 7
    Last Post: 01-07-2012, 04:29 AM
  2. How, to Correct Compilers,!!(Noob)
    By d34tht1ck3t in forum Tutorials
    Replies: 0
    Last Post: 04-14-2008, 09:04 AM
  3. [TUT]How to correctly set your variables[TUT]
    By Galkon in forum Tutorials
    Replies: 16
    Last Post: 03-27-2008, 07:06 PM
  4. How to Correctly add the GodSwords
    By Moparscape Vet in forum Tutorials
    Replies: 4
    Last Post: 12-12-2007, 04:17 AM
  5. How to Correctly add the GodSwords
    By Moparscape Vet in forum Tutorials
    Replies: 2
    Last Post: 12-11-2007, 11:14 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •