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 [Only registered and activated users can see links. ] ".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!
[Only registered and activated users can see links. ] a 508 Runescape private server.
MSN: [Only registered and activated users can see links. ] - If you need help/ wana talk
[Only registered and activated users can see links. ]
+ 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 [Only registered and activated users can see links. ], for what I'm currently working on.
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
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.
Originally Posted by Vincent
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
[Only registered and activated users can see links. ] a 508 Runescape private server.
MSN: [Only registered and activated users can see links. ] - If you need help/ wana talk
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 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.