int loginOkId2 = readD();
String s_bonus = readS();
String account_fields = readS();
int bonusExpire = readD();
float bonus = s_bonus == null || s_bonus.equals("") ? 1 : Float.parseFloat(s_bonus);
L2GameClient client = getLoginServer().getCon().removeWaitingClient(account);
if(client != null)
{
if(client.getState() != L2GameClient.GameClientState.CONNECTED)
{
log.severe("Trying to authd allready authed client.");
client.closeNow(true);
return;
}
if(client.getLoginName() == null || client.getLoginName().isEmpty())
{
client.closeNow(true);
log.warning("PlayerAuthResponse: empty accname for " + client);
return;
}
SessionKey key = client.getSessionId();
if(authed)
{
if(getLoginServer().isLicenseShown())
{
authed = key.playOkID1 == playOkId1 && key.playOkID2 == playOkId2 && key.loginOkID1 == loginOkId1 && key.loginOkID2 == loginOkId2;
}
else
{
authed = key.playOkID1 == playOkId1 && key.playOkID2 == playOkId2;
}
}
if(authed)
{
client.account_fields = StatsSet.unserialize(account_fields);
client.setState(L2GameClient.GameClientState.AUTHED);
client.setBonus(bonus);
client.setBonusExpire(bonusExpire);
getLoginServer().getCon().addAccountInGame(client);
CharacterSelectionInfo csi = new CharacterSelectionInfo(client.getLoginName(), client.getSessionId().playOkID1);
client.sendPacket(csi);
client.setCharSelection(csi.getCharInfo());
sendPacket(new PlayerInGame(client.getLoginName(), Stats.getOnline(true)));
}
else
{
//log.severe("Cheater? SessionKey invalid! Login: " + client.getLoginName() + ", IP: " + client.getIpAddr());
client.sendPacket(new LoginFail(LoginFail.INCORRECT_ACCOUNT_INFO_CONTACT_CUSTOMER_SUPPORT));
ThreadPoolManager.getInstance().scheduleGeneral(new KickWaitingClientTask(client), 1000);
LSConnection.getInstance().sendPacket(new PlayerLogout(client.getLoginName()));
LSConnection.getInstance().removeAccount(client);
}
}
}