Mk124 managed it to let the MapAndreas Heightmap work with Shoebill.
You need the following class:
http://pastebin.com/i9JW5Kt6
You need to put the SAfull.hmap into the data folder of your gamemode / plugin.
To use it you need to create a new instance of the MapAndreas class.
Like this:
Код:
MapAndreas mapAndreas = new MapAndreas(new File(getDataDir(), "SAfull.hmap"));
To use it you can do things like that:
Код:
float z = mapAndreas.findZ(player.getLocation().x, player.getLocation().y);
When you finished your work with MapAndreas you can destroy the instance with:
Shoebill won't load the File into memory, so shoebill is not taking more memory then usual!
It was really important to us, because the SA-MP Plugin takes 80mb.
Besides the low memory usage, Shoebill is 4~ times faster in finding the Z then PAWN.
Speedtests:
Java:
Result: 190ms
Код:
MapAndreas mapAndreas = new MapAndreas(new File(LvdmGamemode.getInstance().getDataDir(), "SAfull.hmap"));
long milli = System.currentTimeMillis();
for(int i = 0; i < 10000000; i++) {
mapAndreas.findZ(i%3000, i/3000);
}
player.sendMessage(Color.RED, "* Ms: " + (System.currentTimeMillis() - milli));
Pawn:
Result: 1004ms
Код:
new Float:z;
new tick = GetTickCount();
for(new i = 0; i < 10000000; i++) {
MapAndreas_FindZ_For2DCoord(i%3000, i/3000,z);
}
printf("Difference: %i ms", GetTickCount() - tick);