Скрытый текст
package net.sf.l2j.gameserver.network; import com.lameguard.session.LameClientV195; Вот import java.net.InetAddress; import java.nio.ByteBuffer; import java.sql.PreparedStatement; import java.util.HashMap; import java.util.List; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.locks.ReentrantLock; import java.util.logging.Level; import java.util.logging.Logger; import javolution.util.FastList; import net.sf.l2j.Config; import net.sf.l2j.L2DatabaseFactory; import net.sf.l2j.gameserver.LoginServerThread; import net.sf.l2j.gameserver.ThreadPoolManager; import net.sf.l2j.gameserver.cache.Static; import net.sf.l2j.gameserver.datatables.SkillTable; import net.sf.l2j.gameserver.model.*; import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance; import net.sf.l2j.gameserver.model.entity.L2Event; import net.sf.l2j.gameserver.network.serverpackets.L2GameServerPacket; import net.sf.l2j.gameserver.network.serverpackets.ServerClose; import net.sf.l2j.gameserver.network.serverpackets.ServerCloseSocket; import net.sf.l2j.gameserver.network.serverpackets.UserInfo; import net.sf.l2j.mysql.Close; import net.sf.l2j.mysql.Connect; import net.sf.l2j.util.EventData; import org.mmocore.network.*; // Referenced classes of package net.sf.l2j.gameserver.network: // GameCrypt, BlowFishKeygen public final class L2GameClient extends MMOClient implements LameClientV195 { class AutoSaveTask implements Runnable { public void run() { try { L2PcInstance player = getActiveChar(); if(player != null) L2GameClient.saveCharToDisk(player); } catch(Throwable e) { L2GameClient._log.severe(e.toString()); } } final L2GameClient this$0; AutoSaveTask() { this$0 = L2GameClient.this; super(); } } class DisconnectTask implements Runnable { public void run() { _autoSaveInDB.cancel(true); L2PcInstance player = getActiveChar(); if(player != null) { if(player.getActiveTradeList() != null) { player.cancelActiveTrade(); player.setTransactionRequester(null); player.getTransactionRequester().setTransactionRequester(null); } if(player.atEvent) { EventData data = new EventData(player.eventX, player.eventY, player.eventZ, player.eventkarma, player.eventpvpkills, player.eventpkkills, player.eventTitle, player.kills, player.eventSitForced); L2Event.connectionLossData.put(player.getName(), data); } if(player.isFlying()) player.removeSkill(SkillTable.getInstance().getInfo(4289, 1)); player.deleteMe(); try { L2GameClient.saveCharToDisk(player); } catch(Exception e2) { } player.gc(); player = null; } setActiveChar(null); LoginServerThread.getInstance().sendLogout(getAccountName()); break MISSING_BLOCK_LABEL_222; Exception e1; e1; L2GameClient._log.log(Level.WARNING, "error while disconnecting client", e1); LoginServerThread.getInstance().sendLogout(getAccountName()); break MISSING_BLOCK_LABEL_222; Exception exception; exception; LoginServerThread.getInstance().sendLogout(getAccountName()); throw exception; } final L2GameClient this$0; DisconnectTask() { this$0 = L2GameClient.this; super(); } } public static final class GameClientState extends Enum { public static GameClientState[] values() { return (GameClientState[])$VALUES.clone(); } public static GameClientState valueOf(String name) { return (GameClientState)Enum.valueOf(net/sf/l2j/gameserver/network/L2GameClient$GameClientState, name); } public static final GameClientState CONNECTED; public static final GameClientState AUTHED; public static final GameClientState IN_GAME; public static final GameClientState DISCONNECTED; private static final GameClientState $VALUES[]; static { CONNECTED = new GameClientState("CONNECTED", 0); AUTHED = new GameClientState("AUTHED", 1); IN_GAME = new GameClientState("IN_GAME", 2); DISCONNECTED = new GameClientState("DISCONNECTED", 3); $VALUES = (new GameClientState[] { CONNECTED, AUTHED, IN_GAME, DISCONNECTED }); } private GameClientState(String s, int i) { super(s, i); } } public L2GameClient(MMOConnection con) { super(con); _activeCharLock = new ReentrantLock(); _charSlotMapping = new FastList(); _cleanupTask = null; _upTryes = 0; _upLastConnection = 0L; _lastSendedPacket = ""; _hwid = "none"; _myhwid = "none"; state = GameClientState.CONNECTED; _connectionStartTime = System.currentTimeMillis(); crypt = new GameCrypt(); _autoSaveInDB = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoSaveTask(), 0x493e0L, 0xdbba0L); } public L2GameClient(MMOConnection con, boolean offline) { super(con); _activeCharLock = new ReentrantLock(); _charSlotMapping = new FastList(); _cleanupTask = null; _upTryes = 0; _upLastConnection = 0L; _lastSendedPacket = ""; _hwid = "none"; _myhwid = "none"; state = GameClientState.IN_GAME; } public byte[] enableCrypt() { byte key[] = BlowFishKeygen.getRandomKey(); crypt.setKey(key); return key; } public GameClientState getState() { return state; } public void setState(GameClientState pState) { state = pState; } public long getConnectionStartTime() { return _connectionStartTime; } public boolean decrypt(ByteBuffer buf, int size) { crypt.decrypt(buf.array(), buf.position(), size); return true; } public boolean encrypt(ByteBuffer buf, int size) { crypt.encrypt(buf.array(), buf.position(), size); buf.position(buf.position() + size); return true; } public L2PcInstance getActiveChar() { return activeChar; } public void setActiveChar(L2PcInstance pActiveChar) { activeChar = pActiveChar; if(activeChar != null) L2World.getInstance().storeObject(getActiveChar()); } public ReentrantLock getActiveCharLock() { return _activeCharLock; } public void setGameGuardOk(boolean val) { _isAuthedGG = val; } public void setAccountName(String pAccountName) { accountName = pAccountName; } public String getAccountName() { return accountName; } public void setSessionId(net.sf.l2j.gameserver.LoginServerThread.SessionKey sk) { sessionId = sk; } public net.sf.l2j.gameserver.LoginServerThread.SessionKey getSessionId() { return sessionId; } public void sendPacket(L2GameServerPacket gsp) { if(getConnection() == null) return; if(gsp == null) { return; } else { getConnection().sendPacket(gsp); gsp.runImpl(); return; } } public String getIpAddr() { return getConnection().getSocket().getInetAddress().getHostAddress(); NullPointerException e; e; return "Disconnected"; } public L2PcInstance markToDeleteChar(int charslot) throws Exception { int objid; Connect con; PreparedStatement statement; objid = getObjectIdForSlot(charslot); if(objid < 0) return null; L2PcInstance character = L2PcInstance.load(objid); if(character.getClanId() != 0) return character; con = null; statement = null; con = L2DatabaseFactory.getInstance().getConnection(); statement = con.prepareStatement("UPDATE characters SET deletetime=? WHERE obj_id=?"); statement.setLong(1, System.currentTimeMillis() + (long)Config.DELETE_DAYS * 0x5265c00L); statement.setInt(2, objid); statement.execute(); Close.CS(con, statement); break MISSING_BLOCK_LABEL_146; Exception e; e; _log.warning((new StringBuilder()).append("Data error on update delete time of char: ").append(e).toString()); Close.CS(con, statement); break MISSING_BLOCK_LABEL_146; Exception exception; exception; Close.CS(con, statement); throw exception; return null; } public L2PcInstance deleteChar(int charslot) throws Exception { int objid = getObjectIdForSlot(charslot); if(objid < 0) return null; L2PcInstance character = L2PcInstance.load(objid); if(character.getClanId() != 0) { return character; } else { deleteCharByObjId(objid); return null; } } public void markRestoredChar(int charslot) throws Exception { int objid; Connect con; PreparedStatement statement; objid = getObjectIdForSlot(charslot); if(objid < 0) return; con = null; statement = null; con = L2DatabaseFactory.getInstance().getConnection(); statement = con.prepareStatement("UPDATE characters SET deletetime=0 WHERE obj_id=?"); statement.setInt(1, objid); statement.execute(); Close.CS(con, statement); break MISSING_BLOCK_LABEL_105; Exception e; e; _log.severe((new StringBuilder()).append("Data error on restoring char: ").append(e).toString()); Close.CS(con, statement); break MISSING_BLOCK_LABEL_105; Exception exception; exception; Close.CS(con, statement); throw exception; } public static void deleteCharByObjId(int objid) { Connect con; PreparedStatement statement; if(objid < 0) return; con = null; statement = null; con = L2DatabaseFactory.getInstance().getConnection(); statement = con.prepareStatement("DELETE FROM character_friends WHERE char_id=? OR friend_id=?"); statement.setInt(1, objid); statement.setInt(2, objid); statement.execute(); Close.S(statement); statement = con.prepareStatement("DELETE FROM character_hennas WHERE char_obj_id=?"); statement.setInt(1, objid); statement.execute(); Close.S(statement); statement = con.prepareStatement("DELETE FROM character_macroses WHERE char_obj_id=?"); statement.setInt(1, objid); statement.execute(); Close.S(statement); statement = con.prepareStatement("DELETE FROM character_quests WHERE char_id=?"); statement.setInt(1, objid); statement.execute(); Close.S(statement); statement = con.prepareStatement("DELETE FROM character_recipebook WHERE char_id=?"); statement.setInt(1, objid); statement.execute(); Close.S(statement); statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE char_obj_id=?"); statement.setInt(1, objid); statement.execute(); Close.S(statement); statement = con.prepareStatement("DELETE FROM character_skills WHERE char_obj_id=?"); statement.setInt(1, objid); statement.execute(); Close.S(statement); statement = con.prepareStatement("DELETE FROM character_buffs WHERE char_obj_id=?"); statement.setInt(1, objid); statement.execute(); Close.S(statement); statement = con.prepareStatement("DELETE FROM character_subclasses WHERE char_obj_id=?"); statement.setInt(1, objid); statement.execute(); Close.S(statement); statement = con.prepareStatement("DELETE FROM heroes WHERE char_id=?"); statement.setInt(1, objid); statement.execute(); Close.S(statement); statement = con.prepareStatement("DELETE FROM olympiad_nobles WHERE char_id=?"); statement.setInt(1, objid); statement.execute(); Close.S(statement); statement = con.prepareStatement("DELETE FROM seven_signs WHERE char_obj_id=?"); statement.setInt(1, objid); statement.execute(); Close.S(statement); statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id IN (SELECT object_id FROM items WHERE items.owner_id=?)"); statement.setInt(1, objid); statement.execute(); Close.S(statement); statement = con.prepareStatement("DELETE FROM items WHERE owner_id=?"); statement.setInt(1, objid); statement.execute(); Close.S(statement); statement = con.prepareStatement("DELETE FROM merchant_lease WHERE player_id=?"); statement.setInt(1, objid); statement.execute(); Close.S(statement); statement = con.prepareStatement("DELETE FROM character_settings WHERE char_obj_id=?"); statement.setInt(1, objid); statement.execute(); Close.S(statement); statement = con.prepareStatement("DELETE FROM characters WHERE obj_Id=?"); statement.setInt(1, objid); statement.execute(); Close.S(statement); Close.CS(con, statement); break MISSING_BLOCK_LABEL_518; Exception e; e; _log.warning((new StringBuilder()).append("Data error on deleting char: ").append(e).toString()); Close.CS(con, statement); break MISSING_BLOCK_LABEL_518; Exception exception; exception; Close.CS(con, statement); throw exception; } public L2PcInstance loadCharFromDisk(int charslot) { Integer objectId = Integer.valueOf(getObjectIdForSlot(charslot)); if(objectId.intValue() == -1) return null; L2Object object = L2World.getInstance().findObject(objectId.intValue()); if(object != null && object.isPlayer()) { L2PcInstance player = (L2PcInstance)object; if(!player.isInOfflineMode()) { player.sendMessage("\u041A\u0442\u043E-\u0442\u043E \u043F\u044B\u0442\u0430\u0435\u0442\u0441\u044F \u0437\u0430\u0439\u0442\u0438 \u0437\u0430 \u0432\u0430\u0448\u0435\u0433\u043E \u0447\u0430\u0440\u0430."); player.kick(); } else { player.setOfflineMode(false); player.kick(); } } L2PcInstance character = L2PcInstance.load(getObjectIdForSlot(charslot)); if(character != null) { character.setRunning(); character.standUp(); character.refreshOverloaded(); character.refreshExpertisePenalty(); character.sendPacket(new UserInfo(character)); character.broadcastKarma(); character.setOnlineStatus(true); } else { _log.severe((new StringBuilder()).append("could not restore in slot: ").append(charslot).toString()); } return character; } public void setCharSelection(CharSelectInfoPackage chars[]) { _charSlotMapping.clear(); for(int i = 0; i < chars.length; i++) { int objectId = chars.getObjectId(); _charSlotMapping.add(Integer.valueOf(objectId)); } } public void setCharSelection(int c) { _charSlotMapping.clear(); _charSlotMapping.add(Integer.valueOf©); } public void close(L2GameServerPacket gsp) { getConnection().close(gsp); } private int getObjectIdForSlot(int charslot) { if(charslot < 0 || charslot >= _charSlotMapping.size()) { _log.warning((new StringBuilder()).append(toString()).append(" tried to delete Character in slot ").append(charslot).append(" but no characters exits at that slot.").toString()); return -1; } else { Integer objectId = (Integer)_charSlotMapping.get(charslot); return objectId.intValue(); } } protected void onForcedDisconnection() { } protected void onDisconnection() { if(getAccountName() == null || getAccountName().equals("") || state != GameClientState.IN_GAME && state != GameClientState.AUTHED) return; L2PcInstance player; _autoSaveInDB.cancel(true); player = getActiveChar(); if(player == null) break MISSING_BLOCK_LABEL_250; if(player.getActiveTradeList() != null) { player.cancelActiveTrade(); if(player.getTransactionRequester() != null) player.getTransactionRequester().setTransactionRequester(null); player.setTransactionRequester(null); } if(player.isInOfflineMode()) { LoginServerThread.getInstance().sendLogout(getAccountName()); return; } if(player.atEvent) { EventData data = new EventData(player.eventX, player.eventY, player.eventZ, player.eventkarma, player.eventpvpkills, player.eventpkkills, player.eventTitle, player.kills, player.eventSitForced); L2Event.connectionLossData.put(player.getName(), data); } if(player.isCastingNow()) player.abortCast(); if(player.isFlying()) player.removeSkill(SkillTable.getInstance().getInfo(4289, 1)); if(player.getPet() != null) player.getPet().unSummon(player); saveCharToDisk(player); player.deleteMe(); if(player.getClient() != null) { player.closeNetConnection(); player.setClient(null); } player.gc(); player = null; setActiveChar(null); LoginServerThread.getInstance().sendLogout(getAccountName()); break MISSING_BLOCK_LABEL_307; Exception e1; e1; _log.log(Level.WARNING, "error while disconnecting client", e1); LoginServerThread.getInstance().sendLogout(getAccountName()); break MISSING_BLOCK_LABEL_307; Exception exception; exception; LoginServerThread.getInstance().sendLogout(getAccountName()); throw exception; state = GameClientState.DISCONNECTED; return; } public static void saveCharToDisk(L2PcInstance cha) { try { cha.getInventory().updateDatabase(true); cha.store(); } catch(Exception e) { _log.severe((new StringBuilder()).append("Error saving player character: ").append(e).toString()); } } public String toString() { InetAddress address = getConnection().getSocket().getInetAddress(); static class _cls1 { static final int $SwitchMap$net$sf$l2j$gameserver$network$L2GameClient$GameClientState[]; static { $SwitchMap$net$sf$l2j$gameserver$network$L2GameClient$GameClientState = new int[GameClientState.values().length]; try { $SwitchMap$net$sf$l2j$gameserver$network$L2GameClient$GameClientState[GameClientState.CONNECTED.ordinal()] = 1; } catch(NoSuchFieldError ex) { } try { $SwitchMap$net$sf$l2j$gameserver$network$L2GameClient$GameClientState[GameClientState.AUTHED.ordinal()] = 2; } catch(NoSuchFieldError ex) { } try { $SwitchMap$net$sf$l2j$gameserver$network$L2GameClient$GameClientState[GameClientState.IN_GAME.ordinal()] = 3; } catch(NoSuchFieldError ex) { } try { $SwitchMap$net$sf$l2j$gameserver$network$L2GameClient$GameClientState[GameClientState.DISCONNECTED.ordinal()] = 4; } catch(NoSuchFieldError ex) { } } } _cls1..SwitchMap.net.sf.l2j.gameserver.network.L2GameClient.GameClientState[getS tate().ordinal()]; JVM INSTR tableswitch 1 4: default 221 // 1 56 // 2 93 // 3 142 // 4 218; goto _L1 _L2 _L3 _L4 _L5 _L2: return (new StringBuilder()).append("[iP: ").append(address != null ? address.getHostAddress() : "disconnected").append("]").toString(); _L3: return (new StringBuilder()).append("[Account: ").append(getAccountName()).append(" - IP: ").append(address != null ? address.getHostAddress() : "disconnected").append("]").toString(); _L4: return (new StringBuilder()).append("[Character: ").append(getActiveChar() != null ? getActiveChar().getName() : "disconnected").append(" - Account: ").append(getAccountName()).append(" - IP: ").append(address != null ? address.getHostAddress() : "disconnected").append("]").toString(); _L5: return "[Disconnected]"; _L1: try { throw new IllegalStateException("Missing state on switch"); } catch(NullPointerException e) { e.printStackTrace(); } return "[Character read failed due to disconnect]"; } public void addUPTryes() { if(_upLastConnection != 0L && System.currentTimeMillis() - _upLastConnection > 700L) _upTryes = 0; _upTryes++; _upLastConnection = System.currentTimeMillis(); } public int getUPTryes() { if(_upLastConnection != 0L && System.currentTimeMillis() - _upLastConnection > 700L) { _upTryes = 0; _upLastConnection = System.currentTimeMillis(); } return _upTryes; } public void setLastSendedPacket(String packet) { _lastSendedPacket = packet; } public String getLastSendedPacket() { return _lastSendedPacket; } public void close() { L2PcInstance player = getActiveChar(); if(player != null) { player.sendPacket(Static.YOU_HAVE_BEEN_DISCONNECTED); player.sendPacket(new ServerClose()); player.sendPacket(new ServerCloseSocket()); } closeNow(); } public void setHWID(String hwid) { _hwid = hwid; } public String getHWID() { return _hwid; } public boolean acceptHWID(String hwid) { if(hwid.equalsIgnoreCase("none")) return true; if(_hwid.equalsIgnoreCase(hwid)) { _myhwid = hwid; return true; } else { return false; } } public String getMyHWID() { return _myhwid; } public void setMyHWID(String hwid) { _myhwid = hwid; } public void setProtected(boolean f) { _protected = f; } public boolean isProtected() { return _protected; } public void setInstanceCount(int instCount) { _instCount = instCount; } public int getInstanceCount() { return _instCount; } public void setPatchVersion(int patchVersion) { _patchVersion = patchVersion; } public int getPatchVersion() { return _patchVersion; } protected static final Logger _log = Logger.getLogger(net/sf/l2j/gameserver/network/L2GameClient.getName()); public GameClientState state; public String accountName; public net.sf.l2j.gameserver.LoginServerThread.SessionKey sessionId; public L2PcInstance activeChar; private ReentrantLock _activeCharLock; private boolean _isAuthedGG; private long _connectionStartTime; private List _charSlotMapping; protected ScheduledFuture _autoSaveInDB; protected ScheduledFuture _cleanupTask; public GameCrypt crypt; private int _upTryes; private long _upLastConnection; private String _lastSendedPacket; private String _hwid; private String _myhwid; private boolean _protected; private int _patchVersion; private int _instCount; }