Thread: Create map region packet.

Results 1 to 9 of 9
  1. #1 Create map region packet. 
    kierandevvs
    Guest
    Ok so I'm messing around with the packet to see if I can get it to work but there's not a whole lot of documentation on this.
    Ive used grahams Palette class to store the regions that i can loop through later but I'm unsure as to how to actually use it.


    To my understanding, setTile gets a region from the specified PaletteTile and dumps it into the index of the loop.
    e.g if I used lumbridge as my region to dump and I used setTile(7, 7, 0, Lummy) this would set the middle region in relation to the player as lummy.

    If this is correct, do I use region coords within PaletteTile, e.g setTile(7, 7, 0, new PaletteTile(400, 400, 0))
    or a coordinate from the region, e.g e.g setTile(7, 7, 0, new PaletteTile(3333, 3333, 0))
    And if I have to specify a tile coord within the region, does it have to be the first tile within the region or can the offset be any as long as its within the region.

    Right now I've tried both methods, the client receives the data but nothing seems to happen visually. I cant tell if its me using the packet wrong or if its something to do with my client sided region copy method.




    Thanks.
    Reply With Quote  
     

  2. #2  
    Registered Member Lil Peep's Avatar
    Join Date
    Oct 2012
    Posts
    881
    Thanks given
    234
    Thanks received
    58
    Rep Power
    0
    Quote Originally Posted by kierandevvs View Post
    Ok so I'm messing around with the packet to see if I can get it to work but there's not a whole lot of documentation on this.
    Ive used grahams Palette class to store the regions that i can loop through later but I'm unsure as to how to actually use it.


    To my understanding, setTile gets a region from the specified PaletteTile and dumps it into the index of the loop.
    e.g if I used lumbridge as my region to dump and I used setTile(7, 7, 0, Lummy) this would set the middle region in relation to the player as lummy.

    If this is correct, do I use region coords within PaletteTile, e.g setTile(7, 7, 0, new PaletteTile(400, 400, 0))
    or a coordinate from the region, e.g e.g setTile(7, 7, 0, new PaletteTile(3333, 3333, 0))
    And if I have to specify a tile coord within the region, does it have to be the first tile within the region or can the offset be any as long as its within the region.

    Right now I've tried both methods, the client receives the data but nothing seems to happen visually. I cant tell if its me using the packet wrong or if its something to do with my client sided region copy method.




    Thanks.
    Can't shed much light on this but it's for regions, so I assume you won't use your absolute x/y coordinates. It would be x / 64 and y / 64 to create a new region I think.

    In theory if 3333, 3333 were lumbridge coordinates then 52, 52 would be the actual region coordinates

    If that doesn't help you should pm thing1, he has his working and has decent knowledge with it.
    Attached image Attached image Attached image Attached image Attached image
    Reply With Quote  
     

  3. #3  
    Ex Rune-Scaper

    Join Date
    Jun 2008
    Posts
    3,534
    Thanks given
    457
    Thanks received
    1,257
    Rep Power
    990
    Quote Originally Posted by kierandevvs View Post
    Ok so I'm messing around with the packet to see if I can get it to work but there's not a whole lot of documentation on this.
    Ive used grahams Palette class to store the regions that i can loop through later but I'm unsure as to how to actually use it.


    To my understanding, setTile gets a region from the specified PaletteTile and dumps it into the index of the loop.
    e.g if I used lumbridge as my region to dump and I used setTile(7, 7, 0, Lummy) this would set the middle region in relation to the player as lummy.

    If this is correct, do I use region coords within PaletteTile, e.g setTile(7, 7, 0, new PaletteTile(400, 400, 0))
    or a coordinate from the region, e.g e.g setTile(7, 7, 0, new PaletteTile(3333, 3333, 0))
    And if I have to specify a tile coord within the region, does it have to be the first tile within the region or can the offset be any as long as its within the region.

    Right now I've tried both methods, the client receives the data but nothing seems to happen visually. I cant tell if its me using the packet wrong or if its something to do with my client sided region copy method.




    Thanks.
    for a 317, here's the packet refactored
    Code:
    				if (opcode == 241) {
    					int regionCount = 0;
    					int[] regionIds = new int[676];
    					for (int z = 0; z < 4; z++) {
    						for (int x = 0; x < 13; x++) {
    							for (int y = 0; y < 13; y++) {
    								int data = localRegions[z][x][y];
    
    								if (data != -1) {
    									int constructedRegionX = data >> 14 & 0x3ff;
    									int constructedRegionY = data >> 3 & 0x7ff;
    									int region = (constructedRegionX / 8 << 8)
    											+ constructedRegionY / 8;
    
    									for (int index = 0; index < regionCount; index++) {
    										if (regionIds[index] != region) {
    											continue;
    										}
    										region = -1;
    										break;
    									}
    
    									if (region != -1) {
    										regionIds[regionCount++] = region;
    									}
    								}
    							}
    						}
    					}
    
    					localRegionMapData = new byte[regionCount][];
    					localRegionLandscapeData = new byte[regionCount][];
    					localRegionIds = new int[regionCount];
    					localRegionMapIds = new int[regionCount];
    					localRegionLandscapeIds = new int[regionCount];
    
    					for (int index = 0; index < regionCount; index++) {
    						int id = localRegionIds[index] = regionIds[index];
    						int constructedRegionX = id >> 8 & 0xff;
    						int constructedRegionY = id & 0xff;
    						int map = localRegionMapIds[index] = provider
    								.resolve(constructedRegionX, constructedRegionY, 0);
    
    						if (map != -1) {
    							provider.provide(3, map);
    						}
    
    						int landscape = localRegionLandscapeIds[index] = provider
    								.resolve(constructedRegionX, constructedRegionY, 1);
    						if (landscape != -1) {
    							provider.provide(3, landscape);
    						}
    					}
    				}
    Attached image
    Reply With Quote  
     

  4. #4  
    :doge:

    Join Date
    Jan 2009
    Posts
    3,758
    Thanks given
    221
    Thanks received
    817
    Rep Power
    2116
    for #83

    Code:
     public ActionSender sendDynamicRegion(DynamicTileBuilder builder) {
            player.setLastKnownRegion(player.getLocation());
            PacketBuilder pb = new PacketBuilder(117, Type.VARIABLE_SHORT);
    
            pb.startBitAccess();
    
            DynamicTile[][][] tiles = builder.getTiles();
            for (int z = 0; z < tiles.length; z++) {
                for (int x = 0; x < tiles[z].length; x++) {
                    for (int y = 0; y < tiles[z][x].length; y++) {
    
                        DynamicTile tile = tiles[z][x][y];
    
                        if (tile == null) {
                            pb.putBits(1, 0);
                            continue;
                        }
    
                        pb.putBits(1, 1);
                        pb.putBits(26, tile.bitpacked());
                    }
                }
            }
            pb.finishBitAccess();
    
            int[] regions = new int[DynamicTileBuilder.HEIGHT_MAP_SIZE * DynamicTileBuilder.PALETTE_SIZE * DynamicTileBuilder.PALETTE_SIZE];
            int encodedAmount = 0;
            for (int z = 0; z < tiles.length; z++) {
                for (int x = 0; x < tiles[z].length; x++) {
                    for (int y = 0; y < tiles[z][x].length; y++) {
                        DynamicTile tile = tiles[z][x][y];
    
                        if (tile != null) {
                            int hash = tile.bitpacked();
    
                            final int rx = (hash >> 14) & 0x3ff;
                            final int ry = (hash >> 3) & 0x7ff;
    
                            int region = ((rx >> 3) << 8) + (ry >> 3);
    
                            for (int i = 0; i < encodedAmount; i++) {
                                if (regions[i] == region) {
                                    region = -1;
                                    break;
                                }
                            }
    
                            if (region != -1) {
                                for (int key : tile.getXTEA()) {
                                    pb.putInt1(key);
                                }
                                regions[encodedAmount++] = region;
                            }
                        }
                    }
                }
            }
            pb.putShortA(player.getLocation().getLocalX());
            pb.put((byte) player.getLocation().getZ());
            pb.putShortA(player.getLocation().getRegionX());
            pb.putShortA(player.getLocation().getLocalY());
            pb.putShort(player.getLocation().getRegionY());
            player.getSession().write(pb.toPacket());
            return this;
        }
    and for DynamicTile#bitpacked
    Code:
      public final int bitpacked() {
            return rotation << 1 | z << 24 | x << 14 | y << 3;
        }
    rip indentation
    Reply With Quote  
     

  5. #5  
    kierandevvs
    Guest
    Well the packet has nothing wrong with it, either the landscape and object methods for loading new regions is broken or I'm sending wrong data to the packet.
    Could anyone clarify on how to actually use it? The only example I've seen is the construction post that loads the data from a file that's is not provided in the thread thus I dont know what data to provide.
    https://www.rune-server.org/runescap...on-packet.html
    Reply With Quote  
     

  6. #6  
    Donator
    clrlslwi's Avatar
    Join Date
    Mar 2016
    Posts
    201
    Thanks given
    32
    Thanks received
    110
    Rep Power
    102
    Quote Originally Posted by kierandevvs View Post
    Right now I've tried both methods, the client receives the data but nothing seems to happen visually.
    It sounds like you haven't removed the check to stop the loading of an already loaded region. You should have something like

    Code:
    if (loadedRegionX == regionX && loadedRegionY == regionY && sceneLoadState == 2) {
    	packetOpcode = -1;
    	return true;
    }
    in your packet handler. Comment it out/remove it, or send a different region.

    If that's not the case, you're going to need to post more code so I can look through it (i.e. the whole packet handler, the packet sending, etc.)
    Reply With Quote  
     

  7. #7  
    kierandevvs
    Guest
    Quote Originally Posted by clrlslwi View Post
    It sounds like you haven't removed the check to stop the loading of an already loaded region. You should have something like

    Code:
    if (loadedRegionX == regionX && loadedRegionY == regionY && sceneLoadState == 2) {
    	packetOpcode = -1;
    	return true;
    }
    in your packet handler. Comment it out/remove it, or send a different region.

    If that's not the case, you're going to need to post more code so I can look through it (i.e. the whole packet handler, the packet sending, etc.)

    I managed to figure it out, thanks for the help guys
    Reply With Quote  
     

  8. #8  
    Registered Member
    Stanaveli's Avatar
    Join Date
    Aug 2014
    Posts
    1,490
    Thanks given
    184
    Thanks received
    653
    Rep Power
    1338
    Quote Originally Posted by kierandevvs View Post
    I managed to figure it out, thanks for the help guys
    Mind explaining what u did in order to get it fixed?
    Keep your head up.



    Reply With Quote  
     

  9. #9  
    kierandevvs
    Guest
    Quote Originally Posted by Stanaveli View Post
    Mind explaining what u did in order to get it fixed?
    My object method and landscape method for copying the data and rendering them were bad on the client.
    I think the previous owners of the client tried adding a new object data structure and never fixed the methods because the map region packet is never used.
    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. Construct map region packet aka 'secondary map region packet'
    By Graham in forum Informative Threads
    Replies: 95
    Last Post: 06-22-2015, 12:19 PM
  2. Replies: 7
    Last Post: 06-12-2014, 08:57 AM
  3. Real construct map region packet (rs2hd)
    By Graham in forum Tutorials
    Replies: 73
    Last Post: 10-10-2009, 06:10 AM
  4. Map Region packet structure..
    By popbob in forum Help
    Replies: 4
    Last Post: 06-24-2009, 01:13 PM
  5. 550 Map Region Packet?
    By IDX in forum RS 503+ Client & Server
    Replies: 3
    Last Post: 06-19-2009, 07:56 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
  •