浏览代码

- Fixed issue on mmocore read code
- Ensures that disconnection code runs only once
- Flushing 1 unnused new packet just to get in sync

KenM 17 年之前
父节点
当前提交
c1402e754b

+ 1 - 1
L2_GameServer_T1/.classpath

@@ -7,12 +7,12 @@
 	<classpathentry kind="lib" path="lib/jython.jar"/>
 	<classpathentry kind="lib" path="lib/jython.jar"/>
 	<classpathentry kind="lib" path="lib/bsh-2.0b4.jar"/>
 	<classpathentry kind="lib" path="lib/bsh-2.0b4.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
-	<classpathentry kind="lib" path="lib/mmocore.jar"/>
 	<classpathentry kind="lib" path="lib/c3p0-0.9.1.2.jar"/>
 	<classpathentry kind="lib" path="lib/c3p0-0.9.1.2.jar"/>
 	<classpathentry kind="lib" path="lib/mysql-connector-java-5.1.5-bin.jar"/>
 	<classpathentry kind="lib" path="lib/mysql-connector-java-5.1.5-bin.jar"/>
 	<classpathentry kind="lib" path="lib/jython-engine.jar"/>
 	<classpathentry kind="lib" path="lib/jython-engine.jar"/>
 	<classpathentry kind="lib" path="lib/bsh-engine.jar"/>
 	<classpathentry kind="lib" path="lib/bsh-engine.jar"/>
 	<classpathentry kind="lib" path="lib/ecj.jar"/>
 	<classpathentry kind="lib" path="lib/ecj.jar"/>
 	<classpathentry kind="lib" path="lib/java-engine.jar"/>
 	<classpathentry kind="lib" path="lib/java-engine.jar"/>
+	<classpathentry kind="lib" path="lib/mmocore.jar"/>
 	<classpathentry kind="output" path="bin"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
 </classpath>

+ 2 - 2
L2_GameServer_T1/java/net/sf/l2j/gameserver/GameServer.java

@@ -681,11 +681,11 @@ public class GameServer
 		_loginThread.start();
 		_loginThread.start();
         
         
         L2GamePacketHandler gph = new L2GamePacketHandler();
         L2GamePacketHandler gph = new L2GamePacketHandler();
-		SelectorConfig<L2GameClient> sc = new SelectorConfig<L2GameClient>(null, gph);
+		SelectorConfig<L2GameClient> sc = new SelectorConfig<L2GameClient>(null, null, gph, gph);
         sc.setMaxSendPerPass(12);
         sc.setMaxSendPerPass(12);
         sc.setSelectorSleepTime(20);
         sc.setSelectorSleepTime(20);
         
         
-		_selectorThread = new SelectorThread<L2GameClient>(sc, null, gph, gph, gph, null);
+		_selectorThread = new SelectorThread<L2GameClient>(sc, gph, gph, null);
 		_selectorThread.openServerSocket(null, Config.PORT_GAME);
 		_selectorThread.openServerSocket(null, Config.PORT_GAME);
 		_selectorThread.start();
 		_selectorThread.start();
 		_log.config("Maximum Numbers of Connected Players: " + Config.MAXIMUM_ONLINE_USERS);
 		_log.config("Maximum Numbers of Connected Players: " + Config.MAXIMUM_ONLINE_USERS);

+ 3 - 2
L2_GameServer_T1/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java

@@ -3333,9 +3333,10 @@ public final class L2PcInstance extends L2PlayableInstance
 	 */
 	 */
 	public void closeNetConnection()
 	public void closeNetConnection()
 	{
 	{
-		if (_client != null)
+		L2GameClient client = _client;
+		if (client != null && !client.getConnection().isClosed())
 		{
 		{
-			_client.close(new LeaveWorld());
+			client.close(new LeaveWorld());
 		}
 		}
 	}
 	}
 
 

+ 16 - 17
L2_GameServer_T1/java/net/sf/l2j/gameserver/network/L2GameClient.java

@@ -62,12 +62,11 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>>
 	public GameClientState state;
 	public GameClientState state;
 
 
 	// Info
 	// Info
-	public String accountName;
-	public SessionKey sessionId;
-	public L2PcInstance activeChar;
+    private String _accountName;
+    private SessionKey _sessionId;
+	private L2PcInstance _activeChar;
 	private ReentrantLock _activeCharLock = new ReentrantLock();
 	private ReentrantLock _activeCharLock = new ReentrantLock();
 
 
