Пакет ServerList (authserver, server to client) неверное кол-во персонажей

Glafferax

Путник
Местный
Сообщения
19
Розыгрыши
0
Репутация
0
Реакции
12
Баллы
0
Хроники
  1. Grand Cursade
Исходники
Присутствуют
Сборка
Солянка
Доброго времени.

Ситуация: на аккаунте 3 персонажа, на экране выбора сервера показывается 1, иногда другие числа, но не 3 уж точно.
Судя по логам отправляется число 3, но видимо структура данных не верная.

Gaikotsu, не могли бы вы подсказать, если знаете ?

Java:
public final class ServerList extends L2LoginServerPacket
{
    private static final Logger _log = LoggerFactory.getLogger(ServerList.class);
    private List<ServerData> _servers = new ArrayList<ServerData>();
    private int _lastServer;
    private int _paddedBytes;

    private static class ServerData
    {
        int serverId;
        InetAddress ip;
        int port;
        int online;
        int maxPlayers;
        boolean status;
        boolean pvp;
        boolean brackets;
        int type;
        int ageLimit;
        int playerSize;
        int[] deleteChars;

        ServerData(int serverId, InetAddress ip, int port, boolean pvp, boolean brackets, int type, int online, int maxPlayers, boolean status, int ageLimit, int playerSize,  int[] deleteChars)
        {
            this.serverId = serverId;
            this.ip = ip;
            this.port = port;
            this.pvp = pvp;
            this.brackets = brackets;
            this.type = type;
            this.online = online;
            this.maxPlayers = maxPlayers;
            this.status = status;
            this.ageLimit = ageLimit;
            this.playerSize = playerSize;
            this.deleteChars = deleteChars;
        }
    }

    public ServerList(Account account)
    {
        _lastServer = account.getLastServer();
        _paddedBytes = 1;

        for(GameServer gs : GameServerManager.getInstance().getGameServers())
        {
            for(HostInfo host : gs.getHosts())
            {
                InetAddress ip;
                try
                {
                    String ipStr = null;
                    if(NetUtils.isInternalIP(account.getLastIP()))
                        ipStr = host.getInnerIP();
                    if(ipStr == null)
                        ipStr = host.getIP();
                    if(ipStr == null)
                        continue;
                    if(ipStr.equals("*"))
                        ipStr = gs.getConnection().getIpAddress();

                    ip = InetAddress.getByName(ipStr);
                }
                catch(UnknownHostException e)
                {
                    continue;
                }

                Pair<Integer, int[]> entry = account.getAccountInfo(host.getId());

                _paddedBytes += (3 + (4 * (entry == null ? 0 : entry.getValue().length)));

                _servers.add(new ServerData(
                        host.getId(),
                        ip, host.getPort(),
                        gs.isPvp(),
                        gs.isShowingBrackets(),
                        gs.getServerType(),
                        gs.getOnline(),
                        gs.getMaxPlayers(),
                        gs.isOnline(),
                        gs.getAgeLimit(),

                        entry == null ? 0 : entry.getKey(),
                        entry == null ? ArrayUtils.EMPTY_INT_ARRAY : entry.getValue())
                );
            }
        }
    }

    @Override
    protected void writeImpl()
    {
        writeC(0x04);
        writeC(_servers.size());
        writeC(_lastServer);

        _log.info("as to client header: " + (byte) 0x04);
        _log.info("as to client server size: " + _servers.size());
        _log.info("as to client server size b: " + (byte) _servers.size());
        _log.info("as to client lastServer: " + _lastServer);
        _log.info("as to client lastServer b: " + (byte) _lastServer);

        for(ServerData server : _servers)
        {
            writeC(server.serverId);
            InetAddress i4 = server.ip;

            byte[] raw = i4.getAddress();
            writeC(raw[0] & 0xff);
            writeC(raw[1] & 0xff);
            writeC(raw[2] & 0xff);
            writeC(raw[3] & 0xff);
            writeD(server.port);
            writeC(server.ageLimit); // age limit
            writeC(server.pvp ? 0x01 : 0x00);
            writeH(0);
            writeH(server.maxPlayers);
            writeC(server.status ? 0x01 : 0x00);
            writeD(server.type);
            writeC(server.brackets ? 0x01 : 0x00);
        }

        writeH(_paddedBytes);
        writeC(_servers.size());
        for(ServerData server : _servers)
        {
            _log.info("to client playerSize: " + server.playerSize);
            _log.info("to client serverId: " + server.serverId);

            writeC(server.serverId);
            writeC(server.playerSize); // acc player size
            writeC(server.deleteChars.length);
            for(int t : server.deleteChars)
                writeD((int)(t - System.currentTimeMillis() / 1000L));
        }
    }
}
 
Java:
    @Override
    protected void writeImpl()
    {
        writeC(0x04);
        writeC(_servers.size());
        writeC(_lastServer);

        for (ServerData server : _servers)
        {
            writeC(server.serverId);
            InetAddress i4 = server.ip;
            byte[] raw = i4.getAddress();
            writeC(raw[0] & 0xff);
            writeC(raw[1] & 0xff);
            writeC(raw[2] & 0xff);
            writeC(raw[3] & 0xff);
            writeD(server.port);
            writeC(server.ageLimit); // age limit
            writeC(server.pvp ? 0x01 : 0x00);
            writeH(server.online);
            writeH(server.maxPlayers);
            writeC(server.status ? 0x01 : 0x00);
            writeD(server.type);
            writeC(server.brackets ? 0x01 : 0x00);
        }

        writeH(0xA4); // ?

        for (ServerData server : _servers)
        {
            writeC(server.serverId);
            writeC(server.playerSize); // acc player size
        }
    }
 
Назад
Сверху Снизу