Thread: [508] Fixing Missing Map Data / Reading Packed Data Files

Results 1 to 10 of 10
  1. #1 [508] Fixing Missing Map Data / Reading Packed Data Files 
    Registered Member
    Join Date
    Dec 2010
    Posts
    67
    Thanks given
    0
    Thanks received
    1
    Rep Power
    1
    Hey guys, gals and others.

    Today I'm going to be showing how to change your Frames.java and MapData.java to read the packed data files. This is if you are still loading your mapdata from Text files.

    I have tested this out on a Bulby Source. So you should be able to transfer it to Pali quite easily ("I actually got this from a Pali Source, so i assume most Pali's should have this. If not then you will have it after this tutorial.") and the other sources I'm sure you can figure it out.

    Now to the important parts.

    Difficulty: 1.5 / 10
    Assumed Knowledge: Converting from Bulby, to your Source.

    First: Changing your MapData.java to load ".dat" files

    So open your MapData.java and replace it completely with this:
    Code:
    package Bulby.world.mapdata;
    
    import java.io.DataInputStream;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.util.HashMap;
    import Bulby.util.*;
    
    
    public class MapData {
    	
        private static HashMap<Integer, int[]> mapRegions;
        private static int mapId;
    
    	public int mapData[] = new int[4];
    
    	public int[] getMapData(int region) {
    		return mapRegions.get(region);
    	}
    
        public void loadRegions() {
    		try {
                DataInputStream in = new DataInputStream(new FileInputStream("./data/mapdata/1.dat"));  
    			do {
    				int i = in.readInt();
    				
    				if(i == 0) {
    					break;
    				} else
    				   
    					if(i != 0) {
    						mapId = in.readInt();
    						for(int data = 0; data < 4; data++) {
    							mapData[data] = in.readInt();
    						}
    					}
    					mapRegions.put(mapId, new int[]{ mapData[0], mapData[1], mapData[2], mapData[3]});
    			} while(true);
    		} catch(IOException ioe) {
    			ioe.printStackTrace(); 
    		}
    	}
    
    	static {
    		mapId = 0;
    		mapRegions = new HashMap<Integer, int[]>();
    	}
    
    }
    Next you are going to want to change all the imports, certain other variables that your source might not have or use etc.

    Second: We will now change one Method in your Frames.java file

    So open up your Frames.java file and searh for:
    Code:
    public void setMapRegion(Player p) {
    OR

    Code:
    setMapRegion
    Then completely replace the current method you have with this:
    Code:
    /**
         * Send the map region and other positioning info to the client.
         * @param p The Player which the frame should be created for.
         */
        public void setMapRegion(Player p) {
            if (p == null || p.stream == null || p.disconnected[0]) {
                return;
            }
            p.stream.createFrameVarSizeWord(142);
            p.stream.writeWordA(p.mapRegionX);
            p.stream.writeWordBigEndianA(p.currentY);
            p.stream.writeWordA(p.currentX);
            boolean forceSend = true;
            if ((((p.mapRegionX / 8) == 48) || ((p.mapRegionX / 8) == 49)) && ((p.mapRegionY / 8) == 48)) {
                forceSend = false;
            }
            if (((p.mapRegionX / 8) == 48) && ((p.mapRegionY / 8) == 148)) {
                forceSend = false;
            }
            for (int xCalc = (p.mapRegionX - 6) / 8; xCalc <= ((p.mapRegionX + 6) / 8); xCalc++) {
                for (int yCalc = (p.mapRegionY - 6) / 8; yCalc <= ((p.mapRegionY + 6) / 8); yCalc++) {
           	int region = yCalc + (xCalc << 1786653352);
                    	if (forceSend || ((yCalc != 49) && (yCalc != 149) && (yCalc != 147) && (xCalc != 50) && ((xCalc != 49) || (yCalc != 47)))) {
                        	int[] mapData = Engine.mapData.getMapData(region);
    					if (mapData == null) {
    						p.setCoords(2827, 3344, 0);
    						sendMessage(p, "You got teleported home due to Mapdata missing.");
    						return;
    					}
                        p.stream.writeDWord(mapData[0]);
                        p.stream.writeDWord(mapData[1]);
                        p.stream.writeDWord(mapData[2]);
                        p.stream.writeDWord(mapData[3]);
                    }
                }
            }
            p.stream.writeByteC(p.heightLevel);
            p.stream.writeWord(p.mapRegionY);
            p.stream.endFrameVarSizeWord();
        }
    Now you may need to change the way your files are read, for example some servers have getByteVector() instead of stream. In the above method you will also need to change the coords to where your home location is.

    Third: Download this ".dat" file so you can use your new Map Data loading way.

    Make sure you copy that into your Server Folder -> bin -> data -> mapdata

    Thanks for reading.

    Now Compile, Run, and Play.

    Hopefully you guys don't get any errors. Just post them if you do. I'm sure I can give you a hand or someone else might.

    Enjoy!
    Rune Fusion a 508 Runescape private server.

    MSN: [email protected] - If you need help/ wana talk

    Reply With Quote  
     

  2. #2  
    Registered Member
    Dark Regen's Avatar
    Join Date
    Jan 2009
    Posts
    678
    Thanks given
    184
    Thanks received
    22
    Rep Power
    185
    It doesn't fix it, it teleports you away, and i think this has been released..
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Dec 2010
    Posts
    67
    Thanks given
    0
    Thanks received
    1
    Rep Power
    1
    Quote Originally Posted by owner pkin View Post
    Gravediggah released this, didnt even gave credits to him
    Where does it say he released it, he doesnt mark his work very well - and i said above that i got this from a server source.

    Its just for people to reference back to if they are still using .txt files for loading their mapdata...
    Rune Fusion a 508 Runescape private server.

    MSN: [email protected] - If you need help/ wana talk

    Reply With Quote  
     

  4. #4  
    Extreme Donator


    Join Date
    Jul 2009
    Age
    27
    Posts
    4,351
    Thanks given
    826
    Thanks received
    1,239
    Rep Power
    1781
    Quote Originally Posted by owner pkin View Post
    gravediggah made it you new-fag,

    http://www.rune-server.org/runescape...-crashing.html

    + this shit is right ripped out of bulby
    You know, Leanbow was trying to make it so the server would push the XTEA's, you could delete the object's in the containing area, and I am pretty sure it would work.

    You can find my GitHub here, for what I'm currently working on.
    Reply With Quote  
     

  5. #5  
    Banned

    Join Date
    Jan 2009
    Age
    31
    Posts
    2,661
    Thanks given
    66
    Thanks received
    207
    Rep Power
    0
    Send 0,0,0,0 as the values and you can go to any map.

    you may need to make a modification to the client though idk i have no problems on a 474 walking on only landscapes.
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Dec 2010
    Posts
    67
    Thanks given
    0
    Thanks received
    1
    Rep Power
    1
    Quote Originally Posted by owner pkin View Post
    YEAH MAN CONVERTING IMPORTS AND SENDMESSAGE'S ARE REALLY HARD !!!!!!!!!
    I didn't say it was hard?

    Quote Originally Posted by GloryScape View Post
    bulby is for new comers. Who even uses bulby 'o.O
    Yeah who even uses bulby exactly. thats why i thought i would show this to people as there arnt many tuts on it.
    Rune Fusion a 508 Runescape private server.

    MSN: [email protected] - If you need help/ wana talk

    Reply With Quote  
     

  7. #7  
    Registered Member

    Join Date
    Feb 2010
    Posts
    715
    Thanks given
    133
    Thanks received
    378
    Rep Power
    550
    Quote Originally Posted by digistr View Post
    Send 0,0,0,0 as the values and you can go to any map.

    you may need to make a modification to the client though idk i have no problems on a 474 walking on only landscapes.
    Yes that will need some client modifications a 0 0 0 0 means the file isn't encrypted, sending 0 0 0 0 will just make it read the file, most likely ending up with a huge size, reading a invalid size number will most likely give you the out of memory exceptions most people are getting because it's making a array of that size to read the file
    Brown released a snippet which checks for a 'to big size' and just return a empty file (array) which results in just loading the landscape
    Reply With Quote  
     

  8. #8  
    Registered Member
    Join Date
    Dec 2010
    Posts
    67
    Thanks given
    0
    Thanks received
    1
    Rep Power
    1
    Quote Originally Posted by digistr View Post
    Send 0,0,0,0 as the values and you can go to any map.

    you may need to make a modification to the client though idk i have no problems on a 474 walking on only landscapes.
    Wow thats neat, I might have to try that latter on. Would be good fun messing around with it.

    Quote Originally Posted by Vincent View Post
    Yes that will need some client modifications a 0 0 0 0 means the file isn't encrypted, sending 0 0 0 0 will just make it read the file, most likely ending up with a huge size, reading a invalid size number will most likely give you the out of memory exceptions most people are getting because it's making a array of that size to read the file
    Brown released a snippet which checks for a 'to big size' and just return a empty file (array) which results in just loading the landscape
    Hmm maybe I wont be testing it out any time soon, im not too great with client moding. Lol
    Rune Fusion a 508 Runescape private server.

    MSN: [email protected] - If you need help/ wana talk

    Reply With Quote  
     

  9. #9  
    Registered Member
    Join Date
    Dec 2009
    Posts
    78
    Thanks given
    28
    Thanks received
    1
    Rep Power
    4
    The client edit he's talking about is the one in the method that returns a container, currently it will throw an exception if it was null/size wasn't correct, make it return an empty buffer of bytes instead.
    Reply With Quote  
     

  10. #10  
    Community Veteran



    Join Date
    Jan 2008
    Posts
    3,444
    Thanks given
    46
    Thanks received
    973
    Rep Power
    4748
    Quote Originally Posted by Senqi View Post
    The client edit he's talking about is the one in the method that returns a container, currently it will throw an exception if it was null/size wasn't correct, make it return an empty buffer of bytes instead.
    the method is the decompressor method

    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: 1
    Last Post: 11-07-2010, 04:41 AM
  2. data.dat what am i missing?
    By Help in forum Help
    Replies: 4
    Last Post: 11-06-2010, 06:01 PM
  3. Reading data into a HashMap?
    By Benjamin in forum Help
    Replies: 4
    Last Post: 12-22-2009, 01:19 PM
  4. [508] Fix Missing Map Data Crashing
    By Gravediggah in forum Snippets
    Replies: 11
    Last Post: 09-24-2009, 12:06 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
  •