Fix Duplicate Items l2jFrozen - 1004

Iniciado por Swarlog, Jun 25, 2025, 09:03 PM

Tema anterior - Siguiente tema

Swarlog

Si tienen el problema de que pueden entrar con la misma cuenta 2 veces para duplicar items en l2jfrozen aquí puede estar la solución.

### Eclipse Workspace Patch 1.0
#P L2jFrozen_GameServer
Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/AuthLogin.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/network/clientpackets/AuthLogin.java    (revision 1004)
+++ head-src/com/l2jfrozen/gameserver/network/clientpackets/AuthLogin.java    (working copy)
@@ -18,6 +18,7 @@
 
 import com.l2jfrozen.Config;
 import com.l2jfrozen.gameserver.network.L2GameClient;
+import com.l2jfrozen.gameserver.network.serverpackets.L2GameServerPacket;
 import com.l2jfrozen.gameserver.thread.LoginServerThread;
 import com.l2jfrozen.gameserver.thread.LoginServerThread.SessionKey;
 
@@ -55,9 +56,17 @@
         // avoid potential exploits
         if (client.getAccountName() == null)
         {
+            // Preventing duplicate login in case client login server socket was
+            // disconnected or this packet was not sent yet
+            if (LoginServerThread.getInstance().addGameServerLogin(_loginName,client))
+            {
             client.setAccountName(_loginName);
-            LoginServerThread.getInstance().addGameServerLogin(_loginName, client);
             LoginServerThread.getInstance().addWaitingClientAndSendRequest(_loginName, client, key);
+            }
+            else
+            {
+                  client.close((L2GameServerPacket) null);
+            }
         }
     }
 
Index: head-src/com/l2jfrozen/gameserver/thread/LoginServerThread.java
 
--- head-src/com/l2jfrozen/gameserver/thread/LoginServerThread.java    (revision 1004)
+++ head-src/com/l2jfrozen/gameserver/thread/LoginServerThread.java    (working copy)
@@ -32,6 +32,7 @@
 import java.security.spec.RSAPublicKeySpec;
 import java.util.List;
 import java.util.Map;
+
 import java.util.logging.Logger;
 
 import javolution.util.FastList;
@@ -507,10 +508,28 @@
         pl = null;
     }
 
-    public void addGameServerLogin(String account, L2GameClient client)
-    {
-        _accountsInGameServer.put(account, client);
-    }
+    public boolean addGameServerLogin(String account, L2GameClient client)   
+    {
+        L2GameClient savedClient = _accountsInGameServer.get(account);
+       
+        if (savedClient != null) {
+        if (savedClient.isDetached()) {
+        if (Config.DEBUG)
+        _log.info("Old Client was disconnected: Offline or OfflineMode --> Login Again");
+        ((FastMap<String, L2GameClient>) _accountsInGameServer).put(account, client);
+        return true;
+        }
+        if (Config.DEBUG)
+        _log.info("Old Client was online --> Close Old Client Connection");
+        savedClient.closeNow();
+        _accountsInGameServer.remove(account);
+        return false;
+        }
+        if (Config.DEBUG)
+        _log.info("Client was not online --> New Client Connection");
+        ((FastMap<String, L2GameClient>) _accountsInGameServer).put(account, client);
+        return true;
+    }
 
     public void sendAccessLevel(String account, int level)
     {