This small tutorial helps stopping client crashes due to missing map data.
Credits:
-Palidino76 for the original methods.
-Me for fixing the crashes.
Step 1. Open up Player.java
Add this import:
Code:
import java.util.LinkedList;
Add these 2 methods:
Code:
public void noMapdata() {
//Missing Map Data fix by Gravediggah
setCoords(3222,3222,0); // Lumbridge
Engine.playerMovement.getNextPlayerMovement(this);
this.frames.setMapRegion(this);
this.frames.sendMessage(this, "Missing map data for your location, your location has been changed to Lumbridge.");
}
public LinkedList<Integer> getRegion() {
//Missing Map Data fix by Gravediggah
LinkedList<Integer> regions = new LinkedList<Integer>();
boolean forceSend = true;
if ((((mapRegionX / 8) == 48) || ((mapRegionX / 8) == 49)) && ((mapRegionY / 8) == 48)) {
forceSend = false;
}
if (((mapRegionX / 8) == 48) && ((mapRegionY / 8) == 148)) {
forceSend = false;
}
for (int xCalc = (mapRegionX - 6) / 8; xCalc <= ((mapRegionX + 6) / 8); xCalc++) {
for (int yCalc = (mapRegionY - 6) / 8; yCalc <= ((mapRegionY + 6) / 8); yCalc++) {
if (forceSend || ((yCalc != 49) && (yCalc != 149) && (yCalc != 147) && (xCalc != 50) && ((xCalc != 49) || (yCalc != 47)))) {
regions.add(yCalc + (xCalc << 1786653352));
}
}
}
return regions;
}
Step 2. Open up MapData.java in palidino76.rs2.world.mapdata
Replace your getData(int myRegion) method with this one:
Code:
public int[] getData(int myRegion) {
//Missing Map Data fix by Gravediggah
for (MapList list : mapLists) {
if (list == null) {
continue;
}
if (list.region == myRegion)
{
return list.data;
}
}
Misc.println("Missing map data: " + myRegion);
return new int[5];
}
Step 3. Open up Frames.java
Add this import:
Code:
import java.util.LinkedList;
Replace your setMapRegion(Player p) method with this one:
Code:
public void setMapRegion(Player p) {
if (p == null || p.stream == null || p.disconnected[0]) {
return;
}
LinkedList<Integer> regions = p.getRegion();
//Missing Map Data fix by Gravediggah
if(regions.size()==0) {
p.noMapdata();
return;
}
for(int region : regions) {
int[] mapData = Engine.mapData.getData(region);
if(mapData.length==5) { // MISSING
p.noMapdata();
return;
}
}
p.stream.createFrameVarSizeWord(142);
p.stream.writeWordA(p.mapRegionX);
p.stream.writeWordBigEndianA(p.currentY);
p.stream.writeWordA(p.currentX);
p.rebuildNPCList = true;
for(int region : regions) {
int[] mapData = Engine.mapData.getData(region);
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();
}