↑ ↓

Сборка Erthey + геодата от L2scripts 14244

с привязкой

  1. Matey
    package test;

    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io_OutputStream;
    import java.io.RandomAccessFile;
    import java.nio.ByteBuffer;
    import java.nio.ByteOrder;
    import java.nio.channels.Channels;
    import java.nio.channels.FileChannel;
    import java.nio.channels.WritableByteChannel;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;




    public class ConvertGeo
    {
    public static void main(String arg[]) throws IOException
    {
    convertGeo();
    }
    public static void convertGeo() throws IOException
    {
    File f = new File("C:/", "geodata");
    if (!f.exists() || !f.isDirectory())
    {
    System.out.println("GeoEngine: Files missing, loading aborted.");
    return;
    }
    int counter = 0;
    Pattern p = Pattern.compile("(\\d{2}_\\d{2})\\.l2s");
    for (File q : f.listFiles())
    {
    if (q.isDirectory())
    {
    continue;
    }
    String fn = q.getName();
    Matcher m = p.matcher(fn);
    if (m.matches())
    {
    fn = fn.substring(0, 5);
    String[] xy = fn.split("_");
    byte rx = Byte.parseByte(xy[0]);
    byte ry = Byte.parseByte(xy[1]);
    loadgeo(rx, ry);
    counter++;
    }
    }
    System.out.println("GeoEngine: Loaded " + counter + " map(s)");

    }


    public static void loadgeo(int x, int y) throws IOException
    {
    String fname = "geodata/" + x + "_" + y + ".l2s";
    File geoFile = new File("C:/", fname);
    try
    {
    @SuppressWarnings("resource")
    FileChannel roChannel = new RandomAccessFile(geoFile, "r").getChannel();
    int size = (int)roChannel.size() - 4;
    ByteBuffer buf = ByteBuffer.allocate(size);
    buf.limit(4);
    byte[] addrBytes = "195.211.223.110".trim().getBytes();
    int checkSum = -2126429781;
    for (int addrByteIdx = 0; addrByteIdx < addrBytes.length; addrByteIdx++)
    {
    checkSum ^= addrBytes[addrByteIdx];
    checkSum = checkSum >>> 1 | checkSum << 31;
    }

    buf.order(ByteOrder.LITTLE_ENDIAN);
    roChannel.read(buf);

    buf.rewind();
    checkSum ^= buf.getInt();

    byte xorByte = (byte)(checkSum >> 24 & 0xFF ^ checkSum >> 16 & 0xFF ^ checkSum >> 8 & 0xFF ^ checkSum >> 0 & 0xFF);

    buf.clear();
    roChannel.read(buf);
    buf.rewind();
    while (buf.hasRemaining())
    {
    buf.put(buf.position(), (byte)(buf.get() ^ xorByte));
    checkSum -= (xorByte = buf.get(buf.position() - 1));
    }
    buf.rewind();
    if (checkSum != 0)
    {
    System.out.println("Invalid geodata!");
    }
    OutputStream outputStream = new FileOutputStream("C:/geoconv/" + x + "_" + y + ".l2j");
    writeBuffer(buf, outputStream);
    outputStream.close();
    }
    catch (IOException e)
    {
    System.out.println(e);
    }
    }
    public static void writeBuffer(ByteBuffer buffer, OutputStream stream) throws IOException
    {
    WritableByteChannel channel = Channels.newChannel(stream);

    channel.write(buffer);
    }
    }

Пoследние рецензии

  1. ProjectFelicity
    ProjectFelicity
    5/5,
    Версия: 14244
    Holy Pussy!

    Thank you !
  2. ladderti
    ladderti
    4/5,
    Версия: 14244
    норм