Dropped MMOCore.
This commit is contained in:
@@ -89,7 +89,6 @@ public final class Config
|
||||
public static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini";
|
||||
public static final String IDFACTORY_CONFIG_FILE = "./config/IdFactory.ini";
|
||||
public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini";
|
||||
public static final String MMO_CONFIG_FILE = "./config/MMO.ini";
|
||||
public static final String NPC_CONFIG_FILE = "./config/NPC.ini";
|
||||
public static final String OLYMPIAD_CONFIG_FILE = "./config/Olympiad.ini";
|
||||
public static final String PVP_CONFIG_FILE = "./config/PVP.ini";
|
||||
@@ -494,15 +493,7 @@ public final class Config
|
||||
public static int THREADS_PER_SCHEDULED_THREAD_POOL;
|
||||
public static int INSTANT_THREAD_POOL_COUNT;
|
||||
public static int THREADS_PER_INSTANT_THREAD_POOL;
|
||||
public static int CLIENT_PACKET_QUEUE_SIZE;
|
||||
public static int CLIENT_PACKET_QUEUE_MAX_BURST_SIZE;
|
||||
public static int CLIENT_PACKET_QUEUE_MAX_PACKETS_PER_SECOND;
|
||||
public static int CLIENT_PACKET_QUEUE_MEASURE_INTERVAL;
|
||||
public static int CLIENT_PACKET_QUEUE_MAX_AVERAGE_PACKETS_PER_SECOND;
|
||||
public static int CLIENT_PACKET_QUEUE_MAX_FLOODS_PER_MIN;
|
||||
public static int CLIENT_PACKET_QUEUE_MAX_OVERFLOWS_PER_MIN;
|
||||
public static int CLIENT_PACKET_QUEUE_MAX_UNDERFLOWS_PER_MIN;
|
||||
public static int CLIENT_PACKET_QUEUE_MAX_UNKNOWN_PER_MIN;
|
||||
public static int IO_PACKET_THREAD_CORE_SIZE;
|
||||
public static boolean DEADLOCK_DETECTOR;
|
||||
public static int DEADLOCK_CHECK_INTERVAL;
|
||||
public static boolean RESTART_ON_DEADLOCK;
|
||||
@@ -511,7 +502,7 @@ public final class Config
|
||||
public static int HERB_AUTO_DESTROY_TIME;
|
||||
public static List<Integer> LIST_PROTECTED_ITEMS;
|
||||
public static boolean DATABASE_CLEAN_UP;
|
||||
public static int CHAR_STORE_INTERVAL;
|
||||
public static int CHAR_DATA_STORE_INTERVAL;
|
||||
public static boolean LAZY_ITEMS_UPDATE;
|
||||
public static boolean UPDATE_ITEMS_ON_CHAR_STORE;
|
||||
public static boolean DESTROY_DROPPED_PLAYER_ITEM;
|
||||
@@ -1113,7 +1104,11 @@ public final class Config
|
||||
public static double HP_REGEN_MULTIPLIER;
|
||||
public static double MP_REGEN_MULTIPLIER;
|
||||
public static double CP_REGEN_MULTIPLIER;
|
||||
public static boolean IS_TELNET_ENABLED;
|
||||
public static boolean TELNET_ENABLED;
|
||||
public static String TELNET_PASSWORD;
|
||||
public static String TELNET_HOSTNAME;
|
||||
public static List<String> TELNET_HOSTS;
|
||||
public static int TELNET_PORT;
|
||||
public static boolean SHOW_LICENCE;
|
||||
public static boolean ACCEPT_NEW_GAMESERVER;
|
||||
public static int SERVER_ID;
|
||||
@@ -1237,7 +1232,7 @@ public final class Config
|
||||
|
||||
final PropertiesParser serverSettings = new PropertiesParser(SERVER_CONFIG_FILE);
|
||||
|
||||
GAMESERVER_HOSTNAME = serverSettings.getString("GameserverHostname", "*");
|
||||
GAMESERVER_HOSTNAME = serverSettings.getString("GameserverHostname", "0.0.0.0");
|
||||
PORT_GAME = serverSettings.getInt("GameserverPort", 7777);
|
||||
|
||||
GAME_SERVER_LOGIN_PORT = serverSettings.getInt("LoginPort", 9014);
|
||||
@@ -1250,7 +1245,7 @@ public final class Config
|
||||
DATABASE_URL = serverSettings.getString("URL", "jdbc:mysql://localhost/l2jmobiush5?useUnicode=true&characterEncoding=utf-8");
|
||||
DATABASE_LOGIN = serverSettings.getString("Login", "root");
|
||||
DATABASE_PASSWORD = serverSettings.getString("Password", "");
|
||||
DATABASE_MAX_CONNECTIONS = serverSettings.getInt("MaximumDbConnections", 500);
|
||||
DATABASE_MAX_CONNECTIONS = serverSettings.getInt("MaximumDbConnections", 10);
|
||||
DATABASE_MAX_IDLE_TIME = serverSettings.getInt("MaximumDbIdleTime", 0);
|
||||
|
||||
try
|
||||
@@ -1284,6 +1279,12 @@ public final class Config
|
||||
}
|
||||
}
|
||||
|
||||
SCHEDULED_THREAD_POOL_COUNT = serverSettings.getInt("ScheduledThreadPoolCount", -1);
|
||||
THREADS_PER_SCHEDULED_THREAD_POOL = serverSettings.getInt("ThreadsPerScheduledThreadPool", 4);
|
||||
INSTANT_THREAD_POOL_COUNT = serverSettings.getInt("InstantThreadPoolCount", -1);
|
||||
THREADS_PER_INSTANT_THREAD_POOL = serverSettings.getInt("ThreadsPerInstantThreadPool", 2);
|
||||
IO_PACKET_THREAD_CORE_SIZE = serverSettings.getInt("UrgentPacketThreadCoreSize", 2);
|
||||
|
||||
SERVER_RESTART_SCHEDULE_ENABLED = serverSettings.getBoolean("ServerRestartScheduleEnabled", false);
|
||||
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
||||
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
||||
@@ -1294,7 +1295,7 @@ public final class Config
|
||||
GAME_SERVER_SUBNETS = ipcd.getSubnets();
|
||||
GAME_SERVER_HOSTS = ipcd.getHosts();
|
||||
|
||||
// Load Feature L2Properties file (if exists)
|
||||
// Load Feature config file (if exists)
|
||||
final PropertiesParser Feature = new PropertiesParser(FEATURE_CONFIG_FILE);
|
||||
|
||||
CH_TELE_FEE_RATIO = Feature.getLong("ClanHallTeleportFunctionFeeRatio", 604800000);
|
||||
@@ -1478,7 +1479,7 @@ public final class Config
|
||||
ALLOW_WYVERN_DURING_SIEGE = Feature.getBoolean("AllowRideWyvernDuringSiege", true);
|
||||
ALLOW_MOUNTS_DURING_SIEGE = Feature.getBoolean("AllowRideMountsDuringSiege", false);
|
||||
|
||||
// Load Character L2Properties file (if exists)
|
||||
// Load Character config file (if exists)
|
||||
final PropertiesParser character = new PropertiesParser(CHARACTER_CONFIG_FILE);
|
||||
|
||||
PLAYER_DELEVEL = character.getBoolean("Delevel", true);
|
||||
@@ -1822,27 +1823,22 @@ public final class Config
|
||||
NEVIT_ADVENT_TIME = character.getInt("NevitAdventTime", 14400);
|
||||
NEVIT_IGNORE_ADVENT_TIME = character.getBoolean("NevitIgnoreAdventTime", false);
|
||||
|
||||
// Load Telnet L2Properties file (if exists)
|
||||
// Load Telnet config file (if exists)
|
||||
final PropertiesParser telnetSettings = new PropertiesParser(TELNET_CONFIG_FILE);
|
||||
|
||||
IS_TELNET_ENABLED = telnetSettings.getBoolean("EnableTelnet", false);
|
||||
TELNET_ENABLED = telnetSettings.getBoolean("EnableTelnet", false);
|
||||
TELNET_PORT = telnetSettings.getInt("Port", 12345);
|
||||
TELNET_HOSTNAME = telnetSettings.getString("BindAddress", "127.0.0.1");
|
||||
TELNET_PASSWORD = telnetSettings.getString("Password", "");
|
||||
TELNET_HOSTS = Arrays.asList(telnetSettings.getString("ListOfHosts", "127.0.0.1,::1").split(","));
|
||||
|
||||
// MMO
|
||||
final PropertiesParser mmoSettings = new PropertiesParser(MMO_CONFIG_FILE);
|
||||
|
||||
MMO_SELECTOR_SLEEP_TIME = mmoSettings.getInt("SleepTime", 20);
|
||||
MMO_MAX_SEND_PER_PASS = mmoSettings.getInt("MaxSendPerPass", 12);
|
||||
MMO_MAX_READ_PER_PASS = mmoSettings.getInt("MaxReadPerPass", 12);
|
||||
MMO_HELPER_BUFFER_COUNT = mmoSettings.getInt("HelperBufferCount", 20);
|
||||
MMO_TCP_NODELAY = mmoSettings.getBoolean("TcpNoDelay", false);
|
||||
|
||||
// Load IdFactory L2Properties file (if exists)
|
||||
// Load IdFactory config file (if exists)
|
||||
final PropertiesParser IdFactory = new PropertiesParser(IDFACTORY_CONFIG_FILE);
|
||||
|
||||
IDFACTORY_TYPE = IdFactory.getEnum("IDFactory", IdFactoryType.class, IdFactoryType.BitSet);
|
||||
BAD_ID_CHECKING = IdFactory.getBoolean("BadIdChecking", true);
|
||||
|
||||
// Load General L2Properties file (if exists)
|
||||
// Load General config file (if exists)
|
||||
final PropertiesParser General = new PropertiesParser(GENERAL_CONFIG_FILE);
|
||||
EVERYBODY_HAS_ADMIN_RIGHTS = General.getBoolean("EverybodyHasAdminRights", false);
|
||||
SERVER_LIST_BRACKET = General.getBoolean("ServerListBrackets", false);
|
||||
@@ -1883,27 +1879,6 @@ public final class Config
|
||||
ALT_DEV_NO_SPAWNS = General.getBoolean("AltDevNoSpawns", false) || Boolean.getBoolean("nospawns");
|
||||
ALT_DEV_SHOW_QUESTS_LOAD_IN_LOGS = General.getBoolean("AltDevShowQuestsLoadInLogs", false);
|
||||
ALT_DEV_SHOW_SCRIPTS_LOAD_IN_LOGS = General.getBoolean("AltDevShowScriptsLoadInLogs", false);
|
||||
SCHEDULED_THREAD_POOL_COUNT = General.getInt("ScheduledThreadPoolCount", -1);
|
||||
THREADS_PER_SCHEDULED_THREAD_POOL = General.getInt("ThreadsPerScheduledThreadPool", 4);
|
||||
INSTANT_THREAD_POOL_COUNT = General.getInt("InstantThreadPoolCount", -1);
|
||||
THREADS_PER_INSTANT_THREAD_POOL = General.getInt("ThreadsPerInstantThreadPool", 2);
|
||||
CLIENT_PACKET_QUEUE_SIZE = General.getInt("ClientPacketQueueSize", 0);
|
||||
if (CLIENT_PACKET_QUEUE_SIZE == 0)
|
||||
{
|
||||
CLIENT_PACKET_QUEUE_SIZE = MMO_MAX_READ_PER_PASS + 2;
|
||||
}
|
||||
CLIENT_PACKET_QUEUE_MAX_BURST_SIZE = General.getInt("ClientPacketQueueMaxBurstSize", 0);
|
||||
if (CLIENT_PACKET_QUEUE_MAX_BURST_SIZE == 0)
|
||||
{
|
||||
CLIENT_PACKET_QUEUE_MAX_BURST_SIZE = MMO_MAX_READ_PER_PASS + 1;
|
||||
}
|
||||
CLIENT_PACKET_QUEUE_MAX_PACKETS_PER_SECOND = General.getInt("ClientPacketQueueMaxPacketsPerSecond", 80);
|
||||
CLIENT_PACKET_QUEUE_MEASURE_INTERVAL = General.getInt("ClientPacketQueueMeasureInterval", 5);
|
||||
CLIENT_PACKET_QUEUE_MAX_AVERAGE_PACKETS_PER_SECOND = General.getInt("ClientPacketQueueMaxAveragePacketsPerSecond", 40);
|
||||
CLIENT_PACKET_QUEUE_MAX_FLOODS_PER_MIN = General.getInt("ClientPacketQueueMaxFloodsPerMin", 2);
|
||||
CLIENT_PACKET_QUEUE_MAX_OVERFLOWS_PER_MIN = General.getInt("ClientPacketQueueMaxOverflowsPerMin", 1);
|
||||
CLIENT_PACKET_QUEUE_MAX_UNDERFLOWS_PER_MIN = General.getInt("ClientPacketQueueMaxUnderflowsPerMin", 1);
|
||||
CLIENT_PACKET_QUEUE_MAX_UNKNOWN_PER_MIN = General.getInt("ClientPacketQueueMaxUnknownPerMin", 5);
|
||||
DEADLOCK_DETECTOR = General.getBoolean("DeadLockDetector", true);
|
||||
DEADLOCK_CHECK_INTERVAL = General.getInt("DeadLockCheckInterval", 20);
|
||||
RESTART_ON_DEADLOCK = General.getBoolean("RestartOnDeadlock", false);
|
||||
@@ -1917,7 +1892,7 @@ public final class Config
|
||||
LIST_PROTECTED_ITEMS.add(Integer.parseInt(id));
|
||||
}
|
||||
DATABASE_CLEAN_UP = General.getBoolean("DatabaseCleanUp", true);
|
||||
CHAR_STORE_INTERVAL = General.getInt("CharacterDataStoreInterval", 15);
|
||||
CHAR_DATA_STORE_INTERVAL = General.getInt("CharacterDataStoreInterval", 15) * 60 * 1000;
|
||||
LAZY_ITEMS_UPDATE = General.getBoolean("LazyItemsUpdate", false);
|
||||
UPDATE_ITEMS_ON_CHAR_STORE = General.getBoolean("UpdateItemsOnCharStore", false);
|
||||
DESTROY_DROPPED_PLAYER_ITEM = General.getBoolean("DestroyPlayerDroppedItem", false);
|
||||
@@ -2087,12 +2062,12 @@ public final class Config
|
||||
GAME_POINT_ITEM_ID = General.getInt("GamePointItemId", -1);
|
||||
ENABLE_FALLING_DAMAGE = General.getBoolean("EnableFallingDamage", true);
|
||||
|
||||
// Load FloodProtector L2Properties file
|
||||
// Load FloodProtector config file
|
||||
final PropertiesParser FloodProtectors = new PropertiesParser(FLOOD_PROTECTOR_CONFIG_FILE);
|
||||
|
||||
loadFloodProtectorConfigs(FloodProtectors);
|
||||
|
||||
// Load NPC L2Properties file (if exists)
|
||||
// Load NPC config file (if exists)
|
||||
final PropertiesParser NPC = new PropertiesParser(NPC_CONFIG_FILE);
|
||||
|
||||
ANNOUNCE_MAMMON_SPAWN = NPC.getBoolean("AnnounceMammonSpawn", false);
|
||||
@@ -2163,7 +2138,7 @@ public final class Config
|
||||
PET_HP_REGEN_MULTIPLIER = NPC.getDouble("PetHpRegenMultiplier", 100) / 100;
|
||||
PET_MP_REGEN_MULTIPLIER = NPC.getDouble("PetMpRegenMultiplier", 100) / 100;
|
||||
|
||||
// Load Rates L2Properties file (if exists)
|
||||
// Load Rates config file (if exists)
|
||||
final PropertiesParser RatesSettings = new PropertiesParser(RATES_CONFIG_FILE);
|
||||
|
||||
RATE_XP = RatesSettings.getFloat("RateXp", 1);
|
||||
@@ -2847,7 +2822,7 @@ public final class Config
|
||||
|
||||
L2WALKER_PROTECTION = WalkerBotProtection.getBoolean("L2WalkerProtection", false);
|
||||
|
||||
// Load PvP L2Properties file (if exists)
|
||||
// Load PvP config file (if exists)
|
||||
final PropertiesParser PVPSettings = new PropertiesParser(PVP_CONFIG_FILE);
|
||||
|
||||
KARMA_DROP_GM = PVPSettings.getBoolean("CanGMDropEquipment", false);
|
||||
@@ -2879,7 +2854,7 @@ public final class Config
|
||||
PVP_NORMAL_TIME = PVPSettings.getInt("PvPVsNormalTime", 120000);
|
||||
PVP_PVP_TIME = PVPSettings.getInt("PvPVsPvPTime", 60000);
|
||||
|
||||
// Load Olympiad L2Properties file (if exists)
|
||||
// Load Olympiad config file (if exists)
|
||||
final PropertiesParser Olympiad = new PropertiesParser(OLYMPIAD_CONFIG_FILE);
|
||||
|
||||
ALT_OLY_START_TIME = Olympiad.getInt("AltOlyStartTime", 18);
|
||||
@@ -3056,7 +3031,7 @@ public final class Config
|
||||
GAME_SERVER_LOGIN_HOST = ServerSettings.getString("LoginHostname", "127.0.0.1");
|
||||
GAME_SERVER_LOGIN_PORT = ServerSettings.getInt("LoginPort", 9013);
|
||||
|
||||
LOGIN_BIND_ADDRESS = ServerSettings.getString("LoginserverHostname", "*");
|
||||
LOGIN_BIND_ADDRESS = ServerSettings.getString("LoginserverHostname", "0.0.0.0");
|
||||
PORT_LOGIN = ServerSettings.getInt("LoginserverPort", 2106);
|
||||
|
||||
try
|
||||
@@ -3093,20 +3068,6 @@ public final class Config
|
||||
NORMAL_CONNECTION_TIME = ServerSettings.getInt("NormalConnectionTime", 700);
|
||||
FAST_CONNECTION_TIME = ServerSettings.getInt("FastConnectionTime", 350);
|
||||
MAX_CONNECTION_PER_IP = ServerSettings.getInt("MaxConnectionPerIP", 50);
|
||||
|
||||
// MMO
|
||||
final PropertiesParser mmoSettings = new PropertiesParser(MMO_CONFIG_FILE);
|
||||
|
||||
MMO_SELECTOR_SLEEP_TIME = mmoSettings.getInt("SleepTime", 20);
|
||||
MMO_MAX_SEND_PER_PASS = mmoSettings.getInt("MaxSendPerPass", 12);
|
||||
MMO_MAX_READ_PER_PASS = mmoSettings.getInt("MaxReadPerPass", 12);
|
||||
MMO_HELPER_BUFFER_COUNT = mmoSettings.getInt("HelperBufferCount", 20);
|
||||
MMO_TCP_NODELAY = mmoSettings.getBoolean("TcpNoDelay", false);
|
||||
|
||||
// Load Telnet L2Properties file (if exists)
|
||||
final PropertiesParser telnetSettings = new PropertiesParser(TELNET_CONFIG_FILE);
|
||||
|
||||
IS_TELNET_ENABLED = telnetSettings.getBoolean("EnableTelnet", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3115,7 +3076,7 @@ public final class Config
|
||||
}
|
||||
|
||||
/**
|
||||
* Save hexadecimal ID of the server in the L2Properties file.<br>
|
||||
* Save hexadecimal ID of the server in the config file.<br>
|
||||
* Check {@link #HEXID_FILE}.
|
||||
* @param serverId the ID of the server whose hexId to save
|
||||
* @param hexId the hexadecimal ID to store
|
||||
@@ -3126,10 +3087,10 @@ public final class Config
|
||||
}
|
||||
|
||||
/**
|
||||
* Save hexadecimal ID of the server in the L2Properties file.
|
||||
* Save hexadecimal ID of the server in the config file.
|
||||
* @param serverId the ID of the server whose hexId to save
|
||||
* @param hexId the hexadecimal ID to store
|
||||
* @param fileName name of the L2Properties file
|
||||
* @param fileName name of the config file
|
||||
*/
|
||||
public static void saveHexid(int serverId, String hexId, String fileName)
|
||||
{
|
||||
|
@@ -1,283 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.mmocore;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.CancelledKeyException;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.WritableByteChannel;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
* @param <T>
|
||||
*/
|
||||
public class MMOConnection<T extends MMOClient<?>>
|
||||
{
|
||||
private final SelectorThread<T> _selectorThread;
|
||||
|
||||
private final Socket _socket;
|
||||
|
||||
private final InetAddress _address;
|
||||
|
||||
private final ReadableByteChannel _readableByteChannel;
|
||||
|
||||
private final WritableByteChannel _writableByteChannel;
|
||||
|
||||
private final int _port;
|
||||
|
||||
private final NioNetStackList<SendablePacket<T>> _sendQueue;
|
||||
|
||||
private final SelectionKey _selectionKey;
|
||||
|
||||
private ByteBuffer _readBuffer;
|
||||
|
||||
private ByteBuffer _primaryWriteBuffer;
|
||||
|
||||
private ByteBuffer _secondaryWriteBuffer;
|
||||
|
||||
private volatile boolean _pendingClose;
|
||||
|
||||
private T _client;
|
||||
|
||||
public MMOConnection(SelectorThread<T> selectorThread, Socket socket, SelectionKey key, boolean tcpNoDelay)
|
||||
{
|
||||
_selectorThread = selectorThread;
|
||||
_socket = socket;
|
||||
_address = socket.getInetAddress();
|
||||
_readableByteChannel = socket.getChannel();
|
||||
_writableByteChannel = socket.getChannel();
|
||||
_port = socket.getPort();
|
||||
_selectionKey = key;
|
||||
|
||||
_sendQueue = new NioNetStackList<>();
|
||||
|
||||
try
|
||||
{
|
||||
_socket.setTcpNoDelay(tcpNoDelay);
|
||||
}
|
||||
catch (SocketException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
final void setClient(T client)
|
||||
{
|
||||
_client = client;
|
||||
}
|
||||
|
||||
public final T getClient()
|
||||
{
|
||||
return _client;
|
||||
}
|
||||
|
||||
public final void sendPacket(SendablePacket<T> sp)
|
||||
{
|
||||
sp._client = _client;
|
||||
|
||||
if (_pendingClose)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (getSendQueue())
|
||||
{
|
||||
_sendQueue.addLast(sp);
|
||||
}
|
||||
|
||||
if (!_sendQueue.isEmpty())
|
||||
{
|
||||
try
|
||||
{
|
||||
_selectionKey.interestOps(_selectionKey.interestOps() | SelectionKey.OP_WRITE);
|
||||
}
|
||||
catch (CancelledKeyException e)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final SelectionKey getSelectionKey()
|
||||
{
|
||||
return _selectionKey;
|
||||
}
|
||||
|
||||
public final InetAddress getInetAddress()
|
||||
{
|
||||
return _address;
|
||||
}
|
||||
|
||||
public final int getPort()
|
||||
{
|
||||
return _port;
|
||||
}
|
||||
|
||||
final void close() throws IOException
|
||||
{
|
||||
_socket.close();
|
||||
}
|
||||
|
||||
final int read(ByteBuffer buf) throws IOException
|
||||
{
|
||||
return _readableByteChannel.read(buf);
|
||||
}
|
||||
|
||||
final int write(ByteBuffer buf) throws IOException
|
||||
{
|
||||
return _writableByteChannel.write(buf);
|
||||
}
|
||||
|
||||
final void createWriteBuffer(ByteBuffer buf)
|
||||
{
|
||||
if (_primaryWriteBuffer == null)
|
||||
{
|
||||
_primaryWriteBuffer = _selectorThread.getPooledBuffer();
|
||||
_primaryWriteBuffer.put(buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
final ByteBuffer temp = _selectorThread.getPooledBuffer();
|
||||
temp.put(buf);
|
||||
|
||||
final int remaining = temp.remaining();
|
||||
_primaryWriteBuffer.flip();
|
||||
final int limit = _primaryWriteBuffer.limit();
|
||||
|
||||
if (remaining >= _primaryWriteBuffer.remaining())
|
||||
{
|
||||
temp.put(_primaryWriteBuffer);
|
||||
_selectorThread.recycleBuffer(_primaryWriteBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
_primaryWriteBuffer.limit(remaining);
|
||||
temp.put(_primaryWriteBuffer);
|
||||
_primaryWriteBuffer.limit(limit);
|
||||
_primaryWriteBuffer.compact();
|
||||
_secondaryWriteBuffer = _primaryWriteBuffer;
|
||||
}
|
||||
_primaryWriteBuffer = temp;
|
||||
}
|
||||
}
|
||||
|
||||
final boolean hasPendingWriteBuffer()
|
||||
{
|
||||
return _primaryWriteBuffer != null;
|
||||
}
|
||||
|
||||
final void movePendingWriteBufferTo(ByteBuffer dest)
|
||||
{
|
||||
_primaryWriteBuffer.flip();
|
||||
dest.put(_primaryWriteBuffer);
|
||||
_selectorThread.recycleBuffer(_primaryWriteBuffer);
|
||||
_primaryWriteBuffer = _secondaryWriteBuffer;
|
||||
_secondaryWriteBuffer = null;
|
||||
}
|
||||
|
||||
final void setReadBuffer(ByteBuffer buf)
|
||||
{
|
||||
_readBuffer = buf;
|
||||
}
|
||||
|
||||
final ByteBuffer getReadBuffer()
|
||||
{
|
||||
return _readBuffer;
|
||||
}
|
||||
|
||||
public final boolean isClosed()
|
||||
{
|
||||
return _pendingClose;
|
||||
}
|
||||
|
||||
final NioNetStackList<SendablePacket<T>> getSendQueue()
|
||||
{
|
||||
return _sendQueue;
|
||||
}
|
||||
|
||||
/*
|
||||
* final SendablePacket<T> getClosePacket() { return _closePacket; }
|
||||
*/
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public final void close(SendablePacket<T> sp)
|
||||
{
|
||||
close(new SendablePacket[]
|
||||
{
|
||||
sp
|
||||
});
|
||||
}
|
||||
|
||||
public final void close(SendablePacket<T>[] closeList)
|
||||
{
|
||||
if (_pendingClose)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (getSendQueue())
|
||||
{
|
||||
if (!_pendingClose)
|
||||
{
|
||||
_pendingClose = true;
|
||||
_sendQueue.clear();
|
||||
for (SendablePacket<T> sp : closeList)
|
||||
{
|
||||
_sendQueue.addLast(sp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_selectionKey.interestOps(_selectionKey.interestOps() & ~SelectionKey.OP_WRITE);
|
||||
}
|
||||
catch (CancelledKeyException e)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
// _closePacket = sp;
|
||||
_selectorThread.closeConnection(this);
|
||||
}
|
||||
|
||||
final void releaseBuffers()
|
||||
{
|
||||
if (_primaryWriteBuffer != null)
|
||||
{
|
||||
_selectorThread.recycleBuffer(_primaryWriteBuffer);
|
||||
_primaryWriteBuffer = null;
|
||||
|
||||
if (_secondaryWriteBuffer != null)
|
||||
{
|
||||
_selectorThread.recycleBuffer(_secondaryWriteBuffer);
|
||||
_secondaryWriteBuffer = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (_readBuffer != null)
|
||||
{
|
||||
_selectorThread.recycleBuffer(_readBuffer);
|
||||
_readBuffer = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.mmocore;
|
||||
|
||||
/**
|
||||
* @author Forsaiken
|
||||
* @param <E>
|
||||
*/
|
||||
public final class NioNetStackList<E>
|
||||
{
|
||||
private final NioNetStackNode _start = new NioNetStackNode();
|
||||
|
||||
private final NioNetStackNodeBuf _buf = new NioNetStackNodeBuf();
|
||||
|
||||
private NioNetStackNode _end = new NioNetStackNode();
|
||||
|
||||
public NioNetStackList()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
public final void addLast(E elem)
|
||||
{
|
||||
final NioNetStackNode newEndNode = _buf.removeFirst();
|
||||
_end._value = elem;
|
||||
_end._next = newEndNode;
|
||||
_end = newEndNode;
|
||||
}
|
||||
|
||||
public final E removeFirst()
|
||||
{
|
||||
final NioNetStackNode old = _start._next;
|
||||
final E value = old._value;
|
||||
_start._next = old._next;
|
||||
_buf.addLast(old);
|
||||
return value;
|
||||
}
|
||||
|
||||
public final boolean isEmpty()
|
||||
{
|
||||
return _start._next == _end;
|
||||
}
|
||||
|
||||
public final void clear()
|
||||
{
|
||||
_start._next = _end;
|
||||
}
|
||||
|
||||
protected final class NioNetStackNode
|
||||
{
|
||||
protected NioNetStackNode _next;
|
||||
|
||||
protected E _value;
|
||||
}
|
||||
|
||||
private final class NioNetStackNodeBuf
|
||||
{
|
||||
private final NioNetStackNode _start = new NioNetStackNode();
|
||||
|
||||
private NioNetStackNode _end = new NioNetStackNode();
|
||||
|
||||
NioNetStackNodeBuf()
|
||||
{
|
||||
_start._next = _end;
|
||||
}
|
||||
|
||||
final void addLast(NioNetStackNode node)
|
||||
{
|
||||
node._next = null;
|
||||
node._value = null;
|
||||
_end._next = node;
|
||||
_end = node;
|
||||
}
|
||||
|
||||
final NioNetStackNode removeFirst()
|
||||
{
|
||||
if (_start._next == _end)
|
||||
{
|
||||
return new NioNetStackNode();
|
||||
}
|
||||
|
||||
final NioNetStackNode old = _start._next;
|
||||
_start._next = old._next;
|
||||
return old;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,139 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.mmocore;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class ReceivablePacket<T extends MMOClient<?>>extends AbstractPacket<T> implements Runnable
|
||||
{
|
||||
NioNetStringBuffer _sbuf;
|
||||
|
||||
protected ReceivablePacket()
|
||||
{
|
||||
}
|
||||
|
||||
protected abstract boolean read();
|
||||
|
||||
@Override
|
||||
public abstract void run();
|
||||
|
||||
/**
|
||||
* Reads <B>byte[]</B> from the buffer. <BR>
|
||||
* Reads as many bytes as the length of the array.
|
||||
* @param dst : the byte array which will be filled with the data.
|
||||
*/
|
||||
protected final void readB(byte[] dst)
|
||||
{
|
||||
_buf.get(dst);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <B>byte[]</B> from the buffer. <BR>
|
||||
* Reads as many bytes as the given length (len). Starts to fill the byte array from the given offset to <B>offset</B> + <B>len</B>.
|
||||
* @param dst : the byte array which will be filled with the data.
|
||||
* @param offset : starts to fill the byte array from the given offset.
|
||||
* @param len : the given length of bytes to be read.
|
||||
*/
|
||||
protected final void readB(byte[] dst, int offset, int len)
|
||||
{
|
||||
_buf.get(dst, offset, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <B>byte</B> from the buffer. <BR>
|
||||
* 8bit integer (00)
|
||||
* @return
|
||||
*/
|
||||
protected final int readC()
|
||||
{
|
||||
return _buf.get() & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <B>short</B> from the buffer. <BR>
|
||||
* 16bit integer (00 00)
|
||||
* @return
|
||||
*/
|
||||
protected final int readH()
|
||||
{
|
||||
return _buf.getShort() & 0xFFFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <B>int</B> from the buffer. <BR>
|
||||
* 32bit integer (00 00 00 00)
|
||||
* @return
|
||||
*/
|
||||
protected final int readD()
|
||||
{
|
||||
return _buf.getInt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <B>long</B> from the buffer. <BR>
|
||||
* 64bit integer (00 00 00 00 00 00 00 00)
|
||||
* @return
|
||||
*/
|
||||
protected final long readQ()
|
||||
{
|
||||
return _buf.getLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <B>double</B> from the buffer. <BR>
|
||||
* 64bit double precision float (00 00 00 00 00 00 00 00)
|
||||
* @return
|
||||
*/
|
||||
protected final double readF()
|
||||
{
|
||||
return _buf.getDouble();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <B>String</B> from the buffer.
|
||||
* @return
|
||||
*/
|
||||
protected final String readS()
|
||||
{
|
||||
_sbuf.clear();
|
||||
|
||||
char ch;
|
||||
while ((ch = _buf.getChar()) != 0)
|
||||
{
|
||||
_sbuf.append(ch);
|
||||
}
|
||||
|
||||
return _sbuf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* packet forge purpose
|
||||
* @param data
|
||||
* @param client
|
||||
* @param sBuffer
|
||||
*/
|
||||
public void setBuffers(ByteBuffer data, T client, NioNetStringBuffer sBuffer)
|
||||
{
|
||||
_buf = data;
|
||||
_client = client;
|
||||
_sbuf = sBuffer;
|
||||
}
|
||||
}
|
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.mmocore;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
*/
|
||||
public final class SelectorConfig
|
||||
{
|
||||
public int READ_BUFFER_SIZE = 64 * 1024;
|
||||
|
||||
public int WRITE_BUFFER_SIZE = 64 * 1024;
|
||||
|
||||
public int HELPER_BUFFER_COUNT = 20;
|
||||
|
||||
public int HELPER_BUFFER_SIZE = 64 * 1024;
|
||||
|
||||
/**
|
||||
* Server will try to send MAX_SEND_PER_PASS packets per socket write call<br>
|
||||
* however it may send less if the write buffer was filled before achieving this value.
|
||||
*/
|
||||
public int MAX_SEND_PER_PASS = 10;
|
||||
|
||||
/**
|
||||
* Server will try to read MAX_READ_PER_PASS packets per socket read call<br>
|
||||
* however it may read less if the read buffer was empty before achieving this value.
|
||||
*/
|
||||
public int MAX_READ_PER_PASS = 10;
|
||||
|
||||
/**
|
||||
* Defines how much time (in milis) should the selector sleep, an higher value increases throughput but also increases latency(to a max of the sleep value itself).<BR>
|
||||
* Also an extremely high value(usually > 100) will decrease throughput due to the server not doing enough sends per second (depends on max sends per pass).<BR>
|
||||
* <BR>
|
||||
* Recommended values:<BR>
|
||||
* 1 for minimal latency.<BR>
|
||||
* 10-30 for an latency/troughput trade-off based on your needs.<BR>
|
||||
*/
|
||||
public int SLEEP_TIME = 10;
|
||||
|
||||
/**
|
||||
* Used to enable/disable TCP_NODELAY which disable/enable Nagle's algorithm.<BR>
|
||||
* <BR>
|
||||
* Nagle's algorithm try to conserve bandwidth by minimizing the number of segments that are sent. When applications wish to decrease network latency and increase performance, they can disable Nagle's algorithm (that is enable TCP_NODELAY). Data will be sent earlier, at the cost of an increase
|
||||
* in bandwidth consumption. The Nagle's algorithm is described in RFC 896.<BR>
|
||||
* <BR>
|
||||
* Summary, data will be sent earlier, thus lowering the ping, at the cost of a small increase in bandwidth consumption.
|
||||
*/
|
||||
public boolean TCP_NODELAY = true;
|
||||
}
|
@@ -1,714 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.mmocore;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.Selector;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
* Parts of design based on network core from WoodenGil
|
||||
* @param <T>
|
||||
* @author KenM
|
||||
*/
|
||||
public final class SelectorThread<T extends MMOClient<?>>extends Thread
|
||||
{
|
||||
// default BYTE_ORDER
|
||||
private static final ByteOrder BYTE_ORDER = ByteOrder.LITTLE_ENDIAN;
|
||||
// default HEADER_SIZE
|
||||
private static final int HEADER_SIZE = 2;
|
||||
// Selector
|
||||
private final Selector _selector;
|
||||
// Implementations
|
||||
private final IPacketHandler<T> _packetHandler;
|
||||
private final IMMOExecutor<T> _executor;
|
||||
private final IClientFactory<T> _clientFactory;
|
||||
private final IAcceptFilter _acceptFilter;
|
||||
// Configurations
|
||||
private final int HELPER_BUFFER_SIZE;
|
||||
private final int HELPER_BUFFER_COUNT;
|
||||
private final int MAX_SEND_PER_PASS;
|
||||
private final int MAX_READ_PER_PASS;
|
||||
private final long SLEEP_TIME;
|
||||
public boolean TCP_NODELAY;
|
||||
// Main Buffers
|
||||
private final ByteBuffer DIRECT_WRITE_BUFFER;
|
||||
private final ByteBuffer WRITE_BUFFER;
|
||||
private final ByteBuffer READ_BUFFER;
|
||||
// String Buffer
|
||||
private final NioNetStringBuffer STRING_BUFFER;
|
||||
// ByteBuffers General Purpose Pool
|
||||
private final LinkedList<ByteBuffer> _bufferPool;
|
||||
// Pending Close
|
||||
private final NioNetStackList<MMOConnection<T>> _pendingClose;
|
||||
|
||||
private boolean _shutdown;
|
||||
|
||||
public SelectorThread(SelectorConfig sc, IMMOExecutor<T> executor, IPacketHandler<T> packetHandler, IClientFactory<T> clientFactory, IAcceptFilter acceptFilter) throws IOException
|
||||
{
|
||||
super.setName("SelectorThread-" + super.getId());
|
||||
|
||||
HELPER_BUFFER_SIZE = sc.HELPER_BUFFER_SIZE;
|
||||
HELPER_BUFFER_COUNT = sc.HELPER_BUFFER_COUNT;
|
||||
MAX_SEND_PER_PASS = sc.MAX_SEND_PER_PASS;
|
||||
MAX_READ_PER_PASS = sc.MAX_READ_PER_PASS;
|
||||
SLEEP_TIME = sc.SLEEP_TIME;
|
||||
TCP_NODELAY = sc.TCP_NODELAY;
|
||||
|
||||
DIRECT_WRITE_BUFFER = ByteBuffer.allocateDirect(sc.WRITE_BUFFER_SIZE).order(BYTE_ORDER);
|
||||
WRITE_BUFFER = ByteBuffer.wrap(new byte[sc.WRITE_BUFFER_SIZE]).order(BYTE_ORDER);
|
||||
READ_BUFFER = ByteBuffer.wrap(new byte[sc.READ_BUFFER_SIZE]).order(BYTE_ORDER);
|
||||
|
||||
STRING_BUFFER = new NioNetStringBuffer(64 * 1024);
|
||||
|
||||
_pendingClose = new NioNetStackList<>();
|
||||
_bufferPool = new LinkedList<>();
|
||||
|
||||
for (int i = 0; i < HELPER_BUFFER_COUNT; i++)
|
||||
{
|
||||
_bufferPool.addLast(ByteBuffer.wrap(new byte[HELPER_BUFFER_SIZE]).order(BYTE_ORDER));
|
||||
}
|
||||
|
||||
_acceptFilter = acceptFilter;
|
||||
_packetHandler = packetHandler;
|
||||
_clientFactory = clientFactory;
|
||||
_executor = executor;
|
||||
_selector = Selector.open();
|
||||
}
|
||||
|
||||
public final void openServerSocket(InetAddress address, int tcpPort) throws IOException
|
||||
{
|
||||
final ServerSocketChannel selectable = ServerSocketChannel.open();
|
||||
selectable.configureBlocking(false);
|
||||
|
||||
final ServerSocket ss = selectable.socket();
|
||||
|
||||
if (address != null)
|
||||
{
|
||||
ss.bind(new InetSocketAddress(address, tcpPort));
|
||||
}
|
||||
else
|
||||
{
|
||||
ss.bind(new InetSocketAddress(tcpPort));
|
||||
}
|
||||
|
||||
selectable.register(_selector, SelectionKey.OP_ACCEPT);
|
||||
}
|
||||
|
||||
final ByteBuffer getPooledBuffer()
|
||||
{
|
||||
if (_bufferPool.isEmpty())
|
||||
{
|
||||
return ByteBuffer.wrap(new byte[HELPER_BUFFER_SIZE]).order(BYTE_ORDER);
|
||||
}
|
||||
|
||||
return _bufferPool.removeFirst();
|
||||
}
|
||||
|
||||
final void recycleBuffer(ByteBuffer buf)
|
||||
{
|
||||
if (_bufferPool.size() < HELPER_BUFFER_COUNT)
|
||||
{
|
||||
buf.clear();
|
||||
_bufferPool.addLast(buf);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public final void run()
|
||||
{
|
||||
int selectedKeysCount = 0;
|
||||
|
||||
SelectionKey key;
|
||||
MMOConnection<T> con;
|
||||
|
||||
Iterator<SelectionKey> selectedKeys;
|
||||
|
||||
while (!_shutdown)
|
||||
{
|
||||
try
|
||||
{
|
||||
selectedKeysCount = _selector.selectNow();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (selectedKeysCount > 0)
|
||||
{
|
||||
selectedKeys = _selector.selectedKeys().iterator();
|
||||
|
||||
while (selectedKeys.hasNext())
|
||||
{
|
||||
key = selectedKeys.next();
|
||||
selectedKeys.remove();
|
||||
|
||||
con = (MMOConnection<T>) key.attachment();
|
||||
|
||||
switch (key.readyOps())
|
||||
{
|
||||
case SelectionKey.OP_CONNECT:
|
||||
{
|
||||
finishConnection(key, con);
|
||||
break;
|
||||
}
|
||||
case SelectionKey.OP_ACCEPT:
|
||||
{
|
||||
acceptConnection(key, con);
|
||||
break;
|
||||
}
|
||||
case SelectionKey.OP_READ:
|
||||
{
|
||||
readPacket(key, con);
|
||||
break;
|
||||
}
|
||||
case SelectionKey.OP_WRITE:
|
||||
{
|
||||
writePacket(key, con);
|
||||
break;
|
||||
}
|
||||
case SelectionKey.OP_READ | SelectionKey.OP_WRITE:
|
||||
{
|
||||
writePacket(key, con);
|
||||
if (key.isValid())
|
||||
{
|
||||
readPacket(key, con);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
synchronized (_pendingClose)
|
||||
{
|
||||
while (!_pendingClose.isEmpty())
|
||||
{
|
||||
try
|
||||
{
|
||||
con = _pendingClose.removeFirst();
|
||||
writeClosePacket(con);
|
||||
closeConnectionImpl(con.getSelectionKey(), con);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Thread.sleep(SLEEP_TIME);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
closeSelectorThread();
|
||||
}
|
||||
|
||||
private final void finishConnection(SelectionKey key, MMOConnection<T> con)
|
||||
{
|
||||
try
|
||||
{
|
||||
((SocketChannel) key.channel()).finishConnect();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
con.getClient().onForcedDisconnection();
|
||||
closeConnectionImpl(key, con);
|
||||
}
|
||||
|
||||
// key might have been invalidated on finishConnect()
|
||||
if (key.isValid())
|
||||
{
|
||||
key.interestOps(key.interestOps() | SelectionKey.OP_READ);
|
||||
key.interestOps(key.interestOps() & ~SelectionKey.OP_CONNECT);
|
||||
}
|
||||
}
|
||||
|
||||
private final void acceptConnection(SelectionKey key, MMOConnection<T> con)
|
||||
{
|
||||
final ServerSocketChannel ssc = (ServerSocketChannel) key.channel();
|
||||
SocketChannel sc;
|
||||
|
||||
try
|
||||
{
|
||||
while ((sc = ssc.accept()) != null)
|
||||
{
|
||||
if ((_acceptFilter == null) || _acceptFilter.accept(sc))
|
||||
{
|
||||
sc.configureBlocking(false);
|
||||
final SelectionKey clientKey = sc.register(_selector, SelectionKey.OP_READ);
|
||||
con = new MMOConnection<>(this, sc.socket(), clientKey, TCP_NODELAY);
|
||||
con.setClient(_clientFactory.create(con));
|
||||
clientKey.attach(con);
|
||||
}
|
||||
else
|
||||
{
|
||||
sc.socket().close();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private final void readPacket(SelectionKey key, MMOConnection<T> con)
|
||||
{
|
||||
if (con.isClosed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
ByteBuffer buf = con.getReadBuffer();
|
||||
if (buf == null)
|
||||
{
|
||||
buf = READ_BUFFER;
|
||||
}
|
||||
|
||||
// if we try to to do a read with no space in the buffer it will read 0 bytes going into infinite loop
|
||||
if (buf.position() == buf.limit())
|
||||
{
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
int result = -2;
|
||||
|
||||
try
|
||||
{
|
||||
result = con.read(buf);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// error handling goes bellow
|
||||
}
|
||||
|
||||
if (result > 0)
|
||||
{
|
||||
buf.flip();
|
||||
|
||||
final T client = con.getClient();
|
||||
|
||||
for (int i = 0; i < MAX_READ_PER_PASS; i++)
|
||||
{
|
||||
if (!tryReadPacket(key, client, buf, con))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// only reachable if MAX_READ_PER_PASS has been reached
|
||||
// check if there are some more bytes in buffer
|
||||
// and allocate/compact to prevent content lose.
|
||||
if (buf.remaining() > 0)
|
||||
{
|
||||
// did we use the READ_BUFFER ?
|
||||
if (buf == READ_BUFFER)
|
||||
{
|
||||
// move the pending byte to the connections READ_BUFFER
|
||||
allocateReadBuffer(con);
|
||||
}
|
||||
else
|
||||
{
|
||||
// move the first byte to the beginning :)
|
||||
buf.compact();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
case 0:
|
||||
case -1:
|
||||
{
|
||||
closeConnectionImpl(key, con);
|
||||
break;
|
||||
}
|
||||
case -2:
|
||||
{
|
||||
con.getClient().onForcedDisconnection();
|
||||
closeConnectionImpl(key, con);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final boolean tryReadPacket(SelectionKey key, T client, ByteBuffer buf, MMOConnection<T> con)
|
||||
{
|
||||
switch (buf.remaining())
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
// buffer is full nothing to read
|
||||
return false;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
// we don`t have enough data for header so we need to read
|
||||
key.interestOps(key.interestOps() | SelectionKey.OP_READ);
|
||||
|
||||
// did we use the READ_BUFFER ?
|
||||
if (buf == READ_BUFFER)
|
||||
{
|
||||
// move the pending byte to the connections READ_BUFFER
|
||||
allocateReadBuffer(con);
|
||||
}
|
||||
else
|
||||
{
|
||||
// move the first byte to the beginning :)
|
||||
buf.compact();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// data size excluding header size :>
|
||||
final int dataPending = (buf.getShort() & 0xFFFF) - HEADER_SIZE;
|
||||
|
||||
// do we got enough bytes for the packet?
|
||||
if (dataPending <= buf.remaining())
|
||||
{
|
||||
// avoid parsing dummy packets (packets without body)
|
||||
if (dataPending > 0)
|
||||
{
|
||||
final int pos = buf.position();
|
||||
parseClientPacket(pos, buf, dataPending, client);
|
||||
buf.position(pos + dataPending);
|
||||
}
|
||||
|
||||
if (buf.hasRemaining())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (buf != READ_BUFFER)
|
||||
{
|
||||
con.setReadBuffer(null);
|
||||
recycleBuffer(buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
READ_BUFFER.clear();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// we don`t have enough bytes for the dataPacket so we need to read
|
||||
key.interestOps(key.interestOps() | SelectionKey.OP_READ);
|
||||
|
||||
// move it`s position
|
||||
buf.position(buf.position() - HEADER_SIZE);
|
||||
// did we use the READ_BUFFER ?
|
||||
if (buf == READ_BUFFER)
|
||||
{
|
||||
// move the pending byte to the connections READ_BUFFER
|
||||
allocateReadBuffer(con);
|
||||
}
|
||||
else
|
||||
{
|
||||
buf.compact();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final void allocateReadBuffer(MMOConnection<T> con)
|
||||
{
|
||||
con.setReadBuffer(getPooledBuffer().put(READ_BUFFER));
|
||||
READ_BUFFER.clear();
|
||||
}
|
||||
|
||||
private final void parseClientPacket(int pos, ByteBuffer buf, int dataSize, T client)
|
||||
{
|
||||
if (!client.decrypt(buf, dataSize) || !buf.hasRemaining())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// apply limit
|
||||
final int limit = buf.limit();
|
||||
buf.limit(pos + dataSize);
|
||||
final ReceivablePacket<T> cp = _packetHandler.handlePacket(buf, client);
|
||||
|
||||
if (cp != null)
|
||||
{
|
||||
cp._buf = buf;
|
||||
cp._sbuf = STRING_BUFFER;
|
||||
cp._client = client;
|
||||
|
||||
if (cp.read())
|
||||
{
|
||||
_executor.execute(cp);
|
||||
}
|
||||
|
||||
cp._buf = null;
|
||||
cp._sbuf = null;
|
||||
}
|
||||
buf.limit(limit);
|
||||
}
|
||||
|
||||
private final void writeClosePacket(MMOConnection<T> con)
|
||||
{
|
||||
SendablePacket<T> sp;
|
||||
synchronized (con.getSendQueue())
|
||||
{
|
||||
if (con.getSendQueue().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while ((sp = con.getSendQueue().removeFirst()) != null)
|
||||
{
|
||||
WRITE_BUFFER.clear();
|
||||
|
||||
putPacketIntoWriteBuffer(con.getClient(), sp);
|
||||
|
||||
WRITE_BUFFER.flip();
|
||||
|
||||
try
|
||||
{
|
||||
con.write(WRITE_BUFFER);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// error handling goes on the if bellow
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected final void writePacket(SelectionKey key, MMOConnection<T> con)
|
||||
{
|
||||
if (!prepareWriteBuffer(con))
|
||||
{
|
||||
key.interestOps(key.interestOps() & ~SelectionKey.OP_WRITE);
|
||||
return;
|
||||
}
|
||||
|
||||
DIRECT_WRITE_BUFFER.flip();
|
||||
|
||||
final int size = DIRECT_WRITE_BUFFER.remaining();
|
||||
|
||||
int result = -1;
|
||||
|
||||
try
|
||||
{
|
||||
result = con.write(DIRECT_WRITE_BUFFER);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// error handling goes on the if bellow
|
||||
}
|
||||
|
||||
// check if no error happened
|
||||
if (result >= 0)
|
||||
{
|
||||
// check if we written everything
|
||||
if (result == size)
|
||||
{
|
||||
// complete write
|
||||
synchronized (con.getSendQueue())
|
||||
{
|
||||
if (con.getSendQueue().isEmpty() && !con.hasPendingWriteBuffer())
|
||||
{
|
||||
key.interestOps(key.interestOps() & ~SelectionKey.OP_WRITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// incomplete write
|
||||
con.createWriteBuffer(DIRECT_WRITE_BUFFER);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
con.getClient().onForcedDisconnection();
|
||||
closeConnectionImpl(key, con);
|
||||
}
|
||||
}
|
||||
|
||||
private final boolean prepareWriteBuffer(MMOConnection<T> con)
|
||||
{
|
||||
boolean hasPending = false;
|
||||
DIRECT_WRITE_BUFFER.clear();
|
||||
|
||||
// if there is pending content add it
|
||||
if (con.hasPendingWriteBuffer())
|
||||
{
|
||||
con.movePendingWriteBufferTo(DIRECT_WRITE_BUFFER);
|
||||
hasPending = true;
|
||||
}
|
||||
|
||||
if ((DIRECT_WRITE_BUFFER.remaining() > 1) && !con.hasPendingWriteBuffer())
|
||||
{
|
||||
final NioNetStackList<SendablePacket<T>> sendQueue = con.getSendQueue();
|
||||
final T client = con.getClient();
|
||||
SendablePacket<T> sp;
|
||||
|
||||
for (int i = 0; i < MAX_SEND_PER_PASS; i++)
|
||||
{
|
||||
synchronized (con.getSendQueue())
|
||||
{
|
||||
if (sendQueue.isEmpty())
|
||||
{
|
||||
sp = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
sp = sendQueue.removeFirst();
|
||||
}
|
||||
}
|
||||
|
||||
if (sp == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
hasPending = true;
|
||||
|
||||
// put into WriteBuffer
|
||||
putPacketIntoWriteBuffer(client, sp);
|
||||
|
||||
WRITE_BUFFER.flip();
|
||||
|
||||
if (DIRECT_WRITE_BUFFER.remaining() < WRITE_BUFFER.limit())
|
||||
{
|
||||
con.createWriteBuffer(WRITE_BUFFER);
|
||||
break;
|
||||
}
|
||||
DIRECT_WRITE_BUFFER.put(WRITE_BUFFER);
|
||||
}
|
||||
}
|
||||
return hasPending;
|
||||
}
|
||||
|
||||
private final void putPacketIntoWriteBuffer(T client, SendablePacket<T> sp)
|
||||
{
|
||||
WRITE_BUFFER.clear();
|
||||
|
||||
// reserve space for the size
|
||||
final int headerPos = WRITE_BUFFER.position();
|
||||
final int dataPos = headerPos + HEADER_SIZE;
|
||||
WRITE_BUFFER.position(dataPos);
|
||||
|
||||
// set the write buffer
|
||||
sp._buf = WRITE_BUFFER;
|
||||
// set the client.
|
||||
sp._client = client;
|
||||
// write content to buffer
|
||||
sp.write();
|
||||
// delete the write buffer
|
||||
sp._buf = null;
|
||||
|
||||
// size (inclusive header)
|
||||
int dataSize = WRITE_BUFFER.position() - dataPos;
|
||||
WRITE_BUFFER.position(dataPos);
|
||||
client.encrypt(WRITE_BUFFER, dataSize);
|
||||
|
||||
// recalculate size after encryption
|
||||
dataSize = WRITE_BUFFER.position() - dataPos;
|
||||
|
||||
WRITE_BUFFER.position(headerPos);
|
||||
// write header
|
||||
WRITE_BUFFER.putShort((short) (dataSize + HEADER_SIZE));
|
||||
WRITE_BUFFER.position(dataPos + dataSize);
|
||||
}
|
||||
|
||||
final void closeConnection(MMOConnection<T> con)
|
||||
{
|
||||
synchronized (_pendingClose)
|
||||
{
|
||||
_pendingClose.addLast(con);
|
||||
}
|
||||
}
|
||||
|
||||
private final void closeConnectionImpl(SelectionKey key, MMOConnection<T> con)
|
||||
{
|
||||
try
|
||||
{
|
||||
// notify connection
|
||||
con.getClient().onDisconnection();
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
// close socket and the SocketChannel
|
||||
con.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// ignore, we are closing anyway
|
||||
}
|
||||
finally
|
||||
{
|
||||
con.releaseBuffers();
|
||||
// clear attachment
|
||||
key.attach(null);
|
||||
// cancel key
|
||||
key.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void shutdown()
|
||||
{
|
||||
_shutdown = true;
|
||||
}
|
||||
|
||||
protected void closeSelectorThread()
|
||||
{
|
||||
for (SelectionKey key : _selector.keys())
|
||||
{
|
||||
try
|
||||
{
|
||||
key.channel().close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_selector.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,139 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.mmocore;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class SendablePacket<T extends MMOClient<?>>extends AbstractPacket<T>
|
||||
{
|
||||
protected final void putInt(int value)
|
||||
{
|
||||
_buf.putInt(value);
|
||||
}
|
||||
|
||||
protected final void putDouble(double value)
|
||||
{
|
||||
_buf.putDouble(value);
|
||||
}
|
||||
|
||||
protected final void putFloat(float value)
|
||||
{
|
||||
_buf.putFloat(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <B>byte</B> to the buffer. <BR>
|
||||
* 8bit integer (00)
|
||||
* @param data
|
||||
*/
|
||||
protected final void writeC(boolean data)
|
||||
{
|
||||
_buf.put((byte) (data ? 0x01 : 0x00));
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <B>byte</B> to the buffer. <BR>
|
||||
* 8bit integer (00)
|
||||
* @param data
|
||||
*/
|
||||
protected final void writeC(int data)
|
||||
{
|
||||
_buf.put((byte) data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <B>double</B> to the buffer. <BR>
|
||||
* 64bit double precision float (00 00 00 00 00 00 00 00)
|
||||
* @param value
|
||||
*/
|
||||
protected final void writeF(double value)
|
||||
{
|
||||
_buf.putDouble(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <B>short</B> to the buffer. <BR>
|
||||
* 16bit integer (00 00)
|
||||
* @param value
|
||||
*/
|
||||
protected final void writeH(int value)
|
||||
{
|
||||
_buf.putShort((short) value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <B>int</B> to the buffer. <BR>
|
||||
* 32bit integer (00 00 00 00)
|
||||
* @param value
|
||||
*/
|
||||
protected final void writeD(int value)
|
||||
{
|
||||
_buf.putInt(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <B>int</B> to the buffer. <BR>
|
||||
* 32bit integer (00 00 00 00)
|
||||
* @param value
|
||||
*/
|
||||
protected final void writeD(boolean value)
|
||||
{
|
||||
_buf.putInt(value ? 0x01 : 0x00);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <B>long</B> to the buffer. <BR>
|
||||
* 64bit integer (00 00 00 00 00 00 00 00)
|
||||
* @param value
|
||||
*/
|
||||
protected final void writeQ(long value)
|
||||
{
|
||||
_buf.putLong(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <B>byte[]</B> to the buffer. <BR>
|
||||
* 8bit integer array (00 ...)
|
||||
* @param data
|
||||
*/
|
||||
protected final void writeB(byte[] data)
|
||||
{
|
||||
_buf.put(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <B>String</B> to the buffer.
|
||||
* @param text
|
||||
*/
|
||||
protected final void writeS(String text)
|
||||
{
|
||||
if (text != null)
|
||||
{
|
||||
final int len = text.length();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
_buf.putChar(text.charAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
_buf.putChar('\000');
|
||||
}
|
||||
|
||||
protected abstract void write();
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.network;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class ChannelInboundHandler<T extends ChannelInboundHandler<?>>extends SimpleChannelInboundHandler<IIncomingPacket<T>>
|
||||
{
|
||||
private Channel _channel;
|
||||
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx)
|
||||
{
|
||||
_channel = ctx.channel();
|
||||
}
|
||||
|
||||
public void setConnectionState(IConnectionState connectionState)
|
||||
{
|
||||
_channel.attr(IConnectionState.ATTRIBUTE_KEY).set(connectionState);
|
||||
}
|
||||
|
||||
public IConnectionState getConnectionState()
|
||||
{
|
||||
return _channel != null ? _channel.attr(IConnectionState.ATTRIBUTE_KEY).get() : null;
|
||||
}
|
||||
}
|
@@ -14,15 +14,14 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.mmocore;
|
||||
package com.l2jmobius.commons.network;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import io.netty.util.AttributeKey;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
* @param <T>
|
||||
* @author Nos
|
||||
*/
|
||||
public interface IPacketHandler<T extends MMOClient<?>>
|
||||
public interface IConnectionState
|
||||
{
|
||||
ReceivablePacket<T> handlePacket(ByteBuffer buf, T client);
|
||||
AttributeKey<IConnectionState> ATTRIBUTE_KEY = AttributeKey.valueOf(IConnectionState.class, "");
|
||||
}
|
@@ -14,13 +14,16 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.mmocore;
|
||||
package com.l2jmobius.commons.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
* @param <T>
|
||||
* @author Nos
|
||||
*/
|
||||
public interface IClientFactory<T extends MMOClient<?>>
|
||||
public interface ICrypt
|
||||
{
|
||||
T create(MMOConnection<T> con);
|
||||
void encrypt(ByteBuf buf);
|
||||
|
||||
void decrypt(ByteBuf buf);
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.network;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
* @param <T>
|
||||
*/
|
||||
public interface IIncomingPacket<T>
|
||||
{
|
||||
/**
|
||||
* Reads a packet.
|
||||
* @param client the client
|
||||
* @param packet the packet reader
|
||||
* @return {@code true} if packet was read successfully, {@code false} otherwise.
|
||||
*/
|
||||
boolean read(T client, PacketReader packet);
|
||||
|
||||
void run(T client) throws Exception;
|
||||
}
|
@@ -14,22 +14,19 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.mmocore;
|
||||
package com.l2jmobius.commons.network;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
* @author Nos
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class AbstractPacket<T extends MMOClient<?>>
|
||||
public interface IIncomingPackets<T>extends IConnectionState
|
||||
{
|
||||
protected ByteBuffer _buf;
|
||||
int getPacketId();
|
||||
|
||||
T _client;
|
||||
IIncomingPacket<T> newIncomingPacket();
|
||||
|
||||
public final T getClient()
|
||||
{
|
||||
return _client;
|
||||
}
|
||||
Set<IConnectionState> getConnectionStates();
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.network;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
*/
|
||||
public interface IOutgoingPacket
|
||||
{
|
||||
/**
|
||||
* @param packet the packet writer
|
||||
* @return {@code true} if packet was writen successfully, {@code false} otherwise.
|
||||
*/
|
||||
boolean write(PacketWriter packet);
|
||||
}
|
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.network;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.buffer.PooledByteBufAllocator;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
*/
|
||||
public class NetworkManager
|
||||
{
|
||||
private final Logger LOGGER = Logger.getLogger(getClass().getName());
|
||||
|
||||
private final ServerBootstrap _serverBootstrap;
|
||||
private final String _host;
|
||||
private final int _port;
|
||||
|
||||
private ChannelFuture _channelFuture;
|
||||
|
||||
public NetworkManager(EventLoopGroup bossGroup, EventLoopGroup workerGroup, ChannelInitializer<SocketChannel> clientInitializer, String host, int port)
|
||||
{
|
||||
// @formatter:off
|
||||
_serverBootstrap = new ServerBootstrap()
|
||||
.group(bossGroup, workerGroup)
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.childHandler(clientInitializer)
|
||||
.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
|
||||
// @formatter:on
|
||||
_host = host;
|
||||
_port = port;
|
||||
}
|
||||
|
||||
public ChannelFuture getChannelFuture()
|
||||
{
|
||||
return _channelFuture;
|
||||
}
|
||||
|
||||
public void start() throws InterruptedException
|
||||
{
|
||||
if ((_channelFuture != null) && !_channelFuture.isDone())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_channelFuture = _serverBootstrap.bind(_host, _port).sync();
|
||||
LOGGER.info(getClass().getSimpleName() + ": Listening on " + _host + ":" + _port);
|
||||
}
|
||||
|
||||
public void stop() throws InterruptedException
|
||||
{
|
||||
_channelFuture.channel().close().sync();
|
||||
}
|
||||
}
|
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
*/
|
||||
public final class PacketReader
|
||||
{
|
||||
private final ByteBuf _buf;
|
||||
|
||||
public PacketReader(ByteBuf buf)
|
||||
{
|
||||
_buf = buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the readable bytes.
|
||||
* @return the readable bytes
|
||||
*/
|
||||
public int getReadableBytes()
|
||||
{
|
||||
return _buf.readableBytes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an unsigned byte.
|
||||
* @return the unsigned byte
|
||||
* @throws IndexOutOfBoundsException if {@code readableBytes} is less than {@code 1}
|
||||
*/
|
||||
public short readC()
|
||||
{
|
||||
return _buf.readUnsignedByte();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an unsigned short.
|
||||
* @return the unsigned short
|
||||
* @throws IndexOutOfBoundsException if {@code readableBytes} is less than {@code 2}
|
||||
*/
|
||||
public int readH()
|
||||
{
|
||||
return _buf.readUnsignedShortLE();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an integer.
|
||||
* @return the integer
|
||||
* @throws IndexOutOfBoundsException if {@code readableBytes} is less than {@code 4}
|
||||
*/
|
||||
public int readD()
|
||||
{
|
||||
return _buf.readIntLE();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a long.
|
||||
* @return the long
|
||||
* @throws IndexOutOfBoundsException if {@code readableBytes} is less than {@code 8}
|
||||
*/
|
||||
public long readQ()
|
||||
{
|
||||
return _buf.readLongLE();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a float.
|
||||
* @return the float
|
||||
* @throws IndexOutOfBoundsException if {@code readableBytes} is less than {@code 4}
|
||||
*/
|
||||
public float readE()
|
||||
{
|
||||
return Float.intBitsToFloat(_buf.readIntLE());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a double.
|
||||
* @return the double
|
||||
* @throws IndexOutOfBoundsException if {@code readableBytes} is less than {@code 8}
|
||||
*/
|
||||
public double readF()
|
||||
{
|
||||
return Double.longBitsToDouble(_buf.readLongLE());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a string.
|
||||
* @return the string
|
||||
* @throws IndexOutOfBoundsException if string {@code null} terminator is not found within {@code readableBytes}
|
||||
*/
|
||||
public String readS()
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
char chr;
|
||||
while ((chr = Character.reverseBytes(_buf.readChar())) != 0)
|
||||
{
|
||||
sb.append(chr);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a fixed length string.
|
||||
* @return the string
|
||||
* @throws IndexOutOfBoundsException if {@code readableBytes} is less than {@code 2 + String.length * 2}
|
||||
*/
|
||||
public String readString()
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
final int stringLength = _buf.readShortLE();
|
||||
if ((stringLength * 2) > getReadableBytes())
|
||||
{
|
||||
throw new IndexOutOfBoundsException("readerIndex(" + _buf.readerIndex() + ") + length(" + (stringLength * 2) + ") exceeds writerIndex(" + _buf.writerIndex() + "): " + _buf);
|
||||
}
|
||||
|
||||
for (int i = 0; i < stringLength; i++)
|
||||
{
|
||||
sb.append(Character.reverseBytes(_buf.readChar()));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a byte array.
|
||||
* @param length the length
|
||||
* @return the byte array
|
||||
* @throws IndexOutOfBoundsException if {@code readableBytes} is less than {@code length}
|
||||
*/
|
||||
public byte[] readB(int length)
|
||||
{
|
||||
final byte[] result = new byte[length];
|
||||
_buf.readBytes(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a byte array.
|
||||
* @param dst the destination
|
||||
* @param dstIndex the destination index to start writing the bytes from
|
||||
* @param length the length
|
||||
* @throws IndexOutOfBoundsException if {@code readableBytes} is less than {@code length}, if the specified dstIndex is less than 0 or if {@code dstIndex + length} is greater than {@code dst.length}
|
||||
*/
|
||||
public void readB(byte[] dst, int dstIndex, int length)
|
||||
{
|
||||
_buf.readBytes(dst, dstIndex, length);
|
||||
}
|
||||
}
|
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
*/
|
||||
public final class PacketWriter
|
||||
{
|
||||
private final ByteBuf _buf;
|
||||
|
||||
public PacketWriter(ByteBuf buf)
|
||||
{
|
||||
_buf = buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the writable bytes.
|
||||
* @return the writable bytes
|
||||
*/
|
||||
public int getWritableBytes()
|
||||
{
|
||||
return _buf.writableBytes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a byte.
|
||||
* @param value the byte (The 24 high-order bits are ignored)
|
||||
*/
|
||||
public void writeC(int value)
|
||||
{
|
||||
_buf.writeByte(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a short.
|
||||
* @param value the short (The 16 high-order bits are ignored)
|
||||
*/
|
||||
public void writeH(int value)
|
||||
{
|
||||
_buf.writeShortLE(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an integer.
|
||||
* @param value the integer
|
||||
*/
|
||||
public void writeD(int value)
|
||||
{
|
||||
_buf.writeIntLE(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a long.
|
||||
* @param value the long
|
||||
*/
|
||||
public void writeQ(long value)
|
||||
{
|
||||
_buf.writeLongLE(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a float.
|
||||
* @param value the float
|
||||
*/
|
||||
public void writeE(float value)
|
||||
{
|
||||
_buf.writeIntLE(Float.floatToIntBits(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a double.
|
||||
* @param value the double
|
||||
*/
|
||||
public void writeF(double value)
|
||||
{
|
||||
_buf.writeLongLE(Double.doubleToLongBits(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a string.
|
||||
* @param value the string
|
||||
*/
|
||||
public void writeS(String value)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
for (int i = 0; i < value.length(); i++)
|
||||
{
|
||||
_buf.writeChar(Character.reverseBytes(value.charAt(i)));
|
||||
}
|
||||
}
|
||||
|
||||
_buf.writeChar(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a string with fixed length specified as [short length, char[length] data].
|
||||
* @param value the string
|
||||
*/
|
||||
public void writeString(String value)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
_buf.writeShortLE(value.length());
|
||||
for (int i = 0; i < value.length(); i++)
|
||||
{
|
||||
_buf.writeChar(Character.reverseBytes(value.charAt(i)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_buf.writeShort(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a byte array.
|
||||
* @param bytes the byte array
|
||||
*/
|
||||
public void writeB(byte[] bytes)
|
||||
{
|
||||
_buf.writeBytes(bytes);
|
||||
}
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.network.codecs;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.commons.network.ICrypt;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.ByteToMessageCodec;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
*/
|
||||
public class CryptCodec extends ByteToMessageCodec<ByteBuf>
|
||||
{
|
||||
private final ICrypt _crypt;
|
||||
|
||||
public CryptCodec(ICrypt crypt)
|
||||
{
|
||||
super();
|
||||
_crypt = crypt;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see io.netty.handler.codec.ByteToMessageCodec#encode(io.netty.channel.ChannelHandlerContext, java.lang.Object, io.netty.buffer.ByteBuf)
|
||||
*/
|
||||
@Override
|
||||
protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out)
|
||||
{
|
||||
// Check if there are any data to encrypt.
|
||||
if (!msg.isReadable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
msg.resetReaderIndex();
|
||||
_crypt.encrypt(msg);
|
||||
msg.resetReaderIndex();
|
||||
out.writeBytes(msg);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see io.netty.handler.codec.ByteToMessageCodec#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out)
|
||||
{
|
||||
in.resetReaderIndex();
|
||||
_crypt.decrypt(in);
|
||||
in.readerIndex(in.writerIndex());
|
||||
out.add(in.copy(0, in.writerIndex()));
|
||||
}
|
||||
}
|
@@ -14,48 +14,28 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.mmocore;
|
||||
package com.l2jmobius.commons.network.codecs;
|
||||
|
||||
import java.nio.BufferOverflowException;
|
||||
import java.util.List;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToMessageEncoder;
|
||||
|
||||
/**
|
||||
* @author Forsaiken
|
||||
* @author Nos
|
||||
*/
|
||||
public final class NioNetStringBuffer
|
||||
@Sharable
|
||||
public class LengthFieldBasedFrameEncoder extends MessageToMessageEncoder<ByteBuf>
|
||||
{
|
||||
private final char[] _buf;
|
||||
|
||||
private final int _size;
|
||||
|
||||
private int _len;
|
||||
|
||||
public NioNetStringBuffer(int size)
|
||||
{
|
||||
_buf = new char[size];
|
||||
_size = size;
|
||||
_len = 0;
|
||||
}
|
||||
|
||||
public final void clear()
|
||||
{
|
||||
_len = 0;
|
||||
}
|
||||
|
||||
public final void append(char c)
|
||||
{
|
||||
if (_len < _size)
|
||||
{
|
||||
_buf[_len++] = c;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BufferOverflowException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString()
|
||||
protected void encode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out)
|
||||
{
|
||||
return new String(_buf, 0, _len);
|
||||
final ByteBuf buf = ctx.alloc().buffer(2);
|
||||
final short length = (short) (msg.readableBytes() + 2);
|
||||
buf.writeShortLE(length);
|
||||
out.add(buf);
|
||||
out.add(msg.retain());
|
||||
}
|
||||
}
|
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.network.codecs;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.network.IConnectionState;
|
||||
import com.l2jmobius.commons.network.IIncomingPacket;
|
||||
import com.l2jmobius.commons.network.IIncomingPackets;
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
* @param <T>
|
||||
*/
|
||||
public class PacketDecoder<T>extends ByteToMessageDecoder
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(PacketDecoder.class.getName());
|
||||
|
||||
private final IIncomingPackets<T>[] _incomingPackets;
|
||||
private final T _client;
|
||||
|
||||
public PacketDecoder(IIncomingPackets<T>[] incomingPackets, T client)
|
||||
{
|
||||
_incomingPackets = incomingPackets;
|
||||
_client = client;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out)
|
||||
{
|
||||
if ((in == null) || !in.isReadable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final short packetId = in.readUnsignedByte();
|
||||
if (packetId >= _incomingPackets.length)
|
||||
{
|
||||
LOGGER.finer("Unknown packet: " + Integer.toHexString(packetId));
|
||||
return;
|
||||
}
|
||||
|
||||
final IIncomingPackets<T> incomingPacket = _incomingPackets[packetId];
|
||||
if (incomingPacket == null)
|
||||
{
|
||||
LOGGER.finer("Unknown packet: " + Integer.toHexString(packetId));
|
||||
return;
|
||||
}
|
||||
|
||||
final IConnectionState connectionState = ctx.channel().attr(IConnectionState.ATTRIBUTE_KEY).get();
|
||||
if ((connectionState == null) || !incomingPacket.getConnectionStates().contains(connectionState))
|
||||
{
|
||||
// LOGGER.warning(incomingPacket + ": Connection at invalid state: " + connectionState + " Required States: " + incomingPacket.getConnectionStates());
|
||||
return;
|
||||
}
|
||||
|
||||
final IIncomingPacket<T> packet = incomingPacket.newIncomingPacket();
|
||||
if ((packet != null) && packet.read(_client, new PacketReader(in)))
|
||||
{
|
||||
out.add(packet);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
// We always consider that we read whole packet.
|
||||
in.readerIndex(in.writerIndex());
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.network.codecs;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.network.IOutgoingPacket;
|
||||
import com.l2jmobius.commons.network.PacketWriter;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
*/
|
||||
@Sharable
|
||||
public class PacketEncoder extends MessageToByteEncoder<IOutgoingPacket>
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(PacketEncoder.class.getName());
|
||||
|
||||
private final int _maxPacketSize;
|
||||
|
||||
public PacketEncoder(int maxPacketSize)
|
||||
{
|
||||
super();
|
||||
_maxPacketSize = maxPacketSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void encode(ChannelHandlerContext ctx, IOutgoingPacket packet, ByteBuf out)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (packet.write(new PacketWriter(out)))
|
||||
{
|
||||
if (out.writerIndex() > _maxPacketSize)
|
||||
{
|
||||
throw new IllegalStateException("Packet (" + packet + ") size (" + out.writerIndex() + ") is bigger than the limit (" + _maxPacketSize + ")");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Avoid sending the packet
|
||||
out.clear();
|
||||
}
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "Failed sending Packet(" + packet + ")", e);
|
||||
// Avoid sending the packet if some exception happened
|
||||
out.clear();
|
||||
}
|
||||
}
|
||||
}
|
@@ -20,8 +20,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -30,14 +28,11 @@ import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
|
||||
public final class CommonUtil
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(CommonUtil.class.getName());
|
||||
|
||||
private static final char[] ILLEGAL_CHARACTERS =
|
||||
{
|
||||
'/',
|
||||
@@ -57,26 +52,6 @@ public final class CommonUtil
|
||||
':'
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if a host name is internal
|
||||
* @param host the host name to check
|
||||
* @return true: host name is internal<br>
|
||||
* false: host name is external
|
||||
*/
|
||||
public static boolean isInternalHostname(String host)
|
||||
{
|
||||
try
|
||||
{
|
||||
final InetAddress addr = InetAddress.getByName(host);
|
||||
return addr.isSiteLocalAddress() || addr.isLoopbackAddress();
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
_log.warning("Util: " + e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to generate the hexadecimal representation of a byte array.<br>
|
||||
* 16 bytes per row, while ascii chars or "." is shown at the end of the line.
|
||||
@@ -123,21 +98,18 @@ public final class CommonUtil
|
||||
{
|
||||
final byte[] array = new byte[size];
|
||||
Rnd.nextBytes(array);
|
||||
|
||||
// Don't allow 0s inside the array!
|
||||
for (int i = 0; i < array.length; i++)
|
||||
{
|
||||
while (array[i] == 0)
|
||||
{
|
||||
array[i] = (byte) Rnd.get(Byte.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the stack trace of a Throwable into a String
|
||||
* @param t Throwable to get the stacktrace from
|
||||
* @return stack trace from Throwable as String
|
||||
*/
|
||||
public static String getStackTrace(Throwable t)
|
||||
{
|
||||
final StringWriter sw = new StringWriter();
|
||||
t.printStackTrace(new PrintWriter(sw));
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces most invalid characters for the given string with an underscore.
|
||||
* @param str the string that may contain invalid characters
|
||||
@@ -222,10 +194,22 @@ public final class CommonUtil
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the stack trace of a Throwable into a String
|
||||
* @param t Throwable to get the stacktrace from
|
||||
* @return stack trace from Throwable as String
|
||||
*/
|
||||
public static String getStackTrace(Throwable t)
|
||||
{
|
||||
final StringWriter sw = new StringWriter();
|
||||
t.printStackTrace(new PrintWriter(sw));
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
public static String getTraceString(StackTraceElement[] stackTraceElements)
|
||||
{
|
||||
final StringJoiner sj = new StringJoiner(Config.EOL);
|
||||
for (final StackTraceElement stackTraceElement : stackTraceElements)
|
||||
for (StackTraceElement stackTraceElement : stackTraceElements)
|
||||
{
|
||||
sj.add(stackTraceElement.toString());
|
||||
}
|
||||
|
@@ -1118,7 +1118,7 @@ public final class BlowfishEngine
|
||||
|
||||
private int func(int x)
|
||||
{
|
||||
return ((S0[(x >>> 24)] + S1[(x >>> 16) & 0xff]) ^ S2[(x >>> 8) & 0xff]) + S3[x & 0xff];
|
||||
return (((S0[(x >>> 24)] + S1[(x >>> 16) & 0xff]) ^ S2[(x >>> 8) & 0xff]) + S3[x & 0xff]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1129,7 +1129,8 @@ public final class BlowfishEngine
|
||||
*/
|
||||
private void processTable(int xl, int xr, int[] table)
|
||||
{
|
||||
for (int s = 0; s < table.length; s += 2)
|
||||
final int size = table.length;
|
||||
for (int s = 0; s < size; s += 2)
|
||||
{
|
||||
xl ^= P[0];
|
||||
xr ^= func(xl) ^ P[1];
|
||||
@@ -1436,7 +1437,7 @@ public final class BlowfishEngine
|
||||
*/
|
||||
private int bytesTo32bits(byte[] src, int srcIndex)
|
||||
{
|
||||
return ((src[srcIndex + 3] & 0xff) << 24) | ((src[srcIndex + 2] & 0xff) << 16) | ((src[srcIndex + 1] & 0xff) << 8) | (src[srcIndex] & 0xff);
|
||||
return ((src[srcIndex + 3] & 0xff) << 24) | ((src[srcIndex + 2] & 0xff) << 16) | ((src[srcIndex + 1] & 0xff) << 8) | ((src[srcIndex] & 0xff));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -16,14 +16,17 @@
|
||||
*/
|
||||
package com.l2jmobius.commons.util.crypt;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.crypto.SecretKey;
|
||||
|
||||
import com.l2jmobius.commons.network.ICrypt;
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
* @author NosBit
|
||||
*/
|
||||
public class LoginCrypt
|
||||
public class LoginCrypt implements ICrypt
|
||||
{
|
||||
private static final byte[] STATIC_BLOWFISH_KEY =
|
||||
{
|
||||
@@ -45,82 +48,102 @@ public class LoginCrypt
|
||||
(byte) 0x6c
|
||||
};
|
||||
|
||||
private static final NewCrypt _STATIC_CRYPT = new NewCrypt(STATIC_BLOWFISH_KEY);
|
||||
private NewCrypt _crypt = null;
|
||||
private static final BlowfishEngine STATIC_BLOWFISH_ENGINE = new BlowfishEngine();
|
||||
|
||||
static
|
||||
{
|
||||
STATIC_BLOWFISH_ENGINE.init(STATIC_BLOWFISH_KEY);
|
||||
}
|
||||
|
||||
private final BlowfishEngine _blowfishEngine = new BlowfishEngine();
|
||||
private boolean _static = true;
|
||||
|
||||
/**
|
||||
* Method to initialize the the blowfish cipher with dynamic key.
|
||||
* @param key the blowfish key to initialize the dynamic blowfish cipher with
|
||||
*/
|
||||
public void setKey(byte[] key)
|
||||
public LoginCrypt(SecretKey blowfishKey)
|
||||
{
|
||||
_crypt = new NewCrypt(key);
|
||||
_blowfishEngine.init(blowfishKey.getEncoded());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to decrypt an incoming login client packet.
|
||||
* @param raw array with encrypted data
|
||||
* @param offset offset where the encrypted data is located
|
||||
* @param size number of bytes of encrypted data
|
||||
* @return true when checksum could be verified, false otherwise
|
||||
* @throws IOException the size is not multiple of blowfishs block size or the raw array can't hold size bytes starting at offset due to it's size
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see com.l2jserver.commons.network.ICrypt#encrypt(io.netty.buffer.ByteBuf)
|
||||
*/
|
||||
public boolean decrypt(byte[] raw, int offset, int size) throws IOException
|
||||
@Override
|
||||
public void encrypt(ByteBuf buf)
|
||||
{
|
||||
if ((size % 8) != 0)
|
||||
{
|
||||
throw new IOException("size have to be multiple of 8");
|
||||
}
|
||||
if ((offset + size) > raw.length)
|
||||
{
|
||||
throw new IOException("raw array too short for size starting from offset");
|
||||
}
|
||||
// Checksum & XOR Key or Checksum only
|
||||
buf.writeZero(_static ? 16 : 12);
|
||||
|
||||
_crypt.decrypt(raw, offset, size);
|
||||
return NewCrypt.verifyChecksum(raw, offset, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to encrypt an outgoing packet to login client.<br>
|
||||
* Performs padding and resizing of data array.
|
||||
* @param raw array with plain data
|
||||
* @param offset offset where the plain data is located
|
||||
* @param size number of bytes of plain data
|
||||
* @return the new array size
|
||||
* @throws IOException packet is too long to make padding and add verification data
|
||||
*/
|
||||
public int encrypt(byte[] raw, int offset, int size) throws IOException
|
||||
{
|
||||
// reserve checksum
|
||||
size += 4;
|
||||
// Padding
|
||||
buf.writeZero(8 - (buf.readableBytes() % 8));
|
||||
|
||||
if (_static)
|
||||
{
|
||||
// reserve for XOR "key"
|
||||
size += 4;
|
||||
|
||||
// padding
|
||||
size += 8 - (size % 8);
|
||||
if ((offset + size) > raw.length)
|
||||
{
|
||||
throw new IOException("packet too long");
|
||||
}
|
||||
NewCrypt.encXORPass(raw, offset, size, Rnd.nextInt());
|
||||
_STATIC_CRYPT.crypt(raw, offset, size);
|
||||
_static = false;
|
||||
|
||||
int key = Rnd.nextInt();
|
||||
buf.skipBytes(4); // The first 4 bytes are ignored
|
||||
while (buf.readerIndex() < (buf.writerIndex() - 8))
|
||||
{
|
||||
int data = buf.readIntLE();
|
||||
key += data;
|
||||
data ^= key;
|
||||
buf.setIntLE(buf.readerIndex() - 4, data);
|
||||
}
|
||||
buf.setIntLE(buf.readerIndex(), key);
|
||||
|
||||
buf.resetReaderIndex();
|
||||
|
||||
final byte[] block = new byte[8];
|
||||
while (buf.isReadable(8))
|
||||
{
|
||||
buf.readBytes(block);
|
||||
STATIC_BLOWFISH_ENGINE.encryptBlock(block, 0);
|
||||
buf.setBytes(buf.readerIndex() - block.length, block);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// padding
|
||||
size += 8 - (size % 8);
|
||||
if ((offset + size) > raw.length)
|
||||
int checksum = 0;
|
||||
while (buf.isReadable(8))
|
||||
{
|
||||
throw new IOException("packet too long");
|
||||
checksum ^= buf.readIntLE();
|
||||
}
|
||||
buf.setIntLE(buf.readerIndex(), checksum);
|
||||
|
||||
buf.resetReaderIndex();
|
||||
|
||||
final byte[] block = new byte[8];
|
||||
while (buf.isReadable(8))
|
||||
{
|
||||
buf.readBytes(block);
|
||||
_blowfishEngine.encryptBlock(block, 0);
|
||||
buf.setBytes(buf.readerIndex() - block.length, block);
|
||||
}
|
||||
NewCrypt.appendChecksum(raw, offset, size);
|
||||
_crypt.crypt(raw, offset, size);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see com.l2jserver.commons.network.ICrypt#decrypt(io.netty.buffer.ByteBuf)
|
||||
*/
|
||||
@Override
|
||||
public void decrypt(ByteBuf buf)
|
||||
{
|
||||
// Packet size must be multiple of 8
|
||||
if ((buf.readableBytes() % 8) != 0)
|
||||
{
|
||||
buf.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
final byte[] block = new byte[8];
|
||||
while (buf.isReadable(8))
|
||||
{
|
||||
buf.readBytes(block);
|
||||
_blowfishEngine.decryptBlock(block, 0);
|
||||
buf.setBytes(buf.readerIndex() - block.length, block);
|
||||
}
|
||||
|
||||
// TODO: verify checksum also dont forget!
|
||||
}
|
||||
}
|
||||
|
@@ -17,13 +17,11 @@
|
||||
package com.l2jmobius.commons.util.crypt;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.Key;
|
||||
import java.security.KeyPair;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ScrambledKeyPair
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(ScrambledKeyPair.class.getName());
|
||||
@@ -68,8 +66,23 @@ public class ScrambledKeyPair
|
||||
{
|
||||
scrambledMod[0x40 + i] = (byte) (scrambledMod[0x40 + i] ^ scrambledMod[i]);
|
||||
}
|
||||
_log.fine("Modulus was scrambled");
|
||||
_log.finer("Modulus was scrambled");
|
||||
|
||||
return scrambledMod;
|
||||
}
|
||||
|
||||
public byte[] getScrambledModulus()
|
||||
{
|
||||
return _scrambledModulus;
|
||||
}
|
||||
|
||||
public Key getPrivateKey()
|
||||
{
|
||||
return _pair.getPrivate();
|
||||
}
|
||||
|
||||
public Key getPublicKey()
|
||||
{
|
||||
return _pair.getPublic();
|
||||
}
|
||||
}
|
||||
|
@@ -19,10 +19,8 @@ package com.l2jmobius.gameserver;
|
||||
import java.awt.Toolkit;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.Calendar;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogManager;
|
||||
@@ -32,8 +30,6 @@ import com.l2jmobius.Config;
|
||||
import com.l2jmobius.Server;
|
||||
import com.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.commons.mmocore.SelectorConfig;
|
||||
import com.l2jmobius.commons.mmocore.SelectorThread;
|
||||
import com.l2jmobius.commons.util.DeadLockDetector;
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.AnnouncementsTable;
|
||||
@@ -135,26 +131,23 @@ import com.l2jmobius.gameserver.model.entity.Hero;
|
||||
import com.l2jmobius.gameserver.model.entity.TvTManager;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.olympiad.Olympiad;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.L2GamePacketHandler;
|
||||
import com.l2jmobius.gameserver.network.ClientNetworkManager;
|
||||
import com.l2jmobius.gameserver.network.loginserver.LoginServerNetworkManager;
|
||||
import com.l2jmobius.gameserver.network.telnet.TelnetServer;
|
||||
import com.l2jmobius.gameserver.scripting.ScriptEngineManager;
|
||||
import com.l2jmobius.gameserver.taskmanager.KnownListUpdateTaskManager;
|
||||
import com.l2jmobius.gameserver.taskmanager.TaskManager;
|
||||
import com.l2jmobius.loginserver.network.util.IPv4Filter;
|
||||
import com.l2jmobius.status.Status;
|
||||
|
||||
public final class GameServer
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(GameServer.class.getName());
|
||||
private static final Logger LOGGER = Logger.getLogger(GameServer.class.getName());
|
||||
|
||||
// Local Constants
|
||||
private static final String LOG_FOLDER = "log"; // Name of folder for log file
|
||||
private static final String LOG_NAME = "./log.cfg"; // Name of log file
|
||||
|
||||
private final SelectorThread<L2GameClient> _selectorThread;
|
||||
private final L2GamePacketHandler _gamePacketHandler;
|
||||
private final DeadLockDetector _deadDetectThread;
|
||||
public static GameServer gameServer;
|
||||
private static GameServer INSTANCE;
|
||||
public static final Calendar dateTimeServerStarted = Calendar.getInstance();
|
||||
|
||||
public GameServer() throws Exception
|
||||
@@ -167,7 +160,7 @@ public final class GameServer
|
||||
printSection("IdFactory");
|
||||
if (!IdFactory.getInstance().isInitialized())
|
||||
{
|
||||
_log.severe(getClass().getSimpleName() + ": Could not read object IDs from database. Please check your configuration.");
|
||||
LOGGER.severe(getClass().getSimpleName() + ": Could not read object IDs from database. Please check your configuration.");
|
||||
throw new Exception("Could not initialize the ID factory!");
|
||||
}
|
||||
|
||||
@@ -178,6 +171,9 @@ public final class GameServer
|
||||
EventDispatcher.getInstance();
|
||||
ScriptEngineManager.getInstance();
|
||||
|
||||
printSection("Telnet");
|
||||
TelnetServer.getInstance();
|
||||
|
||||
printSection("World");
|
||||
// start game time control early
|
||||
GameTimeController.init();
|
||||
@@ -233,7 +229,7 @@ public final class GameServer
|
||||
|
||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||
{
|
||||
_log.info("PremiumManager: Premium system is enabled.");
|
||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||
PremiumManager.getInstance();
|
||||
}
|
||||
|
||||
@@ -295,12 +291,13 @@ public final class GameServer
|
||||
|
||||
try
|
||||
{
|
||||
_log.info("Loading server scripts...");
|
||||
LOGGER.info("Loading server scripts...");
|
||||
ScriptEngineManager.getInstance().executeMasterHandler();
|
||||
ScriptEngineManager.getInstance().executeScriptList();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Failed to execute script list!", e);
|
||||
LOGGER.log(Level.WARNING, "Failed to execute script list!", e);
|
||||
}
|
||||
|
||||
SpawnTable.getInstance().load();
|
||||
@@ -340,7 +337,7 @@ public final class GameServer
|
||||
SevenSignsFestival.getInstance();
|
||||
AutoSpawnHandler.getInstance();
|
||||
|
||||
_log.info("AutoSpawnHandler: Loaded " + AutoSpawnHandler.getInstance().size() + " handlers in total.");
|
||||
LOGGER.info("AutoSpawnHandler: Loaded " + AutoSpawnHandler.getInstance().size() + " handlers in total.");
|
||||
|
||||
if (Config.L2JMOD_ALLOW_WEDDING)
|
||||
{
|
||||
@@ -365,7 +362,7 @@ public final class GameServer
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(Shutdown.getInstance());
|
||||
|
||||
_log.info("IdFactory: Free ObjectID's remaining: " + IdFactory.getInstance().size());
|
||||
LOGGER.info("IdFactory: Free ObjectID's remaining: " + IdFactory.getInstance().size());
|
||||
|
||||
TvTManager.getInstance();
|
||||
KnownListUpdateTaskManager.getInstance();
|
||||
@@ -375,6 +372,11 @@ public final class GameServer
|
||||
OfflineTradersTable.getInstance().restoreOfflineTraders();
|
||||
}
|
||||
|
||||
if (Config.SERVER_RESTART_SCHEDULE_ENABLED)
|
||||
{
|
||||
ServerRestartManager.getInstance();
|
||||
}
|
||||
|
||||
if (Config.DEADLOCK_DETECTOR)
|
||||
{
|
||||
_deadDetectThread = new DeadLockDetector();
|
||||
@@ -387,55 +389,43 @@ public final class GameServer
|
||||
}
|
||||
System.gc();
|
||||
final long totalMem = Runtime.getRuntime().maxMemory() / 1048576;
|
||||
_log.info(getClass().getSimpleName() + ": Started, using " + getUsedMemoryMB() + " of " + totalMem + " MB total memory.");
|
||||
_log.info(getClass().getSimpleName() + ": Geodata use " + geodataMemory + " MB of memory.");
|
||||
_log.info(getClass().getSimpleName() + ": Maximum number of connected players is " + Config.MAXIMUM_ONLINE_USERS + ".");
|
||||
_log.info(getClass().getSimpleName() + ": Server loaded in " + ((System.currentTimeMillis() - serverLoadStart) / 1000) + " seconds.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Started, using " + getUsedMemoryMB() + " of " + totalMem + " MB total memory.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Geodata use " + geodataMemory + " MB of memory.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Maximum number of connected players is " + Config.MAXIMUM_ONLINE_USERS + ".");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Server loaded in " + ((System.currentTimeMillis() - serverLoadStart) / 1000) + " seconds.");
|
||||
|
||||
final SelectorConfig sc = new SelectorConfig();
|
||||
sc.MAX_READ_PER_PASS = Config.MMO_MAX_READ_PER_PASS;
|
||||
sc.MAX_SEND_PER_PASS = Config.MMO_MAX_SEND_PER_PASS;
|
||||
sc.SLEEP_TIME = Config.MMO_SELECTOR_SLEEP_TIME;
|
||||
sc.HELPER_BUFFER_COUNT = Config.MMO_HELPER_BUFFER_COUNT;
|
||||
sc.TCP_NODELAY = Config.MMO_TCP_NODELAY;
|
||||
ClientNetworkManager.getInstance().start();
|
||||
|
||||
_gamePacketHandler = new L2GamePacketHandler();
|
||||
_selectorThread = new SelectorThread<>(sc, _gamePacketHandler, _gamePacketHandler, _gamePacketHandler, new IPv4Filter());
|
||||
|
||||
InetAddress bindAddress = null;
|
||||
if (!Config.GAMESERVER_HOSTNAME.equals("*"))
|
||||
if (Boolean.getBoolean("newLoginServer"))
|
||||
{
|
||||
try
|
||||
{
|
||||
bindAddress = InetAddress.getByName(Config.GAMESERVER_HOSTNAME);
|
||||
}
|
||||
catch (UnknownHostException e1)
|
||||
{
|
||||
_log.log(Level.SEVERE, getClass().getSimpleName() + ": WARNING: The GameServer bind address is invalid, using all avaliable IPs! Reason: " + e1.getMessage(), e1);
|
||||
}
|
||||
LoginServerNetworkManager.getInstance().connect();
|
||||
}
|
||||
else
|
||||
{
|
||||
LoginServerThread.getInstance().start();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_selectorThread.openServerSocket(bindAddress, Config.PORT_GAME);
|
||||
_selectorThread.start();
|
||||
_log.log(Level.INFO, getClass().getSimpleName() + ": is now listening on: " + Config.GAMESERVER_HOSTNAME + ":" + Config.PORT_GAME);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
_log.log(Level.SEVERE, getClass().getSimpleName() + ": FATAL: Failed to open server socket. Reason: " + e.getMessage(), e);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
if (Config.SERVER_RESTART_SCHEDULE_ENABLED)
|
||||
{
|
||||
ServerRestartManager.getInstance();
|
||||
}
|
||||
|
||||
LoginServerThread.getInstance().start();
|
||||
Toolkit.getDefaultToolkit().beep();
|
||||
}
|
||||
|
||||
public long getStartedTime()
|
||||
{
|
||||
return ManagementFactory.getRuntimeMXBean().getStartTime();
|
||||
}
|
||||
|
||||
public String getUptime()
|
||||
{
|
||||
final long uptime = ManagementFactory.getRuntimeMXBean().getUptime() / 1000;
|
||||
final long hours = uptime / 3600;
|
||||
final long mins = (uptime - (hours * 3600)) / 60;
|
||||
final long secs = ((uptime - (hours * 3600)) - (mins * 60));
|
||||
if (hours > 0)
|
||||
{
|
||||
return hours + "hrs " + mins + "mins " + secs + "secs";
|
||||
}
|
||||
return mins + "mins " + secs + "secs";
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
Server.serverMode = Server.MODE_GAMESERVER;
|
||||
@@ -455,12 +445,8 @@ public final class GameServer
|
||||
Config.load();
|
||||
printSection("Database");
|
||||
DatabaseFactory.getInstance();
|
||||
gameServer = new GameServer();
|
||||
|
||||
if (Config.IS_TELNET_ENABLED)
|
||||
{
|
||||
new Status(Server.serverMode).start();
|
||||
}
|
||||
INSTANCE = new GameServer();
|
||||
}
|
||||
|
||||
public long getUsedMemoryMB()
|
||||
@@ -468,16 +454,6 @@ public final class GameServer
|
||||
return (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1048576;
|
||||
}
|
||||
|
||||
public SelectorThread<L2GameClient> getSelectorThread()
|
||||
{
|
||||
return _selectorThread;
|
||||
}
|
||||
|
||||
public L2GamePacketHandler getL2GamePacketHandler()
|
||||
{
|
||||
return _gamePacketHandler;
|
||||
}
|
||||
|
||||
public DeadLockDetector getDeadLockDetectorThread()
|
||||
{
|
||||
return _deadDetectThread;
|
||||
@@ -490,6 +466,11 @@ public final class GameServer
|
||||
{
|
||||
s = "-" + s;
|
||||
}
|
||||
_log.info(s);
|
||||
LOGGER.info(s);
|
||||
}
|
||||
|
||||
public static GameServer getInstance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
|
@@ -36,22 +36,20 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.commons.network.BaseSendablePacket;
|
||||
import com.l2jmobius.commons.util.CommonUtil;
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.commons.util.crypt.NewCrypt;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.ConnectionState;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient.GameClientState;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.loginserverpackets.game.AuthRequest;
|
||||
import com.l2jmobius.gameserver.network.loginserverpackets.game.BlowFishKey;
|
||||
@@ -78,8 +76,8 @@ import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
public class LoginServerThread extends Thread
|
||||
{
|
||||
protected static final Logger _log = Logger.getLogger(LoginServerThread.class.getName());
|
||||
protected static final Logger _logAccounting = Logger.getLogger("accounting");
|
||||
protected static final Logger LOGGER = Logger.getLogger(LoginServerThread.class.getName());
|
||||
protected static final Logger ACCOUNTING_LOGGER = Logger.getLogger("accounting");
|
||||
|
||||
/** @see com.l2jmobius.loginserver.L2LoginServer#PROTOCOL_REV */
|
||||
private static final int REVISION = 0x0106;
|
||||
@@ -104,7 +102,7 @@ public class LoginServerThread extends Thread
|
||||
private int _requestID;
|
||||
private final boolean _reserveHost;
|
||||
private int _maxPlayer;
|
||||
private final List<WaitingClient> _waitingClients;
|
||||
private final Set<WaitingClient> _waitingClients = ConcurrentHashMap.newKeySet();
|
||||
private final Map<String, L2GameClient> _accountsInGameServer = new ConcurrentHashMap<>();
|
||||
private int _status;
|
||||
private String _serverName;
|
||||
@@ -134,10 +132,18 @@ public class LoginServerThread extends Thread
|
||||
_reserveHost = Config.RESERVE_HOST_ON_LOGIN;
|
||||
_subnets = Config.GAME_SERVER_SUBNETS;
|
||||
_hosts = Config.GAME_SERVER_HOSTS;
|
||||
_waitingClients = new CopyOnWriteArrayList<>();
|
||||
_maxPlayer = Config.MAXIMUM_ONLINE_USERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the single instance of LoginServerThread.
|
||||
* @return single instance of LoginServerThread
|
||||
*/
|
||||
public static LoginServerThread getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
@@ -150,18 +156,13 @@ public class LoginServerThread extends Thread
|
||||
try
|
||||
{
|
||||
// Connection
|
||||
_log.info("Connecting to login on " + _hostname + ":" + _port);
|
||||
LOGGER.info(getClass().getSimpleName() + ": Connecting to login on " + _hostname + ":" + _port);
|
||||
_loginSocket = new Socket(_hostname, _port);
|
||||
final InputStream in = _loginSocket.getInputStream();
|
||||
_out = new BufferedOutputStream(_loginSocket.getOutputStream());
|
||||
|
||||
// init Blowfish
|
||||
final byte[] blowfishKey = CommonUtil.generateHex(40);
|
||||
// Protect the new blowfish key what cannot begin with zero
|
||||
if (blowfishKey[0] == 0)
|
||||
{
|
||||
blowfishKey[0] = (byte) Rnd.get(32, 64);
|
||||
}
|
||||
_blowfish = new NewCrypt("_;v.]05-31!|+-%xT!^[$\00");
|
||||
while (!isInterrupted())
|
||||
{
|
||||
@@ -171,7 +172,7 @@ public class LoginServerThread extends Thread
|
||||
|
||||
if (lengthHi < 0)
|
||||
{
|
||||
_log.finer("LoginServerThread: Login terminated the connection.");
|
||||
LOGGER.finer(getClass().getSimpleName() + ": Login terminated the connection.");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -189,7 +190,7 @@ public class LoginServerThread extends Thread
|
||||
|
||||
if (receivedBytes != (length - 2))
|
||||
{
|
||||
_log.warning("Incomplete Packet is sent to the server, closing connection.(LS)");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Incomplete Packet is sent to the server, closing connection.(LS)");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -199,11 +200,12 @@ public class LoginServerThread extends Thread
|
||||
|
||||
if (!checksumOk)
|
||||
{
|
||||
_log.warning("Incorrect packet checksum, ignoring packet (LS)");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Incorrect packet checksum, ignoring packet (LS)");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (incoming[0] & 0xff)
|
||||
final int packetType = incoming[0] & 0xff;
|
||||
switch (packetType)
|
||||
{
|
||||
case 0x00:
|
||||
{
|
||||
@@ -211,7 +213,7 @@ public class LoginServerThread extends Thread
|
||||
if (init.getRevision() != REVISION)
|
||||
{
|
||||
// TODO: revision mismatch
|
||||
_log.warning("/!\\ Revision mismatch between LS and GS /!\\");
|
||||
LOGGER.warning("/!\\ Revision mismatch between LS and GS /!\\");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -219,11 +221,14 @@ public class LoginServerThread extends Thread
|
||||
|
||||
try
|
||||
{
|
||||
publicKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new RSAPublicKeySpec(new BigInteger(init.getRSAKey()), RSAKeyGenParameterSpec.F4));
|
||||
final KeyFactory kfac = KeyFactory.getInstance("RSA");
|
||||
final BigInteger modulus = new BigInteger(init.getRSAKey());
|
||||
final RSAPublicKeySpec kspec1 = new RSAPublicKeySpec(modulus, RSAKeyGenParameterSpec.F4);
|
||||
publicKey = (RSAPublicKey) kfac.generatePublic(kspec1);
|
||||
}
|
||||
catch (GeneralSecurityException e)
|
||||
{
|
||||
_log.warning("Trouble while init the public key send by login");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Trouble while init the public key send by login");
|
||||
break;
|
||||
}
|
||||
// send the blowfish key through the rsa encryption
|
||||
@@ -236,7 +241,7 @@ public class LoginServerThread extends Thread
|
||||
case 0x01:
|
||||
{
|
||||
final LoginServerFail lsf = new LoginServerFail(incoming);
|
||||
_log.info("Damn! Registeration Failed: " + lsf.getReasonString());
|
||||
LOGGER.info(getClass().getSimpleName() + ": Damn! Registeration Failed: " + lsf.getReasonString());
|
||||
// login will close the connection here
|
||||
break;
|
||||
}
|
||||
@@ -246,14 +251,39 @@ public class LoginServerThread extends Thread
|
||||
final int serverID = aresp.getServerId();
|
||||
_serverName = aresp.getServerName();
|
||||
Config.saveHexid(serverID, hexToString(_hexID));
|
||||
_log.info("Registered on login as Server " + serverID + " : " + _serverName);
|
||||
LOGGER.info(getClass().getSimpleName() + ": Registered on login as Server " + serverID + ": " + _serverName);
|
||||
final ServerStatus st = new ServerStatus();
|
||||
st.addAttribute(ServerStatus.SERVER_LIST_SQUARE_BRACKET, Config.SERVER_LIST_BRACKET ? ServerStatus.ON : ServerStatus.OFF);
|
||||
if (Config.SERVER_LIST_BRACKET)
|
||||
{
|
||||
st.addAttribute(ServerStatus.SERVER_LIST_SQUARE_BRACKET, ServerStatus.ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
st.addAttribute(ServerStatus.SERVER_LIST_SQUARE_BRACKET, ServerStatus.OFF);
|
||||
}
|
||||
st.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
st.addAttribute(ServerStatus.SERVER_LIST_STATUS, Config.SERVER_GMONLY ? ServerStatus.STATUS_GM_ONLY : ServerStatus.STATUS_AUTO);
|
||||
st.addAttribute(ServerStatus.SERVER_AGE, Config.SERVER_LIST_AGE == 15 ? ServerStatus.SERVER_AGE_15 : Config.SERVER_LIST_AGE == 18 ? ServerStatus.SERVER_AGE_18 : ServerStatus.SERVER_AGE_ALL);
|
||||
if (Config.SERVER_GMONLY)
|
||||
{
|
||||
st.addAttribute(ServerStatus.SERVER_LIST_STATUS, ServerStatus.STATUS_GM_ONLY);
|
||||
}
|
||||
else
|
||||
{
|
||||
st.addAttribute(ServerStatus.SERVER_LIST_STATUS, ServerStatus.STATUS_AUTO);
|
||||
}
|
||||
if (Config.SERVER_LIST_AGE == 15)
|
||||
{
|
||||
st.addAttribute(ServerStatus.SERVER_AGE, ServerStatus.SERVER_AGE_15);
|
||||
}
|
||||
else if (Config.SERVER_LIST_AGE == 18)
|
||||
{
|
||||
st.addAttribute(ServerStatus.SERVER_AGE, ServerStatus.SERVER_AGE_18);
|
||||
}
|
||||
else
|
||||
{
|
||||
st.addAttribute(ServerStatus.SERVER_AGE, ServerStatus.SERVER_AGE_ALL);
|
||||
}
|
||||
sendPacket(st);
|
||||
if (L2World.getInstance().getAllPlayersCount() > 0)
|
||||
if (L2World.getInstance().getPlayers().size() > 0)
|
||||
{
|
||||
final List<String> playerList = new ArrayList<>();
|
||||
for (L2PcInstance player : L2World.getInstance().getPlayers())
|
||||
@@ -285,15 +315,15 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
final PlayerInGame pig = new PlayerInGame(par.getAccount());
|
||||
sendPacket(pig);
|
||||
wcToRemove.gameClient.setState(GameClientState.AUTHED);
|
||||
wcToRemove.gameClient.setConnectionState(ConnectionState.AUTHENTICATED);
|
||||
wcToRemove.gameClient.setSessionId(wcToRemove.session);
|
||||
final CharSelectionInfo cl = new CharSelectionInfo(wcToRemove.account, wcToRemove.gameClient.getSessionId().playOkID1);
|
||||
wcToRemove.gameClient.getConnection().sendPacket(cl);
|
||||
wcToRemove.gameClient.sendPacket(cl);
|
||||
wcToRemove.gameClient.setCharSelection(cl.getCharInfo());
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.warning("Session key is not correct. Closing connection for account " + wcToRemove.account + ".");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Session key is not correct. Closing connection for account " + wcToRemove.account);
|
||||
// wcToRemove.gameClient.getConnection().sendPacket(new LoginFail(LoginFail.SYSTEM_ERROR_LOGIN_LATER));
|
||||
wcToRemove.gameClient.close(new LoginFail(LoginFail.SYSTEM_ERROR_LOGIN_LATER));
|
||||
_accountsInGameServer.remove(wcToRemove.account);
|
||||
@@ -324,15 +354,15 @@ public class LoginServerThread extends Thread
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
_log.log(Level.WARNING, "", e);
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": ", e);
|
||||
}
|
||||
catch (SocketException e)
|
||||
{
|
||||
_log.warning("LoginServer not avaible, trying to reconnect...");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": LoginServer not avaible, trying to reconnect...");
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Disconnected from Login, Trying to reconnect: " + e.getMessage(), e);
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Disconnected from Login, Trying to reconnect: ", e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -380,7 +410,7 @@ public class LoginServerThread extends Thread
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
_log.warning("Error while sending player auth request");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,7 +454,7 @@ public class LoginServerThread extends Thread
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
_log.warning("Error while sending logout packet to login");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login");
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -530,18 +560,11 @@ public class LoginServerThread extends Thread
|
||||
public void doKickPlayer(String account)
|
||||
{
|
||||
final L2GameClient client = _accountsInGameServer.get(account);
|
||||
if (client == null)
|
||||
if (client != null)
|
||||
{
|
||||
return;
|
||||
ACCOUNTING_LOGGER.info("Kicked by login, " + client);
|
||||
client.close(SystemMessage.getSystemMessage(SystemMessageId.ANOTHER_PERSON_HAS_LOGGED_IN_WITH_THE_SAME_ACCOUNT));
|
||||
}
|
||||
final LogRecord record = new LogRecord(Level.WARNING, "Kicked by login");
|
||||
record.setParameters(new Object[]
|
||||
{
|
||||
client
|
||||
});
|
||||
_logAccounting.log(record);
|
||||
client.setAditionalClosePacket(SystemMessage.getSystemMessage(SystemMessageId.ANOTHER_PERSON_HAS_LOGGED_IN_WITH_THE_SAME_ACCOUNT));
|
||||
client.closeNow();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -550,6 +573,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
private void getCharsOnServer(String account)
|
||||
{
|
||||
|
||||
int chars = 0;
|
||||
final List<Long> charToDel = new ArrayList<>();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
@@ -571,7 +595,7 @@ public class LoginServerThread extends Thread
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
@@ -800,15 +824,6 @@ public class LoginServerThread extends Thread
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the single instance of LoginServerThread.
|
||||
* @return single instance of LoginServerThread
|
||||
*/
|
||||
public static LoginServerThread getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final LoginServerThread _instance = new LoginServerThread();
|
||||
|
@@ -39,6 +39,8 @@ import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Hero;
|
||||
import com.l2jmobius.gameserver.model.olympiad.Olympiad;
|
||||
import com.l2jmobius.gameserver.network.ClientNetworkManager;
|
||||
import com.l2jmobius.gameserver.network.EventLoopGroupManager;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||
@@ -53,7 +55,7 @@ import com.l2jmobius.gameserver.util.Broadcast;
|
||||
*/
|
||||
public class Shutdown extends Thread
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(Shutdown.class.getName());
|
||||
private static final Logger LOGGER = Logger.getLogger(Shutdown.class.getName());
|
||||
private static Shutdown _counterInstance = null;
|
||||
|
||||
private int _secondsShut;
|
||||
@@ -83,7 +85,7 @@ public class Shutdown extends Thread
|
||||
|
||||
public void startTelnetShutdown(String IP, int seconds, boolean restart)
|
||||
{
|
||||
_log.warning("IP: " + IP + " issued shutdown command. " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
|
||||
LOGGER.warning("IP: " + IP + " issued shutdown command. " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
|
||||
|
||||
_shutdownMode = restart ? GM_RESTART : GM_SHUTDOWN;
|
||||
|
||||
@@ -131,7 +133,7 @@ public class Shutdown extends Thread
|
||||
*/
|
||||
public void telnetAbort(String IP)
|
||||
{
|
||||
_log.warning("IP: " + IP + " issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
|
||||
LOGGER.warning("IP: " + IP + " issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
|
||||
|
||||
if (_counterInstance != null)
|
||||
{
|
||||
@@ -182,18 +184,18 @@ public class Shutdown extends Thread
|
||||
if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS && !Config.STORE_OFFLINE_TRADE_IN_REALTIME)
|
||||
{
|
||||
OfflineTradersTable.getInstance().storeOffliners();
|
||||
_log.info("Offline Traders Table: Offline shops stored(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Offline Traders Table: Offline shops stored(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
_log.log(Level.WARNING, "Error saving offline shops.", t);
|
||||
LOGGER.log(Level.WARNING, "Error saving offline shops.", t);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
disconnectAllCharacters();
|
||||
_log.info("All players disconnected and saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("All players disconnected and saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
@@ -204,7 +206,7 @@ public class Shutdown extends Thread
|
||||
try
|
||||
{
|
||||
GameTimeController.getInstance().stopTimer();
|
||||
_log.info("Game Time Controller: Timer stopped(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Game Time Controller: Timer stopped(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
@@ -215,7 +217,7 @@ public class Shutdown extends Thread
|
||||
try
|
||||
{
|
||||
ThreadPool.shutdown();
|
||||
_log.info("Thread Pool Manager: Manager has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Thread Pool Manager: Manager has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
@@ -225,7 +227,7 @@ public class Shutdown extends Thread
|
||||
try
|
||||
{
|
||||
LoginServerThread.getInstance().interrupt();
|
||||
_log.info("Login Server Thread: Thread interruped(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Login Server Thread: Thread interruped(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
@@ -239,8 +241,9 @@ public class Shutdown extends Thread
|
||||
// saveData sends messages to exit players, so shutdown selector after it
|
||||
try
|
||||
{
|
||||
GameServer.gameServer.getSelectorThread().shutdown();
|
||||
_log.info("Game Server: Selector thread has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
ClientNetworkManager.getInstance().stop();
|
||||
EventLoopGroupManager.getInstance().shutdown();
|
||||
LOGGER.info("Game Server: Selector thread has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
@@ -251,7 +254,7 @@ public class Shutdown extends Thread
|
||||
try
|
||||
{
|
||||
DatabaseFactory.getInstance().close();
|
||||
_log.info("Database Factory: Database connection has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Database Factory: Database connection has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
@@ -267,14 +270,14 @@ public class Shutdown extends Thread
|
||||
Runtime.getRuntime().halt(0);
|
||||
}
|
||||
|
||||
_log.info("The server has been successfully shut down in " + (tc1.getEstimatedTime() / 1000) + "seconds.");
|
||||
LOGGER.info("The server has been successfully shut down in " + (tc1.getEstimatedTime() / 1000) + "seconds.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// gm shutdown: send warnings and then call exit to start shutdown sequence
|
||||
countdown();
|
||||
// last point where logging is operational :(
|
||||
_log.warning("GM shutdown countdown is over. " + MODE_TEXT[_shutdownMode] + " NOW!");
|
||||
LOGGER.warning("GM shutdown countdown is over. " + MODE_TEXT[_shutdownMode] + " NOW!");
|
||||
switch (_shutdownMode)
|
||||
{
|
||||
case GM_SHUTDOWN:
|
||||
@@ -310,11 +313,11 @@ public class Shutdown extends Thread
|
||||
|
||||
if (activeChar != null)
|
||||
{
|
||||
_log.warning("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") issued shutdown command. " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
|
||||
LOGGER.warning("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") issued shutdown command. " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.warning("Server scheduled restart issued shutdown command. Restart in " + seconds + " seconds!");
|
||||
LOGGER.warning("Server scheduled restart issued shutdown command. Restart in " + seconds + " seconds!");
|
||||
}
|
||||
|
||||
if (_shutdownMode > 0)
|
||||
@@ -363,7 +366,7 @@ public class Shutdown extends Thread
|
||||
*/
|
||||
public void abort(L2PcInstance activeChar)
|
||||
{
|
||||
_log.warning("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
|
||||
LOGGER.warning("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
|
||||
if (_counterInstance != null)
|
||||
{
|
||||
_counterInstance._abort();
|
||||
@@ -508,17 +511,17 @@ public class Shutdown extends Thread
|
||||
{
|
||||
case SIGTERM:
|
||||
{
|
||||
_log.info("SIGTERM received. Shutting down NOW!");
|
||||
LOGGER.info("SIGTERM received. Shutting down NOW!");
|
||||
break;
|
||||
}
|
||||
case GM_SHUTDOWN:
|
||||
{
|
||||
_log.info("GM shutdown received. Shutting down NOW!");
|
||||
LOGGER.info("GM shutdown received. Shutting down NOW!");
|
||||
break;
|
||||
}
|
||||
case GM_RESTART:
|
||||
{
|
||||
_log.info("GM restart received. Restarting NOW!");
|
||||
LOGGER.info("GM restart received. Restarting NOW!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -528,72 +531,72 @@ public class Shutdown extends Thread
|
||||
if (!SevenSigns.getInstance().isSealValidationPeriod())
|
||||
{
|
||||
SevenSignsFestival.getInstance().saveFestivalData(false);
|
||||
_log.info("SevenSignsFestival: Festival data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("SevenSignsFestival: Festival data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
|
||||
// Save Seven Signs data before closing. :)
|
||||
SevenSigns.getInstance().saveSevenSignsData();
|
||||
_log.info("SevenSigns: Seven Signs data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("SevenSigns: Seven Signs data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
SevenSigns.getInstance().saveSevenSignsStatus();
|
||||
_log.info("SevenSigns: Seven Signs status saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("SevenSigns: Seven Signs status saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
|
||||
// Save all raidboss and GrandBoss status ^_^
|
||||
RaidBossSpawnManager.getInstance().cleanUp();
|
||||
_log.info("RaidBossSpawnManager: All raidboss info saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("RaidBossSpawnManager: All raidboss info saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
GrandBossManager.getInstance().cleanUp();
|
||||
_log.info("GrandBossManager: All Grand Boss info saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("GrandBossManager: All Grand Boss info saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
ItemAuctionManager.getInstance().shutdown();
|
||||
_log.info("Item Auction Manager: All tasks stopped(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Item Auction Manager: All tasks stopped(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
Olympiad.getInstance().saveOlympiadStatus();
|
||||
_log.info("Olympiad System: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Olympiad System: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
Hero.getInstance().shutdown();
|
||||
_log.info("Hero System: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Hero System: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
ClanTable.getInstance().storeClanScore();
|
||||
_log.info("Clan System: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Clan System: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
|
||||
// Save Cursed Weapons data before closing.
|
||||
CursedWeaponsManager.getInstance().saveData();
|
||||
_log.info("Cursed Weapons Manager: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Cursed Weapons Manager: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
|
||||
// Save all manor data
|
||||
if (!Config.ALT_MANOR_SAVE_ALL_ACTIONS)
|
||||
{
|
||||
CastleManorManager.getInstance().storeMe();
|
||||
_log.info("Castle Manor Manager: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Castle Manor Manager: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
|
||||
CHSiegeManager.getInstance().onServerShutDown();
|
||||
_log.info("CHSiegeManager: Siegable hall attacker lists saved!");
|
||||
LOGGER.info("CHSiegeManager: Siegable hall attacker lists saved!");
|
||||
|
||||
// Save all global (non-player specific) Quest data that needs to persist after reboot
|
||||
QuestManager.getInstance().save();
|
||||
_log.info("Quest Manager: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Quest Manager: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
|
||||
// Save all global variables data
|
||||
GlobalVariablesManager.getInstance().storeMe();
|
||||
_log.info("Global Variables Manager: Variables saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Global Variables Manager: Variables saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
|
||||
// Save Fishing tournament data
|
||||
if (Config.ALT_FISH_CHAMPIONSHIP_ENABLED)
|
||||
{
|
||||
FishingChampionshipManager.getInstance().shutdown();
|
||||
_log.info("Fishing Championship data has been saved.");
|
||||
LOGGER.info("Fishing Championship data has been saved.");
|
||||
}
|
||||
|
||||
// Save items on ground before closing
|
||||
if (Config.SAVE_DROPPED_ITEM)
|
||||
{
|
||||
ItemsOnGroundManager.getInstance().saveInDb();
|
||||
_log.info("Items On Ground Manager: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Items On Ground Manager: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
ItemsOnGroundManager.getInstance().cleanUp();
|
||||
_log.info("Items On Ground Manager: Cleaned up(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Items On Ground Manager: Cleaned up(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
|
||||
// Save bot reports to database
|
||||
if (Config.BOTREPORT_ENABLE)
|
||||
{
|
||||
BotReportTable.getInstance().saveReportedCharData();
|
||||
_log.info("Bot Report Table: Successfully saved reports to database!");
|
||||
LOGGER.info("Bot Report Table: Successfully saved reports to database!");
|
||||
}
|
||||
|
||||
try
|
||||
@@ -632,7 +635,7 @@ public class Shutdown extends Thread
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
_log.log(Level.WARNING, "Failed logout char " + player, t);
|
||||
LOGGER.log(Level.WARNING, "Failed logout char " + player, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -189,14 +189,14 @@ public class CharSummonTable
|
||||
final int curMp = rs.getInt("curMp");
|
||||
final int time = rs.getInt("time");
|
||||
|
||||
removeServitor(activeChar);
|
||||
skill = SkillData.getInstance().getSkill(skillId, activeChar.getSkillLevel(skillId));
|
||||
if (skill == null)
|
||||
{
|
||||
removeServitor(activeChar);
|
||||
return;
|
||||
}
|
||||
|
||||
skill.applyEffects(activeChar, activeChar);
|
||||
|
||||
if (activeChar.hasServitor())
|
||||
{
|
||||
final L2ServitorInstance summon = (L2ServitorInstance) activeChar.getSummon();
|
||||
|
@@ -33,7 +33,6 @@ import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.TradeItem;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient.GameClientState;
|
||||
|
||||
public class OfflineTradersTable
|
||||
{
|
||||
@@ -187,14 +186,13 @@ public class OfflineTradersTable
|
||||
|
||||
try
|
||||
{
|
||||
final L2GameClient client = new L2GameClient(null);
|
||||
final L2GameClient client = new L2GameClient();
|
||||
client.setDetached(true);
|
||||
player = L2PcInstance.load(rs.getInt("charId"));
|
||||
client.setActiveChar(player);
|
||||
player.setOnlineStatus(true, false);
|
||||
client.setAccountName(player.getAccountNamePlayer());
|
||||
L2World.getInstance().addPlayerToWorld(player);
|
||||
client.setState(GameClientState.IN_GAME);
|
||||
player.setClient(client);
|
||||
player.setOfflineStartTime(time);
|
||||
player.spawnMe(player.getX(), player.getY(), player.getZ());
|
||||
|
@@ -35,7 +35,7 @@ import com.l2jmobius.gameserver.model.L2AdminCommandAccessRight;
|
||||
import com.l2jmobius.gameserver.model.StatsSet;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
@@ -317,7 +317,7 @@ public final class AdminData implements IGameXmlReader
|
||||
* Broadcast to GMs.
|
||||
* @param packet the packet
|
||||
*/
|
||||
public void broadcastToGMs(L2GameServerPacket packet)
|
||||
public void broadcastToGMs(IClientOutgoingPacket packet)
|
||||
{
|
||||
for (L2PcInstance gm : getAllGms(true))
|
||||
{
|
||||
|
@@ -51,7 +51,7 @@ import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
*/
|
||||
public final class BotReportTable
|
||||
{
|
||||
// Zoey76: TODO: Split XML parsing from SQL operations, use IXmlReader instead of SAXParser.
|
||||
// Zoey76: TODO: Split XML parsing from SQL operations, use IGameXmlReader instead of SAXParser.
|
||||
private static final Logger LOGGER = Logger.getLogger(BotReportTable.class.getName());
|
||||
|
||||
private static final int COLUMN_BOT_ID = 1;
|
||||
@@ -443,7 +443,7 @@ public final class BotReportTable
|
||||
*/
|
||||
private static int hashIp(L2PcInstance player)
|
||||
{
|
||||
final String con = player.getClient().getConnection().getInetAddress().getHostAddress();
|
||||
final String con = player.getClient().getConnectionAddress().getHostAddress();
|
||||
final String[] rawByte = con.split("\\.");
|
||||
final int[] rawIp = new int[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
|
@@ -26,7 +26,7 @@ import com.l2jmobius.gameserver.model.VehiclePathPoint;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2BoatInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2CharTemplate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
public class BoatManager
|
||||
{
|
||||
@@ -151,7 +151,7 @@ public class BoatManager
|
||||
* @param point2
|
||||
* @param packet
|
||||
*/
|
||||
public void broadcastPacket(VehiclePathPoint point1, VehiclePathPoint point2, L2GameServerPacket packet)
|
||||
public void broadcastPacket(VehiclePathPoint point1, VehiclePathPoint point2, IClientOutgoingPacket packet)
|
||||
{
|
||||
broadcastPacketsToPlayers(point1, point2, packet);
|
||||
}
|
||||
@@ -162,25 +162,25 @@ public class BoatManager
|
||||
* @param point2
|
||||
* @param packets
|
||||
*/
|
||||
public void broadcastPackets(VehiclePathPoint point1, VehiclePathPoint point2, L2GameServerPacket... packets)
|
||||
public void broadcastPackets(VehiclePathPoint point1, VehiclePathPoint point2, IClientOutgoingPacket... packets)
|
||||
{
|
||||
broadcastPacketsToPlayers(point1, point2, packets);
|
||||
}
|
||||
|
||||
private void broadcastPacketsToPlayers(VehiclePathPoint point1, VehiclePathPoint point2, L2GameServerPacket... packets)
|
||||
private void broadcastPacketsToPlayers(VehiclePathPoint point1, VehiclePathPoint point2, IClientOutgoingPacket... packets)
|
||||
{
|
||||
for (L2PcInstance player : L2World.getInstance().getPlayers())
|
||||
{
|
||||
if (Math.hypot(player.getX() - point1.getX(), player.getY() - point1.getY()) < Config.BOAT_BROADCAST_RADIUS)
|
||||
{
|
||||
for (L2GameServerPacket p : packets)
|
||||
for (IClientOutgoingPacket p : packets)
|
||||
{
|
||||
player.sendPacket(p);
|
||||
}
|
||||
}
|
||||
else if (Math.hypot(player.getX() - point2.getX(), player.getY() - point2.getY()) < Config.BOAT_BROADCAST_RADIUS)
|
||||
{
|
||||
for (L2GameServerPacket p : packets)
|
||||
for (IClientOutgoingPacket p : packets)
|
||||
{
|
||||
player.sendPacket(p);
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Duel;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
public final class DuelManager
|
||||
{
|
||||
@@ -173,7 +173,7 @@ public final class DuelManager
|
||||
* @param player
|
||||
* @param packet
|
||||
*/
|
||||
public void broadcastToOppositTeam(L2PcInstance player, L2GameServerPacket packet)
|
||||
public void broadcastToOppositTeam(L2PcInstance player, IClientOutgoingPacket packet)
|
||||
{
|
||||
if ((player == null) || !player.isInDuel())
|
||||
{
|
||||
|
@@ -56,7 +56,7 @@ import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
|
||||
import com.l2jmobius.gameserver.model.quest.Quest;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
@@ -1407,7 +1407,7 @@ public final class TerritoryWarManager implements Siegable
|
||||
}
|
||||
}
|
||||
|
||||
public void announceToParticipants(L2GameServerPacket sm, int exp, int sp)
|
||||
public void announceToParticipants(IClientOutgoingPacket sm, int exp, int sp)
|
||||
{
|
||||
// broadcast to clan members
|
||||
for (Territory ter : _territoryList.values())
|
||||
|
@@ -24,7 +24,7 @@ import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
@@ -97,7 +97,7 @@ public abstract class AbstractPlayerGroup
|
||||
* Broadcast a packet to every member of this group.
|
||||
* @param packet the packet to broadcast
|
||||
*/
|
||||
public void broadcastPacket(L2GameServerPacket packet)
|
||||
public void broadcastPacket(IClientOutgoingPacket packet)
|
||||
{
|
||||
forEachMember(m ->
|
||||
{
|
||||
|
@@ -23,7 +23,7 @@ import com.l2jmobius.gameserver.instancemanager.HandysBlockCheckerManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.BlockCheckerEngine;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
@@ -111,7 +111,7 @@ public final class ArenaParticipantsHolder
|
||||
return _bluePlayers.size();
|
||||
}
|
||||
|
||||
public void broadCastPacketToTeam(L2GameServerPacket packet)
|
||||
public void broadCastPacketToTeam(IClientOutgoingPacket packet)
|
||||
{
|
||||
for (L2PcInstance p : _redPlayers)
|
||||
{
|
||||
|
@@ -63,8 +63,8 @@ import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExBrExtraUserInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExSubPledgeSkillAdd;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PledgeReceiveSubPledgeCreated;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PledgeShowInfoUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListAll;
|
||||
@@ -1534,7 +1534,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
}
|
||||
}
|
||||
|
||||
public void broadcastToOnlineAllyMembers(L2GameServerPacket packet)
|
||||
public void broadcastToOnlineAllyMembers(IClientOutgoingPacket packet)
|
||||
{
|
||||
for (L2Clan clan : ClanTable.getInstance().getClanAllies(getAllyId()))
|
||||
{
|
||||
@@ -1542,7 +1542,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
}
|
||||
}
|
||||
|
||||
public void broadcastToOnlineMembers(L2GameServerPacket packet)
|
||||
public void broadcastToOnlineMembers(IClientOutgoingPacket packet)
|
||||
{
|
||||
for (L2ClanMember member : _members.values())
|
||||
{
|
||||
@@ -1564,7 +1564,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
}
|
||||
}
|
||||
|
||||
public void broadcastToOtherOnlineMembers(L2GameServerPacket packet, L2PcInstance player)
|
||||
public void broadcastToOtherOnlineMembers(IClientOutgoingPacket packet, L2PcInstance player)
|
||||
{
|
||||
for (L2ClanMember member : _members.values())
|
||||
{
|
||||
|
@@ -47,7 +47,7 @@ import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.DeleteObject;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExSendUIEvent;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
@@ -328,7 +328,7 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
|
||||
|
||||
public abstract void sendInfo(L2PcInstance activeChar);
|
||||
|
||||
public void sendPacket(L2GameServerPacket mov)
|
||||
public void sendPacket(IClientOutgoingPacket... packets)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -52,7 +52,7 @@ import com.l2jmobius.gameserver.network.serverpackets.ExOpenMPCC;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPartyPetWindowAdd;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPartyPetWindowDelete;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExSetPartyLooting;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PartyMemberPosition;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PartySmallWindowAdd;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PartySmallWindowAll;
|
||||
@@ -265,7 +265,7 @@ public class L2Party extends AbstractPlayerGroup
|
||||
* @param player
|
||||
* @param msg
|
||||
*/
|
||||
public void broadcastToPartyMembers(L2PcInstance player, L2GameServerPacket msg)
|
||||
public void broadcastToPartyMembers(L2PcInstance player, IClientOutgoingPacket msg)
|
||||
{
|
||||
for (L2PcInstance member : getMembers())
|
||||
{
|
||||
|
@@ -19,7 +19,7 @@ package com.l2jmobius.gameserver.model;
|
||||
import com.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.L2GameClientPacket;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
@@ -34,7 +34,7 @@ public class L2Request
|
||||
protected L2PcInstance _partner;
|
||||
protected boolean _isRequestor;
|
||||
protected boolean _isAnswerer;
|
||||
protected L2GameClientPacket _requestPacket;
|
||||
protected IClientIncomingPacket _requestPacket;
|
||||
|
||||
public L2Request(L2PcInstance player)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ public class L2Request
|
||||
* Set the packet incomed from requester.
|
||||
* @param packet
|
||||
*/
|
||||
private synchronized void setRequestPacket(L2GameClientPacket packet)
|
||||
private synchronized void setRequestPacket(IClientIncomingPacket packet)
|
||||
{
|
||||
_requestPacket = packet;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public class L2Request
|
||||
* Return the packet originally incomed from requester.
|
||||
* @return
|
||||
*/
|
||||
public L2GameClientPacket getRequestPacket()
|
||||
public IClientIncomingPacket getRequestPacket()
|
||||
{
|
||||
return _requestPacket;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public class L2Request
|
||||
* @param packet
|
||||
* @return
|
||||
*/
|
||||
public synchronized boolean setRequest(L2PcInstance partner, L2GameClientPacket packet)
|
||||
public synchronized boolean setRequest(L2PcInstance partner, IClientIncomingPacket packet)
|
||||
{
|
||||
if (partner == null)
|
||||
{
|
||||
|
@@ -26,7 +26,7 @@ import com.l2jmobius.gameserver.instancemanager.PetitionManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PetitionVotePacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
@@ -136,7 +136,7 @@ public final class Petition
|
||||
return _type.toString().replace("_", " ");
|
||||
}
|
||||
|
||||
public void sendPetitionerPacket(L2GameServerPacket responsePacket)
|
||||
public void sendPetitionerPacket(IClientOutgoingPacket responsePacket)
|
||||
{
|
||||
if ((getPetitioner() == null) || !getPetitioner().isOnline())
|
||||
{
|
||||
@@ -150,7 +150,7 @@ public final class Petition
|
||||
getPetitioner().sendPacket(responsePacket);
|
||||
}
|
||||
|
||||
public void sendResponderPacket(L2GameServerPacket responsePacket)
|
||||
public void sendResponderPacket(IClientOutgoingPacket responsePacket)
|
||||
{
|
||||
if ((getResponder() == null) || !getResponder().isOnline())
|
||||
{
|
||||
|
@@ -132,8 +132,8 @@ import com.l2jmobius.gameserver.network.serverpackets.ChangeMoveType;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ChangeWaitType;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExRotation;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.FlyToLocation.FlyType;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillCanceld;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillCanceled;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillLaunched;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MoveToLocation;
|
||||
@@ -533,9 +533,8 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
* In order to inform other players of state modification on the L2Character, server just need to go through _knownPlayers to send Server->Client Packet
|
||||
* @param mov
|
||||
*/
|
||||
public void broadcastPacket(L2GameServerPacket mov)
|
||||
public void broadcastPacket(IClientOutgoingPacket mov)
|
||||
{
|
||||
mov.setInvisible(isInvisible());
|
||||
final Collection<L2PcInstance> plrs = getKnownList().getKnownPlayers().values();
|
||||
for (L2PcInstance player : plrs)
|
||||
{
|
||||
@@ -554,9 +553,8 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
* @param mov
|
||||
* @param radiusInKnownlist
|
||||
*/
|
||||
public void broadcastPacket(L2GameServerPacket mov, int radiusInKnownlist)
|
||||
public void broadcastPacket(IClientOutgoingPacket mov, int radiusInKnownlist)
|
||||
{
|
||||
mov.setInvisible(isInvisible());
|
||||
final Collection<L2PcInstance> plrs = getKnownList().getKnownPlayers().values();
|
||||
for (L2PcInstance player : plrs)
|
||||
{
|
||||
@@ -3915,7 +3913,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
{
|
||||
getAI().notifyEvent(CtrlEvent.EVT_FINISH_CASTING); // setting back previous intention
|
||||
}
|
||||
broadcastPacket(new MagicSkillCanceld(getObjectId())); // broadcast packet to stop animations client-side
|
||||
broadcastPacket(new MagicSkillCanceled(getObjectId())); // broadcast packet to stop animations client-side
|
||||
sendPacket(ActionFailed.STATIC_PACKET); // send an "action failed" packet to the caster
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ import com.l2jmobius.gameserver.model.items.L2Weapon;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CharInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.taskmanager.DecayTaskManager;
|
||||
|
||||
public abstract class L2Decoy extends L2Character
|
||||
@@ -49,7 +49,7 @@ public abstract class L2Decoy extends L2Character
|
||||
public void onSpawn()
|
||||
{
|
||||
super.onSpawn();
|
||||
sendPacket(new CharInfo(this));
|
||||
sendPacket(new CharInfo(this, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,7 +59,7 @@ public abstract class L2Decoy extends L2Character
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
player.sendPacket(new CharInfo(this));
|
||||
player.sendPacket(new CharInfo(this, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,15 +159,15 @@ public abstract class L2Decoy extends L2Character
|
||||
@Override
|
||||
public void sendInfo(L2PcInstance activeChar)
|
||||
{
|
||||
activeChar.sendPacket(new CharInfo(this));
|
||||
activeChar.sendPacket(new CharInfo(this, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacket(L2GameServerPacket mov)
|
||||
public void sendPacket(IClientOutgoingPacket... packets)
|
||||
{
|
||||
if (getOwner() != null)
|
||||
{
|
||||
getOwner().sendPacket(mov);
|
||||
getOwner().sendPacket(packets);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -59,7 +59,7 @@ import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPartyPetWindowAdd;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPartyPetWindowDelete;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPartyPetWindowUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PetDelete;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PetInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PetItemList;
|
||||
@@ -852,26 +852,6 @@ public abstract class L2Summon extends L2Playable
|
||||
return getOwner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void broadcastPacket(L2GameServerPacket mov)
|
||||
{
|
||||
if (getOwner() != null)
|
||||
{
|
||||
mov.setInvisible(getOwner().isInvisible());
|
||||
}
|
||||
super.broadcastPacket(mov);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void broadcastPacket(L2GameServerPacket mov, int radiusInKnownlist)
|
||||
{
|
||||
if (getOwner() != null)
|
||||
{
|
||||
mov.setInvisible(getOwner().isInvisible());
|
||||
}
|
||||
super.broadcastPacket(mov, radiusInKnownlist);
|
||||
}
|
||||
|
||||
public void updateAndBroadcastStatus(int val)
|
||||
{
|
||||
if (getOwner() == null)
|
||||
@@ -1095,11 +1075,11 @@ public abstract class L2Summon extends L2Playable
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacket(L2GameServerPacket mov)
|
||||
public void sendPacket(IClientOutgoingPacket... packets)
|
||||
{
|
||||
if (getOwner() != null)
|
||||
{
|
||||
getOwner().sendPacket(mov);
|
||||
getOwner().sendPacket(packets);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -40,8 +40,8 @@ import com.l2jmobius.gameserver.model.interfaces.ILocational;
|
||||
import com.l2jmobius.gameserver.model.items.L2Weapon;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
@@ -269,7 +269,7 @@ public abstract class L2Vehicle extends L2Character
|
||||
return _passengers;
|
||||
}
|
||||
|
||||
public void broadcastToPassengers(L2GameServerPacket sm)
|
||||
public void broadcastToPassengers(IClientOutgoingPacket sm)
|
||||
{
|
||||
for (L2PcInstance player : _passengers)
|
||||
{
|
||||
|
@@ -262,7 +262,6 @@ import com.l2jmobius.gameserver.network.serverpackets.ConfirmDlg;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExAutoSoulShot;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExBrExtraUserInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExDominionWarStart;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExDuelUpdateUserInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExFishingEnd;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExFishingStart;
|
||||
@@ -280,9 +279,9 @@ import com.l2jmobius.gameserver.network.serverpackets.FriendStatusPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.GameGuardQuery;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.GetOnVehicle;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.HennaInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.LeaveWorld;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MyTargetSelected;
|
||||
@@ -2052,10 +2051,8 @@ public final class L2PcInstance extends L2Playable
|
||||
removeSkill(getKnownSkill(4270), false, true);
|
||||
setIsOverloaded(false);
|
||||
}
|
||||
sendPacket(new UserInfo(this));
|
||||
broadcastUserInfo();
|
||||
sendPacket(new EtcStatusUpdate(this));
|
||||
broadcastPacket(new CharInfo(this));
|
||||
broadcastPacket(new ExBrExtraUserInfo(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3942,7 +3939,12 @@ public final class L2PcInstance extends L2Playable
|
||||
|
||||
public String getIPAddress()
|
||||
{
|
||||
return (_client != null) && (_client.getConnectionAddress() != null) ? _client.getConnectionAddress().getHostAddress() : "N/A";
|
||||
String ip = "N/A";
|
||||
if ((_client != null) && (_client.getConnectionAddress() != null))
|
||||
{
|
||||
ip = _client.getConnectionAddress().getHostAddress();
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3951,15 +3953,23 @@ public final class L2PcInstance extends L2Playable
|
||||
*/
|
||||
private void closeNetConnection(boolean closeClient)
|
||||
{
|
||||
if (_client != null)
|
||||
final L2GameClient client = _client;
|
||||
if (client != null)
|
||||
{
|
||||
if (_client.isDetached())
|
||||
if (client.isDetached())
|
||||
{
|
||||
_client.cleanMe(true);
|
||||
client.cleanMe(true);
|
||||
}
|
||||
else if (!_client.getConnection().isClosed())
|
||||
else if (client.getChannel().isActive())
|
||||
{
|
||||
_client.close(closeClient ? LeaveWorld.STATIC_PACKET : ServerClose.STATIC_PACKET);
|
||||
if (closeClient)
|
||||
{
|
||||
client.close(LeaveWorld.STATIC_PACKET);
|
||||
}
|
||||
else
|
||||
{
|
||||
client.close(ServerClose.STATIC_PACKET);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4132,15 +4142,30 @@ public final class L2PcInstance extends L2Playable
|
||||
*/
|
||||
public final void broadcastUserInfo()
|
||||
{
|
||||
// Send a Server->Client packet UserInfo to this L2PcInstance
|
||||
// Send user info to the current player
|
||||
sendPacket(new UserInfo(this));
|
||||
|
||||
// Send a Server->Client packet CharInfo to all L2PcInstance in _KnownPlayers of the L2PcInstance
|
||||
broadcastPacket(new CharInfo(this));
|
||||
broadcastPacket(new ExBrExtraUserInfo(this));
|
||||
if (TerritoryWarManager.getInstance().isTWInProgress() && (TerritoryWarManager.getInstance().checkIsRegistered(-1, getObjectId()) || TerritoryWarManager.getInstance().checkIsRegistered(-1, getClan())))
|
||||
|
||||
// Broadcast char info to known players
|
||||
broadcastCharInfo();
|
||||
}
|
||||
|
||||
public final void broadcastCharInfo()
|
||||
{
|
||||
final CharInfo charInfo = new CharInfo(this, false);
|
||||
for (L2PcInstance player : getKnownList().getKnownPlayers().values())
|
||||
{
|
||||
broadcastPacket(new ExDominionWarStart(this));
|
||||
if (isVisibleFor(player))
|
||||
{
|
||||
if (isInvisible() && player.canOverrideCond(PcCondOverride.SEE_ALL_PLAYERS))
|
||||
{
|
||||
player.sendPacket(new CharInfo(this, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(charInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4156,15 +4181,13 @@ public final class L2PcInstance extends L2Playable
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void broadcastPacket(L2GameServerPacket mov)
|
||||
public final void broadcastPacket(IClientOutgoingPacket mov)
|
||||
{
|
||||
if (!(mov instanceof CharInfo))
|
||||
{
|
||||
sendPacket(mov);
|
||||
}
|
||||
|
||||
mov.setInvisible(isInvisible());
|
||||
|
||||
for (L2PcInstance player : getKnownList().getKnownPlayers().values())
|
||||
{
|
||||
if ((player == null) || !isVisibleFor(player))
|
||||
@@ -4189,15 +4212,13 @@ public final class L2PcInstance extends L2Playable
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastPacket(L2GameServerPacket mov, int radiusInKnownlist)
|
||||
public void broadcastPacket(IClientOutgoingPacket mov, int radiusInKnownlist)
|
||||
{
|
||||
if (!(mov instanceof CharInfo))
|
||||
{
|
||||
sendPacket(mov);
|
||||
}
|
||||
|
||||
mov.setInvisible(isInvisible());
|
||||
|
||||
for (L2PcInstance player : getKnownList().getKnownPlayers().values())
|
||||
{
|
||||
if (player == null)
|
||||
@@ -4255,11 +4276,14 @@ public final class L2PcInstance extends L2Playable
|
||||
* Send a Server->Client packet StatusUpdate to the L2PcInstance.
|
||||
*/
|
||||
@Override
|
||||
public void sendPacket(L2GameServerPacket packet)
|
||||
public void sendPacket(IClientOutgoingPacket... packets)
|
||||
{
|
||||
if (_client != null)
|
||||
{
|
||||
_client.sendPacket(packet);
|
||||
for (IClientOutgoingPacket packet : packets)
|
||||
{
|
||||
_client.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12955,7 +12979,7 @@ public final class L2PcInstance extends L2Playable
|
||||
{
|
||||
setXYZ(getBoat().getLocation());
|
||||
|
||||
activeChar.sendPacket(new CharInfo(this));
|
||||
activeChar.sendPacket(new CharInfo(this, isInvisible() && activeChar.canOverrideCond(PcCondOverride.SEE_ALL_PLAYERS)));
|
||||
activeChar.sendPacket(new ExBrExtraUserInfo(this));
|
||||
final int relation1 = getRelation(activeChar);
|
||||
final int relation2 = activeChar.getRelation(this);
|
||||
@@ -12982,7 +13006,7 @@ public final class L2PcInstance extends L2Playable
|
||||
else if (isInAirShip())
|
||||
{
|
||||
setXYZ(getAirShip().getLocation());
|
||||
activeChar.sendPacket(new CharInfo(this));
|
||||
activeChar.sendPacket(new CharInfo(this, isInvisible() && activeChar.canOverrideCond(PcCondOverride.SEE_ALL_PLAYERS)));
|
||||
activeChar.sendPacket(new ExBrExtraUserInfo(this));
|
||||
final int relation1 = getRelation(activeChar);
|
||||
final int relation2 = activeChar.getRelation(this);
|
||||
@@ -13008,7 +13032,7 @@ public final class L2PcInstance extends L2Playable
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new CharInfo(this));
|
||||
activeChar.sendPacket(new CharInfo(this, isInvisible() && activeChar.canOverrideCond(PcCondOverride.SEE_ALL_PLAYERS)));
|
||||
activeChar.sendPacket(new ExBrExtraUserInfo(this));
|
||||
final int relation1 = getRelation(activeChar);
|
||||
final int relation2 = activeChar.getRelation(this);
|
||||
@@ -13058,7 +13082,7 @@ public final class L2PcInstance extends L2Playable
|
||||
if (isTransformed())
|
||||
{
|
||||
// Required double send for fix Mounted H5+
|
||||
sendPacket(new CharInfo(activeChar));
|
||||
sendPacket(new CharInfo(activeChar, false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14256,7 +14280,6 @@ public final class L2PcInstance extends L2Playable
|
||||
public void setCharmOfCourage(boolean val)
|
||||
{
|
||||
_hasCharmOfCourage = val;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -31,8 +31,8 @@ import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.DeleteObject;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MonRaceInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
|
||||
@@ -222,7 +222,7 @@ public class L2RaceManagerInstance extends L2Npc
|
||||
}
|
||||
}
|
||||
|
||||
protected void broadcast(L2GameServerPacket pkt)
|
||||
protected void broadcast(IClientOutgoingPacket pkt)
|
||||
{
|
||||
for (L2RaceManagerInstance manager : _managers)
|
||||
{
|
||||
|
@@ -40,7 +40,7 @@ import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.AbstractNpcInfo.TrapInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.taskmanager.DecayTaskManager;
|
||||
|
||||
@@ -101,7 +101,7 @@ public final class L2TrapInstance extends L2Npc
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastPacket(L2GameServerPacket mov)
|
||||
public void broadcastPacket(IClientOutgoingPacket mov)
|
||||
{
|
||||
for (L2PcInstance player : getKnownList().getKnownPlayers().values())
|
||||
{
|
||||
@@ -113,7 +113,7 @@ public final class L2TrapInstance extends L2Npc
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastPacket(L2GameServerPacket mov, int radiusInKnownlist)
|
||||
public void broadcastPacket(IClientOutgoingPacket mov, int radiusInKnownlist)
|
||||
{
|
||||
for (L2PcInstance player : getKnownList().getKnownPlayers().values())
|
||||
{
|
||||
|
@@ -46,7 +46,7 @@ import com.l2jmobius.gameserver.network.serverpackets.ExDuelEnd;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExDuelReady;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExDuelStart;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExDuelUpdateUserInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SocialAction;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
@@ -632,7 +632,7 @@ public class Duel
|
||||
* Broadcast a packet to the challenger team
|
||||
* @param packet
|
||||
*/
|
||||
public void broadcastToTeam1(L2GameServerPacket packet)
|
||||
public void broadcastToTeam1(IClientOutgoingPacket packet)
|
||||
{
|
||||
if (_playerA == null)
|
||||
{
|
||||
@@ -656,7 +656,7 @@ public class Duel
|
||||
* Broadcast a packet to the challenged team
|
||||
* @param packet
|
||||
*/
|
||||
public void broadcastToTeam2(L2GameServerPacket packet)
|
||||
public void broadcastToTeam2(IClientOutgoingPacket packet)
|
||||
{
|
||||
if (_playerB == null)
|
||||
{
|
||||
|
@@ -41,11 +41,8 @@ import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.PlayerEventHolder;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CharInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExBrExtraUserInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
|
||||
|
||||
/**
|
||||
* @author Nik
|
||||
@@ -281,11 +278,7 @@ public class L2Event
|
||||
player.getPoly().setPolyInfo(null, "1");
|
||||
player.decayMe();
|
||||
player.spawnMe(player.getX(), player.getY(), player.getZ());
|
||||
final CharInfo info1 = new CharInfo(player);
|
||||
player.broadcastPacket(info1);
|
||||
final UserInfo info2 = new UserInfo(player);
|
||||
player.sendPacket(info2);
|
||||
player.broadcastPacket(new ExBrExtraUserInfo(player));
|
||||
player.broadcastUserInfo();
|
||||
|
||||
player.stopTransformation(true);
|
||||
}
|
||||
|
@@ -878,7 +878,7 @@ public class Siege implements Siegable
|
||||
*/
|
||||
public void listRegisterClan(L2PcInstance player)
|
||||
{
|
||||
player.sendPacket(new SiegeInfo(getCastle()));
|
||||
player.sendPacket(new SiegeInfo(getCastle(), player));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -256,7 +256,7 @@ public final class SiegableHall extends ClanHall
|
||||
|
||||
public final void showSiegeInfo(L2PcInstance player)
|
||||
{
|
||||
player.sendPacket(new SiegeInfo(this));
|
||||
player.sendPacket(new SiegeInfo(this, player));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -34,7 +34,7 @@ import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
@@ -393,12 +393,12 @@ public final class ItemAuction
|
||||
}
|
||||
}
|
||||
|
||||
public final void broadcastToAllBidders(L2GameServerPacket packet)
|
||||
public final void broadcastToAllBidders(IClientOutgoingPacket packet)
|
||||
{
|
||||
ThreadPool.execute(() -> broadcastToAllBiddersInternal(packet));
|
||||
}
|
||||
|
||||
public final void broadcastToAllBiddersInternal(L2GameServerPacket packet)
|
||||
public final void broadcastToAllBiddersInternal(IClientOutgoingPacket packet)
|
||||
{
|
||||
for (int i = _auctionBids.size(); i-- > 0;)
|
||||
{
|
||||
|
@@ -37,8 +37,8 @@ import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.zone.type.L2OlympiadStadiumZone;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExOlympiadMode;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
@@ -457,7 +457,7 @@ public abstract class AbstractOlympiadGame
|
||||
|
||||
public abstract void broadcastOlympiadInfo(L2OlympiadStadiumZone stadium);
|
||||
|
||||
protected abstract void broadcastPacket(L2GameServerPacket packet);
|
||||
protected abstract void broadcastPacket(IClientOutgoingPacket packet);
|
||||
|
||||
protected abstract boolean needBuffers();
|
||||
|
||||
|
@@ -37,7 +37,7 @@ import com.l2jmobius.gameserver.model.zone.type.L2OlympiadStadiumZone;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExOlympiadMatchResult;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExOlympiadUserInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
@@ -119,7 +119,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void broadcastPacket(L2GameServerPacket packet)
|
||||
protected final void broadcastPacket(IClientOutgoingPacket packet)
|
||||
{
|
||||
if (_playerOne.updatePlayer())
|
||||
{
|
||||
|
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.zone.type.L2OlympiadStadiumZone;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExOlympiadMatchResult;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExOlympiadUserInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
@@ -258,7 +258,7 @@ public class OlympiadGameTeams extends AbstractOlympiadGame
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void broadcastPacket(L2GameServerPacket packet)
|
||||
protected final void broadcastPacket(IClientOutgoingPacket packet)
|
||||
{
|
||||
Participant par;
|
||||
for (int i = 0; i < _teamOneSize; i++)
|
||||
|
@@ -66,7 +66,7 @@ import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.zone.L2ZoneType;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcQuestHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExNpcQuestHtmlMessage;
|
||||
import com.l2jmobius.gameserver.scripting.ScriptEngineManager;
|
||||
|
||||
/**
|
||||
@@ -2450,7 +2450,7 @@ public class Quest extends AbstractScript implements IIdentifiable
|
||||
|
||||
if (questwindow && (questId > 0) && (questId < 20000) && (questId != 999))
|
||||
{
|
||||
final NpcQuestHtmlMessage npcReply = new NpcQuestHtmlMessage(npc != null ? npc.getObjectId() : 0, questId);
|
||||
final ExNpcQuestHtmlMessage npcReply = new ExNpcQuestHtmlMessage(npc != null ? npc.getObjectId() : 0, questId);
|
||||
npcReply.setHtml(content);
|
||||
npcReply.replace("%playername%", player.getName());
|
||||
player.sendPacket(npcReply);
|
||||
|
@@ -175,7 +175,7 @@ public final class QuestState
|
||||
}
|
||||
}
|
||||
|
||||
_player.sendPacket(new QuestList());
|
||||
_player.sendPacket(new QuestList(_player));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ public final class QuestState
|
||||
}
|
||||
|
||||
// send a packet to the client to inform it of the quest progress (step change)
|
||||
_player.sendPacket(new QuestList());
|
||||
_player.sendPacket(new QuestList(_player));
|
||||
|
||||
final Quest q = getQuest();
|
||||
if (!q.isCustomQuest() && (cond > 0))
|
||||
@@ -684,7 +684,7 @@ public final class QuestState
|
||||
if (repeatable)
|
||||
{
|
||||
_player.delQuestState(getQuestName());
|
||||
_player.sendPacket(new QuestList());
|
||||
_player.sendPacket(new QuestList(_player));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -33,7 +33,7 @@ import com.l2jmobius.gameserver.model.events.ListenersContainer;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.OnCreatureZoneEnter;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.OnCreatureZoneExit;
|
||||
import com.l2jmobius.gameserver.model.interfaces.ILocational;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* Abstract base class for any zone type handles basic operations.
|
||||
@@ -526,7 +526,7 @@ public abstract class L2ZoneType extends ListenersContainer
|
||||
* Broadcasts packet to all players inside the zone
|
||||
* @param packet
|
||||
*/
|
||||
public void broadcastPacket(L2GameServerPacket packet)
|
||||
public void broadcastPacket(IClientOutgoingPacket packet)
|
||||
{
|
||||
if (_characterList.isEmpty())
|
||||
{
|
||||
|
@@ -37,7 +37,7 @@ import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExOlympiadMatchEnd;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExOlympiadUserInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
@@ -146,7 +146,7 @@ public class L2OlympiadStadiumZone extends L2ZoneRespawn
|
||||
}
|
||||
}
|
||||
|
||||
public final void broadcastPacketToObservers(L2GameServerPacket packet)
|
||||
public final void broadcastPacketToObservers(IClientOutgoingPacket packet)
|
||||
{
|
||||
for (L2Character character : getCharactersInside())
|
||||
{
|
||||
|
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import com.l2jmobius.commons.network.codecs.CryptCodec;
|
||||
import com.l2jmobius.commons.network.codecs.LengthFieldBasedFrameEncoder;
|
||||
import com.l2jmobius.commons.network.codecs.PacketDecoder;
|
||||
import com.l2jmobius.commons.network.codecs.PacketEncoder;
|
||||
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
*/
|
||||
public class ClientInitializer extends ChannelInitializer<SocketChannel>
|
||||
{
|
||||
private static final LengthFieldBasedFrameEncoder LENGTH_ENCODER = new LengthFieldBasedFrameEncoder();
|
||||
private static final PacketEncoder PACKET_ENCODER = new PacketEncoder(0x8000 - 2);
|
||||
|
||||
@Override
|
||||
protected void initChannel(SocketChannel ch)
|
||||
{
|
||||
final L2GameClient client = new L2GameClient();
|
||||
ch.pipeline().addLast("length-decoder", new LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, 0x8000 - 2, 0, 2, -2, 2, false));
|
||||
ch.pipeline().addLast("length-encoder", LENGTH_ENCODER);
|
||||
ch.pipeline().addLast("crypt-codec", new CryptCodec(client.getCrypt()));
|
||||
// ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO));
|
||||
ch.pipeline().addLast("packet-decoder", new PacketDecoder<>(IncomingPackets.PACKET_ARRAY, client));
|
||||
ch.pipeline().addLast("packet-encoder", PACKET_ENCODER);
|
||||
ch.pipeline().addLast(client);
|
||||
}
|
||||
}
|
@@ -14,33 +14,28 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.mmocore;
|
||||
package com.l2jmobius.gameserver.network;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.network.NetworkManager;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
* @param <T>
|
||||
* @author Nos
|
||||
*/
|
||||
public abstract class MMOClient<T extends MMOConnection<?>>
|
||||
public class ClientNetworkManager extends NetworkManager
|
||||
{
|
||||
private final T _con;
|
||||
|
||||
public MMOClient(T con)
|
||||
protected ClientNetworkManager()
|
||||
{
|
||||
_con = con;
|
||||
super(EventLoopGroupManager.getInstance().getBossGroup(), EventLoopGroupManager.getInstance().getWorkerGroup(), new ClientInitializer(), Config.GAMESERVER_HOSTNAME, Config.PORT_GAME);
|
||||
}
|
||||
|
||||
public T getConnection()
|
||||
public static ClientNetworkManager getInstance()
|
||||
{
|
||||
return _con;
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
public abstract boolean decrypt(ByteBuffer buf, int size);
|
||||
|
||||
public abstract boolean encrypt(ByteBuffer buf, int size);
|
||||
|
||||
protected abstract void onDisconnection();
|
||||
|
||||
protected abstract void onForcedDisconnection();
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final ClientNetworkManager _instance = new ClientNetworkManager();
|
||||
}
|
||||
}
|
@@ -1,248 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
|
||||
public class ClientStats
|
||||
{
|
||||
public int processedPackets = 0;
|
||||
public int droppedPackets = 0;
|
||||
public int unknownPackets = 0;
|
||||
public int totalQueueSize = 0;
|
||||
public int maxQueueSize = 0;
|
||||
public int totalBursts = 0;
|
||||
public int maxBurstSize = 0;
|
||||
public int shortFloods = 0;
|
||||
public int longFloods = 0;
|
||||
public int totalQueueOverflows = 0;
|
||||
public int totalUnderflowExceptions = 0;
|
||||
|
||||
private final int[] _packetsInSecond;
|
||||
private long _packetCountStartTick = 0;
|
||||
private int _head;
|
||||
private int _totalCount = 0;
|
||||
|
||||
private int _floodsInMin = 0;
|
||||
private long _floodStartTick = 0;
|
||||
private int _unknownPacketsInMin = 0;
|
||||
private long _unknownPacketStartTick = 0;
|
||||
private int _overflowsInMin = 0;
|
||||
private long _overflowStartTick = 0;
|
||||
private int _underflowReadsInMin = 0;
|
||||
private long _underflowReadStartTick = 0;
|
||||
|
||||
private volatile boolean _floodDetected = false;
|
||||
private volatile boolean _queueOverflowDetected = false;
|
||||
|
||||
private final int BUFFER_SIZE;
|
||||
|
||||
public ClientStats()
|
||||
{
|
||||
BUFFER_SIZE = Config.CLIENT_PACKET_QUEUE_MEASURE_INTERVAL;
|
||||
_packetsInSecond = new int[BUFFER_SIZE];
|
||||
_head = BUFFER_SIZE - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if incoming packet need to be dropped
|
||||
*/
|
||||
protected final boolean dropPacket()
|
||||
{
|
||||
final boolean result = _floodDetected || _queueOverflowDetected;
|
||||
if (result)
|
||||
{
|
||||
droppedPackets++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Later during flood returns true (and send ActionFailed) once per second.
|
||||
* @param queueSize
|
||||
* @return true if flood detected first and ActionFailed packet need to be sent.
|
||||
*/
|
||||
protected final boolean countPacket(int queueSize)
|
||||
{
|
||||
processedPackets++;
|
||||
totalQueueSize += queueSize;
|
||||
if (maxQueueSize < queueSize)
|
||||
{
|
||||
maxQueueSize = queueSize;
|
||||
}
|
||||
if (_queueOverflowDetected && (queueSize < 2))
|
||||
{
|
||||
_queueOverflowDetected = false;
|
||||
}
|
||||
|
||||
return countPacket();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Counts unknown packets and return true if threshold is reached.
|
||||
*/
|
||||
protected final boolean countUnknownPacket()
|
||||
{
|
||||
unknownPackets++;
|
||||
|
||||
final long tick = System.currentTimeMillis();
|
||||
if ((tick - _unknownPacketStartTick) > 60000)
|
||||
{
|
||||
_unknownPacketStartTick = tick;
|
||||
_unknownPacketsInMin = 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
_unknownPacketsInMin++;
|
||||
return _unknownPacketsInMin > Config.CLIENT_PACKET_QUEUE_MAX_UNKNOWN_PER_MIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param count - current number of processed packets in burst
|
||||
* @return burst length and return true if execution of the queue need to be aborted.
|
||||
*/
|
||||
protected final boolean countBurst(int count)
|
||||
{
|
||||
if (count > maxBurstSize)
|
||||
{
|
||||
maxBurstSize = count;
|
||||
}
|
||||
|
||||
if (count < Config.CLIENT_PACKET_QUEUE_MAX_BURST_SIZE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
totalBursts++;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Counts queue overflows and return true if threshold is reached.
|
||||
*/
|
||||
protected final boolean countQueueOverflow()
|
||||
{
|
||||
_queueOverflowDetected = true;
|
||||
totalQueueOverflows++;
|
||||
|
||||
final long tick = System.currentTimeMillis();
|
||||
if ((tick - _overflowStartTick) > 60000)
|
||||
{
|
||||
_overflowStartTick = tick;
|
||||
_overflowsInMin = 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
_overflowsInMin++;
|
||||
return _overflowsInMin > Config.CLIENT_PACKET_QUEUE_MAX_OVERFLOWS_PER_MIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Counts underflow exceptions and return true if threshold is reached.
|
||||
*/
|
||||
protected final boolean countUnderflowException()
|
||||
{
|
||||
totalUnderflowExceptions++;
|
||||
|
||||
final long tick = System.currentTimeMillis();
|
||||
if ((tick - _underflowReadStartTick) > 60000)
|
||||
{
|
||||
_underflowReadStartTick = tick;
|
||||
_underflowReadsInMin = 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
_underflowReadsInMin++;
|
||||
return _underflowReadsInMin > Config.CLIENT_PACKET_QUEUE_MAX_UNDERFLOWS_PER_MIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if maximum number of floods per minute is reached.
|
||||
*/
|
||||
protected final boolean countFloods()
|
||||
{
|
||||
return _floodsInMin > Config.CLIENT_PACKET_QUEUE_MAX_FLOODS_PER_MIN;
|
||||
}
|
||||
|
||||
private final boolean longFloodDetected()
|
||||
{
|
||||
return (_totalCount / BUFFER_SIZE) > Config.CLIENT_PACKET_QUEUE_MAX_AVERAGE_PACKETS_PER_SECOND;
|
||||
}
|
||||
|
||||
/**
|
||||
* Later during flood returns true (and send ActionFailed) once per second.
|
||||
* @return true if flood detected first and ActionFailed packet need to be sent.
|
||||
*/
|
||||
private final synchronized boolean countPacket()
|
||||
{
|
||||
_totalCount++;
|
||||
final long tick = System.currentTimeMillis();
|
||||
if ((tick - _packetCountStartTick) > 1000)
|
||||
{
|
||||
_packetCountStartTick = tick;
|
||||
|
||||
// clear flag if no more flooding during last seconds
|
||||
if (_floodDetected && !longFloodDetected() && (_packetsInSecond[_head] < (Config.CLIENT_PACKET_QUEUE_MAX_PACKETS_PER_SECOND / 2)))
|
||||
{
|
||||
_floodDetected = false;
|
||||
}
|
||||
|
||||
// wrap head of the buffer around the tail
|
||||
if (_head <= 0)
|
||||
{
|
||||
_head = BUFFER_SIZE;
|
||||
}
|
||||
_head--;
|
||||
|
||||
_totalCount -= _packetsInSecond[_head];
|
||||
_packetsInSecond[_head] = 1;
|
||||
return _floodDetected;
|
||||
}
|
||||
|
||||
final int count = ++_packetsInSecond[_head];
|
||||
if (!_floodDetected)
|
||||
{
|
||||
if (count > Config.CLIENT_PACKET_QUEUE_MAX_PACKETS_PER_SECOND)
|
||||
{
|
||||
shortFloods++;
|
||||
}
|
||||
else if (longFloodDetected())
|
||||
{
|
||||
longFloods++;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_floodDetected = true;
|
||||
if ((tick - _floodStartTick) > 60000)
|
||||
{
|
||||
_floodStartTick = tick;
|
||||
_floodsInMin = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_floodsInMin++;
|
||||
}
|
||||
|
||||
return true; // Return true only in the beginning of the flood
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -14,15 +14,18 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.mmocore;
|
||||
package com.l2jmobius.gameserver.network;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import com.l2jmobius.commons.network.IConnectionState;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
* @author Nos
|
||||
*/
|
||||
public interface IAcceptFilter
|
||||
public enum ConnectionState implements IConnectionState
|
||||
{
|
||||
boolean accept(SocketChannel sc) throws UnknownHostException;
|
||||
CONNECTED,
|
||||
DISCONNECTED,
|
||||
CLOSING,
|
||||
AUTHENTICATED,
|
||||
IN_GAME
|
||||
}
|
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network;
|
||||
|
||||
import com.l2jmobius.commons.network.ICrypt;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
/**
|
||||
* @author UnAfraid, Nos
|
||||
*/
|
||||
public class Crypt implements ICrypt
|
||||
{
|
||||
// private final L2GameClient _client;
|
||||
private final byte[] _inKey = new byte[16];
|
||||
private final byte[] _outKey = new byte[16];
|
||||
private boolean _isEnabled;
|
||||
|
||||
public Crypt(L2GameClient client)
|
||||
{
|
||||
// _client = client;
|
||||
}
|
||||
|
||||
public void setKey(byte[] key)
|
||||
{
|
||||
System.arraycopy(key, 0, _inKey, 0, 16);
|
||||
System.arraycopy(key, 0, _outKey, 0, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encrypt(ByteBuf buf)
|
||||
{
|
||||
if (!_isEnabled)
|
||||
{
|
||||
_isEnabled = true;
|
||||
onPacketSent(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
onPacketSent(buf);
|
||||
|
||||
int a = 0;
|
||||
while (buf.isReadable())
|
||||
{
|
||||
final int b = buf.readByte() & 0xFF;
|
||||
a = b ^ _outKey[(buf.readerIndex() - 1) & 15] ^ a;
|
||||
buf.setByte(buf.readerIndex() - 1, a);
|
||||
}
|
||||
|
||||
shiftKey(_outKey, buf.writerIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decrypt(ByteBuf buf)
|
||||
{
|
||||
if (!_isEnabled)
|
||||
{
|
||||
onPacketReceive(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
int a = 0;
|
||||
while (buf.isReadable())
|
||||
{
|
||||
final int b = buf.readByte() & 0xFF;
|
||||
buf.setByte(buf.readerIndex() - 1, b ^ _inKey[(buf.readerIndex() - 1) & 15] ^ a);
|
||||
a = b;
|
||||
}
|
||||
|
||||
shiftKey(_inKey, buf.writerIndex());
|
||||
|
||||
onPacketReceive(buf);
|
||||
}
|
||||
|
||||
private void onPacketSent(ByteBuf buf)
|
||||
{
|
||||
final byte[] data = new byte[buf.writerIndex()];
|
||||
buf.getBytes(0, data);
|
||||
// EventDispatcher.getInstance().notifyEvent(new OnPacketSent(_client, data));
|
||||
}
|
||||
|
||||
private void onPacketReceive(ByteBuf buf)
|
||||
{
|
||||
final byte[] data = new byte[buf.writerIndex()];
|
||||
buf.getBytes(0, data);
|
||||
// EventDispatcher.getInstance().notifyEvent(new OnPacketReceived(_client, data));
|
||||
}
|
||||
|
||||
private void shiftKey(byte[] key, int size)
|
||||
{
|
||||
int old = key[8] & 0xff;
|
||||
old |= (key[9] << 8) & 0xff00;
|
||||
old |= (key[10] << 0x10) & 0xff0000;
|
||||
old |= (key[11] << 0x18) & 0xff000000;
|
||||
|
||||
old += size;
|
||||
|
||||
key[8] = (byte) (old & 0xff);
|
||||
key[9] = (byte) ((old >> 0x08) & 0xff);
|
||||
key[10] = (byte) ((old >> 0x10) & 0xff);
|
||||
key[11] = (byte) ((old >> 0x18) & 0xff);
|
||||
}
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
*/
|
||||
public class EventLoopGroupManager
|
||||
{
|
||||
private final NioEventLoopGroup _bossGroup = new NioEventLoopGroup(1);
|
||||
private final NioEventLoopGroup _workerGroup = new NioEventLoopGroup(Config.IO_PACKET_THREAD_CORE_SIZE);
|
||||
|
||||
public NioEventLoopGroup getBossGroup()
|
||||
{
|
||||
return _bossGroup;
|
||||
}
|
||||
|
||||
public NioEventLoopGroup getWorkerGroup()
|
||||
{
|
||||
return _workerGroup;
|
||||
}
|
||||
|
||||
public void shutdown()
|
||||
{
|
||||
_bossGroup.shutdownGracefully();
|
||||
_workerGroup.shutdownGracefully();
|
||||
}
|
||||
|
||||
public static EventLoopGroupManager getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final EventLoopGroupManager _instance = new EventLoopGroupManager();
|
||||
}
|
||||
}
|
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.l2jmobius.commons.network.IConnectionState;
|
||||
import com.l2jmobius.commons.network.IIncomingPacket;
|
||||
import com.l2jmobius.commons.network.IIncomingPackets;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.*;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public enum ExIncomingPackets implements IIncomingPackets<L2GameClient>
|
||||
{
|
||||
REQUEST_GOTO_LOBBY(0x36, RequestGotoLobby::new, ConnectionState.AUTHENTICATED),
|
||||
REQUEST_EX_2ND_PASSWORD_CHECK(0x93, RequestEx2ndPasswordCheck::new, ConnectionState.AUTHENTICATED),
|
||||
REQUEST_EX_2ND_PASSWORD_VERIFY(0x94, RequestEx2ndPasswordVerify::new, ConnectionState.AUTHENTICATED),
|
||||
REQUEST_EX_2ND_PASSWORD_REQ(0x95, RequestEx2ndPasswordReq::new, ConnectionState.AUTHENTICATED),
|
||||
REQUEST_MANOR_LIST(0x01, RequestManorList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PROCEDURE_CROP_LIST(0x02, RequestProcureCropList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SET_SEED(0x03, RequestSetSeed::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SET_CROP(0x04, RequestSetCrop::new, ConnectionState.IN_GAME),
|
||||
REQUEST_WRITE_HERO_WORDS(0x05, RequestWriteHeroWords::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_ASK_JOIN_MPCC(0x06, RequestExAskJoinMPCC::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_ACCEPT_JOIN_MPCC(0x07, RequestExAcceptJoinMPCC::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_OUST_FROM_MPCC(0x08, RequestExOustFromMPCC::new, ConnectionState.IN_GAME),
|
||||
REQUEST_OUST_FROM_PARTY_ROOM(0x09, RequestOustFromPartyRoom::new, ConnectionState.IN_GAME),
|
||||
REQUEST_DISMISS_PARTY_ROOM(0x0A, RequestDismissPartyRoom::new, ConnectionState.IN_GAME),
|
||||
REQUEST_WITHDRAW_PARTY_ROOM(0x0B, RequestWithdrawPartyRoom::new, ConnectionState.IN_GAME),
|
||||
REQUEST_CHANGE_PARTY_LEADER(0x0C, RequestChangePartyLeader::new, ConnectionState.IN_GAME),
|
||||
REQUEST_AUTO_SOULSHOT(0x0D, RequestAutoSoulShot::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_ENCHANT_SKILL_INFO(0x0E, RequestExEnchantSkillInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_ENCHANT_SKILL(0x0F, RequestExEnchantSkill::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_PLEDGE_CREST_LARGE(0x10, RequestExPledgeCrestLarge::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_SET_PLEDGE_CREST_LARGE(0x11, RequestExSetPledgeCrestLarge::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PLEDGE_SET_ACADEMY_MASTER(0x12, RequestPledgeSetAcademyMaster::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PLEDGE_POWER_GRADE_LIST(0x13, RequestPledgePowerGradeList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PLEDGE_MEMBER_POWER_INFO(0x14, RequestPledgeMemberPowerInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PLEDGE_SET_MEMBER_POWER_GRADE(0x15, RequestPledgeSetMemberPowerGrade::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PLEDGE_MEMBER_INFO(0x16, RequestPledgeMemberInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PLEDGE_WAR_LIST(0x17, RequestPledgeWarList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_FISH_RANKING(0x18, RequestExFishRanking::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PCCAFE_COUPON_USE(0x19, RequestPCCafeCouponUse::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SERVER_LOGIN(0x1A, null, ConnectionState.IN_GAME),
|
||||
REQUEST_DUEL_START(0x1B, RequestDuelStart::new, ConnectionState.IN_GAME),
|
||||
REQUEST_DUAL_ANSWER_START(0x1C, RequestDuelAnswerStart::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_SET_TUTORIAL(0x1D, null, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_RQ_ITEM_LINK(0x1E, RequestExRqItemLink::new, ConnectionState.IN_GAME),
|
||||
CANNOT_MOVE_ANYMORE_AIR_SHIP(0x1F, null, ConnectionState.IN_GAME),
|
||||
MOVE_TO_LOCATION_IN_AIR_SHIP(0x20, MoveToLocationInAirShip::new, ConnectionState.IN_GAME),
|
||||
REQUEST_KEY_MAPPING(0x21, RequestKeyMapping::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SAVE_KEY_MAPPING(0x22, RequestSaveKeyMapping::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_REMOVE_ITEM_ATTRIBUTE(0x23, RequestExRemoveItemAttribute::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SAVE_INVENTORY_ORDER(0x24, RequestSaveInventoryOrder::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EXIT_PARTY_MATCHING_WAITING_ROOM(0x25, RequestExitPartyMatchingWaitingRoom::new, ConnectionState.IN_GAME),
|
||||
REQUEST_CONFIRM_TARGET_ITEM(0x26, RequestConfirmTargetItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_CONFIRM_REFINER_ITEM(0x27, RequestConfirmRefinerItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_CONFIRM_GEMSTONE(0x28, RequestConfirmGemStone::new, ConnectionState.IN_GAME),
|
||||
REQUEST_OLYMPIAD_OBSERVER_END(0x29, RequestOlympiadObserverEnd::new, ConnectionState.IN_GAME),
|
||||
REQUEST_CURSED_WEAPON_LIST(0x2A, RequestCursedWeaponList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_CURSED_WEAPON_LOCATION(0x2B, RequestCursedWeaponLocation::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PLEDGE_REORGANIZE_MEMBER(0x2C, RequestPledgeReorganizeMember::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_MPCC_SHOW_PARTY_MEMBERS_INFO(0x2D, RequestExMPCCShowPartyMembersInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_OLYMPIAD_MATCH_LIST(0x2E, RequestOlympiadMatchList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_ASK_JOIN_PARTY_ROOM(0x2F, RequestAskJoinPartyRoom::new, ConnectionState.IN_GAME),
|
||||
ANSWER_JOIN_PARTY_ROOM(0x30, AnswerJoinPartyRoom::new, ConnectionState.IN_GAME),
|
||||
REQUEST_LIST_PARTY_MATCHING_WAITING_ROOM(0x31, RequestListPartyMatchingWaitingRoom::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_ENCHANT_SKILL_SAFE(0x32, RequestExEnchantSkillSafe::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_ENCHANT_SKILL_UNTRAIN(0x33, RequestExEnchantSkillUntrain::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_ENCHANT_SKILL_ROUTE_CHANGE(0x34, RequestExEnchantSkillRouteChange::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_ENCHANT_ITEM_ATTRIBUTE(0x35, RequestExEnchantItemAttribute::new, ConnectionState.IN_GAME),
|
||||
EX_GET_ON_AIR_SHIP(0x36, null, ConnectionState.IN_GAME),
|
||||
MOVE_TO_LOCATION_AIR_SHIP(0x38, MoveToLocationAirShip::new, ConnectionState.IN_GAME),
|
||||
REQUEST_BID_ITEM_AUCTION(0x39, RequestBidItemAuction::new, ConnectionState.IN_GAME),
|
||||
REQUEST_INFO_ITEM_AUCTION(0x3A, RequestInfoItemAuction::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_CHANGE_NAME(0x3B, RequestExChangeName::new, ConnectionState.IN_GAME),
|
||||
REQUEST_ALL_CASTLE_INFO(0x3C, RequestAllCastleInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_ALL_FORTRESS_INFO(0x3D, RequestAllFortressInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_ALL_AGIT_INGO(0x3e, RequestAllAgitInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_FORTRESS_SIEGE_INFO(0x3F, RequestFortressSiegeInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_GET_BOSS_RECORD(0x40, RequestGetBossRecord::new, ConnectionState.IN_GAME),
|
||||
REQUEST_REFINE(0x41, RequestRefine::new, ConnectionState.IN_GAME),
|
||||
REQUEST_CONFIRM_CANCEL_ITEM(0x42, RequestConfirmCancelItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_REFINE_CANCEL(0x43, RequestRefineCancel::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_MAGIC_SKILL_USE_GROUND(0x44, RequestExMagicSkillUseGround::new, ConnectionState.IN_GAME),
|
||||
REQUEST_DUEL_SURRENDER(0x45, RequestDuelSurrender::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_ENCHANT_SKILL_INFO_DETAIL(0x46, RequestExEnchantSkillInfoDetail::new, ConnectionState.IN_GAME),
|
||||
REQUEST_FORTRESS_MAP_INFO(0x48, RequestFortressMapInfo::new, ConnectionState.IN_GAME),
|
||||
SET_PRIVATE_STORE_WHOLE_MSG(0x49, SetPrivateStoreWholeMsg::new, ConnectionState.IN_GAME),
|
||||
REQUEST_DISPEL(0x4B, RequestDispel::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_TRY_TO_PUT_ENCHANT_TARGET_ITEM(0x4C, RequestExTryToPutEnchantTargetItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_TRY_TO_PUT_ENCHANT_SUPPORT_ITEM(0x4D, RequestExTryToPutEnchantSupportItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_CANCEL_ENCHANT_ITEM(0x4E, RequestExCancelEnchantItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_CHANGE_NICKNAME_COLOR(0x4F, RequestChangeNicknameColor::new, ConnectionState.IN_GAME),
|
||||
REQUEST_RESET_NICKNAME(0x50, RequestResetNickname::new, ConnectionState.IN_GAME),
|
||||
EX_BOOKMARK_PACKET(0x51, ExBookmarkPacket::new, ConnectionState.IN_GAME),
|
||||
REQUEST_WITHDRAW_PREMIUM_ITEM(0x52, RequestWithDrawPremiumItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_JUMP(0x53, null, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_START_SHOW_CRATAE_CUBE_RANK(0x54, null, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_STOP_SHOW_CRATAE_CUBE_RANK(0x55, null, ConnectionState.IN_GAME),
|
||||
NOTIFY_START_MINI_GAME(0x56, null, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_JOIN_DOMINION_WAR(0x57, RequestJoinDominionWar::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_DOMINION_INFO(0x58, RequestDominionInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_CLEFT_ENTER(0x59, null, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_CUBE_GAME_CHANGE_TEAM(0x5A, RequestExCubeGameChangeTeam::new, ConnectionState.IN_GAME),
|
||||
END_SCENE_PLAYER(0x5B, EndScenePlayer::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_CUBE_GAME_READY_ANSWER(0x5C, RequestExCubeGameReadyAnswer::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_LIST_MPCC_WAITING(0x5D, null, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_MANAGE_MPCC_ROOM(0x5E, null, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_JOIN_MPCC_ROOM(0x5F, null, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_OUST_FROM_MPCC_ROOM(0x60, null, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_DISMISS_MPCC_ROOM(0x61, null, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_WITHDRAW_MPCC_ROOM(0x62, null, ConnectionState.IN_GAME),
|
||||
REQUEST_SEED_PHASE(0x63, RequestSeedPhase::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_MPCC_PARTYMASTER_LIST(0x64, null, ConnectionState.IN_GAME),
|
||||
REQUEST_POST_ITEM_LIST(0x65, RequestPostItemList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SEND_POST(0x66, RequestSendPost::new, ConnectionState.IN_GAME),
|
||||
REQUEST_RECEIVED_POST_LIST(0x67, RequestReceivedPostList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_DELETE_RECEIVED_POST(0x68, RequestDeleteReceivedPost::new, ConnectionState.IN_GAME),
|
||||
REQUEST_RECEIVED_POST(0x69, RequestReceivedPost::new, ConnectionState.IN_GAME),
|
||||
REQUEST_POST_ATTACHMENT(0x6A, RequestPostAttachment::new, ConnectionState.IN_GAME),
|
||||
REQUEST_REJECT_POST_ATTACHMENT(0x6B, RequestRejectPostAttachment::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SENT_POST_LIST(0x6C, RequestSentPostList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_DELETE_SENT_POST(0x6D, RequestDeleteSentPost::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SENT_POST(0x6E, RequestSentPost::new, ConnectionState.IN_GAME),
|
||||
REQUEST_CANCEL_SENT_POST(0x6F, RequestCancelPostAttachment::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SHOW_NEW_USER_PETITION(0x70, null, ConnectionState.IN_GAME),
|
||||
REQUEST_SHOW_STEP_TWO(0x71, null, ConnectionState.IN_GAME),
|
||||
REQUEST_SHOW_STEP_THREE(0x72, null, ConnectionState.IN_GAME),
|
||||
EX_CONNECT_TO_RAID_SERVER(0x73, null, ConnectionState.IN_GAME),
|
||||
EX_RETURN_FROM_RAID_SERVER(0x74, null, ConnectionState.IN_GAME),
|
||||
REQUEST_REFUND_ITEM(0x75, RequestRefundItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_BUI_SELL_UI_CLOSE(0x76, RequestBuySellUIClose::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_EVENT_MATCH_OBSERVER_END(0x77, null, ConnectionState.IN_GAME),
|
||||
REQUEST_PARTY_LOOT_MODIFICATION(0x78, RequestPartyLootModification::new, ConnectionState.IN_GAME),
|
||||
ANSWER_PARTY_LOOT_MODIFICATION(0x79, AnswerPartyLootModification::new, ConnectionState.IN_GAME),
|
||||
ANSWER_COUPLE_ACTION(0x7A, AnswerCoupleAction::new, ConnectionState.IN_GAME),
|
||||
BR_EVENT_RANKER_LIST(0x7B, BrEventRankerList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_ASK_MEMBERSHIP(0x7C, null, ConnectionState.IN_GAME),
|
||||
REQUEST_ADD_EXPAND_QUEST_ALARM(0x7D, null, ConnectionState.IN_GAME),
|
||||
REQUEST_NEW_VOTE_SYSTEM(0x7E, RequestVoteNew::new, ConnectionState.IN_GAME),
|
||||
REQUEST_AGIT_ACTION(0x80, null, ConnectionState.IN_GAME), // TODO: Implement / HANDLE SWITCH
|
||||
REQUEST_EX_ADD_POST_FRIEND_FOR_POST_BOX(0x84, RequestExAddContactToContactList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_DELETE_POST_FRIEND_FOR_POST_BOX(0x85, RequestExDeleteContactFromContactList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_SHOW_POST_FRIEND_FOR_POST_BOX(0x86, RequestExShowContactList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_FRIEND_LIST_FOR_POST_BOX(0x87, RequestExFriendListExtended::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EX_OLYMPIAD_MATCH_LIST_REFRESH(0x88, RequestExOlympiadMatchListRefresh::new, ConnectionState.IN_GAME),
|
||||
REQUEST_BR_GAME_POINT(0x89, RequestBrGamePoint::new, ConnectionState.IN_GAME),
|
||||
REQUEST_BR_PRODUCT_LIST(0x8A, RequestBrProductList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_BR_PRODUCT_INFO(0x8B, RequestBrProductInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_BR_BUI_PRODUCT(0x8C, RequestBrBuyProduct::new, ConnectionState.IN_GAME),
|
||||
REQUEST_BR_RECENT_PRODUCT_LIST(0x8D, RequestBrRecentProductList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_BR_MINI_GAME_LOAD_SCORES(0x8E, null, ConnectionState.IN_GAME),
|
||||
REQUEST_BR_MINI_GAME_INSERT_SCORE(0x8F, null, ConnectionState.IN_GAME),
|
||||
REQUEST_BR_LECTURE_MARK(0x90, null, ConnectionState.IN_GAME),
|
||||
REQUEST_GOODS_INVENTORY_INFO(0x91, null, ConnectionState.IN_GAME),
|
||||
REQUEST_USE_GOODS_INVENTORY_ITEM(0x92, null, ConnectionState.IN_GAME),
|
||||
REQUEST_HARDWARE_INFO(0x96, null, ConnectionState.values());
|
||||
|
||||
public static final ExIncomingPackets[] PACKET_ARRAY;
|
||||
static
|
||||
{
|
||||
final short maxPacketId = (short) Arrays.stream(values()).mapToInt(IIncomingPackets::getPacketId).max().orElse(0);
|
||||
PACKET_ARRAY = new ExIncomingPackets[maxPacketId + 1];
|
||||
for (ExIncomingPackets incomingPacket : values())
|
||||
{
|
||||
PACKET_ARRAY[incomingPacket.getPacketId()] = incomingPacket;
|
||||
}
|
||||
}
|
||||
|
||||
private int _packetId;
|
||||
private Supplier<IIncomingPacket<L2GameClient>> _incomingPacketFactory;
|
||||
private Set<IConnectionState> _connectionStates;
|
||||
|
||||
ExIncomingPackets(int packetId, Supplier<IIncomingPacket<L2GameClient>> incomingPacketFactory, IConnectionState... connectionStates)
|
||||
{
|
||||
// packetId is an unsigned short
|
||||
if (packetId > 0xFFFF)
|
||||
{
|
||||
throw new IllegalArgumentException("packetId must not be bigger than 0xFFFF");
|
||||
}
|
||||
_packetId = packetId;
|
||||
_incomingPacketFactory = incomingPacketFactory != null ? incomingPacketFactory : () -> null;
|
||||
_connectionStates = new HashSet<>(Arrays.asList(connectionStates));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPacketId()
|
||||
{
|
||||
return _packetId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIncomingPacket<L2GameClient> newIncomingPacket()
|
||||
{
|
||||
return _incomingPacketFactory.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<IConnectionState> getConnectionStates()
|
||||
{
|
||||
return _connectionStates;
|
||||
}
|
||||
}
|
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
*/
|
||||
public class GameCrypt
|
||||
{
|
||||
private final byte[] _inKey = new byte[16];
|
||||
private final byte[] _outKey = new byte[16];
|
||||
private boolean _isEnabled;
|
||||
|
||||
public void setKey(byte[] key)
|
||||
{
|
||||
System.arraycopy(key, 0, _inKey, 0, 16);
|
||||
System.arraycopy(key, 0, _outKey, 0, 16);
|
||||
}
|
||||
|
||||
public void decrypt(byte[] raw, int offset, int size)
|
||||
{
|
||||
if (!_isEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int temp = 0;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
final int temp2 = raw[offset + i] & 0xFF;
|
||||
raw[offset + i] = (byte) (temp2 ^ _inKey[i & 15] ^ temp);
|
||||
temp = temp2;
|
||||
}
|
||||
|
||||
int old = _inKey[8] & 0xff;
|
||||
old |= (_inKey[9] << 8) & 0xff00;
|
||||
old |= (_inKey[10] << 0x10) & 0xff0000;
|
||||
old |= (_inKey[11] << 0x18) & 0xff000000;
|
||||
|
||||
old += size;
|
||||
|
||||
_inKey[8] = (byte) (old & 0xff);
|
||||
_inKey[9] = (byte) ((old >> 0x08) & 0xff);
|
||||
_inKey[10] = (byte) ((old >> 0x10) & 0xff);
|
||||
_inKey[11] = (byte) ((old >> 0x18) & 0xff);
|
||||
}
|
||||
|
||||
public void encrypt(byte[] raw, int offset, int size)
|
||||
{
|
||||
if (!_isEnabled)
|
||||
{
|
||||
_isEnabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
int temp = 0;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
final int temp2 = raw[offset + i] & 0xFF;
|
||||
temp = temp2 ^ _outKey[i & 15] ^ temp;
|
||||
raw[offset + i] = (byte) temp;
|
||||
}
|
||||
|
||||
int old = _outKey[8] & 0xff;
|
||||
old |= (_outKey[9] << 8) & 0xff00;
|
||||
old |= (_outKey[10] << 0x10) & 0xff0000;
|
||||
old |= (_outKey[11] << 0x18) & 0xff000000;
|
||||
|
||||
old += size;
|
||||
|
||||
_outKey[8] = (byte) (old & 0xff);
|
||||
_outKey[9] = (byte) ((old >> 0x08) & 0xff);
|
||||
_outKey[10] = (byte) ((old >> 0x10) & 0xff);
|
||||
_outKey[11] = (byte) ((old >> 0x18) & 0xff);
|
||||
}
|
||||
}
|
@@ -0,0 +1,250 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.l2jmobius.commons.network.IConnectionState;
|
||||
import com.l2jmobius.commons.network.IIncomingPacket;
|
||||
import com.l2jmobius.commons.network.IIncomingPackets;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.*;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public enum IncomingPackets implements IIncomingPackets<L2GameClient>
|
||||
{
|
||||
LOGOUT(0x00, Logout::new, ConnectionState.AUTHENTICATED, ConnectionState.IN_GAME),
|
||||
ATTACK(0x01, Attack::new, ConnectionState.IN_GAME),
|
||||
REQUEST_START_PLEDGE_WAR(0x03, RequestStartPledgeWar::new, ConnectionState.IN_GAME),
|
||||
REQUEST_REPLY_START_PLEDGE(0x04, RequestReplyStartPledgeWar::new, ConnectionState.IN_GAME),
|
||||
REQUEST_STOP_PLEDGE_WAR(0x05, RequestStopPledgeWar::new, ConnectionState.IN_GAME),
|
||||
REQUEST_REPLY_STOP_PLEDGE_WAR(0x06, RequestReplyStopPledgeWar::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SURRENDER_PLEDGE_WAR(0x07, RequestSurrenderPledgeWar::new, ConnectionState.IN_GAME),
|
||||
REQUEST_REPLY_SURRENDER_PLEDGE_WAR(0x08, RequestReplySurrenderPledgeWar::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SET_PLEDGE_CREST(0x09, RequestSetPledgeCrest::new, ConnectionState.IN_GAME),
|
||||
REQUEST_GIVE_NICK_NAME(0x0B, RequestGiveNickName::new, ConnectionState.IN_GAME),
|
||||
CHARACTER_CREATE(0x0C, CharacterCreate::new, ConnectionState.AUTHENTICATED),
|
||||
CHARACTER_DELETE(0x0D, CharacterDelete::new, ConnectionState.AUTHENTICATED),
|
||||
PROTOCOL_VERSION(0x0E, ProtocolVersion::new, ConnectionState.CONNECTED),
|
||||
MOVE_BACKWARD_TO_LOCATION(0x0F, MoveBackwardToLocation::new, ConnectionState.IN_GAME),
|
||||
ENTER_WORLD(0x11, EnterWorld::new, ConnectionState.IN_GAME),
|
||||
CHARACTER_SELECT(0x12, CharacterSelect::new, ConnectionState.AUTHENTICATED),
|
||||
NEW_CHARACTER(0x13, NewCharacter::new, ConnectionState.AUTHENTICATED),
|
||||
REQUEST_ITEM_LIST(0x14, RequestItemList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_UN_EQUIP_ITEM(0x16, RequestUnEquipItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_DROP_ITEM(0x17, RequestDropItem::new, ConnectionState.IN_GAME),
|
||||
USE_ITEM(0x19, UseItem::new, ConnectionState.IN_GAME),
|
||||
TRADE_REQUEST(0x1A, TradeRequest::new, ConnectionState.IN_GAME),
|
||||
ADD_TRADE_ITEM(0x1B, AddTradeItem::new, ConnectionState.IN_GAME),
|
||||
TRADE_DONE(0x1C, TradeDone::new, ConnectionState.IN_GAME),
|
||||
ACTION(0x1F, Action::new, ConnectionState.IN_GAME),
|
||||
REQUEST_LINK_HTML(0x22, RequestLinkHtml::new, ConnectionState.IN_GAME),
|
||||
REQUEST_BYPASS_TO_SERVER(0x23, RequestBypassToServer::new, ConnectionState.IN_GAME),
|
||||
REQUEST_BBS_WRITE(0x24, RequestBBSwrite::new, ConnectionState.IN_GAME),
|
||||
REQUEST_JOIN_PLEDGE(0x26, RequestJoinPledge::new, ConnectionState.IN_GAME),
|
||||
REQUEST_ANSWER_JOIN_PLEDGE(0x27, RequestAnswerJoinPledge::new, ConnectionState.IN_GAME),
|
||||
REQUEST_WITHDRAWAL_PLEDGE(0x28, RequestWithdrawalPledge::new, ConnectionState.IN_GAME),
|
||||
REQUEST_OUST_PLEDGE_MEMBER(0x29, RequestOustPledgeMember::new, ConnectionState.IN_GAME),
|
||||
AUTH_LOGIN(0x2B, AuthLogin::new, ConnectionState.CONNECTED),
|
||||
REQUEST_GET_ITEM_FROM_PET(0x2C, RequestGetItemFromPet::new, ConnectionState.IN_GAME),
|
||||
REQUEST_ALLY_INFO(0x2E, RequestAllyInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_CRYSTALLIZE_ITEM(0x2F, RequestCrystallizeItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PRIVATE_STORE_MANAGE_SELL(0x30, RequestPrivateStoreManageSell::new, ConnectionState.IN_GAME),
|
||||
SET_PRIVATE_STORE_LIST_SELL(0x31, SetPrivateStoreListSell::new, ConnectionState.IN_GAME),
|
||||
ATTACK_REQUEST(0x32, AttackRequest::new, ConnectionState.IN_GAME),
|
||||
REQUEST_TELEPORT(0x33, null, ConnectionState.IN_GAME),
|
||||
SOCIAL_ACTION(0x34, null, ConnectionState.IN_GAME),
|
||||
CHANGE_MOVE_TYPE(0x35, null, ConnectionState.IN_GAME),
|
||||
CHANGE_WAIT_TYPE(0x36, null, ConnectionState.IN_GAME),
|
||||
REQUEST_SELL_ITEM(0x37, RequestSellItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_MAGIC_SKILL_LIST(0x38, null, ConnectionState.IN_GAME),
|
||||
REQUEST_MAGIC_SKILL_USE(0x39, RequestMagicSkillUse::new, ConnectionState.IN_GAME),
|
||||
APPEARING(0x3A, Appearing::new, ConnectionState.IN_GAME),
|
||||
SEND_WARE_HOUSE_DEPOSIT_LIST(0x3B, SendWareHouseDepositList::new, ConnectionState.IN_GAME),
|
||||
SEND_WARE_HOUSE_WITH_DRAW_LIST(0x3C, SendWareHouseWithDrawList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SHORT_CUT_REG(0x3D, RequestShortCutReg::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SHORT_CUT_DEL(0x3F, RequestShortCutDel::new, ConnectionState.IN_GAME),
|
||||
REQUEST_BUY_ITEM(0x40, RequestBuyItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_JOIN_PARTY(0x42, RequestJoinParty::new, ConnectionState.IN_GAME),
|
||||
REQUEST_ANSWER_JOIN_PARTY(0x43, RequestAnswerJoinParty::new, ConnectionState.IN_GAME),
|
||||
REQUEST_WITH_DRAWAL_PARTY(0x44, RequestWithDrawalParty::new, ConnectionState.IN_GAME),
|
||||
REQUEST_OUST_PARTY_MEMBER(0x45, RequestOustPartyMember::new, ConnectionState.IN_GAME),
|
||||
CANNOT_MOVE_ANYMORE(0x47, CannotMoveAnymore::new, ConnectionState.IN_GAME),
|
||||
REQUEST_TARGET_CANCELD(0x48, RequestTargetCanceld::new, ConnectionState.IN_GAME),
|
||||
SAY2(0x49, Say2::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PLEDGE_MEMBER_LIST(0x4D, RequestPledgeMemberList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_MAGIC_LIST(0x4F, null, ConnectionState.IN_GAME),
|
||||
REQUEST_SKILL_LIST(0x50, RequestSkillList::new, ConnectionState.IN_GAME),
|
||||
MOVE_WITH_DELTA(0x52, MoveWithDelta::new, ConnectionState.IN_GAME),
|
||||
REQUEST_GET_ON_VEHICLE(0x53, RequestGetOnVehicle::new, ConnectionState.IN_GAME),
|
||||
REQUEST_GET_OFF_VEHICLE(0x54, RequestGetOffVehicle::new, ConnectionState.IN_GAME),
|
||||
ANSWER_TRADE_REQUEST(0x55, AnswerTradeRequest::new, ConnectionState.IN_GAME),
|
||||
REQUEST_ACTION_USE(0x56, RequestActionUse::new, ConnectionState.IN_GAME),
|
||||
REQUEST_RESTART(0x57, RequestRestart::new, ConnectionState.IN_GAME),
|
||||
VALIDATE_POSITION(0x59, ValidatePosition::new, ConnectionState.IN_GAME),
|
||||
START_ROTATING(0x5B, StartRotating::new, ConnectionState.IN_GAME),
|
||||
FINISH_ROTATING(0x5C, FinishRotating::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SHOW_BOARD(0x5E, RequestShowBoard::new, ConnectionState.IN_GAME),
|
||||
REQUEST_ENCHANT_ITEM(0x5F, RequestEnchantItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_DESTROY_ITEM(0x60, RequestDestroyItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_QUEST_LIST(0x62, RequestQuestList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_QUEST_ABORT(0x63, RequestQuestAbort::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PLEDGE_INFO(0x65, RequestPledgeInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PLEDGE_EXTENDED_INFO(0x66, RequestPledgeExtendedInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PLEDGE_CREST(0x67, RequestPledgeCrest::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SEND_FRIEND_MSG(0x6B, RequestSendFriendMsg::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SHOW_MINI_MAP(0x6C, RequestShowMiniMap::new, ConnectionState.IN_GAME),
|
||||
REQUEST_RECORD_INFO(0x6E, RequestRecordInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_HENNA_EQUIP(0x6F, RequestHennaEquip::new, ConnectionState.IN_GAME),
|
||||
REQUEST_HENNA_REMOVE_LIST(0x70, RequestHennaRemoveList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_HENNA_ITEM_REMOVE_INFO(0x71, RequestHennaItemRemoveInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_HENNA_REMOVE(0x72, RequestHennaRemove::new, ConnectionState.IN_GAME),
|
||||
REQUEST_ACQUIRE_SKILL_INFO(0x73, RequestAcquireSkillInfo::new, ConnectionState.IN_GAME),
|
||||
SEND_BYPASS_BUILD_CMD(0x74, SendBypassBuildCmd::new, ConnectionState.IN_GAME),
|
||||
REQUEST_MOVE_TO_LOCATION_IN_VEHICLE(0x75, RequestMoveToLocationInVehicle::new, ConnectionState.IN_GAME),
|
||||
CANNOT_MOVE_ANYMORE_IN_VEHICLE(0x76, CannotMoveAnymoreInVehicle::new, ConnectionState.IN_GAME),
|
||||
REQUEST_FRIEND_INVITE(0x77, RequestFriendInvite::new, ConnectionState.IN_GAME),
|
||||
REQUEST_ANSWER_FRIEND_INVITE(0x78, RequestAnswerFriendInvite::new, ConnectionState.IN_GAME),
|
||||
REQUEST_FRIEND_LIST(0x79, RequestFriendList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_FRIEND_DEL(0x7A, RequestFriendDel::new, ConnectionState.IN_GAME),
|
||||
CHARACTER_RESTORE(0x7B, CharacterRestore::new, ConnectionState.AUTHENTICATED),
|
||||
REQUEST_ACQUIRE_SKILL(0x7C, RequestAcquireSkill::new, ConnectionState.IN_GAME),
|
||||
REQUEST_RESTART_POINT(0x7D, RequestRestartPoint::new, ConnectionState.IN_GAME),
|
||||
REQUEST_GM_COMMAND(0x7E, RequestGMCommand::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PARTY_MATCH_CONFIG(0x7F, RequestPartyMatchConfig::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PARTY_MATCH_LIST(0x80, RequestPartyMatchList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PARTY_MATCH_DETAIL(0x81, RequestPartyMatchDetail::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PRIVATE_STORE_BUY(0x83, RequestPrivateStoreBuy::new, ConnectionState.IN_GAME),
|
||||
REQUEST_TUTORIAL_LINK_HTML(0x85, RequestTutorialLinkHtml::new, ConnectionState.IN_GAME),
|
||||
REQUEST_TUTORIAL_PASS_CMD_TO_SERVER(0x86, RequestTutorialPassCmdToServer::new, ConnectionState.IN_GAME),
|
||||
REQUEST_TUTORIAL_QUESTION_MARK(0x87, RequestTutorialQuestionMark::new, ConnectionState.IN_GAME),
|
||||
REQUEST_TUTORIAL_CLIENT_EVENT(0x88, RequestTutorialClientEvent::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PETITION(0x89, RequestPetition::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PETITION_CANCEL(0x8A, RequestPetitionCancel::new, ConnectionState.IN_GAME),
|
||||
REQUEST_GM_LIST(0x8B, RequestGmList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_JOIN_ALLY(0x8C, RequestJoinAlly::new, ConnectionState.IN_GAME),
|
||||
REQUEST_ANSWER_JOIN_ALLY(0x8D, RequestAnswerJoinAlly::new, ConnectionState.IN_GAME),
|
||||
ALLY_LEAVE(0x8E, AllyLeave::new, ConnectionState.IN_GAME),
|
||||
ALLY_DISMISS(0x8F, AllyDismiss::new, ConnectionState.IN_GAME),
|
||||
REQUEST_DISMISS_ALLY(0x90, RequestDismissAlly::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SET_ALLY_CREST(0x91, RequestSetAllyCrest::new, ConnectionState.IN_GAME),
|
||||
REQUEST_ALLY_CREST(0x92, RequestAllyCrest::new, ConnectionState.IN_GAME),
|
||||
REQUEST_CHANGE_PET_NAME(0x93, RequestChangePetName::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PET_USE_ITEM(0x94, RequestPetUseItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_GIVE_ITEM_TO_PET(0x95, RequestGiveItemToPet::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PRIVATE_STORE_QUIT_SELL(0x96, RequestPrivateStoreQuitSell::new, ConnectionState.IN_GAME),
|
||||
SET_PRIVATE_STORE_MSG_SELL(0x97, SetPrivateStoreMsgSell::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PET_GET_ITEM(0x98, RequestPetGetItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PRIVATE_STORE_MANAGE_BUY(0x99, RequestPrivateStoreManageBuy::new, ConnectionState.IN_GAME),
|
||||
SET_PRIVATE_STORE_LIST_BUY(0x9A, SetPrivateStoreListBuy::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PRIVATE_STORE_QUIT_BUY(0x9C, RequestPrivateStoreQuitBuy::new, ConnectionState.IN_GAME),
|
||||
SET_PRIVATE_STORE_MSG_BUY(0x9D, SetPrivateStoreMsgBuy::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PRIVATE_STORE_SELL(0x9F, RequestPrivateStoreSell::new, ConnectionState.IN_GAME),
|
||||
SEND_TIME_CHECK_PACKET(0xA0, null, ConnectionState.IN_GAME),
|
||||
REQUEST_SKILL_COOL_TIME(0xA6, null, ConnectionState.IN_GAME),
|
||||
REQUEST_PACKAGE_SENDABLE_ITEM_LIST(0xA7, RequestPackageSendableItemList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PACKAGE_SEND(0xA8, RequestPackageSend::new, ConnectionState.IN_GAME),
|
||||
REQUEST_BLOCK(0xA9, RequestBlock::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SIEGE_INFO(0xAA, RequestSiegeInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SIEGE_ATTACKER_LIST(0xAB, RequestSiegeAttackerList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SIEGE_DEFENDER_LIST(0xAC, RequestSiegeDefenderList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_JOIN_SIEGE(0xAD, RequestJoinSiege::new, ConnectionState.IN_GAME),
|
||||
REQUEST_CONFIRM_SIEGE_WAITING_LIST(0xAE, RequestConfirmSiegeWaitingList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SET_CASTLE_SIEGE_TIME(0xAF, RequestSetCastleSiegeTime::new, ConnectionState.IN_GAME),
|
||||
MULTI_SELL_CHOOSE(0xB0, MultiSellChoose::new, ConnectionState.IN_GAME),
|
||||
NET_PING(0xB1, null, ConnectionState.IN_GAME),
|
||||
REQUEST_REMAIN_TIME(0xB2, null, ConnectionState.IN_GAME),
|
||||
BYPASS_USER_CMD(0xB3, BypassUserCmd::new, ConnectionState.IN_GAME),
|
||||
SNOOP_QUIT(0xB4, SnoopQuit::new, ConnectionState.IN_GAME),
|
||||
REQUEST_RECIPE_BOOK_OPEN(0xB5, RequestRecipeBookOpen::new, ConnectionState.IN_GAME),
|
||||
REQUEST_RECIPE_BOOK_DESTROY(0xB6, RequestRecipeBookDestroy::new, ConnectionState.IN_GAME),
|
||||
REQUEST_RECIPE_ITEM_MAKE_INFO(0xB7, RequestRecipeItemMakeInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_RECIPE_ITEM_MAKE_SELF(0xB8, RequestRecipeItemMakeSelf::new, ConnectionState.IN_GAME),
|
||||
REQUEST_RECIPE_SHOP_MANAGE_LIST(0xB9, null, ConnectionState.IN_GAME),
|
||||
REQUEST_RECIPE_SHOP_MESSAGE_SET(0xBA, RequestRecipeShopMessageSet::new, ConnectionState.IN_GAME),
|
||||
REQUEST_RECIPE_SHOP_LIST_SET(0xBB, RequestRecipeShopListSet::new, ConnectionState.IN_GAME),
|
||||
REQUEST_RECIPE_SHOP_MANAGE_QUIT(0xBC, RequestRecipeShopManageQuit::new, ConnectionState.IN_GAME),
|
||||
REQUEST_RECIPE_SHOP_MANAGE_CANCEL(0xBD, null, ConnectionState.IN_GAME),
|
||||
REQUEST_RECIPE_SHOP_MAKE_INFO(0xBE, RequestRecipeShopMakeInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_RECIPE_SHOP_MAKE_ITEM(0xBF, RequestRecipeShopMakeItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_RECIPE_SHOP_MANAGE_PREV(0xC0, RequestRecipeShopManagePrev::new, ConnectionState.IN_GAME),
|
||||
OBSERVER_RETURN(0xC1, ObserverReturn::new, ConnectionState.IN_GAME),
|
||||
REQUEST_EVALUATE(0xC2, null, ConnectionState.IN_GAME),
|
||||
REQUEST_HENNA_ITEM_LIST(0xC3, RequestHennaItemList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_HENNA_ITEM_INFO(0xC4, RequestHennaItemInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_BUY_SEED(0xC5, RequestBuySeed::new, ConnectionState.IN_GAME),
|
||||
DLG_ANSWER(0xC6, DlgAnswer::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PREVIEW_ITEM(0xC7, RequestPreviewItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SSQ_STATUS(0xC8, null, ConnectionState.IN_GAME),
|
||||
REQUEST_PETITION_FEEDBACK(0xC9, RequestPetitionFeedback::new, ConnectionState.IN_GAME),
|
||||
GAME_GUARD_REPLY(0xCB, GameGuardReply::new, ConnectionState.IN_GAME),
|
||||
REQUEST_PLEDGE_POWER(0xCC, RequestPledgePower::new, ConnectionState.IN_GAME),
|
||||
REQUEST_MAKE_MACRO(0xCD, RequestMakeMacro::new, ConnectionState.IN_GAME),
|
||||
REQUEST_DELETE_MACRO(0xCE, RequestDeleteMacro::new, ConnectionState.IN_GAME),
|
||||
REQUEST_BUY_PROCURE(0xCF, null, ConnectionState.IN_GAME),
|
||||
EX_PACKET(0xD0, ExPacket::new, ConnectionState.values()); // This packet has its own connection state checking so we allow all of them
|
||||
|
||||
public static final IncomingPackets[] PACKET_ARRAY;
|
||||
static
|
||||
{
|
||||
final short maxPacketId = (short) Arrays.stream(values()).mapToInt(IIncomingPackets::getPacketId).max().orElse(0);
|
||||
PACKET_ARRAY = new IncomingPackets[maxPacketId + 1];
|
||||
for (IncomingPackets incomingPacket : values())
|
||||
{
|
||||
PACKET_ARRAY[incomingPacket.getPacketId()] = incomingPacket;
|
||||
}
|
||||
}
|
||||
|
||||
private short _packetId;
|
||||
private Supplier<IIncomingPacket<L2GameClient>> _incomingPacketFactory;
|
||||
private Set<IConnectionState> _connectionStates;
|
||||
|
||||
IncomingPackets(int packetId, Supplier<IIncomingPacket<L2GameClient>> incomingPacketFactory, IConnectionState... connectionStates)
|
||||
{
|
||||
// packetId is an unsigned byte
|
||||
if (packetId > 0xFF)
|
||||
{
|
||||
throw new IllegalArgumentException("packetId must not be bigger than 0xFF");
|
||||
}
|
||||
|
||||
_packetId = (short) packetId;
|
||||
_incomingPacketFactory = incomingPacketFactory != null ? incomingPacketFactory : () -> null;
|
||||
_connectionStates = new HashSet<>(Arrays.asList(connectionStates));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPacketId()
|
||||
{
|
||||
return _packetId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIncomingPacket<L2GameClient> newIncomingPacket()
|
||||
{
|
||||
return _incomingPacketFactory.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<IConnectionState> getConnectionStates()
|
||||
{
|
||||
return _connectionStates;
|
||||
}
|
||||
}
|
@@ -17,13 +17,11 @@
|
||||
package com.l2jmobius.gameserver.network;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
@@ -35,57 +33,50 @@ import java.util.logging.Logger;
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.commons.mmocore.MMOClient;
|
||||
import com.l2jmobius.commons.mmocore.MMOConnection;
|
||||
import com.l2jmobius.commons.mmocore.ReceivablePacket;
|
||||
import com.l2jmobius.commons.network.ChannelInboundHandler;
|
||||
import com.l2jmobius.commons.network.ICrypt;
|
||||
import com.l2jmobius.commons.network.IIncomingPacket;
|
||||
import com.l2jmobius.commons.network.IOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.LoginServerThread;
|
||||
import com.l2jmobius.gameserver.LoginServerThread.SessionKey;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.OfflineTradersTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SecondaryAuthData;
|
||||
import com.l2jmobius.gameserver.idfactory.IdFactory;
|
||||
import com.l2jmobius.gameserver.instancemanager.AntiFeedManager;
|
||||
import com.l2jmobius.gameserver.model.CharSelectInfoPackage;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.PcCondOverride;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.L2Event;
|
||||
import com.l2jmobius.gameserver.model.olympiad.OlympiadManager;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ServerClose;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.security.SecondaryPasswordAuth;
|
||||
import com.l2jmobius.gameserver.util.FloodProtectors;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
/**
|
||||
* Represents a client connected on Game Server.
|
||||
* @author KenM
|
||||
*/
|
||||
public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> implements Runnable
|
||||
public final class L2GameClient extends ChannelInboundHandler<L2GameClient>
|
||||
{
|
||||
protected static final Logger _log = Logger.getLogger(L2GameClient.class.getName());
|
||||
protected static final Logger LOGGER = Logger.getLogger(L2GameClient.class.getName());
|
||||
protected static final Logger _logAccounting = Logger.getLogger("accounting");
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
*/
|
||||
public static enum GameClientState
|
||||
{
|
||||
/** Client has just connected . */
|
||||
CONNECTED,
|
||||
/** Client has authed but doesn't has character attached to it yet. */
|
||||
AUTHED,
|
||||
/** Client has selected a char and is in game. */
|
||||
IN_GAME
|
||||
}
|
||||
|
||||
private GameClientState _state;
|
||||
private final int _objectId;
|
||||
|
||||
// Info
|
||||
private final InetAddress _addr;
|
||||
private InetAddress _addr;
|
||||
private Channel _channel;
|
||||
private String _accountName;
|
||||
private SessionKey _sessionId;
|
||||
private L2PcInstance _activeChar;
|
||||
@@ -93,7 +84,7 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
private SecondaryPasswordAuth _secondaryAuth;
|
||||
|
||||
private boolean _isAuthedGG;
|
||||
private final long _connectionStartTime;
|
||||
private final long _connectionStartTime = System.currentTimeMillis();
|
||||
private List<CharSelectInfoPackage> _charSlotMapping = null;
|
||||
|
||||
// flood protectors
|
||||
@@ -103,51 +94,85 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
protected final ScheduledFuture<?> _autoSaveInDB;
|
||||
protected ScheduledFuture<?> _cleanupTask = null;
|
||||
|
||||
private L2GameServerPacket _aditionalClosePacket;
|
||||
|
||||
// Crypt
|
||||
private final GameCrypt _crypt;
|
||||
|
||||
private final ClientStats _stats;
|
||||
private final Crypt _crypt;
|
||||
|
||||
private boolean _isDetached = false;
|
||||
|
||||
private boolean _protocol;
|
||||
|
||||
private final ArrayBlockingQueue<ReceivablePacket<L2GameClient>> _packetQueue;
|
||||
private final ReentrantLock _queueLock = new ReentrantLock();
|
||||
|
||||
private int[][] trace;
|
||||
|
||||
public L2GameClient(MMOConnection<L2GameClient> con)
|
||||
public L2GameClient()
|
||||
{
|
||||
super(con);
|
||||
_state = GameClientState.CONNECTED;
|
||||
_connectionStartTime = System.currentTimeMillis();
|
||||
_crypt = new GameCrypt();
|
||||
_stats = new ClientStats();
|
||||
|
||||
_packetQueue = new ArrayBlockingQueue<>(Config.CLIENT_PACKET_QUEUE_SIZE);
|
||||
|
||||
if (Config.CHAR_STORE_INTERVAL > 0)
|
||||
_objectId = IdFactory.getInstance().getNextId();
|
||||
_crypt = new Crypt(this);
|
||||
if (Config.CHAR_DATA_STORE_INTERVAL > 0)
|
||||
{
|
||||
_autoSaveInDB = ThreadPool.scheduleAtFixedRate(new AutoSaveTask(), 300000L, Config.CHAR_STORE_INTERVAL * 60000L);
|
||||
_autoSaveInDB = ThreadPool.scheduleAtFixedRate(new AutoSaveTask(), 300000L, Config.CHAR_DATA_STORE_INTERVAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
_autoSaveInDB = null;
|
||||
}
|
||||
}
|
||||
|
||||
public int getObjectId()
|
||||
{
|
||||
return _objectId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx)
|
||||
{
|
||||
super.channelActive(ctx);
|
||||
|
||||
setConnectionState(ConnectionState.CONNECTED);
|
||||
final InetSocketAddress address = (InetSocketAddress) ctx.channel().remoteAddress();
|
||||
_addr = address.getAddress();
|
||||
_channel = ctx.channel();
|
||||
LOGGER.finer("Client Connected: " + ctx.channel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx)
|
||||
{
|
||||
LOGGER.finer("Client Disconnected: " + ctx.channel());
|
||||
|
||||
// no long running tasks here, do it async
|
||||
try
|
||||
{
|
||||
_addr = con != null ? con.getInetAddress() : InetAddress.getLocalHost();
|
||||
ThreadPool.execute(new DisconnectTask());
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
catch (RejectedExecutionException e)
|
||||
{
|
||||
throw new Error("Unable to determine localhost address.");
|
||||
// server is closing
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, IIncomingPacket<L2GameClient> packet)
|
||||
{
|
||||
try
|
||||
{
|
||||
packet.run(this);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "Exception for: " + toString() + " on packet.run: " + packet.getClass().getSimpleName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
|
||||
{
|
||||
}
|
||||
|
||||
public Channel getChannel()
|
||||
{
|
||||
return _channel;
|
||||
}
|
||||
|
||||
public byte[] enableCrypt()
|
||||
{
|
||||
final byte[] key = BlowFishKeygen.getRandomKey();
|
||||
@@ -155,25 +180,6 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
return key;
|
||||
}
|
||||
|
||||
public GameClientState getState()
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
|
||||
public void setState(GameClientState pState)
|
||||
{
|
||||
if (_state != pState)
|
||||
{
|
||||
_state = pState;
|
||||
_packetQueue.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public ClientStats getStats()
|
||||
{
|
||||
return _stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* For loaded offline traders returns localhost address.
|
||||
* @return cached connection IP address, for checking detached clients.
|
||||
@@ -188,21 +194,6 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
return _connectionStartTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean decrypt(ByteBuffer buf, int size)
|
||||
{
|
||||
_crypt.decrypt(buf.array(), buf.position(), size);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
@@ -211,10 +202,6 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
public void setActiveChar(L2PcInstance pActiveChar)
|
||||
{
|
||||
_activeChar = pActiveChar;
|
||||
// JIV remove - done on spawn
|
||||
/*
|
||||
* if (_activeChar != null) { L2World.getInstance().storeObject(getActiveChar()); }
|
||||
*/
|
||||
}
|
||||
|
||||
public ReentrantLock getActiveCharLock()
|
||||
@@ -262,15 +249,26 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
return _sessionId;
|
||||
}
|
||||
|
||||
public void sendPacket(L2GameServerPacket gsp)
|
||||
public void sendPacket(IClientOutgoingPacket packet)
|
||||
{
|
||||
if (_isDetached || (gsp == null) || (gsp.isInvisible() && (getActiveChar() != null) && !getActiveChar().canOverrideCond(PcCondOverride.SEE_ALL_PLAYERS)))
|
||||
if (_isDetached || (packet == null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
getConnection().sendPacket(gsp);
|
||||
gsp.runImpl();
|
||||
// Write into the channel.
|
||||
_channel.writeAndFlush(packet);
|
||||
|
||||
// Run packet implementation.
|
||||
packet.runImpl(getActiveChar());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param smId
|
||||
*/
|
||||
public void sendPacket(SystemMessageId smId)
|
||||
{
|
||||
sendPacket(SystemMessage.getSystemMessage(smId));
|
||||
}
|
||||
|
||||
public boolean isDetached()
|
||||
@@ -357,7 +355,7 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "Error updating delete time of character.", e);
|
||||
LOGGER.log(Level.SEVERE, "Error updating delete time of character.", e);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -382,7 +380,7 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "Error saving character..", e);
|
||||
LOGGER.log(Level.SEVERE, "Error saving character..", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,7 +400,7 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "Error restoring character.", e);
|
||||
LOGGER.log(Level.SEVERE, "Error restoring character.", e);
|
||||
}
|
||||
|
||||
final LogRecord record = new LogRecord(Level.WARNING, "Restore");
|
||||
@@ -571,7 +569,7 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "Error deleting character.", e);
|
||||
LOGGER.log(Level.SEVERE, "Error deleting character.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -587,7 +585,7 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
if (character != null)
|
||||
{
|
||||
// exploit prevention, should not happens in normal way
|
||||
_log.severe("Attempt of double login: " + character.getName() + "(" + objId + ") " + getAccountName());
|
||||
LOGGER.severe("Attempt of double login: " + character.getName() + "(" + objId + ") " + getAccountName());
|
||||
if (character.getClient() != null)
|
||||
{
|
||||
character.getClient().closeNow();
|
||||
@@ -612,7 +610,7 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.severe("could not restore in slot: " + charslot);
|
||||
LOGGER.severe("could not restore in slot: " + charslot);
|
||||
}
|
||||
|
||||
// setCharacter(character);
|
||||
@@ -620,11 +618,11 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list
|
||||
* @param chars
|
||||
*/
|
||||
public void setCharSelection(List<CharSelectInfoPackage> list)
|
||||
public void setCharSelection(List<CharSelectInfoPackage> chars)
|
||||
{
|
||||
_charSlotMapping = list;
|
||||
_charSlotMapping = chars;
|
||||
}
|
||||
|
||||
public CharSelectInfoPackage getCharSelection(int charslot)
|
||||
@@ -641,33 +639,13 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
return _secondaryAuth;
|
||||
}
|
||||
|
||||
public void close(L2GameServerPacket gsp)
|
||||
public void close(IOutgoingPacket packet)
|
||||
{
|
||||
if (getConnection() == null)
|
||||
if (packet != null)
|
||||
{
|
||||
return; // ofline shop
|
||||
_channel.writeAndFlush(packet);
|
||||
}
|
||||
if (_aditionalClosePacket != null)
|
||||
{
|
||||
getConnection().close(new L2GameServerPacket[]
|
||||
{
|
||||
_aditionalClosePacket,
|
||||
gsp
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
getConnection().close(gsp);
|
||||
}
|
||||
}
|
||||
|
||||
public void close(L2GameServerPacket[] gspArray)
|
||||
{
|
||||
if (getConnection() == null)
|
||||
{
|
||||
return; // ofline shop
|
||||
}
|
||||
getConnection().close(gspArray);
|
||||
_channel.close();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -679,37 +657,12 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
final CharSelectInfoPackage info = getCharSelection(charslot);
|
||||
if (info == null)
|
||||
{
|
||||
_log.warning(toString() + " tried to delete Character in slot " + charslot + " but no characters exits at that slot.");
|
||||
LOGGER.warning(toString() + " tried to delete Character in slot " + charslot + " but no characters exits at that slot.");
|
||||
return -1;
|
||||
}
|
||||
return info.getObjectId();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onForcedDisconnection()
|
||||
{
|
||||
final LogRecord record = new LogRecord(Level.WARNING, "Disconnected abnormally");
|
||||
record.setParameters(new Object[]
|
||||
{
|
||||
this
|
||||
});
|
||||
_logAccounting.log(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDisconnection()
|
||||
{
|
||||
// no long running tasks here, do it async
|
||||
try
|
||||
{
|
||||
ThreadPool.execute(new DisconnectTask());
|
||||
}
|
||||
catch (RejectedExecutionException e)
|
||||
{
|
||||
// server is closing
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close client connection with {@link ServerClose} packet
|
||||
*/
|
||||
@@ -735,14 +688,15 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
{
|
||||
try
|
||||
{
|
||||
final InetAddress address = getConnection().getInetAddress();
|
||||
switch (getState())
|
||||
final InetAddress address = _addr;
|
||||
final ConnectionState state = (ConnectionState) getConnectionState();
|
||||
switch (state)
|
||||
{
|
||||
case CONNECTED:
|
||||
{
|
||||
return "[IP: " + (address == null ? "disconnected" : address.getHostAddress()) + "]";
|
||||
}
|
||||
case AUTHED:
|
||||
case AUTHENTICATED:
|
||||
{
|
||||
return "[Account: " + getAccountName() + " - IP: " + (address == null ? "disconnected" : address.getHostAddress()) + "]";
|
||||
}
|
||||
@@ -822,8 +776,10 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
_log.log(Level.WARNING, "Error while disconnecting client.", e1);
|
||||
LOGGER.log(Level.WARNING, "Error while disconnecting client.", e1);
|
||||
}
|
||||
|
||||
IdFactory.getInstance().releaseId(getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -881,7 +837,7 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
_log.log(Level.WARNING, "Error during cleanup.", e1);
|
||||
LOGGER.log(Level.WARNING, "Error during cleanup.", e1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -896,14 +852,14 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
if (_autoSaveInDB != null)
|
||||
{
|
||||
_autoSaveInDB.cancel(true);
|
||||
// ThreadPoolManager.getInstance().removeGeneral((Runnable) _autoSaveInDB);
|
||||
// ThreadPool.getInstance().removeGeneral((Runnable) _autoSaveInDB);
|
||||
}
|
||||
|
||||
if (getActiveChar() != null) // this should only happen on connection loss
|
||||
{
|
||||
if (getActiveChar().isLocked())
|
||||
{
|
||||
_log.log(Level.WARNING, "Player " + getActiveChar().getName() + " still performing subclass actions during disconnect.");
|
||||
LOGGER.warning("Player " + getActiveChar().getName() + " still performing subclass actions during disconnect.");
|
||||
}
|
||||
|
||||
// we store all data from players who are disconnected while in an event in order to restore it in the next login
|
||||
@@ -912,20 +868,20 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
L2Event.savePlayerEventStatus(getActiveChar());
|
||||
}
|
||||
|
||||
// prevent closing again
|
||||
getActiveChar().setClient(null);
|
||||
|
||||
if (getActiveChar().isOnline())
|
||||
{
|
||||
getActiveChar().deleteMe();
|
||||
AntiFeedManager.getInstance().onDisconnect(L2GameClient.this);
|
||||
}
|
||||
|
||||
// prevent closing again
|
||||
getActiveChar().setClient(null);
|
||||
}
|
||||
setActiveChar(null);
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
_log.log(Level.WARNING, "Error while cleanup client.", e1);
|
||||
LOGGER.log(Level.WARNING, "Error while cleanup client.", e1);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -953,7 +909,7 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "Error on AutoSaveTask.", e);
|
||||
LOGGER.log(Level.SEVERE, "Error on AutoSaveTask.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -976,184 +932,12 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
return true;
|
||||
}
|
||||
|
||||
final Logger _logAudit = Logger.getLogger("audit");
|
||||
_logAudit.log(Level.INFO, "AUDIT: Client " + toString() + " kicked for reason: " + punishment);
|
||||
final Logger logAudit = Logger.getLogger("audit");
|
||||
logAudit.info("AUDIT: Client " + toString() + " kicked for reason: " + punishment);
|
||||
closeNow();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if detached, or flood detected, or queue overflow detected and queue still not empty.
|
||||
* @return false if client can receive packets.
|
||||
*/
|
||||
public boolean dropPacket()
|
||||
{
|
||||
if (_isDetached)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// flood protection
|
||||
if (getStats().countPacket(_packetQueue.size()))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return true;
|
||||
}
|
||||
|
||||
return getStats().dropPacket();
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts buffer underflow exceptions.
|
||||
*/
|
||||
public void onBufferUnderflow()
|
||||
{
|
||||
if (getStats().countUnderflowException())
|
||||
{
|
||||
_log.severe("Client " + toString() + " - Disconnected: Too many buffer underflow exceptions.");
|
||||
closeNow();
|
||||
return;
|
||||
}
|
||||
if (_state != GameClientState.CONNECTED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Config.PACKET_HANDLER_DEBUG)
|
||||
{
|
||||
_log.severe("Client " + toString() + " - Disconnected, too many buffer underflows in non-authed state.");
|
||||
}
|
||||
closeNow();
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts unknown packets
|
||||
*/
|
||||
public void onUnknownPacket()
|
||||
{
|
||||
if (getStats().countUnknownPacket())
|
||||
{
|
||||
_log.severe("Client " + toString() + " - Disconnected: Too many unknown packets.");
|
||||
closeNow();
|
||||
return;
|
||||
}
|
||||
if (_state != GameClientState.CONNECTED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Config.PACKET_HANDLER_DEBUG)
|
||||
{
|
||||
_log.severe("Client " + toString() + " - Disconnected, too many unknown packets in non-authed state.");
|
||||
}
|
||||
closeNow();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add packet to the queue and start worker thread if needed
|
||||
* @param packet
|
||||
*/
|
||||
public void execute(ReceivablePacket<L2GameClient> packet)
|
||||
{
|
||||
if (getStats().countFloods())
|
||||
{
|
||||
_log.severe("Client " + toString() + " - Disconnected, too many floods:" + getStats().longFloods + " long and " + getStats().shortFloods + " short.");
|
||||
closeNow();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_packetQueue.offer(packet))
|
||||
{
|
||||
if (getStats().countQueueOverflow())
|
||||
{
|
||||
_log.severe("Client " + toString() + " - Disconnected, too many queue overflows.");
|
||||
closeNow();
|
||||
}
|
||||
else
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (_queueLock.isLocked())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (_state == GameClientState.CONNECTED)
|
||||
{
|
||||
if (getStats().processedPackets > 3)
|
||||
{
|
||||
if (Config.PACKET_HANDLER_DEBUG)
|
||||
{
|
||||
_log.severe("Client " + toString() + " - Disconnected, too many packets in non-authed state.");
|
||||
}
|
||||
closeNow();
|
||||
return;
|
||||
}
|
||||
ThreadPool.execute(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
ThreadPool.execute(this);
|
||||
}
|
||||
}
|
||||
catch (RejectedExecutionException e)
|
||||
{
|
||||
// if the server is shutdown we ignore
|
||||
// _log.severe("Failed executing: " + packet.getClass().getSimpleName() + " for Client: " + toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (!_queueLock.tryLock())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
int count = 0;
|
||||
ReceivablePacket<L2GameClient> packet;
|
||||
while (true)
|
||||
{
|
||||
packet = _packetQueue.poll();
|
||||
if (packet == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_isDetached) // clear queue immediately after detach
|
||||
{
|
||||
_packetQueue.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
packet.run();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.severe("Exception during execution " + packet.getClass().getSimpleName() + ", client: " + toString() + "," + e.getMessage());
|
||||
}
|
||||
|
||||
count++;
|
||||
if (getStats().countBurst(count))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_queueLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void setClientTracert(int[][] tracert)
|
||||
{
|
||||
trace = tracert;
|
||||
@@ -1175,8 +959,13 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setAditionalClosePacket(L2GameServerPacket aditionalClosePacket)
|
||||
public void sendActionFailed()
|
||||
{
|
||||
_aditionalClosePacket = aditionalClosePacket;
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
|
||||
public ICrypt getCrypt()
|
||||
{
|
||||
return _crypt;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,558 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketWriter;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public enum OutgoingPackets
|
||||
{
|
||||
// Packets
|
||||
DIE(0x00),
|
||||
REVIVE(0x01),
|
||||
ATTACK_OUTOF_RANGE(0x02),
|
||||
ATTACKIN_COOL_TIME(0x03),
|
||||
ATTACK_DEAD_TARGET(0x04),
|
||||
SPAWN_ITEM(0x05),
|
||||
DELETE_OBJECT(0x08),
|
||||
CHARACTER_SELECTION_INFO(0x09),
|
||||
LOGIN_FAIL(0x0A),
|
||||
CHARACTER_SELECTED(0x0B),
|
||||
NPC_INFO(0x0C),
|
||||
NEW_CHARACTER_SUCCESS(0x0D),
|
||||
NEW_CHARACTER_FAIL(0x0E),
|
||||
CHARACTER_CREATE_SUCCESS(0x0F),
|
||||
CHARACTER_CREATE_FAIL(0x10),
|
||||
ITEM_LIST(0x11),
|
||||
SUNRISE(0x12),
|
||||
SUNSET(0x13),
|
||||
TRADE_START(0x14),
|
||||
TRADE_START_OK(0x15),
|
||||
DROP_ITEM(0x16),
|
||||
GET_ITEM(0x17),
|
||||
STATUS_UPDATE(0x18),
|
||||
NPC_HTML_MESSAGE(0x19),
|
||||
TRADE_OWN_ADD(0x1A),
|
||||
TRADE_OTHER_ADD(0x1B),
|
||||
TRADE_DONE(0x1C),
|
||||
CHARACTER_DELETE_SUCCESS(0x1D),
|
||||
CHARACTER_DELETE_FAIL(0x1E),
|
||||
ACTION_FAIL(0x1F),
|
||||
SERVER_CLOSE(0x20),
|
||||
INVENTORY_UPDATE(0x21),
|
||||
TELEPORT_TO_LOCATION(0x22),
|
||||
TARGET_SELECTED(0x23),
|
||||
TARGET_UNSELECTED(0x24),
|
||||
AUTO_ATTACK_START(0x25),
|
||||
AUTO_ATTACK_STOP(0x26),
|
||||
SOCIAL_ACTION(0x27),
|
||||
CHANGE_MOVE_TYPE(0x28),
|
||||
CHANGE_WAIT_TYPE(0x29),
|
||||
MANAGE_PLEDGE_POWER(0x2A),
|
||||
CREATE_PLEDGE(0x2B),
|
||||
ASK_JOIN_PLEDGE(0x2C),
|
||||
JOIN_PLEDGE(0x2D),
|
||||
VERSION_CHECK(0x2E),
|
||||
MOVE_TO_LOCATION(0x2F),
|
||||
NPC_SAY(0x30),
|
||||
CHAR_INFO(0x31),
|
||||
USER_INFO(0x32),
|
||||
ATTACK(0x33),
|
||||
WITHDRAWAL_PLEDGE(0x34),
|
||||
OUST_PLEDGE_MEMBER(0x35),
|
||||
SET_OUST_PLEDGE_MEMBER(0x36),
|
||||
DISMISS_PLEDGE(0x37),
|
||||
SET_DISMISS_PLEDGE(0x38),
|
||||
ASK_JOIN_PARTY(0x39),
|
||||
JOIN_PARTY(0x3A),
|
||||
WITHDRAWAL_PARTY(0x3B),
|
||||
OUST_PARTY_MEMBER(0x3C),
|
||||
SET_OUST_PARTY_MEMBER(0x3D),
|
||||
DISMISS_PARTY(0x3E),
|
||||
SET_DISMISS_PARTY(0x3F),
|
||||
USER_ACK(0x40),
|
||||
WAREHOUSE_DEPOSIT_LIST(0x41),
|
||||
WAREHOUSE_WITHDRAW_LIST(0x42),
|
||||
WAREHOUSE_DONE(0x43),
|
||||
SHORT_CUT_REGISTER(0x44),
|
||||
SHORT_CUT_INIT(0x45),
|
||||
SHORT_CUT_DELETE(0x46),
|
||||
STOP_MOVE(0x47),
|
||||
MAGIC_SKILL_USE(0x48),
|
||||
MAGIC_SKILL_CANCELED(0x49),
|
||||
SAY2(0x4A),
|
||||
EQUIP_UPDATE(0x4B),
|
||||
DOOR_INFO(0x4C),
|
||||
DOOR_STATUS_UPDATE(0x4D),
|
||||
PARTY_SMALL_WINDOW_ALL(0x4E),
|
||||
PARTY_SMALL_WINDOW_ADD(0x4F),
|
||||
PARTY_SMALL_WINDOW_DELETE_ALL(0x50),
|
||||
PARTY_SMALL_WINDOW_DELETE(0x51),
|
||||
PARTY_SMALL_WINDOW_UPDATE(0x52),
|
||||
TRADE_PRESS_OWN_OK(0x53),
|
||||
MAGIC_SKILL_LAUNCHED(0x54),
|
||||
FRIEND_ADD_REQUEST_RESULT(0x55),
|
||||
FRIEND_ADD(0x56),
|
||||
FRIEND_REMOVE(0x57),
|
||||
FRIEND_LIST(0x58),
|
||||
FRIEND_STATUS(0x59),
|
||||
PLEDGE_SHOW_MEMBER_LIST_ALL(0x5A),
|
||||
PLEDGE_SHOW_MEMBER_LIST_UPDATE(0x5B),
|
||||
PLEDGE_SHOW_MEMBER_LIST_ADD(0x5C),
|
||||
PLEDGE_SHOW_MEMBER_LIST_DELETE(0x5D),
|
||||
MAGIC_LIST(0x5E),
|
||||
SKILL_LIST(0x5F),
|
||||
VEHICLE_INFO(0x60),
|
||||
FINISH_ROTATING(0x61),
|
||||
SYSTEM_MESSAGE(0x62),
|
||||
START_PLEDGE_WAR(0x63),
|
||||
REPLY_START_PLEDGE_WAR(0x64),
|
||||
STOP_PLEDGE_WAR(0x65),
|
||||
REPLY_STOP_PLEDGE_WAR(0x66),
|
||||
SURRENDER_PLEDGE_WAR(0x67),
|
||||
REPLY_SURRENDER_PLEDGE_WAR(0x68),
|
||||
SET_PLEDGE_CREST(0x69),
|
||||
PLEDGE_CREST(0x6A),
|
||||
SETUP_GAUGE(0x6B),
|
||||
VEHICLE_DEPARTURE(0x6C),
|
||||
VEHICLE_CHECK_LOCATION(0x6D),
|
||||
GET_ON_VEHICLE(0x6E),
|
||||
GET_OFF_VEHICLE(0x6F),
|
||||
TRADE_REQUEST(0x70),
|
||||
RESTART_RESPONSE(0x71),
|
||||
MOVE_TO_PAWN(0x72),
|
||||
SSQ_INFO(0x73),
|
||||
GAME_GUARD_QUERY(0x74),
|
||||
L2_FRIEND_LIST(0x75),
|
||||
L2_FRIEND(0x76),
|
||||
L2_FRIEND_STATUS(0x77),
|
||||
L2_FRIEND_SAY(0x78),
|
||||
VALIDATE_LOCATION(0x79),
|
||||
START_ROTATING(0x7A),
|
||||
SHOW_BOARD(0x7B),
|
||||
CHOOSE_INVENTORY_ITEM(0x7C),
|
||||
DUMMY(0x7D),
|
||||
MOVE_TO_LOCATION_IN_VEHICLE(0x7E),
|
||||
STOP_MOVE_IN_VEHICLE(0x7F),
|
||||
VALIDATE_LOCATION_IN_VEHICLE(0x80),
|
||||
TRADE_UPDATE(0x81),
|
||||
TRADE_PRESS_OTHER_OK(0x82),
|
||||
FRIEND_ADD_REQUEST(0x83),
|
||||
LOG_OUT_OK(0x84),
|
||||
ABNORMAL_STATUS_UPDATE(0x85),
|
||||
QUEST_LIST(0x86),
|
||||
ENCHANT_RESULT(0x87),
|
||||
PLEDGE_SHOW_MEMBER_LIST_DELETE_ALL(0x88),
|
||||
PLEDGE_INFO(0x89),
|
||||
PLEDGE_EXTENDED_INFO(0x8A),
|
||||
SURRENDER_PERSONALLY(0x8B),
|
||||
RIDE(0x8C),
|
||||
GIVE_NICK_NAME_DONE(0x8D),
|
||||
PLEDGE_SHOW_INFO_UPDATE(0x8E),
|
||||
CLIENT_ACTION(0x8F),
|
||||
ACQUIRE_SKILL_LIST(0x90),
|
||||
ACQUIRE_SKILL_INFO(0x91),
|
||||
SERVER_OBJECT_INFO(0x92),
|
||||
GM_HIDE(0x93),
|
||||
ACQUIRE_SKILL_DONE(0x94),
|
||||
GM_VIEW_CHARACTER_INFO(0x95),
|
||||
GM_VIEW_PLEDGE_INFO(0x96),
|
||||
GM_VIEW_SKILL_INFO(0x97),
|
||||
GM_VIEW_MAGIC_INFO(0x98),
|
||||
GM_VIEW_QUEST_INFO(0x99),
|
||||
GM_VIEW_ITEM_LIST(0x9A),
|
||||
GM_VIEW_WAREHOUSE_WITHDRAW_LIST(0x9B),
|
||||
LIST_PARTY_WAITING(0x9C),
|
||||
PARTY_ROOM_INFO(0x9D),
|
||||
PLAY_SOUND(0x9E),
|
||||
STATIC_OBJECT(0x9F),
|
||||
PRIVATE_STORE_SELL_MANAGE_LIST(0xA0),
|
||||
PRIVATE_STORE_SELL_LIST(0xA1),
|
||||
PRIVATE_STORE_SELL_MSG(0xA2),
|
||||
SHOW_MINIMAP(0xA3),
|
||||
REVIVE_REQUEST(0xA4),
|
||||
ABNORMAL_VISUAL_EFFECT(0xA5),
|
||||
TUTORIAL_SHOW_HTML(0xA6),
|
||||
SHOW_TUTORIAL_MARK(0xA7),
|
||||
TUTORIAL_ENABLE_CLIENT_EVENT(0xA8),
|
||||
TUTORIAL_CLOSE_HTML(0xA9),
|
||||
SHOW_RADAR(0xAA),
|
||||
WITHDRAW_ALLIANCE(0xAB),
|
||||
OUST_ALLIANCE_MEMBER_PLEDGE(0xAC),
|
||||
DISMISS_ALLIANCE(0xAD),
|
||||
SET_ALLIANCE_CREST(0xAE),
|
||||
ALLIANCE_CREST(0xAF),
|
||||
SERVER_CLOSE_SOCKET(0xB0),
|
||||
PET_STATUS_SHOW(0xB1),
|
||||
PET_INFO(0xB2),
|
||||
PET_ITEM_LIST(0xB3),
|
||||
PET_INVENTORY_UPDATE(0xB4),
|
||||
ALLIANCE_INFO(0xB5),
|
||||
PET_STATUS_UPDATE(0xB6),
|
||||
PET_DELETE(0xB7),
|
||||
DELETE_RADAR(0xB8),
|
||||
MY_TARGET_SELECTED(0xB9),
|
||||
PARTY_MEMBER_POSITION(0xBA),
|
||||
ASK_JOIN_ALLIANCE(0xBB),
|
||||
JOIN_ALLIANCE(0xBC),
|
||||
PRIVATE_STORE_BUY_MANAGE_LIST(0xBD),
|
||||
PRIVATE_STORE_BUY_LIST(0xBE),
|
||||
PRIVATE_STORE_BUY_MSG(0xBF),
|
||||
VEHICLE_START(0xC0),
|
||||
REQUEST_TIME_CHECK(0xC1),
|
||||
START_ALLIANCE_WAR(0xC2),
|
||||
REPLY_START_ALLIANCE_WAR(0xC3),
|
||||
STOP_ALLIANCE_WAR(0xC4),
|
||||
REPLY_STOP_ALLIANCE_WAR(0xC5),
|
||||
SURRENDER_ALLIANCE_WAR(0xC6),
|
||||
SKILL_COOL_TIME(0xC7),
|
||||
PACKAGE_TO_LIST(0xC8),
|
||||
CASTLE_SIEGE_INFO(0xC9),
|
||||
CASTLE_SIEGE_ATTACKER_LIST(0xCA),
|
||||
CASTLE_SIEGE_DEFENDER_LIST(0xCB),
|
||||
NICK_NAME_CHANGED(0xCC),
|
||||
PLEDGE_STATUS_CHANGED(0xCD),
|
||||
RELATION_CHANGED(0xCE),
|
||||
EVENT_TRIGGER(0xCF),
|
||||
MULTI_SELL_LIST(0xD0),
|
||||
SET_SUMMON_REMAIN_TIME(0xD1),
|
||||
PACKAGE_SENDABLE_LIST(0xD2),
|
||||
EARTHQUAKE(0xD3),
|
||||
FLY_TO_LOCATION(0xD4),
|
||||
BLOCK_LIST(0xD5),
|
||||
SPECIAL_CAMERA(0xD6),
|
||||
NORMAL_CAMERA(0xD7),
|
||||
SKILL_REMAIN_SEC(0xD8),
|
||||
NET_PING(0xD9),
|
||||
DICE(0xDA),
|
||||
SNOOP(0xDB),
|
||||
RECIPE_BOOK_ITEM_LIST(0xDC),
|
||||
RECIPE_ITEM_MAKE_INFO(0xDD),
|
||||
RECIPE_SHOP_MANAGE_LIST(0xDE),
|
||||
RECIPE_SHOP_SELL_LIST(0xDF),
|
||||
RECIPE_SHOP_ITEM_INFO(0xE0),
|
||||
RECIPE_SHOP_MSG(0xE1),
|
||||
SHOW_CALC(0xE2),
|
||||
MON_RACE_INFO(0xE3),
|
||||
HENNA_ITEM_INFO(0xE4),
|
||||
HENNA_INFO(0xE5),
|
||||
HENNA_UNEQUIP_LIST(0xE6),
|
||||
HENNA_UNEQUIP_INFO(0xE7),
|
||||
MACRO_LIST(0xE8),
|
||||
BUY_LIST_SEED(0xE9),
|
||||
SHOW_TOWN_MAP(0xEA),
|
||||
OBSERVER_START(0xEB),
|
||||
OBSERVER_END(0xEC),
|
||||
CHAIR_SIT(0xED),
|
||||
HENNA_EQUIP_LIST(0xEE),
|
||||
SELL_LIST_PROCURE(0xEF),
|
||||
GM_HENNA_INFO(0xF0),
|
||||
RADAR_CONTROL(0xF1),
|
||||
CLIENT_SET_TIME(0xF2),
|
||||
CONFIRM_DLG(0xF3),
|
||||
PARTY_SPELLED(0xF4),
|
||||
SHOP_PREVIEW_LIST(0xF5),
|
||||
SHOP_PREVIEW_INFO(0xF6),
|
||||
CAMERA_MODE(0xF7),
|
||||
SHOW_XMAS_SEAL(0xF8),
|
||||
ETC_STATUS_UPDATE(0xF9),
|
||||
SHORT_BUFF_STATUS_UPDATE(0xFA),
|
||||
SSQ_STATUS(0xFB),
|
||||
PETITION_VOTE(0xFC),
|
||||
AGIT_DECO_INFO(0xFD),
|
||||
// ExPackets
|
||||
EX_DUMMY(0xFE, 0x00),
|
||||
EX_REGEN_MAX(0xFE, 0x01),
|
||||
EX_EVENT_MATCH_USER_INFO(0xFE, 0x02),
|
||||
EX_COLOSSEUM_FENCE_INFO(0xFE, 0x03),
|
||||
EX_EVENT_MATCH_SPELLED_INFO(0xFE, 0x04),
|
||||
EX_EVENT_MATCH_FIRECRACKER(0xFE, 0x05),
|
||||
EX_EVENT_MATCH_TEAM_UNLOCKED(0xFE, 0x06),
|
||||
EX_EVENT_MATCH_GM_TEST(0xFE, 0x07),
|
||||
EX_PARTY_ROOM_MEMBER(0xFE, 0x08),
|
||||
EX_CLOSE_PARTY_ROOM(0xFE, 0x09),
|
||||
EX_MANAGE_PARTY_ROOM_MEMBER(0xFE, 0x0A),
|
||||
EX_EVENT_MATCH_LOCK_RESULT(0xFE, 0x0B),
|
||||
EX_AUTO_SOULSHOT(0xFE, 0x0C),
|
||||
EX_EVENT_MATCH_LIST(0xFE, 0x0D),
|
||||
EX_EVENT_MATCH_OBSERVER(0xFE, 0x0E),
|
||||
EX_EVENT_MATCH_MESSAGE(0xFE, 0x0F),
|
||||
EX_EVENT_MATCH_SCORE(0xFE, 0x10),
|
||||
EX_SERVER_PRIMITIVE(0xFE, 0x11),
|
||||
EX_OPEN_MPCC(0xFE, 0x12),
|
||||
EX_CLOSE_MPCC(0xFE, 0x13),
|
||||
EX_SHOW_CASTLE_INFO(0xFE, 0x14),
|
||||
EX_SHOW_FORTRESS_INFO(0xFE, 0x15),
|
||||
EX_SHOW_AGIT_INFO(0xFE, 0x16),
|
||||
EX_SHOW_FORTRESS_SIEGE_INFO(0xFE, 0x17),
|
||||
EX_PARTY_PET_WINDOW_ADD(0xFE, 0x18),
|
||||
EX_PARTY_PET_WINDOW_UPDATE(0xFE, 0x19),
|
||||
EX_ASK_JOIN_MPCC(0xFE, 0x1A),
|
||||
EX_PLEDGE_EMBLEM(0xFE, 0x1B),
|
||||
EX_EVENT_MATCH_TEAM_INFO(0xFE, 0x1C),
|
||||
EX_EVENT_MATCH_CREATE(0xFE, 0x1D),
|
||||
EX_FISHING_START(0xFE, 0x1E),
|
||||
EX_FISHING_END(0xFE, 0x1F),
|
||||
EX_SHOW_QUEST_INFO(0xFE, 0x20),
|
||||
EX_SHOW_QUEST_MARK(0xFE, 0x21),
|
||||
EX_SEND_MANOR_LIST(0xFE, 0x22),
|
||||
EX_SHOW_SEED_INFO(0xFE, 0x23),
|
||||
EX_SHOW_CROP_INFO(0xFE, 0x24),
|
||||
EX_SHOW_MANOR_DEFAULT_INFO(0xFE, 0x25),
|
||||
EX_SHOW_SEED_SETTING(0xFE, 0x26),
|
||||
EX_FISHING_START_COMBAT(0xFE, 0x27),
|
||||
EX_FISHING_HP_REGEN(0xFE, 0x28),
|
||||
EX_ENCHANT_SKILL_LIST(0xFE, 0x29),
|
||||
EX_ENCHANT_SKILL_INFO(0xFE, 0x2A),
|
||||
EX_SHOW_CROP_SETTING(0xFE, 0x2B),
|
||||
EX_SHOW_SELL_CROP_LIST(0xFE, 0x2C),
|
||||
EX_OLYMPIAD_MATCH_END(0xFE, 0x2D),
|
||||
EX_MAIL_ARRIVED(0xFE, 0x2E),
|
||||
EX_STORAGE_MAX_COUNT(0xFE, 0x2F),
|
||||
EX_EVENT_MATCH_MANAGE(0xFE, 0x30),
|
||||
EX_MULTI_PARTY_COMMAND_CHANNEL_INFO(0xFE, 0x31),
|
||||
EX_PC_CAFE_POINT_INFO(0xFE, 0x32),
|
||||
EX_SET_COMPASS_ZONE_CODE(0xFE, 0x33),
|
||||
EX_GET_BOSS_RECORD(0xFE, 0x34),
|
||||
EX_ASK_JOIN_PARTY_ROOM(0xFE, 0x35),
|
||||
EX_LIST_PARTY_MATCHING_WAITING_ROOM(0xFE, 0x36),
|
||||
EX_SET_MPCC_ROUTING(0xFE, 0x37),
|
||||
EX_SHOW_ADVENTURER_GUIDE_BOOK(0xFE, 0x38),
|
||||
EX_SHOW_SCREEN_MESSAGE(0xFE, 0x39),
|
||||
PLEDGE_SKILL_LIST(0xFE, 0x3A),
|
||||
PLEDGE_SKILL_LIST_ADD(0xFE, 0x3B),
|
||||
PLEDGE_POWER_GRADE_LIST(0xFE, 0x3C),
|
||||
PLEDGE_RECEIVE_POWER_INFO(0xFE, 0x3D),
|
||||
PLEDGE_RECEIVE_MEMBER_INFO(0xFE, 0x3E),
|
||||
PLEDGE_RECEIVE_WAR_LIST(0xFE, 0x3F),
|
||||
PLEDGE_RECEIVE_SUB_PLEDGE_CREATED(0xFE, 0x40),
|
||||
EX_RED_SKY(0xFE, 0x41),
|
||||
PLEDGE_RECEIVE_UPDATE_POWER(0xFE, 0x42),
|
||||
FLY_SELF_DESTINATION(0xFE, 0x43),
|
||||
SHOW_PC_CAFE_COUPON_SHOW_UI(0xFE, 0x44),
|
||||
EX_SEARCH_ORC(0xFE, 0x45),
|
||||
EX_CURSED_WEAPON_LIST(0xFE, 0x46),
|
||||
EX_CURSED_WEAPON_LOCATION(0xFE, 0x47),
|
||||
EX_RESTART_CLIENT(0xFE, 0x48),
|
||||
EX_REQUEST_HACK_SHIELD(0xFE, 0x49),
|
||||
EX_USE_SHARED_GROUP_ITEM(0xFE, 0x4A),
|
||||
EX_MPCC_SHOW_PARTY_MEMBER_INFO(0xFE, 0x4B),
|
||||
EX_DUEL_ASK_START(0xFE, 0x4C),
|
||||
EX_DUEL_READY(0xFE, 0x4D),
|
||||
EX_DUEL_START(0xFE, 0x4E),
|
||||
EX_DUEL_END(0xFE, 0x4F),
|
||||
EX_DUEL_UPDATE_USER_INFO(0xFE, 0x50),
|
||||
EX_SHOW_VARIATION_MAKE_WINDOW(0xFE, 0x51),
|
||||
EX_SHOW_VARIATION_CANCEL_WINDOW(0xFE, 0x52),
|
||||
EX_PUT_ITEM_RESULT_FOR_VARIATION_MAKE(0xFE, 0x53),
|
||||
EX_PUT_INTENSIVE_RESULT_FOR_VARIATION_MAKE(0xFE, 0x54),
|
||||
EX_PUT_COMMISSION_RESULT_FOR_VARIATION_MAKE(0xFE, 0x55),
|
||||
EX_VARIATION_RESULT(0xFE, 0x56),
|
||||
EX_PUT_ITEM_RESULT_FOR_VARIATION_CANCEL(0xFE, 0x57),
|
||||
EX_VARIATION_CANCEL_RESULT(0xFE, 0x58),
|
||||
EX_DUEL_ENEMY_RELATION(0xFE, 0x59),
|
||||
EX_PLAY_ANIMATION(0xFE, 0x5A),
|
||||
EX_MPCC_PARTY_INFO_UPDATE(0xFE, 0x5B),
|
||||
EX_PLAY_SCENE(0xFE, 0x5C),
|
||||
EX_SPAWN_EMITTER(0xFE, 0x5D),
|
||||
EX_ENCHANT_SKILL_INFO_DETAIL(0xFE, 0x5E),
|
||||
EX_BASIC_ACTION_LIST(0xFE, 0x5F),
|
||||
EX_AIRSHIP_INFO(0xFE, 0x60),
|
||||
EX_ATTRIBUTE_ENCHANT_RESULT(0xFE, 0x61),
|
||||
EX_CHOOSE_INVENTORY_ATTRIBUTE_ITEM(0xFE, 0x62),
|
||||
EX_GET_ON_AIRSHIP(0xFE, 0x63),
|
||||
EX_GET_OFF_AIRSHIP(0xFE, 0x64),
|
||||
EX_MOVE_TO_LOCATION_AIRSHIP(0xFE, 0x65),
|
||||
EX_STOP_MOVE_AIRSHIP(0xFE, 0x66),
|
||||
EX_SHOW_TRACE(0xFE, 0x67),
|
||||
EX_ITEM_AUCTION_INFO(0xFE, 0x68),
|
||||
EX_NEED_TO_CHANGE_NAME(0xFE, 0x69),
|
||||
EX_PARTY_PET_WINDOW_DELETE(0xFE, 0x6A),
|
||||
EX_TUTORIAL_LIST(0xFE, 0x6B),
|
||||
EX_RP_ITEM_LINK(0xFE, 0x6C),
|
||||
EX_MOVE_TO_LOCATION_IN_AIRSHIP(0xFE, 0x6D),
|
||||
EX_STOP_MOVE_IN_AIRSHIP(0xFE, 0x6E),
|
||||
EX_VALIDATE_LOCATION_IN_AIRSHIP(0xFE, 0x6F),
|
||||
EX_UI_SETTING(0xFE, 0x70),
|
||||
EX_MOVE_TO_TARGET_IN_AIRSHIP(0xFE, 0x71),
|
||||
EX_ATTACK_IN_AIRSHIP(0xFE, 0x72),
|
||||
EX_MAGIC_SKILL_USE_IN_AIRSHIP(0xFE, 0x73),
|
||||
EX_SHOW_BASE_ATTRIBUTE_CANCEL_WINDOW(0xFE, 0x74),
|
||||
EX_BASE_ATTRIBUTE_CANCEL_RESULT(0xFE, 0x75),
|
||||
EX_SUB_PLEDGE_SKILL_ADD(0xFE, 0x76),
|
||||
EX_RESPONSE_FREE_SERVER(0xFE, 0x77),
|
||||
EX_SHOW_PROCURE_CROP_DETAIL(0xFE, 0x78),
|
||||
EX_HERO_LIST(0xFE, 0x79),
|
||||
EX_OLYMPIAD_USER_INFO(0xFE, 0x7A),
|
||||
EX_OLYMPIAD_SPELLED_INFO(0xFE, 0x7B),
|
||||
EX_OLYMPIAD_MODE(0xFE, 0x7C),
|
||||
EX_SHOW_FORTRESS_MAP_INFO(0xFE, 0x7D),
|
||||
EX_PVP_MATCH_RECORD(0xFE, 0x7E),
|
||||
EX_PVP_MATCH_USER_DIE(0xFE, 0x7F),
|
||||
EX_PRIVATE_STORE_PACKAGE_MSG(0xFE, 0x80),
|
||||
EX_PUT_ENCHANT_TARGET_ITEM_RESULT(0xFE, 0x81),
|
||||
EX_PUT_ENCHANT_SUPPORT_ITEM_RESULT(0xFE, 0x82),
|
||||
EX_REQUEST_CHANGE_NICKNAME_COLOR(0xFE, 0x83),
|
||||
EX_GET_BOOKMARK_INFO(0xFE, 0x84),
|
||||
EX_NOTIFY_PREMIUM_ITEM(0xFE, 0x85),
|
||||
EX_GET_PREMIUM_ITEM_LIST(0xFE, 0x86),
|
||||
EX_PERIODIC_ITEM_LIST(0xFE, 0x87),
|
||||
EX_JUMP_TO_LOCATION(0xFE, 0x88),
|
||||
EX_PVP_MATCH_CC_RECORD(0xFE, 0x89),
|
||||
EX_PVP_MATCH_CC_MY_RECORD(0xFE, 0x8A),
|
||||
EX_PVP_MATCH_CC_RETIRE(0xFE, 0x8B),
|
||||
EX_SHOW_TERRITORY(0xFE, 0x8C),
|
||||
EX_NPC_QUEST_HTML_MESSAGE(0xFE, 0x8D),
|
||||
EX_SEND_UI_EVENT(0xFE, 0x8E),
|
||||
EX_NOTIFY_BIRTHDAY(0xFE, 0x8F),
|
||||
EX_SHOW_DOMINION_REGISTRY(0xFE, 0x90),
|
||||
EX_REPLY_REGISTER_DOMINION(0xFE, 0x91),
|
||||
EX_REPLY_DOMINION_INFO(0xFE, 0x92),
|
||||
EX_SHOW_OWNTHING_POS(0xFE, 0x93),
|
||||
EX_CLEFT_LIST(0xFE, 0x94),
|
||||
EX_CLEFT_STATE(0xFE, 0x95),
|
||||
EX_DOMINION_CHANNEL_SET(0xFE, 0x96),
|
||||
EX_BLOCK_UP_SET_LIST(0xFE, 0x97),
|
||||
EX_BLOCK_UP_SET_STATE(0xFE, 0x98),
|
||||
EX_START_SCENE_PLAYER(0xFE, 0x99),
|
||||
EX_AIRSHIP_TELEPORT_LIST(0xFE, 0x9A),
|
||||
EX_MPCC_ROOM_INFO(0xFE, 0x9B),
|
||||
EX_LIST_MPCC_WAITING(0xFE, 0x9C),
|
||||
EX_DISSMISS_MPCC_ROOM(0xFE, 0x9D),
|
||||
EX_MANAGE_MPCC_ROOM_MEMBER(0xFE, 0x9E),
|
||||
EX_MPCC_ROOM_MEMBER(0xFE, 0x9F),
|
||||
EX_VITALITY_POINT_INFO(0xFE, 0xA0),
|
||||
EX_SHOW_SEED_MAP_INFO(0xFE, 0xA1),
|
||||
EX_MPCC_PARTYMASTER_LIST(0xFE, 0xA2),
|
||||
EX_DOMINION_WAR_START(0xFE, 0xA3),
|
||||
EX_DOMINION_WAR_END(0xFE, 0xA4),
|
||||
EX_SHOW_LINES(0xFE, 0xA5),
|
||||
EX_PARTY_MEMBER_RENAMED(0xFE, 0xA6),
|
||||
EX_ENCHANT_SKILL_RESULT(0xFE, 0xA7),
|
||||
EX_REFUND_LIST(0xFE, 0xA8),
|
||||
EX_NOTICE_POST_ARRIVED(0xFE, 0xA9),
|
||||
EX_SHOW_RECEIVED_POST_LIST(0xFE, 0xAA),
|
||||
EX_REPLY_RECEIVED_POST(0xFE, 0xAB),
|
||||
EX_SHOW_SENT_POST_LIST(0xFE, 0xAC),
|
||||
EX_REPLY_SENT_POST(0xFE, 0xAD),
|
||||
EX_RESPONSE_SHOW_STEP_ONE(0xFE, 0xAE),
|
||||
EX_RESPONSE_SHOW_STEP_TWO(0xFE, 0xAF),
|
||||
EX_RESPONSE_SHOW_CONTENTS(0xFE, 0xB0),
|
||||
EX_SHOW_PETITION_HTML(0xFE, 0xB1),
|
||||
EX_REPLY_POST_ITEM_LIST(0xFE, 0xB2),
|
||||
EX_CHANGE_POST_STATE(0xFE, 0xB3),
|
||||
EX_NOTICE_POST_SENT(0xFE, 0xB4),
|
||||
EX_INITIALIZE_SEED(0xFE, 0xB5),
|
||||
EX_RAID_RESERVE_RESULT(0xFE, 0xB6),
|
||||
EX_BUY_SELL_LIST(0xFE, 0xB7),
|
||||
EX_CLOSE_RAID_SOCKET(0xFE, 0xB8),
|
||||
EX_PRIVATE_MARKET_LIST(0xFE, 0xB9),
|
||||
EX_RAID_CHARACTER_SELECTED(0xFE, 0xBA),
|
||||
EX_ASK_COUPLE_ACTION(0xFE, 0xBB),
|
||||
EX_BR_BROADCAST_EVENT_STATE(0xFE, 0xBC),
|
||||
EX_BR_LOAD_EVENT_TOP_RANKERS(0xFE, 0xBD),
|
||||
EX_CHANGE_NPC_STATE(0xFE, 0xBE),
|
||||
EX_ASK_MODIFY_PARTY_LOOTING(0xFE, 0xBF),
|
||||
EX_SET_PARTY_LOOTING(0xFE, 0xC0),
|
||||
EX_ROTATION(0xFE, 0xC1),
|
||||
EX_CHANGE_CLIENT_EFFECT_INFO(0xFE, 0xC2),
|
||||
EX_MEMBERSHIP_INFO(0xFE, 0xC3),
|
||||
EX_REPLY_HAND_OVER_PARTY_MASTER(0xFE, 0xC4),
|
||||
EX_QUEST_NPC_LOG_LIST(0xFE, 0xC5),
|
||||
EX_QUEST_ITEM_LIST(0xFE, 0xC6),
|
||||
EX_GM_VIEW_QUEST_ITEM_LIST(0xFE, 0xC7),
|
||||
EX_RESTART_RESPONSE(0xFE, 0xC8),
|
||||
EX_VOTE_SYSTEM_INFO(0xFE, 0xC9),
|
||||
EX_SHUTTLE_INFO(0xFE, 0xCA),
|
||||
EX_SUTTLE_GET_ON(0xFE, 0xCB),
|
||||
EX_SUTTLE_GET_OFF(0xFE, 0xCC),
|
||||
EX_SUTTLE_MOVE(0xFE, 0xCD),
|
||||
EX_MOVE_TO_LOCATION_IN_SUTTLE(0xFE, 0xCE),
|
||||
EX_STOP_MOVE_IN_SHUTTLE(0xFE, 0xCF),
|
||||
EX_VALIDATE_LOCATION_IN_SHUTTLE(0xFE, 0xD0),
|
||||
EX_AGIT_AUCTION_CMD(0xFE, 0xD1),
|
||||
EX_CONFIRM_ADDING_POST_FRIEND(0xFE, 0xD2),
|
||||
EX_RECEIVE_SHOW_POST_FRIEND(0xFE, 0xD3),
|
||||
EX_RECEIVE_OLYMPIAD(0xFE, 0xD4),
|
||||
EX_BR_GAME_POINT(0xFE, 0xD5),
|
||||
EX_BR_PRODUCT_LIST(0xFE, 0xD6),
|
||||
EX_BR_PRODUCT_INFO(0xFE, 0xD7),
|
||||
EX_BR_BUY_PRODUCT(0xFE, 0xD8),
|
||||
EX_BR_PREMIUM_STATE(0xFE, 0xD9),
|
||||
EX_BR_EXTRA_USER_INFO(0xFE, 0xDA),
|
||||
EX_BR_BUFF_EVENT_STATE(0xFE, 0xDB),
|
||||
EX_BR_RECENT_PRODUCT_LIST(0xFE, 0xDC),
|
||||
EX_BR_MINIGAME_LOAD_SCORES(0xFE, 0xDD),
|
||||
EX_BR_AGATHION_ENERGY_INFO(0xFE, 0xDE),
|
||||
EX_NAVIT_ADVENT_POINT_INFO(0xFE, 0xDF),
|
||||
EX_NAVIT_ADVENT_EFFECT(0xFE, 0xE0),
|
||||
EX_NAVIT_ADVENT_TIME_CHANGE(0xFE, 0xE1),
|
||||
EX_GOODS_INVENTORY_CHANGED_NOTIFY(0xFE, 0xE2),
|
||||
EX_GOODS_INVENTORY_INFO(0xFE, 0xE3),
|
||||
EX_GOODS_INVENTORY_RESULT(0xFE, 0xE4),
|
||||
EX_2ND_PASSWORD_CHECK(0xFE, 0xE5),
|
||||
EX_2ND_PASSWORD_VERIFY(0xFE, 0xE6),
|
||||
EX_2ND_PASSWORD_ACK(0xFE, 0xE7),
|
||||
EX_SAY2_FAIL(0xFE, 0xE8);
|
||||
|
||||
private final int _id1;
|
||||
private final int _id2;
|
||||
|
||||
OutgoingPackets(int id1)
|
||||
{
|
||||
this(id1, -1);
|
||||
}
|
||||
|
||||
OutgoingPackets(int id1, int id2)
|
||||
{
|
||||
_id1 = id1;
|
||||
_id2 = id2;
|
||||
}
|
||||
|
||||
public int getId1()
|
||||
{
|
||||
return _id1;
|
||||
}
|
||||
|
||||
public int getId2()
|
||||
{
|
||||
return _id2;
|
||||
}
|
||||
|
||||
public void writeId(PacketWriter packet)
|
||||
{
|
||||
packet.writeC(_id1);
|
||||
if (_id2 > 0)
|
||||
{
|
||||
packet.writeH(_id2);
|
||||
}
|
||||
}
|
||||
|
||||
public static OutgoingPackets getPacket(int id1, int id2)
|
||||
{
|
||||
for (OutgoingPackets packet : values())
|
||||
{
|
||||
if ((packet.getId1() == id1) && (packet.getId2() == id2))
|
||||
{
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.items.type.CrystalType;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
public abstract class AbstractRefinePacket extends L2GameClientPacket
|
||||
public abstract class AbstractRefinePacket implements IClientIncomingPacket
|
||||
{
|
||||
public static final int GRADE_NONE = 0;
|
||||
public static final int GRADE_MID = 1;
|
||||
|
@@ -17,6 +17,7 @@
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.PcCondOverride;
|
||||
@@ -24,10 +25,11 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
import com.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||
import com.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
|
||||
public final class Action extends L2GameClientPacket
|
||||
public final class Action implements IClientIncomingPacket
|
||||
{
|
||||
private int _objectId;
|
||||
@SuppressWarnings("unused")
|
||||
@@ -39,20 +41,21 @@ public final class Action extends L2GameClientPacket
|
||||
private int _actionId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_objectId = readD(); // Target object Identifier
|
||||
_originX = readD();
|
||||
_originY = readD();
|
||||
_originZ = readD();
|
||||
_actionId = readC(); // Action identifier : 0-Simple click, 1-Shift click
|
||||
_objectId = packet.readD(); // Target object Identifier
|
||||
_originX = packet.readD();
|
||||
_originY = packet.readD();
|
||||
_originZ = packet.readD();
|
||||
_actionId = packet.readC(); // Action identifier : 0-Simple click, 1-Shift click
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
// Get the current L2PcInstance of the player
|
||||
final L2PcInstance activeChar = getActiveChar();
|
||||
final L2PcInstance activeChar = client.getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
@@ -61,7 +64,7 @@ public final class Action extends L2GameClientPacket
|
||||
if (activeChar.inObserverMode())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.OBSERVERS_CANNOT_PARTICIPATE);
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
client.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -97,27 +100,27 @@ public final class Action extends L2GameClientPacket
|
||||
if (obj == null)
|
||||
{
|
||||
// pressing e.g. pickup many times quickly would get you here
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
client.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!obj.isTargetable() && !activeChar.canOverrideCond(PcCondOverride.TARGET_ALL))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
client.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Players can't interact with objects in the other instances, except from multiverse
|
||||
if ((obj.getInstanceId() != activeChar.getInstanceId()) && (activeChar.getInstanceId() != -1))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
client.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Only GMs can directly interact with invisible characters
|
||||
if (!obj.isVisibleFor(activeChar))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
client.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -125,7 +128,7 @@ public final class Action extends L2GameClientPacket
|
||||
if (activeChar.getActiveRequester() != null)
|
||||
{
|
||||
// Actions prohibited when in trade
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
client.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -151,16 +154,10 @@ public final class Action extends L2GameClientPacket
|
||||
default:
|
||||
{
|
||||
// Invalid action detected (probably client cheating), log this
|
||||
_log.warning(getType() + ": Character: " + activeChar.getName() + " requested invalid action: " + _actionId);
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
_log.warning("[C] Action: Character: " + activeChar.getName() + " requested invalid action: " + _actionId);
|
||||
client.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -16,10 +16,12 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.TradeItem;
|
||||
import com.l2jmobius.gameserver.model.TradeList;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.TradeOtherAdd;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.TradeOwnAdd;
|
||||
@@ -28,24 +30,25 @@ import com.l2jmobius.gameserver.network.serverpackets.TradeOwnAdd;
|
||||
* This class ...
|
||||
* @version $Revision: 1.5.2.2.2.5 $ $Date: 2005/03/27 15:29:29 $
|
||||
*/
|
||||
public final class AddTradeItem extends L2GameClientPacket
|
||||
public final class AddTradeItem implements IClientIncomingPacket
|
||||
{
|
||||
private int _tradeId;
|
||||
private int _objectId;
|
||||
private long _count;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_tradeId = readD();
|
||||
_objectId = readD();
|
||||
_count = readQ();
|
||||
_tradeId = packet.readD();
|
||||
_objectId = packet.readD();
|
||||
_count = packet.readQ();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
final L2PcInstance player = client.getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
|
@@ -17,29 +17,32 @@
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
public final class AllyDismiss extends L2GameClientPacket
|
||||
public final class AllyDismiss implements IClientIncomingPacket
|
||||
{
|
||||
private String _clanName;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_clanName = readS();
|
||||
_clanName = packet.readS();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
if (_clanName == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
final L2PcInstance player = client.getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
|
@@ -17,21 +17,24 @@
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
public final class AllyLeave extends L2GameClientPacket
|
||||
public final class AllyLeave implements IClientIncomingPacket
|
||||
{
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
final L2PcInstance player = client.getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
|
@@ -16,8 +16,10 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExRotation;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SocialAction;
|
||||
@@ -27,24 +29,25 @@ import com.l2jmobius.gameserver.util.Util;
|
||||
/**
|
||||
* @author JIV
|
||||
*/
|
||||
public class AnswerCoupleAction extends L2GameClientPacket
|
||||
public class AnswerCoupleAction implements IClientIncomingPacket
|
||||
{
|
||||
private int _charObjId;
|
||||
private int _actionId;
|
||||
private int _answer;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_actionId = readD();
|
||||
_answer = readD();
|
||||
_charObjId = readD();
|
||||
_actionId = packet.readD();
|
||||
_answer = packet.readD();
|
||||
_charObjId = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance activeChar = getActiveChar();
|
||||
final L2PcInstance activeChar = client.getActiveChar();
|
||||
final L2PcInstance target = L2World.getInstance().getPlayer(_charObjId);
|
||||
if ((activeChar == null) || (target == null))
|
||||
{
|
||||
@@ -63,7 +66,7 @@ public class AnswerCoupleAction extends L2GameClientPacket
|
||||
final int distance = (int) activeChar.calculateDistance(target, false, false);
|
||||
if ((distance > 125) || (distance < 15) || (activeChar.getObjectId() == target.getObjectId()))
|
||||
{
|
||||
sendPacket(SystemMessageId.THE_REQUEST_CANNOT_BE_COMPLETED_BECAUSE_THE_TARGET_DOES_NOT_MEET_LOCATION_REQUIREMENTS);
|
||||
client.sendPacket(SystemMessageId.THE_REQUEST_CANNOT_BE_COMPLETED_BECAUSE_THE_TARGET_DOES_NOT_MEET_LOCATION_REQUIREMENTS);
|
||||
target.sendPacket(SystemMessageId.THE_REQUEST_CANNOT_BE_COMPLETED_BECAUSE_THE_TARGET_DOES_NOT_MEET_LOCATION_REQUIREMENTS);
|
||||
return;
|
||||
}
|
||||
|
@@ -16,11 +16,13 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.PartyMatchRoom;
|
||||
import com.l2jmobius.gameserver.model.PartyMatchRoomList;
|
||||
import com.l2jmobius.gameserver.model.PartyMatchWaitingList;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExManagePartyRoomMember;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPartyRoomMember;
|
||||
@@ -31,20 +33,21 @@ import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
* Format: (ch) d
|
||||
* @author -Wooden-, Tryskell
|
||||
*/
|
||||
public final class AnswerJoinPartyRoom extends L2GameClientPacket
|
||||
public final class AnswerJoinPartyRoom implements IClientIncomingPacket
|
||||
{
|
||||
private int _answer; // 1 or 0
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_answer = readD();
|
||||
_answer = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance player = getActiveChar();
|
||||
final L2PcInstance player = client.getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
|
@@ -16,30 +16,34 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.model.L2Party;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
|
||||
/**
|
||||
* @author JIV
|
||||
*/
|
||||
public class AnswerPartyLootModification extends L2GameClientPacket
|
||||
public class AnswerPartyLootModification implements IClientIncomingPacket
|
||||
{
|
||||
public int _answer;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_answer = readD();
|
||||
_answer = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
final L2PcInstance activeChar = client.getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2Party party = activeChar.getParty();
|
||||
if (party != null)
|
||||
{
|
||||
|
@@ -16,8 +16,10 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
@@ -27,20 +29,21 @@ import com.l2jmobius.gameserver.network.serverpackets.TradeDone;
|
||||
* This class ...
|
||||
* @version $Revision: 1.5.4.2 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class AnswerTradeRequest extends L2GameClientPacket
|
||||
public final class AnswerTradeRequest implements IClientIncomingPacket
|
||||
{
|
||||
private int _response;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_response = readD();
|
||||
_response = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
final L2PcInstance player = client.getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
@@ -49,7 +52,7 @@ public final class AnswerTradeRequest extends L2GameClientPacket
|
||||
if (!player.getAccessLevel().allowTransaction())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
client.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,9 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExBrExtraUserInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
|
||||
|
||||
@@ -29,18 +31,18 @@ import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
|
||||
* <p>
|
||||
* @version $Revision: 1.3.4.4 $ $Date: 2005/03/29 23:15:33 $
|
||||
*/
|
||||
public final class Appearing extends L2GameClientPacket
|
||||
public final class Appearing implements IClientIncomingPacket
|
||||
{
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
final L2PcInstance activeChar = client.getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
@@ -50,13 +52,7 @@ public final class Appearing extends L2GameClientPacket
|
||||
activeChar.onTeleported();
|
||||
}
|
||||
|
||||
sendPacket(new UserInfo(activeChar));
|
||||
sendPacket(new ExBrExtraUserInfo(activeChar));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
client.sendPacket(new UserInfo(activeChar));
|
||||
client.sendPacket(new ExBrExtraUserInfo(activeChar));
|
||||
}
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
@@ -24,13 +25,14 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
import com.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||
import com.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
|
||||
/**
|
||||
* TODO: This class is a copy of AttackRequest, we should get proper structure for both.
|
||||
*/
|
||||
public final class Attack extends L2GameClientPacket
|
||||
public final class Attack implements IClientIncomingPacket
|
||||
{
|
||||
// cddddc
|
||||
private int _objectId;
|
||||
@@ -44,19 +46,20 @@ public final class Attack extends L2GameClientPacket
|
||||
private int _attackId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_objectId = readD();
|
||||
_originX = readD();
|
||||
_originY = readD();
|
||||
_originZ = readD();
|
||||
_attackId = readC(); // 0 for simple click 1 for shift-click
|
||||
_objectId = packet.readD();
|
||||
_originX = packet.readD();
|
||||
_originY = packet.readD();
|
||||
_originZ = packet.readD();
|
||||
_attackId = packet.readC(); // 0 for simple click 1 for shift-click
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance activeChar = getActiveChar();
|
||||
final L2PcInstance activeChar = client.getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
|
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
@@ -24,10 +25,11 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
import com.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||
import com.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
|
||||
public final class AttackRequest extends L2GameClientPacket
|
||||
public final class AttackRequest implements IClientIncomingPacket
|
||||
{
|
||||
// cddddc
|
||||
private int _objectId;
|
||||
@@ -41,19 +43,20 @@ public final class AttackRequest extends L2GameClientPacket
|
||||
private int _attackId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_objectId = readD();
|
||||
_originX = readD();
|
||||
_originY = readD();
|
||||
_originZ = readD();
|
||||
_attackId = readC(); // 0 for simple click 1 for shift-click
|
||||
_objectId = packet.readD();
|
||||
_originX = packet.readD();
|
||||
_originY = packet.readD();
|
||||
_originZ = packet.readD();
|
||||
_attackId = packet.readC(); // 0 for simple click 1 for shift-click
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance activeChar = getActiveChar();
|
||||
final L2PcInstance activeChar = client.getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
|
@@ -16,16 +16,17 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.LoginServerThread;
|
||||
import com.l2jmobius.gameserver.LoginServerThread.SessionKey;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.9.2.3.2.4 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class AuthLogin extends L2GameClientPacket
|
||||
public final class AuthLogin implements IClientIncomingPacket
|
||||
{
|
||||
// loginName + keys must match what the loginserver used.
|
||||
private String _loginName;
|
||||
@@ -38,22 +39,22 @@ public final class AuthLogin extends L2GameClientPacket
|
||||
private int _loginKey2;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_loginName = readS().toLowerCase();
|
||||
_playKey2 = readD();
|
||||
_playKey1 = readD();
|
||||
_loginKey1 = readD();
|
||||
_loginKey2 = readD();
|
||||
_loginName = packet.readS().toLowerCase();
|
||||
_playKey2 = packet.readD();
|
||||
_playKey1 = packet.readD();
|
||||
_loginKey1 = packet.readD();
|
||||
_loginKey2 = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2GameClient client = getClient();
|
||||
if (_loginName.isEmpty() || !client.isProtocolOk())
|
||||
{
|
||||
client.close((L2GameServerPacket) null);
|
||||
client.close((IClientOutgoingPacket) null);
|
||||
return;
|
||||
}
|
||||
final SessionKey key = new SessionKey(_loginKey1, _loginKey2, _playKey1, _playKey2);
|
||||
@@ -69,7 +70,7 @@ public final class AuthLogin extends L2GameClientPacket
|
||||
}
|
||||
else
|
||||
{
|
||||
client.close((L2GameServerPacket) null);
|
||||
client.close((IClientOutgoingPacket) null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,12 +16,14 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExBrLoadEventTopRankers;
|
||||
|
||||
/**
|
||||
* Halloween rank list client packet. Format: (ch)ddd
|
||||
*/
|
||||
public class BrEventRankerList extends L2GameClientPacket
|
||||
public class BrEventRankerList implements IClientIncomingPacket
|
||||
{
|
||||
private int _eventId;
|
||||
private int _day;
|
||||
@@ -29,20 +31,21 @@ public class BrEventRankerList extends L2GameClientPacket
|
||||
private int _ranking;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_eventId = readD();
|
||||
_day = readD(); // 0 - current, 1 - previous
|
||||
_ranking = readD();
|
||||
_eventId = packet.readD();
|
||||
_day = packet.readD(); // 0 - current, 1 - previous
|
||||
_ranking = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
// TODO count, bestScore, myScore
|
||||
final int count = 0;
|
||||
final int bestScore = 0;
|
||||
final int myScore = 0;
|
||||
getClient().sendPacket(new ExBrLoadEventTopRankers(_eventId, _day, count, bestScore, myScore));
|
||||
client.sendPacket(new ExBrLoadEventTopRankers(_eventId, _day, count, bestScore, myScore));
|
||||
}
|
||||
}
|
||||
|
@@ -16,28 +16,31 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.handler.IUserCommandHandler;
|
||||
import com.l2jmobius.gameserver.handler.UserCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.1.2.1.2.2 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public class BypassUserCmd extends L2GameClientPacket
|
||||
public class BypassUserCmd implements IClientIncomingPacket
|
||||
{
|
||||
private int _command;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_command = readD();
|
||||
_command = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
final L2PcInstance player = client.getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
@@ -54,7 +57,7 @@ public class BypassUserCmd extends L2GameClientPacket
|
||||
}
|
||||
else
|
||||
{
|
||||
handler.useUserCommand(_command, getClient().getActiveChar());
|
||||
handler.useUserCommand(_command, client.getActiveChar());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,15 +16,17 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.ai.CtrlEvent;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.1.2.1.2.4 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class CannotMoveAnymore extends L2GameClientPacket
|
||||
public final class CannotMoveAnymore implements IClientIncomingPacket
|
||||
{
|
||||
private int _x;
|
||||
private int _y;
|
||||
@@ -32,18 +34,19 @@ public final class CannotMoveAnymore extends L2GameClientPacket
|
||||
private int _heading;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_x = readD();
|
||||
_y = readD();
|
||||
_z = readD();
|
||||
_heading = readD();
|
||||
_x = packet.readD();
|
||||
_y = packet.readD();
|
||||
_z = packet.readD();
|
||||
_heading = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
final L2PcInstance player = client.getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
|
@@ -16,14 +16,16 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.StopMoveInVehicle;
|
||||
|
||||
/**
|
||||
* @author Maktakien
|
||||
*/
|
||||
public final class CannotMoveAnymoreInVehicle extends L2GameClientPacket
|
||||
public final class CannotMoveAnymoreInVehicle implements IClientIncomingPacket
|
||||
{
|
||||
private int _x;
|
||||
private int _y;
|
||||
@@ -32,19 +34,20 @@ public final class CannotMoveAnymoreInVehicle extends L2GameClientPacket
|
||||
private int _boatId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_boatId = readD();
|
||||
_x = readD();
|
||||
_y = readD();
|
||||
_z = readD();
|
||||
_heading = readD();
|
||||
_boatId = packet.readD();
|
||||
_x = packet.readD();
|
||||
_y = packet.readD();
|
||||
_z = packet.readD();
|
||||
_heading = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
final L2PcInstance player = client.getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
|
@@ -25,6 +25,7 @@ import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.InitialEquipmentData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.InitialShortcutData;
|
||||
@@ -55,7 +56,7 @@ import com.l2jmobius.gameserver.network.serverpackets.CharSelectionInfo;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class CharacterCreate extends L2GameClientPacket
|
||||
public final class CharacterCreate implements IClientIncomingPacket
|
||||
{
|
||||
protected static final Logger _logAccounting = Logger.getLogger("accounting");
|
||||
|
||||
@@ -75,30 +76,31 @@ public final class CharacterCreate extends L2GameClientPacket
|
||||
private byte _face;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_name = readS();
|
||||
_race = readD();
|
||||
_sex = (byte) readD();
|
||||
_classId = readD();
|
||||
_int = readD();
|
||||
_str = readD();
|
||||
_con = readD();
|
||||
_men = readD();
|
||||
_dex = readD();
|
||||
_wit = readD();
|
||||
_hairStyle = (byte) readD();
|
||||
_hairColor = (byte) readD();
|
||||
_face = (byte) readD();
|
||||
_name = packet.readS();
|
||||
_race = packet.readD();
|
||||
_sex = (byte) packet.readD();
|
||||
_classId = packet.readD();
|
||||
_int = packet.readD();
|
||||
_str = packet.readD();
|
||||
_con = packet.readD();
|
||||
_men = packet.readD();
|
||||
_dex = packet.readD();
|
||||
_wit = packet.readD();
|
||||
_hairStyle = (byte) packet.readD();
|
||||
_hairColor = (byte) packet.readD();
|
||||
_face = (byte) packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
// Last Verified: May 30, 2009 - Gracia Final - Players are able to create characters with names consisting of as little as 1,2,3 letter/number combinations.
|
||||
if ((_name.length() < 1) || (_name.length() > 16))
|
||||
{
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_16_ENG_CHARS));
|
||||
client.sendPacket(new CharCreateFail(CharCreateFail.REASON_16_ENG_CHARS));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -108,7 +110,7 @@ public final class CharacterCreate extends L2GameClientPacket
|
||||
{
|
||||
if (_name.toLowerCase().contains(st.toLowerCase()))
|
||||
{
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_INCORRECT_NAME));
|
||||
client.sendPacket(new CharCreateFail(CharCreateFail.REASON_INCORRECT_NAME));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -117,31 +119,31 @@ public final class CharacterCreate extends L2GameClientPacket
|
||||
// Last Verified: May 30, 2009 - Gracia Final
|
||||
if (!Util.isAlphaNumeric(_name) || !isValidName(_name))
|
||||
{
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_INCORRECT_NAME));
|
||||
client.sendPacket(new CharCreateFail(CharCreateFail.REASON_INCORRECT_NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_face > 2) || (_face < 0))
|
||||
{
|
||||
_log.warning("Character Creation Failure: Character face " + _face + " is invalid. Possible client hack. " + getClient());
|
||||
_log.warning("Character Creation Failure: Character face " + _face + " is invalid. Possible client hack. " + client);
|
||||
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
client.sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_hairStyle < 0) || ((_sex == 0) && (_hairStyle > 4)) || ((_sex != 0) && (_hairStyle > 6)))
|
||||
{
|
||||
_log.warning("Character Creation Failure: Character hair style " + _hairStyle + " is invalid. Possible client hack. " + getClient());
|
||||
_log.warning("Character Creation Failure: Character hair style " + _hairStyle + " is invalid. Possible client hack. " + client);
|
||||
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
client.sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_hairColor > 3) || (_hairColor < 0))
|
||||
{
|
||||
_log.warning("Character Creation Failure: Character hair color " + _hairColor + " is invalid. Possible client hack. " + getClient());
|
||||
_log.warning("Character Creation Failure: Character hair color " + _hairColor + " is invalid. Possible client hack. " + client);
|
||||
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
client.sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -153,25 +155,25 @@ public final class CharacterCreate extends L2GameClientPacket
|
||||
*/
|
||||
synchronized (CharNameTable.getInstance())
|
||||
{
|
||||
if ((CharNameTable.getInstance().getAccountCharacterCount(getClient().getAccountName()) >= Config.MAX_CHARACTERS_NUMBER_PER_ACCOUNT) && (Config.MAX_CHARACTERS_NUMBER_PER_ACCOUNT != 0))
|
||||
if ((CharNameTable.getInstance().getAccountCharacterCount(client.getAccountName()) >= Config.MAX_CHARACTERS_NUMBER_PER_ACCOUNT) && (Config.MAX_CHARACTERS_NUMBER_PER_ACCOUNT != 0))
|
||||
{
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_TOO_MANY_CHARACTERS));
|
||||
client.sendPacket(new CharCreateFail(CharCreateFail.REASON_TOO_MANY_CHARACTERS));
|
||||
return;
|
||||
}
|
||||
else if (CharNameTable.getInstance().doesCharNameExist(_name))
|
||||
{
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_NAME_ALREADY_EXISTS));
|
||||
client.sendPacket(new CharCreateFail(CharCreateFail.REASON_NAME_ALREADY_EXISTS));
|
||||
return;
|
||||
}
|
||||
|
||||
template = PlayerTemplateData.getInstance().getTemplate(_classId);
|
||||
if ((template == null) || (ClassId.getClassId(_classId).level() > 0))
|
||||
{
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
client.sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
return;
|
||||
}
|
||||
final PcAppearance app = new PcAppearance(_face, _hairColor, _hairStyle, _sex != 0);
|
||||
newChar = L2PcInstance.create(template, getClient().getAccountName(), _name, app);
|
||||
newChar = L2PcInstance.create(template, client.getAccountName(), _name, app);
|
||||
}
|
||||
|
||||
// HP and MP are at maximum and CP is zero by default.
|
||||
@@ -179,15 +181,15 @@ public final class CharacterCreate extends L2GameClientPacket
|
||||
newChar.setCurrentMp(newChar.getMaxMp());
|
||||
// newChar.setMaxLoad(template.getBaseLoad());
|
||||
|
||||
sendPacket(new CharCreateOk());
|
||||
client.sendPacket(new CharCreateOk());
|
||||
|
||||
initNewChar(getClient(), newChar);
|
||||
initNewChar(client, newChar);
|
||||
|
||||
final LogRecord record = new LogRecord(Level.INFO, "Created new character");
|
||||
record.setParameters(new Object[]
|
||||
{
|
||||
newChar,
|
||||
getClient()
|
||||
client
|
||||
});
|
||||
_logAccounting.log(record);
|
||||
}
|
||||
|
@@ -18,10 +18,12 @@ package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.model.CharSelectInfoPackage;
|
||||
import com.l2jmobius.gameserver.model.events.Containers;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerDelete;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CharDeleteFail;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CharDeleteSuccess;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CharSelectionInfo;
|
||||
@@ -30,21 +32,22 @@ import com.l2jmobius.gameserver.network.serverpackets.CharSelectionInfo;
|
||||
* This class ...
|
||||
* @version $Revision: 1.8.2.1.2.3 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class CharacterDelete extends L2GameClientPacket
|
||||
public final class CharacterDelete implements IClientIncomingPacket
|
||||
{
|
||||
// cd
|
||||
private int _charSlot;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_charSlot = readD();
|
||||
_charSlot = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
// if (!getClient().getFloodProtectors().getCharacterSelect().tryPerformAction("CharacterDelete"))
|
||||
// if (!client.getFloodProtectors().getCharacterSelect().tryPerformAction("CharacterDelete"))
|
||||
// {
|
||||
// sendPacket(new CharDeleteFail(CharDeleteFail.REASON_DELETION_FAILED));
|
||||
// return;
|
||||
@@ -52,7 +55,7 @@ public final class CharacterDelete extends L2GameClientPacket
|
||||
|
||||
try
|
||||
{
|
||||
switch (getClient().markToDeleteChar(_charSlot))
|
||||
switch (client.markToDeleteChar(_charSlot))
|
||||
{
|
||||
default:
|
||||
case -1: // Error
|
||||
@@ -61,19 +64,19 @@ public final class CharacterDelete extends L2GameClientPacket
|
||||
}
|
||||
case 0: // Success!
|
||||
{
|
||||
sendPacket(new CharDeleteSuccess());
|
||||
final CharSelectInfoPackage charInfo = getClient().getCharSelection(_charSlot);
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerDelete(charInfo.getObjectId(), charInfo.getName(), getClient()), Containers.Players());
|
||||
client.sendPacket(new CharDeleteSuccess());
|
||||
final CharSelectInfoPackage charInfo = client.getCharSelection(_charSlot);
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerDelete(charInfo.getObjectId(), charInfo.getName(), client), Containers.Players());
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
sendPacket(new CharDeleteFail(CharDeleteFail.REASON_YOU_MAY_NOT_DELETE_CLAN_MEMBER));
|
||||
client.sendPacket(new CharDeleteFail(CharDeleteFail.REASON_YOU_MAY_NOT_DELETE_CLAN_MEMBER));
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
sendPacket(new CharDeleteFail(CharDeleteFail.REASON_CLAN_LEADERS_MAY_NOT_BE_DELETED));
|
||||
client.sendPacket(new CharDeleteFail(CharDeleteFail.REASON_CLAN_LEADERS_MAY_NOT_BE_DELETED));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -83,8 +86,8 @@ public final class CharacterDelete extends L2GameClientPacket
|
||||
_log.log(Level.SEVERE, "Error:", e);
|
||||
}
|
||||
|
||||
final CharSelectionInfo cl = new CharSelectionInfo(getClient().getAccountName(), getClient().getSessionId().playOkID1, 0);
|
||||
sendPacket(cl);
|
||||
getClient().setCharSelection(cl.getCharInfo());
|
||||
final CharSelectionInfo cl = new CharSelectionInfo(client.getAccountName(), client.getSessionId().playOkID1, 0);
|
||||
client.sendPacket(cl);
|
||||
client.setCharSelection(cl.getCharInfo());
|
||||
}
|
||||
}
|
||||
|
@@ -16,39 +16,42 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.model.CharSelectInfoPackage;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerRestore;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CharSelectionInfo;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.4.2.1.2.2 $ $Date: 2005/03/27 15:29:29 $
|
||||
*/
|
||||
public final class CharacterRestore extends L2GameClientPacket
|
||||
public final class CharacterRestore implements IClientIncomingPacket
|
||||
{
|
||||
// cd
|
||||
private int _charSlot;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_charSlot = readD();
|
||||
_charSlot = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
if (!getClient().getFloodProtectors().getCharacterSelect().tryPerformAction("CharacterRestore"))
|
||||
if (!client.getFloodProtectors().getCharacterSelect().tryPerformAction("CharacterRestore"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
getClient().markRestoredChar(_charSlot);
|
||||
final CharSelectionInfo cl = new CharSelectionInfo(getClient().getAccountName(), getClient().getSessionId().playOkID1, 0);
|
||||
sendPacket(cl);
|
||||
getClient().setCharSelection(cl.getCharInfo());
|
||||
final CharSelectInfoPackage charInfo = getClient().getCharSelection(_charSlot);
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerRestore(charInfo.getObjectId(), charInfo.getName(), getClient()));
|
||||
client.markRestoredChar(_charSlot);
|
||||
final CharSelectionInfo cl = new CharSelectionInfo(client.getAccountName(), client.getSessionId().playOkID1, 0);
|
||||
client.sendPacket(cl);
|
||||
client.setCharSelection(cl.getCharInfo());
|
||||
final CharSelectInfoPackage charInfo = client.getCharSelection(_charSlot);
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerRestore(charInfo.getObjectId(), charInfo.getName(), client));
|
||||
}
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@ import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SecondaryAuthData;
|
||||
import com.l2jmobius.gameserver.instancemanager.AntiFeedManager;
|
||||
@@ -34,8 +35,8 @@ import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerSelec
|
||||
import com.l2jmobius.gameserver.model.events.returns.TerminateReturn;
|
||||
import com.l2jmobius.gameserver.model.punishment.PunishmentAffect;
|
||||
import com.l2jmobius.gameserver.model.punishment.PunishmentType;
|
||||
import com.l2jmobius.gameserver.network.ConnectionState;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient.GameClientState;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CharSelected;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SSQInfo;
|
||||
@@ -45,7 +46,7 @@ import com.l2jmobius.gameserver.network.serverpackets.ServerClose;
|
||||
* This class ...
|
||||
* @version $Revision: 1.5.2.1.2.5 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public class CharacterSelect extends L2GameClientPacket
|
||||
public class CharacterSelect implements IClientIncomingPacket
|
||||
{
|
||||
protected static final Logger _logAccounting = Logger.getLogger("accounting");
|
||||
|
||||
@@ -62,19 +63,19 @@ public class CharacterSelect extends L2GameClientPacket
|
||||
private int _unk4; // new in C4
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_charSlot = readD();
|
||||
_unk1 = readH();
|
||||
_unk2 = readD();
|
||||
_unk3 = readD();
|
||||
_unk4 = readD();
|
||||
_charSlot = packet.readD();
|
||||
_unk1 = packet.readH();
|
||||
_unk2 = packet.readD();
|
||||
_unk3 = packet.readD();
|
||||
_unk4 = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2GameClient client = getClient();
|
||||
if (!client.getFloodProtectors().getCharacterSelect().tryPerformAction("CharacterSelect"))
|
||||
{
|
||||
return;
|
||||
@@ -138,18 +139,18 @@ public class CharacterSelect extends L2GameClientPacket
|
||||
client.setActiveChar(cha);
|
||||
cha.setOnlineStatus(true, true);
|
||||
|
||||
final TerminateReturn terminate = EventDispatcher.getInstance().notifyEvent(new OnPlayerSelect(cha, cha.getObjectId(), cha.getName(), getClient()), Containers.Players(), TerminateReturn.class);
|
||||
final TerminateReturn terminate = EventDispatcher.getInstance().notifyEvent(new OnPlayerSelect(cha, cha.getObjectId(), cha.getName(), client), Containers.Players(), TerminateReturn.class);
|
||||
if ((terminate != null) && terminate.terminate())
|
||||
{
|
||||
cha.deleteMe();
|
||||
return;
|
||||
}
|
||||
|
||||
sendPacket(new SSQInfo());
|
||||
client.sendPacket(new SSQInfo());
|
||||
|
||||
client.setState(GameClientState.IN_GAME);
|
||||
client.setConnectionState(ConnectionState.IN_GAME);
|
||||
final CharSelected cs = new CharSelected(cha, client.getSessionId().playOkID1);
|
||||
sendPacket(cs);
|
||||
client.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
@@ -17,6 +17,7 @@
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.enums.PlayerAction;
|
||||
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
|
||||
@@ -27,30 +28,32 @@ import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerDlgAn
|
||||
import com.l2jmobius.gameserver.model.events.returns.TerminateReturn;
|
||||
import com.l2jmobius.gameserver.model.holders.DoorRequestHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.SummonRequestHolder;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.util.GMAudit;
|
||||
|
||||
/**
|
||||
* @author Dezmond_snz
|
||||
*/
|
||||
public final class DlgAnswer extends L2GameClientPacket
|
||||
public final class DlgAnswer implements IClientIncomingPacket
|
||||
{
|
||||
private int _messageId;
|
||||
private int _answer;
|
||||
private int _requesterId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_messageId = readD();
|
||||
_answer = readD();
|
||||
_requesterId = readD();
|
||||
_messageId = packet.readD();
|
||||
_answer = packet.readD();
|
||||
_requesterId = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
final L2PcInstance activeChar = client.getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
|
@@ -16,19 +16,22 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
|
||||
/**
|
||||
* @author zabbix Lets drink to code!
|
||||
*/
|
||||
public final class DummyPacket extends L2GameClientPacket
|
||||
public final class DummyPacket implements IClientIncomingPacket
|
||||
{
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -16,25 +16,28 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
|
||||
/**
|
||||
* @author JIV
|
||||
*/
|
||||
public final class EndScenePlayer extends L2GameClientPacket
|
||||
public final class EndScenePlayer implements IClientIncomingPacket
|
||||
{
|
||||
private int _movieId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_movieId = readD();
|
||||
_movieId = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
final L2PcInstance activeChar = client.getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
@@ -45,7 +48,7 @@ public final class EndScenePlayer extends L2GameClientPacket
|
||||
}
|
||||
if (activeChar.getMovieId() != _movieId)
|
||||
{
|
||||
_log.warning("Player " + getClient() + " sent EndScenePlayer with wrong movie id: " + _movieId);
|
||||
_log.warning("Player " + client + " sent EndScenePlayer with wrong movie id: " + _movieId);
|
||||
return;
|
||||
}
|
||||
activeChar.setMovieId(0);
|
||||
|
@@ -17,6 +17,7 @@
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.LoginServerThread;
|
||||
import com.l2jmobius.gameserver.SevenSigns;
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
@@ -59,6 +60,7 @@ import com.l2jmobius.gameserver.model.quest.Quest;
|
||||
import com.l2jmobius.gameserver.model.quest.QuestState;
|
||||
import com.l2jmobius.gameserver.model.skills.CommonSkill;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
@@ -96,37 +98,38 @@ import com.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
|
||||
* packet format rev87 bddddbdcccccccccccccccccccc
|
||||
* <p>
|
||||
*/
|
||||
public class EnterWorld extends L2GameClientPacket
|
||||
public class EnterWorld implements IClientIncomingPacket
|
||||
{
|
||||
private final int[][] tracert = new int[5][4];
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
readB(new byte[32]); // Unknown Byte Array
|
||||
readD(); // Unknown Value
|
||||
readD(); // Unknown Value
|
||||
readD(); // Unknown Value
|
||||
readD(); // Unknown Value
|
||||
readB(new byte[32]); // Unknown Byte Array
|
||||
readD(); // Unknown Value
|
||||
packet.readB(32); // Unknown Byte Array
|
||||
packet.readD(); // Unknown Value
|
||||
packet.readD(); // Unknown Value
|
||||
packet.readD(); // Unknown Value
|
||||
packet.readD(); // Unknown Value
|
||||
packet.readB(32); // Unknown Byte Array
|
||||
packet.readD(); // Unknown Value
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
for (int o = 0; o < 4; o++)
|
||||
{
|
||||
tracert[i][o] = readC();
|
||||
tracert[i][o] = packet.readC();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
final L2PcInstance activeChar = client.getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
_log.warning("EnterWorld failed! activeChar returned 'null'.");
|
||||
getClient().closeNow();
|
||||
client.closeNow();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -138,7 +141,7 @@ public class EnterWorld extends L2GameClientPacket
|
||||
|
||||
LoginServerThread.getInstance().sendClientTracert(activeChar.getAccountName(), adress);
|
||||
|
||||
getClient().setClientTracert(tracert);
|
||||
client.setClientTracert(tracert);
|
||||
|
||||
// Restore to instanced area if enabled
|
||||
if (Config.RESTORE_PLAYER_INSTANCE)
|
||||
@@ -285,8 +288,8 @@ public class EnterWorld extends L2GameClientPacket
|
||||
}
|
||||
}
|
||||
|
||||
sendPacket(new PledgeShowMemberListAll(activeChar.getClan(), activeChar));
|
||||
sendPacket(new PledgeStatusChanged(activeChar.getClan()));
|
||||
client.sendPacket(new PledgeShowMemberListAll(activeChar.getClan(), activeChar));
|
||||
client.sendPacket(new PledgeStatusChanged(activeChar.getClan()));
|
||||
|
||||
// Residential skills support
|
||||
if (activeChar.getClan().getCastleId() > 0)
|
||||
@@ -350,16 +353,16 @@ public class EnterWorld extends L2GameClientPacket
|
||||
activeChar.getMacros().sendUpdate();
|
||||
|
||||
// Send Item List
|
||||
sendPacket(new ItemList(activeChar, false));
|
||||
client.sendPacket(new ItemList(activeChar, false));
|
||||
|
||||
// Send GG check
|
||||
activeChar.queryGameGuard();
|
||||
|
||||
// Send Teleport Bookmark List
|
||||
sendPacket(new ExGetBookMarkInfoPacket(activeChar));
|
||||
client.sendPacket(new ExGetBookMarkInfoPacket(activeChar));
|
||||
|
||||
// Send Shortcuts
|
||||
sendPacket(new ShortCutInit(activeChar));
|
||||
client.sendPacket(new ShortCutInit(activeChar));
|
||||
|
||||
// Send Action list
|
||||
activeChar.sendPacket(ExBasicActionList.STATIC_PACKET);
|
||||
@@ -377,7 +380,7 @@ public class EnterWorld extends L2GameClientPacket
|
||||
loadTutorial(activeChar);
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new QuestList());
|
||||
activeChar.sendPacket(new QuestList(activeChar));
|
||||
|
||||
if (Config.PLAYER_SPAWN_PROTECTION > 0)
|
||||
{
|
||||
@@ -413,7 +416,7 @@ public class EnterWorld extends L2GameClientPacket
|
||||
// Expand Skill
|
||||
activeChar.sendPacket(new ExStorageMaxCount(activeChar));
|
||||
|
||||
sendPacket(new FriendList(activeChar));
|
||||
client.sendPacket(new FriendList(activeChar));
|
||||
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOUR_FRIEND_S1_JUST_LOGGED_IN);
|
||||
sm.addString(activeChar.getName());
|
||||
@@ -443,14 +446,14 @@ public class EnterWorld extends L2GameClientPacket
|
||||
notice.replace("%clan_name%", activeChar.getClan().getName());
|
||||
notice.replace("%notice_text%", activeChar.getClan().getNotice());
|
||||
notice.disableValidation();
|
||||
sendPacket(notice);
|
||||
client.sendPacket(notice);
|
||||
}
|
||||
else if (Config.SERVER_NEWS)
|
||||
{
|
||||
final String serverNews = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/servnews.htm");
|
||||
if (serverNews != null)
|
||||
{
|
||||
sendPacket(new NpcHtmlMessage(serverNews));
|
||||
client.sendPacket(new NpcHtmlMessage(serverNews));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,14 +465,14 @@ public class EnterWorld extends L2GameClientPacket
|
||||
if (activeChar.isAlikeDead()) // dead or fake dead
|
||||
{
|
||||
// no broadcast needed since the player will already spawn dead to others
|
||||
sendPacket(new Die(activeChar));
|
||||
client.sendPacket(new Die(activeChar));
|
||||
}
|
||||
|
||||
activeChar.onPlayerEnter();
|
||||
|
||||
sendPacket(new SkillCoolTime(activeChar));
|
||||
sendPacket(new ExVoteSystemInfo(activeChar));
|
||||
sendPacket(new ExShowContactList(activeChar));
|
||||
client.sendPacket(new SkillCoolTime(activeChar));
|
||||
client.sendPacket(new ExVoteSystemInfo(activeChar));
|
||||
client.sendPacket(new ExShowContactList(activeChar));
|
||||
|
||||
for (L2ItemInstance i : activeChar.getInventory().getItems())
|
||||
{
|
||||
@@ -539,7 +542,7 @@ public class EnterWorld extends L2GameClientPacket
|
||||
{
|
||||
if (MailManager.getInstance().hasUnreadPost(activeChar))
|
||||
{
|
||||
sendPacket(ExNoticePostArrived.valueOf(false));
|
||||
client.sendPacket(ExNoticePostArrived.valueOf(false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -678,10 +681,4 @@ public class EnterWorld extends L2GameClientPacket
|
||||
qs.getQuest().notifyEvent("UC", null, player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.IIncomingPacket;
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class ExBookmarkPacket implements IClientIncomingPacket
|
||||
{
|
||||
private IIncomingPacket<L2GameClient> _exBookmarkPacket;
|
||||
|
||||
@Override
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
final int subId = packet.readD();
|
||||
|
||||
switch (subId)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
_exBookmarkPacket = new RequestBookMarkSlotInfo();
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
_exBookmarkPacket = new RequestSaveBookMarkSlot();
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
_exBookmarkPacket = new RequestModifyBookMarkSlot();
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
_exBookmarkPacket = new RequestDeleteBookMarkSlot();
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
_exBookmarkPacket = new RequestTeleportBookMark();
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
_exBookmarkPacket = new RequestChangeBookMarkSlot();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (_exBookmarkPacket != null) && _exBookmarkPacket.read(client, packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(L2GameClient client) throws Exception
|
||||
{
|
||||
_exBookmarkPacket.run(client);
|
||||
}
|
||||
}
|
@@ -16,11 +16,14 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
|
||||
/**
|
||||
* Format: (c) dddd d: dx d: dy d: dz d: AirShip id ??
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class ExGetOnAirShip extends L2GameClientPacket
|
||||
public class ExGetOnAirShip implements IClientIncomingPacket
|
||||
{
|
||||
private int _x;
|
||||
private int _y;
|
||||
@@ -28,16 +31,17 @@ public class ExGetOnAirShip extends L2GameClientPacket
|
||||
private int _shipId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_x = readD();
|
||||
_y = readD();
|
||||
_z = readD();
|
||||
_shipId = readD();
|
||||
_x = packet.readD();
|
||||
_y = packet.readD();
|
||||
_z = packet.readD();
|
||||
_shipId = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
_log.info("[T1:ExGetOnAirShip] x: " + _x);
|
||||
_log.info("[T1:ExGetOnAirShip] y: " + _y);
|
||||
|
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.IIncomingPacket;
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.network.ExIncomingPackets;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
*/
|
||||
public class ExPacket implements IClientIncomingPacket
|
||||
{
|
||||
// private static final Logger LOGGER = Logger.getLogger(ExPacket.class.getName());
|
||||
|
||||
private ExIncomingPackets _exIncomingPacket;
|
||||
private IIncomingPacket<L2GameClient> _exPacket;
|
||||
|
||||
@Override
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
final int exPacketId = packet.readH() & 0xFFFF;
|
||||
if ((exPacketId < 0) || (exPacketId >= ExIncomingPackets.PACKET_ARRAY.length))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_exIncomingPacket = ExIncomingPackets.PACKET_ARRAY[exPacketId];
|
||||
if (_exIncomingPacket == null)
|
||||
{
|
||||
// LOGGER.finer(getClass().getSimpleName() + ": Unknown packet: " + Integer.toHexString(exPacketId));
|
||||
return false;
|
||||
}
|
||||
|
||||
_exPacket = _exIncomingPacket.newIncomingPacket();
|
||||
return (_exPacket != null) && _exPacket.read(client, packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(L2GameClient client) throws Exception
|
||||
{
|
||||
if (!_exIncomingPacket.getConnectionStates().contains(client.getConnectionState()))
|
||||
{
|
||||
// LOGGER.finer(_exIncomingPacket + ": Connection at invalid state: " + client.getConnectionState() + " Required State: " + _exIncomingPacket.getConnectionStates());
|
||||
return;
|
||||
}
|
||||
_exPacket.run(client);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user