public static final void CharlistRequest(LittleEndianAccessor slea, MapleClient c) { if (!c.isLoggedIn()) { c.getSession().close(true); return; } if (GameConstants.GMS) { slea.readByte(); } int server = slea.readByte(); int channel = slea.readByte() + 1; if ((!World.isChannelAvailable(channel)) || (server != 0)) { c.getSession().write(LoginPacket.getLoginFailed(10)); return; } List chars = c.loadCharacters(server); if ((chars != null) && (ChannelServer.getInstance(channel) != null)) { c.setWorld(server); c.setChannel(channel); c.getSession() .write(LoginPacket.getCharList(c.getSecondPassword(), chars, c.getCharacterSlots())); } else { c.getSession().close(true); } }
public static final void CharlistRequest(final LittleEndianAccessor slea, final MapleClient c) { if (!c.isLoggedIn()) { c.getSession().close(); return; } if (GameConstants.GMS) { slea.readByte(); // 2? } final int server = slea.readByte(); final int channel = slea.readByte() + 1; if (!World.isChannelAvailable(channel) || server != 0) { // TODOO: MULTI WORLDS c.getSession().write(LoginPacket.getLoginFailed(10)); // cannot process so many return; } // System.out.println("Client " + c.getSession().getRemoteAddress().toString().split(":")[0] + " // is connecting to server " + server + " channel " + channel + ""); final List<MapleCharacter> chars = c.loadCharacters(server); if (chars != null && ChannelServer.getInstance(channel) != null) { c.setWorld(server); c.setChannel(channel); c.getSession().write(LoginPacket.getSecondAuthSuccess(c)); c.getSession() .write(LoginPacket.getCharList(c.getSecondPassword(), chars, c.getCharacterSlots())); } else { c.getSession().close(); } }
@Override public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) { int server = slea.readByte(); int channel = slea.readByte() + 1; c.setWorld(server); // log.info("Client is connecting to server {} channel {}", server, channel); c.setChannel(channel); c.sendCharList(server); }
public static final void Character_WithoutSecondPassword( final LittleEndianAccessor slea, final MapleClient c, final boolean haspic, final boolean view) { slea.readByte(); // 1? slea.readByte(); // 1? final int charId = slea.readInt(); if (view) { c.setChannel(1); c.setWorld(slea.readInt()); } final String currentpw = c.getSecondPassword(); if (!c.isLoggedIn() || loginFailCount(c) || (currentpw != null && (!currentpw.equals("") || haspic)) || !c.login_Auth(charId) || ChannelServer.getInstance(c.getChannel()) == null || c.getWorld() != 0) { // TODOO: MULTI WORLDS c.getSession().close(); return; } c.updateMacs(slea.readMapleAsciiString()); slea.readMapleAsciiString(); if (slea.available() != 0) { final String setpassword = slea.readMapleAsciiString(); if (setpassword.length() >= 6 && setpassword.length() <= 16) { c.setSecondPassword(setpassword); c.updateSecondPassword(); } else { c.getSession().write(LoginPacket.secondPwError((byte) 0x14)); return; } } else if (GameConstants.GMS && haspic) { return; } if (c.getIdleTask() != null) { c.getIdleTask().cancel(true); } final String s = c.getSessionIPAddress(); LoginServer.putLoginAuth( charId, s.substring(s.indexOf('/') + 1, s.length()), c.getTempIP(), c.getChannel()); c.updateLoginState(MapleClient.LOGIN_SERVER_TRANSITION, s); c.getSession() .write( CField.getServerIP( c, Integer.parseInt(ChannelServer.getInstance(c.getChannel()).getIP().split(":")[1]), charId)); }
@Override public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) { String pic = slea.readMapleAsciiString(); int charId = slea.readInt(); byte world = (byte) slea.readInt(); // world c.setWorld(world); byte channel = (byte) Randomizer.rand(0, Server.getInstance().getWorld(world).getChannels().size()); c.setChannel(channel); String macs = slea.readMapleAsciiString(); c.updateMacs(macs); if (c.hasBannedMac()) { c.getSession().close(true); return; } if (c.checkPic(pic)) { try { if (c.getIdleTask() != null) { c.getIdleTask().cancel(true); } c.updateLoginState(MapleClient.LOGIN_SERVER_TRANSITION); String channelServerIP = MapleClient.getChannelServerIPFromSubnet( c.getSession().getRemoteAddress().toString().replace("/", "").split(":")[0], channel); if (channelServerIP.equals("0.0.0.0")) { String[] socket = Server.getInstance().getIP(world, channel).split(":"); c.announce( MaplePacketCreator.getServerIP( InetAddress.getByName(socket[0]), Integer.parseInt(socket[1]), charId)); } else { String[] socket = Server.getInstance().getIP(world, channel).split(":"); c.announce( MaplePacketCreator.getServerIP( InetAddress.getByName(channelServerIP), Integer.parseInt(socket[1]), charId)); } } catch (UnknownHostException e) { log.error("Host not found", e); } } else { c.announce(MaplePacketCreator.wrongPic()); } }
public static final void Character_WithSecondPassword( LittleEndianAccessor slea, MapleClient c, boolean view) { String password = slea.readMapleAsciiString(); int charId = slea.readInt(); if (view) { c.setChannel(1); c.setWorld(slea.readInt()); } if ((!c.isLoggedIn()) || (loginFailCount(c)) || (c.getSecondPassword() == null) || (!c.login_Auth(charId)) || (ChannelServer.getInstance(c.getChannel()) == null) || (c.getWorld() != 0)) { c.getSession().close(true); return; } if (GameConstants.GMS) { c.updateMacs(slea.readMapleAsciiString()); } if ((c.CheckSecondPassword(password)) && (password.length() >= 6) && (password.length() <= 16)) { if (c.getIdleTask() != null) { c.getIdleTask().cancel(true); } String s = c.getSessionIPAddress(); LoginServer.putLoginAuth(charId, s.substring(s.indexOf('/') + 1, s.length()), c.getTempIP()); c.updateLoginState(MapleClient.LOGIN_SERVER_TRANSITION, s); c.getSession() .write( CField.getServerIP( c, Integer.parseInt(ChannelServer.getInstance(c.getChannel()).getIP().split(":")[1]), charId)); System.out.println("Sent serverIp"); } else { c.getSession().write(LoginPacket.secondPwError((byte) 0x14)); } }