-	@SuppressWarnings("unused")
 	private boolean _isAuthedGG;
 	private boolean _isAuthedGG;
 	private long _connectionStartTime;
 	private long _connectionStartTime;
 	private List<Integer> _charSlotMapping = new FastList<Integer>();
 	private List<Integer> _charSlotMapping = new FastList<Integer>();
@@ -76,7 +75,7 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>>
 	protected final ScheduledFuture<?> _autoSaveInDB;
 	protected final ScheduledFuture<?> _autoSaveInDB;
 
 
 	// Crypt
 	// Crypt
-	public GameCrypt crypt;
+	private GameCrypt _crypt;
 
 
 	// Flood protection
 	// Flood protection
 	public byte packetsSentInSec = 0;
 	public byte packetsSentInSec = 0;
@@ -87,7 +86,7 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>>
 		super(con);
 		super(con);
 		state = GameClientState.CONNECTED;
 		state = GameClientState.CONNECTED;
 		_connectionStartTime = System.currentTimeMillis();
 		_connectionStartTime = System.currentTimeMillis();
-		crypt = new GameCrypt();
+        _crypt = new GameCrypt();
         
         
         if (Config.CHAR_STORE_INTERVAL > 0)
         if (Config.CHAR_STORE_INTERVAL > 0)
         {
         {
@@ -104,7 +103,7 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>>
 	public byte[] enableCrypt()
 	public byte[] enableCrypt()
 	{
 	{
 		byte[] key = BlowFishKeygen.getRandomKey();
 		byte[] key = BlowFishKeygen.getRandomKey();
-		crypt.setKey(key);
+        _crypt.setKey(key);
 		return key;
 		return key;
 	}
 	}
 
 
@@ -126,27 +125,27 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>>
 	@Override
 	@Override
 	public boolean decrypt(ByteBuffer buf, int size)
 	public boolean decrypt(ByteBuffer buf, int size)
 	{
 	{
-		crypt.decrypt(buf.array(), buf.position(), size);
+        _crypt.decrypt(buf.array(), buf.position(), size);
 		return true;
 		return true;
 	}
 	}
 
 
 	@Override
 	@Override
 	public boolean encrypt(final ByteBuffer buf, final int size)
 	public boolean encrypt(final ByteBuffer buf, final int size)
 	{
 	{
-		crypt.encrypt(buf.array(), buf.position(), size);
+        _crypt.encrypt(buf.array(), buf.position(), size);
 		buf.position(buf.position() + size);
 		buf.position(buf.position() + size);
 		return true;
 		return true;
 	}
 	}
 
 
 	public L2PcInstance getActiveChar()
 	public L2PcInstance getActiveChar()
 	{
 	{
-		return activeChar;
+		return _activeChar;
 	}
 	}
 
 
 	public void setActiveChar(L2PcInstance pActiveChar)
 	public void setActiveChar(L2PcInstance pActiveChar)
 	{
 	{
-		activeChar = pActiveChar;
-		if (activeChar != null)
+		_activeChar = pActiveChar;
+		if (_activeChar != null)
 		{
 		{
 			L2World.getInstance().storeObject(getActiveChar());
 			L2World.getInstance().storeObject(getActiveChar());
 		}
 		}
@@ -169,22 +168,22 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>>
 
 
 	public void setAccountName(String pAccountName)
 	public void setAccountName(String pAccountName)
 	{
 	{
-		accountName = pAccountName;
+		_accountName = pAccountName;
 	}
 	}
 
 
 	public String getAccountName()
 	public String getAccountName()
 	{
 	{
-		return accountName;
+		return _accountName;
 	}
 	}
 
 
 	public void setSessionId(SessionKey sk)
 	public void setSessionId(SessionKey sk)
 	{
 	{
-		sessionId = sk;
+		_sessionId = sk;
 	}
 	}
 
 
 	public SessionKey getSessionId()
 	public SessionKey getSessionId()
 	{
 	{
-		return sessionId;
+		return _sessionId;
 	}
 	}
 
 
 	public void sendPacket(L2GameServerPacket gsp)
 	public void sendPacket(L2GameServerPacket gsp)
@@ -494,7 +493,7 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>>
     }
     }
 
 
     @Override
     @Override
-    protected void onDisconection()
+    protected void onDisconnection()
 	{
 	{
     	// no long running tasks here, do it async
     	// no long running tasks here, do it async
     	try
     	try

+ 88 - 0
L2_GameServer_T1/java/net/sf/l2j/gameserver/serverpackets/ExShowTrace.java

@@ -0,0 +1,88 @@
+/* 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 2, 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package net.sf.l2j.gameserver.serverpackets;
+
+import java.util.List;
+
+import net.sf.l2j.gameserver.model.L2Object;
+
+import javolution.util.FastList;
+
+/**
+ *
+ * @author  KenM
+ */
+public final class ExShowTrace extends L2GameServerPacket
+{
+    private final List<Trace> _traces = new FastList<Trace>();
+    
+    public void addTrace(int x, int y, int z, int time)
+    {
+        _traces.add(new Trace(x, y, z, time));
+    }
+    
+    public void addTrace(L2Object obj, int time)
+    {
+        this.addTrace(obj.getX(), obj.getY(), obj.getZ(), time);
+    }
+    
+    static final class Trace
+    {
+        public final int _x;
+        public final int _y;
+        public final int _z;
+        public final int _time;
+        
+        public Trace(int x, int y, int z, int time)
+        {
+            _x = x;
+            _y = y;
+            _z = z;
+            _time = time;
+        }
+    }
+    
+    /**
+     * @see net.sf.l2j.gameserver.serverpackets.L2GameServerPacket#getType()
+     */
+    @Override
+    public String getType()
+    {
+        return "[S] FE:67 ExShowTrace";
+    }
+
+    /**
+     * @see net.sf.l2j.gameserver.serverpackets.L2GameServerPacket#writeImpl()
+     */
+    @Override
+    protected void writeImpl()
+    {
+        writeC(0xfe);
+        writeH(0x67);
+        
+        writeH(_traces.size());
+        for (Trace t : _traces)
+        {
+            writeD(t._x);
+            writeD(t._y);
+            writeD(t._z);
+            writeH(t._time);
+        }
+    }
+    
+}

+ 1 - 1
L2_GameServer_T1/java/net/sf/l2j/loginserver/L2LoginClient.java

@@ -245,7 +245,7 @@ public final class L2LoginClient extends MMOClient<MMOConnection<L2LoginClient>>
 	}
 	}
 
 
 	@Override
 	@Override
-	public void onDisconection()
+	public void onDisconnection()
 	{
 	{
 		if (Config.DEBUG)
 		if (Config.DEBUG)
 		{
 		{

+ 2 - 2
L2_GameServer_T1/java/net/sf/l2j/loginserver/L2LoginServer.java

@@ -178,10 +178,10 @@ public class L2LoginServer
 		
 		
 		L2LoginPacketHandler loginPacketHandler = new L2LoginPacketHandler();
 		L2LoginPacketHandler loginPacketHandler = new L2LoginPacketHandler();
 		SelectorHelper sh = new SelectorHelper();
 		SelectorHelper sh = new SelectorHelper();
-        SelectorConfig ssc = new SelectorConfig(null, sh);
+        SelectorConfig ssc = new SelectorConfig(null, null, sh, loginPacketHandler);
 		try
 		try
 		{
 		{
-			_selectorThread = new SelectorThread<L2LoginClient>(ssc, null, loginPacketHandler, sh, sh, sh);
+			_selectorThread = new SelectorThread<L2LoginClient>(ssc, sh, sh, sh);
 			_selectorThread.setAcceptFilter(sh);
 			_selectorThread.setAcceptFilter(sh);
 		}
 		}
 		catch (IOException e)
 		catch (IOException e)

+ 3 - 3
L2_GameServer_T1/launcher/L2 LoginServer.launch

@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
 <launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
 <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
 <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/L2_GameServer_t1"/>
+<listEntry value="/L2_GameServer_t1_pub"/>
 </listAttribute>
 </listAttribute>
-<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="E:\shared\L2J_Tests\l2j-server\login"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="L2_GameServer_t1"/>
+<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="E:\shared\L2J_Tests\l2j-t1\login"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="L2_GameServer_t1_pub"/>
 <stringAttribute key="org.eclipse.debug.ui.target_debug_perspective" value="perspective_default"/>
 <stringAttribute key="org.eclipse.debug.ui.target_debug_perspective" value="perspective_default"/>
 <booleanAttribute key="org.eclipse.jdt.launching.STOP_IN_MAIN" value="true"/>
 <booleanAttribute key="org.eclipse.jdt.launching.STOP_IN_MAIN" value="true"/>
 <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="net.sf.l2j.loginserver.L2LoginServer"/>
 <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="net.sf.l2j.loginserver.L2LoginServer"/>

二进制
L2_GameServer_T1/lib/mmocore.jar