[Tens de ter uma conta e sessão iniciada para poderes visualizar este link]
[Tens de ter uma conta e sessão iniciada para poderes visualizar este link]
Download MMoCore.jar
-------------------------------
Rework MMoCore
build.xml (modified) (1 diff) [Tens de ter uma conta e sessão iniciada para poderes visualizar este link]
Download MMoCore.jar
-------------------------------
Rework MMoCore
config/Network/mmocore.properties (added)
java/com/l2jrox/Config.java (modified) (5 diffs)
java/com/l2jrox/gameserver/GameServer.java (modified) (3 diffs)
java/com/l2jrox/gameserver/handler/admincommandhandlers/AdminEditChar.java (modified) (2 diffs)
java/com/l2jrox/gameserver/model/entity/Olympiad.java (modified) (1 diff)
java/com/l2jrox/gameserver/network/L2GameClient.java (modified) (4 diffs)
java/com/l2jrox/gameserver/network/clientpackets/EnterWorld.java (modified) (1 diff)
java/com/l2jrox/loginserver/L2LoginClient.java (modified) (6 diffs)
java/com/l2jrox/loginserver/L2LoginServer.java (modified) (3 diffs)
java/com/l2jrox/loginserver/LoginController.java (modified) (1 diff)
java/com/l2jrox/loginserver/clientpackets/AuthGameGuard.java (modified) (1 diff)
java/com/l2jrox/loginserver/clientpackets/RequestAuthLogin.java (modified) (2 diffs)
java/com/l2jrox/loginserver/clientpackets/RequestServerList.java (modified) (1 diff)
java/com/l2jrox/loginserver/clientpackets/RequestServerLogin.java (modified) (1 diff)
lib/mmocore.jar (modified) (previous)
===================================================
- Código:
Index: /Trunk/L2jRox - GS/java/com/l2jrox/Config.java
===================================================
--- /Trunk/L2jRox - GS/java/com/l2jrox/Config.java (revision 17)
+++ /Trunk/L2jRox - GS/java/com/l2jrox/Config.java (revision 18)
@@ -86,5 +86,6 @@
public static final String CONFIGURATION_FILE = "./config/Network/Network.properties"; /** Properties file for game server (connection and ingame) configurations */
public static final String TELNET_FILE = "./config/Telnet.properties"; /** Properties file for telnet configuration */
- public static final String HEXID_FILE = "./config/Network/hexid.txt"; /** Text file containing hexadecimal value of server ID */
+ public static final String MMOCORE_CONFIG_FILE = "./config/Network/mmocore.properties";
+ public static final String HEXID_FILE = "./config/Network/hexid.txt"; /** Text file containing hexadecimal value of server ID */
//LoginServer
/** Properties file for login server configurations */
@@ -219,5 +220,10 @@
public static byte BACK_BLOW_SUCCESS; /** Daggers skills success rate config */
public static byte SIDE_BLOW_SUCCESS; /** Daggers skills success rate config */
-
+ //MMocore
+ public static int MMO_SELECTOR_SLEEP_TIME;
+ public static int MMO_MAX_SEND_PER_PASS;
+ public static int MMO_MAX_READ_PER_PASS;
+ public static int MMO_HELPER_BUFFER_COUNT;
+ public static int MMO_IO_SELECTOR_THREAD_COUNT;
//GRAND BOSS SETTINGS
public static int Antharas_Wait_Time;
@@ -1536,4 +1542,25 @@
throw new Error("Failed to Load " + GEO_FILE + " File.");
}
+
+ // MMOCORE
+ try
+ {
+ Properties mmoSettings = new Properties();
+ InputStream is = new FileInputStream(new File(MMOCORE_CONFIG_FILE));
+ mmoSettings.load(is);
+
+ MMO_SELECTOR_SLEEP_TIME = Integer.parseInt(mmoSettings.getProperty("SleepTime", "20"));
+ MMO_IO_SELECTOR_THREAD_COUNT = Integer.parseInt(mmoSettings.getProperty("IOSelectorThreadCount", "2"));
+ MMO_MAX_SEND_PER_PASS = Integer.parseInt(mmoSettings.getProperty("MaxSendPerPass", "12"));
+ MMO_MAX_READ_PER_PASS = Integer.parseInt(mmoSettings.getProperty("MaxReadPerPass", "12"));
+ MMO_HELPER_BUFFER_COUNT = Integer.parseInt(mmoSettings.getProperty("HelperBufferCount", "20"));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw new Error("Failed to Load " + MMOCORE_CONFIG_FILE + " File.");
+ }
+
+
try
{
@@ -2057,5 +2084,8 @@
+ " File.");
}
- // Grandboss
+
+
+
+ // Grandboss
try
{
@@ -2239,5 +2269,25 @@
throw new Error("Failed to Load " + TELNET_FILE + " File.");
}
+ // MMOCORE
+ try
+ {
+ Properties mmoSettings = new Properties();
+ InputStream is = new FileInputStream(new File(MMOCORE_CONFIG_FILE));
+ mmoSettings.load(is);
+
+ MMO_SELECTOR_SLEEP_TIME = Integer.parseInt(mmoSettings.getProperty("SleepTime", "20"));
+ MMO_IO_SELECTOR_THREAD_COUNT = Integer.parseInt(mmoSettings.getProperty("IOSelectorThreadCount", "2"));
+ MMO_MAX_SEND_PER_PASS = Integer.parseInt(mmoSettings.getProperty("MaxSendPerPass", "12"));
+ MMO_MAX_READ_PER_PASS = Integer.parseInt(mmoSettings.getProperty("MaxReadPerPass", "12"));
+ MMO_HELPER_BUFFER_COUNT = Integer.parseInt(mmoSettings.getProperty("HelperBufferCount", "20"));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw new Error("Failed to Load " + MMOCORE_CONFIG_FILE + " File.");
+ }
+
}
+
else
{
Index: /Trunk/L2jRox - GS/java/com/l2jrox/loginserver/L2LoginClient.java
===================================================================
--- /Trunk/L2jRox - GS/java/com/l2jrox/loginserver/L2LoginClient.java (revision 4)
+++ /Trunk/L2jRox - GS/java/com/l2jrox/loginserver/L2LoginClient.java (revision 18)
@@ -68,5 +68,5 @@
super(con);
_state = LoginClientState.CONNECTED;
- String ip = getConnection().getSocketChannel().socket().getInetAddress().getHostAddress();
+ String ip = getConnection().getInetAddress().getHostAddress();
// TODO unhardcode this
@@ -103,5 +103,5 @@
{
e.printStackTrace();
- closeNow();
+ super.getConnection().close(null);
return false;
}
@@ -112,5 +112,5 @@
System.arraycopy(buf.array(), buf.position(), dump, 0, size);
_log.warning("Wrong checksum from client: "+toString());
- closeNow();
+ super.getConnection().close(null);
}
@@ -245,5 +245,5 @@
@Override
- public void onDisconection()
+ public void onDisconnection()
{
if (Config.DEBUG)
@@ -265,5 +265,5 @@
public String toString()
{
- InetAddress address = getConnection().getSocketChannel().socket().getInetAddress();
+ InetAddress address = getConnection().getInetAddress();
if (getState() == LoginClientState.AUTHED_LOGIN)
{
@@ -275,3 +275,8 @@
}
}
+ @Override
+ protected void onForcedDisconnection()
+ {
+ // Empty
+ }
}
Index: /Trunk/L2jRox - GS/java/com/l2jrox/loginserver/clientpackets/RequestAuthLogin.java
===================================================================
--- /Trunk/L2jRox - GS/java/com/l2jrox/loginserver/clientpackets/RequestAuthLogin.java (revision 4)
+++ /Trunk/L2jRox - GS/java/com/l2jrox/loginserver/clientpackets/RequestAuthLogin.java (revision 18)
@@ -74,5 +74,5 @@
public boolean readImpl()
{
- if (getAvaliableBytes() >= 128)
+ if (super._buf.remaining() >= 128)
{
readB(_raw);
@@ -162,5 +162,5 @@
catch (HackingException e)
{
- InetAddress address = getClient().getConnection().getSocketChannel().socket().getInetAddress();
+ InetAddress address = getClient().getConnection().getInetAddress();
lc.addBanForAddress(address, Config.LOGIN_BLOCK_AFTER_BAN*1000);
_log.info("Banned ("+address+") for "+Config.LOGIN_BLOCK_AFTER_BAN+" seconds, due to "+e.getConnects()+" incorrect login attempts.");
Index: /Trunk/L2jRox - GS/java/com/l2jrox/loginserver/clientpackets/RequestServerLogin.java
===================================================================
--- /Trunk/L2jRox - GS/java/com/l2jrox/loginserver/clientpackets/RequestServerLogin.java (revision 4)
+++ /Trunk/L2jRox - GS/java/com/l2jrox/loginserver/clientpackets/RequestServerLogin.java (revision 18)
@@ -61,5 +61,5 @@
public boolean readImpl()
{
- if (getAvaliableBytes() >= 9)
+ if (super._buf.remaining() >= 9)
{
_skey1 = readD();
Index: /Trunk/L2jRox - GS/java/com/l2jrox/loginserver/clientpackets/RequestServerList.java
===================================================================
--- /Trunk/L2jRox - GS/java/com/l2jrox/loginserver/clientpackets/RequestServerList.java (revision 4)
+++ /Trunk/L2jRox - GS/java/com/l2jrox/loginserver/clientpackets/RequestServerList.java (revision 18)
@@ -57,5 +57,5 @@
public boolean readImpl()
{
- if (getAvaliableBytes() >= 8)
+ if (super._buf.remaining() >= 8)
{
_skey1 = readD(); // loginOk 1
Index: /Trunk/L2jRox - GS/java/com/l2jrox/loginserver/clientpackets/AuthGameGuard.java
===================================================================
--- /Trunk/L2jRox - GS/java/com/l2jrox/loginserver/clientpackets/AuthGameGuard.java (revision 4)
+++ /Trunk/L2jRox - GS/java/com/l2jrox/loginserver/clientpackets/AuthGameGuard.java (revision 18)
@@ -63,5 +63,5 @@
protected boolean readImpl()
{
- if (getAvaliableBytes() >= 20)
+ if (super._buf.remaining() >= 20)
{
_sessionId = readD();
Index: /Trunk/L2jRox - GS/java/com/l2jrox/loginserver/LoginController.java
===================================================================
--- /Trunk/L2jRox - GS/java/com/l2jrox/loginserver/LoginController.java (revision 4)
+++ /Trunk/L2jRox - GS/java/com/l2jrox/loginserver/LoginController.java (revision 18)
@@ -519,5 +519,5 @@
{
boolean ok = false;
- InetAddress address = client.getConnection().getSocketChannel().socket().getInetAddress();
+ InetAddress address = client.getConnection().getInetAddress();
// log it anyway
Log.add("'" + (user == null ? "null" : user) + "' " + (address == null ? "null" : address.getHostAddress()), "logins_ip");
Index: /Trunk/L2jRox - GS/java/com/l2jrox/loginserver/L2LoginServer.java
===================================================================
--- /Trunk/L2jRox - GS/java/com/l2jrox/loginserver/L2LoginServer.java (revision 4)
+++ /Trunk/L2jRox - GS/java/com/l2jrox/loginserver/L2LoginServer.java (revision 18)
@@ -34,5 +34,5 @@
import com.l2jrox.status.Status;
import com.l2jrox.util.Util;
-import com.l2jserver.mmocore.network.SelectorServerConfig;
+import com.l2jserver.mmocore.network.SelectorConfig;
import com.l2jserver.mmocore.network.SelectorThread;
@@ -181,11 +181,14 @@
Util.printSection("Login Server [l2jrox] Status");
- SelectorServerConfig ssc = new SelectorServerConfig(bindAddress, Config.PORT_LOGIN);
- L2LoginPacketHandler loginPacketHandler = new L2LoginPacketHandler();
- SelectorHelper sh = new SelectorHelper();
- try
- {
- _selectorThread = new SelectorThread(ssc, loginPacketHandler, sh, sh);
- _selectorThread.setAcceptFilter(sh);
+ 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;
+ final L2LoginPacketHandler lph = new L2LoginPacketHandler();
+ final SelectorHelper sh = new SelectorHelper();
+ try
+ {
+ _selectorThread = new SelectorThread(sc, sh, lph, sh, sh);
}
catch (IOException e)
@@ -238,5 +241,5 @@
try
{
- _selectorThread.openServerSocket();
+ _selectorThread.openServerSocket(bindAddress, Config.PORT_LOGIN);
}
catch (IOException e)
Index: /Trunk/L2jRox - GS/java/com/l2jrox/gameserver/network/L2GameClient.java
===================================================================
--- /Trunk/L2jRox - GS/java/com/l2jrox/gameserver/network/L2GameClient.java (revision 4)
+++ /Trunk/L2jRox - GS/java/com/l2jrox/gameserver/network/L2GameClient.java (revision 18)
@@ -424,5 +424,5 @@
{
int objectId = chars[i].getObjectId();
- _charSlotMapping.add(new Integer(objectId));
+ _charSlotMapping.add(Integer.valueOf(objectId));
}
}
@@ -460,5 +460,5 @@
@Override
- protected void onDisconection()
+ protected void onDisconnection()
{
// no long running tasks here, do it async
@@ -472,5 +472,9 @@
}
}
-
+ public void closeNow()
+ {
+ super.getConnection().close(null);
+ cleanMe(true);
+ }
/**
* Produces the best possible string representation of this client.
@@ -481,5 +485,5 @@
try
{
- InetAddress address = getConnection().getSocketChannel().socket().getInetAddress();
+ InetAddress address = getConnection().getInetAddress();
switch (getState())
{
Index: /Trunk/L2jRox - GS/java/com/l2jrox/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- /Trunk/L2jRox - GS/java/com/l2jrox/gameserver/network/clientpackets/EnterWorld.java (revision 17)
+++ /Trunk/L2jRox - GS/java/com/l2jrox/gameserver/network/clientpackets/EnterWorld.java (revision 18)
@@ -463,12 +463,12 @@
if(!Config.ALLOW_DUALBOX && activeChar != null)
{
- String thisip = activeChar.getClient().getConnection().getSocketChannel().socket().getInetAddress().getHostAddress();
+ String thisip = activeChar.getClient().getConnection().getInetAddress().getHostAddress();
Collection allPlayers = L2World.getInstance().getAllPlayers();
L2PcInstance[] players = allPlayers.toArray(new L2PcInstance[allPlayers.size()]);
for (L2PcInstance player: players)
{
- if (player.getClient().getConnection().getSocketChannel().socket().getInetAddress().getHostAddress() == null)
+ if (player.getClient().getConnection().getInetAddress().getHostAddress() == null)
return;
- String ip = player.getClient().getConnection().getSocketChannel().socket().getInetAddress().getHostAddress();
+ String ip = player.getClient().getConnection().getInetAddress().getHostAddress();
if (thisip.equals(ip) && activeChar != player && player != null)
{
Index: /Trunk/L2jRox - GS/java/com/l2jrox/gameserver/model/entity/Olympiad.java
===================================================================
--- /Trunk/L2jRox - GS/java/com/l2jrox/gameserver/model/entity/Olympiad.java (revision 4)
+++ /Trunk/L2jRox - GS/java/com/l2jrox/gameserver/model/entity/Olympiad.java (revision 18)
@@ -1829,10 +1829,10 @@
if (_playerOne != null && _playerOne.isOnline() != 0)
- ip1 = _playerOne.getClient().getConnection().getSocketChannel().socket().getInetAddress().getHostAddress();
+ ip1 = _playerOne.getClient().getConnection().getInetAddress().getHostAddress();
if (_playerTwo != null && _playerTwo.isOnline() != 0)
- ip2 = _playerTwo.getClient().getConnection().getSocketChannel().socket().getInetAddress().getHostAddress();
+ ip2 = _playerTwo.getClient().getConnection().getInetAddress().getHostAddress();
if (ip1 == ip2)
{
- _log.config("Match from same ip " + _playerOneName + "(IP : " + _playerOne.getClient().getConnection().getSocketChannel().socket().getInetAddress() + " )" + " vs " + _playerTwoName + "(IP : " + _playerOne.getClient().getConnection().getSocketChannel().socket().getInetAddress()+ " )" );
+ _log.config("Match from same ip " + _playerOneName + "(IP : " + _playerOne.getClient().getConnection().getInetAddress() + " )" + " vs " + _playerTwoName + "(IP : " + _playerOne.getClient().getConnection().getInetAddress()+ " )" );
@SuppressWarnings("unused")
String gmBroadcastMsg = "";
Index: /Trunk/L2jRox - GS/java/com/l2jrox/gameserver/handler/admincommandhandlers/AdminEditChar.java
===================================================================
--- /Trunk/L2jRox - GS/java/com/l2jrox/gameserver/handler/admincommandhandlers/AdminEditChar.java (revision 4)
+++ /Trunk/L2jRox - GS/java/com/l2jrox/gameserver/handler/admincommandhandlers/AdminEditChar.java (revision 18)
@@ -888,5 +888,5 @@
for (int i = 0; i < players.length; i++)
{
- ip=players[i].getClient().getConnection().getSocketChannel().socket().getInetAddress().getHostAddress();
+ ip=players[i].getClient().getConnection().getInetAddress().getHostAddress();
if (ip.equals(IpAdress))
{
@@ -969,5 +969,5 @@
else
{
- ip = client.getConnection().getSocketChannel().socket().getInetAddress().getHostAddress();
+ ip = client.getConnection().getInetAddress().getHostAddress();
if (ipMap.get(ip) == null)
ipMap.put(ip, new ArrayList());
Index: /Trunk/L2jRox - GS/java/com/l2jrox/gameserver/GameServer.java
===================================================================
--- /Trunk/L2jRox - GS/java/com/l2jrox/gameserver/GameServer.java (revision 17)
+++ /Trunk/L2jRox - GS/java/com/l2jrox/gameserver/GameServer.java (revision 18)
@@ -19,4 +19,6 @@
import java.io.IOException;
import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.util.Calendar;
import java.util.logging.Level;
@@ -102,5 +104,5 @@
import com.l2jrox.gameserver.util.DynamicExtension;
import com.l2jrox.status.Status;
-import com.l2jserver.mmocore.network.SelectorServerConfig;
+import com.l2jserver.mmocore.network.SelectorConfig;
import com.l2jserver.mmocore.network.SelectorThread;
@@ -411,8 +413,37 @@
_loginThread.start();
- SelectorServerConfig ssc = new SelectorServerConfig(Config.PORT_GAME);
- L2GamePacketHandler gph = new L2GamePacketHandler();
- _selectorThread = new SelectorThread(ssc, gph, gph, gph);
- _selectorThread.openServerSocket();
+ 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;
+ final L2GamePacketHandler gph = new L2GamePacketHandler();
+ _selectorThread = new SelectorThread(sc, gph, gph, gph, null);
+ InetAddress bindAddress = null;
+ if (!Config.GAMESERVER_HOSTNAME.equals("*"))
+ {
+ try
+ {
+ bindAddress = InetAddress.getByName(Config.GAMESERVER_HOSTNAME);
+ }
+ catch (UnknownHostException e1)
+ {
+ _log.severe("WARNING: The GameServer bind address is invalid, using all avaliable IPs. Reason: " + e1.getMessage());
+ if (Config.DEVELOPER)
+ e1.printStackTrace();
+ }
+ }
+ try
+ {
+ _selectorThread.openServerSocket(bindAddress, Config.PORT_GAME);
+ }
+ catch (IOException e)
+ {
+ _log.severe("FATAL: Failed to open server socket. Reason: " + e.getMessage());
+ if (Config.DEVELOPER)
+ e.printStackTrace();
+ System.exit(1);
+ }
+
_selectorThread.start();
_log.config("Maximo de Player a ser Conectados: " + Config.MAXIMUM_ONLINE_USERS);
Index: /Trunk/L2jRox - GS/build.xml
===================================================================
--- /Trunk/L2jRox - GS/build.xml (revision 4)
+++ /Trunk/L2jRox - GS/build.xml (revision 18)
@@ -203,4 +203,5 @@
+
Index: /Trunk/L2jRox - GS/config/Network/mmocore.properties
===================================================================
--- /Trunk/L2jRox - GS/config/Network/mmocore.properties (revision 18)
+++ /Trunk/L2jRox - GS/config/Network/mmocore.properties (revision 18)
@@ -0,0 +1,30 @@
+#---------------------------------------------------------------
+# L2JBrasil MMoCore settings #
+# _///////\\\\\\\_ #
+#---------------------------------------------------------------
+
+#-----------------------------------------------------------------------------#
+# Sleep time for all Selectors
+# After he finished his job the Selector waits the given time in milliseconds #
+# Lower values will speed up the loop and the Ping is smaller
+#-----------------------------------------------------------------------------#
+SleepTime = 20
+
+#-----------------------------------------------------------------------------------#
+# Every loop it send a maximum of the given packages to each connection #
+# Lower values will speed up the loop and the Ping is smaller but cause less output #
+#-----------------------------------------------------------------------------------#
+MaxSendPerPass = 12
+
+#----------------------------------------------------------------------------------#
+# Every loop it read a maximum of the given packages from each connection #
+# Lower values will speed up the loop and the Ping is smaller but cause less input #
+#----------------------------------------------------------------------------------#
+MaxReadPerPass = 12
+
+#----------------------------------------------------------------------------------------#
+# Each unfinished read/write need a TEMP storage Buffer #
+# on large player amount we need more Buffers #
+# if there are not enough buffers new ones are generated but not stored for future usage #
+#----------------------------------------------------------------------------------------#
+HelperBufferCount = 20