From d77326f0742201643f7423ba7ae29420d4fa52cf Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Fri, 16 Oct 2020 09:28:40 +0000 Subject: [PATCH] Attempt to store HWID in temporary trace map and account variables. --- .../dist/game/config/Server.ini | 3 +- .../holders/ClientHardwareInfoHolder.java | 106 ++++++++++++++++++ .../model/variables/AccountVariables.java | 4 + .../network/clientpackets/EnterWorld.java | 80 +++++++++++-- .../clientpackets/RequestHardWareInfo.java | 19 ---- .../dist/game/config/Server.ini | 3 +- .../holders/ClientHardwareInfoHolder.java | 106 ++++++++++++++++++ .../model/variables/AccountVariables.java | 4 + .../network/clientpackets/EnterWorld.java | 80 +++++++++++-- .../clientpackets/RequestHardWareInfo.java | 19 ---- .../dist/game/config/Server.ini | 3 +- .../holders/ClientHardwareInfoHolder.java | 106 ++++++++++++++++++ .../model/variables/AccountVariables.java | 4 + .../network/clientpackets/EnterWorld.java | 80 +++++++++++-- .../clientpackets/RequestHardWareInfo.java | 19 ---- .../dist/game/config/Server.ini | 3 +- .../holders/ClientHardwareInfoHolder.java | 106 ++++++++++++++++++ .../model/variables/AccountVariables.java | 4 + .../network/clientpackets/EnterWorld.java | 80 +++++++++++-- .../clientpackets/RequestHardWareInfo.java | 19 ---- .../dist/game/config/Server.ini | 3 +- .../holders/ClientHardwareInfoHolder.java | 106 ++++++++++++++++++ .../model/variables/AccountVariables.java | 4 + .../network/clientpackets/EnterWorld.java | 80 +++++++++++-- .../clientpackets/RequestHardWareInfo.java | 19 ---- .../dist/game/config/Server.ini | 3 +- .../holders/ClientHardwareInfoHolder.java | 106 ++++++++++++++++++ .../model/variables/AccountVariables.java | 4 + .../network/clientpackets/EnterWorld.java | 80 +++++++++++-- .../clientpackets/RequestHardWareInfo.java | 19 ---- .../dist/game/config/Server.ini | 3 +- .../holders/ClientHardwareInfoHolder.java | 106 ++++++++++++++++++ .../model/variables/AccountVariables.java | 4 + .../network/clientpackets/EnterWorld.java | 80 +++++++++++-- .../clientpackets/RequestHardWareInfo.java | 19 ---- .../dist/game/config/Server.ini | 3 +- .../holders/ClientHardwareInfoHolder.java | 106 ++++++++++++++++++ .../model/variables/AccountVariables.java | 4 + .../network/clientpackets/EnterWorld.java | 80 +++++++++++-- .../clientpackets/RequestHardWareInfo.java | 19 ---- .../dist/game/config/Server.ini | 3 +- .../holders/ClientHardwareInfoHolder.java | 106 ++++++++++++++++++ .../model/variables/AccountVariables.java | 4 + .../network/clientpackets/EnterWorld.java | 80 +++++++++++-- .../clientpackets/RequestHardWareInfo.java | 19 ---- .../dist/game/config/Server.ini | 3 +- .../holders/ClientHardwareInfoHolder.java | 106 ++++++++++++++++++ .../model/variables/AccountVariables.java | 4 + .../network/clientpackets/EnterWorld.java | 80 +++++++++++-- .../clientpackets/RequestHardWareInfo.java | 19 ---- .../dist/game/config/Server.ini | 3 +- .../holders/ClientHardwareInfoHolder.java | 106 ++++++++++++++++++ .../model/variables/AccountVariables.java | 4 + .../network/clientpackets/EnterWorld.java | 80 +++++++++++-- .../clientpackets/RequestHardWareInfo.java | 19 ---- .../dist/game/config/Server.ini | 3 +- .../holders/ClientHardwareInfoHolder.java | 106 ++++++++++++++++++ .../model/variables/AccountVariables.java | 4 + .../network/clientpackets/EnterWorld.java | 80 +++++++++++-- .../clientpackets/RequestHardWareInfo.java | 19 ---- .../dist/game/config/Server.ini | 3 +- .../holders/ClientHardwareInfoHolder.java | 106 ++++++++++++++++++ .../model/variables/AccountVariables.java | 4 + .../network/clientpackets/EnterWorld.java | 80 +++++++++++-- .../clientpackets/RequestHardWareInfo.java | 19 ---- .../dist/game/config/Server.ini | 3 +- .../holders/ClientHardwareInfoHolder.java | 106 ++++++++++++++++++ .../model/variables/AccountVariables.java | 4 + .../network/clientpackets/EnterWorld.java | 80 +++++++++++-- .../clientpackets/RequestHardWareInfo.java | 19 ---- .../dist/game/config/Server.ini | 3 +- .../holders/ClientHardwareInfoHolder.java | 106 ++++++++++++++++++ .../model/variables/AccountVariables.java | 4 + .../network/clientpackets/EnterWorld.java | 80 +++++++++++-- .../clientpackets/RequestHardWareInfo.java | 19 ---- 75 files changed, 2760 insertions(+), 420 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/config/Server.ini b/L2J_Mobius_1.0_Ertheia/dist/game/config/Server.ini index 0f845b88e5..de720042a0 100644 --- a/L2J_Mobius_1.0_Ertheia/dist/game/config/Server.ini +++ b/L2J_Mobius_1.0_Ertheia/dist/game/config/Server.ini @@ -158,13 +158,12 @@ RestartOnDeadlock = False # --------------------------------------------------------------------------- -# Player HWID settings (DO NOT USE) +# Player HWID settings # --------------------------------------------------------------------------- # Check if hardware information is sent upon login. # Players without hardware information are kicked from the game. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. -# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?) # Default: False EnableHardwareInfo = False diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java index 4a835b3931..0ddbf33e30 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.model.holders; +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.variables.AccountVariables; + /** * @author Mobius */ @@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder _vgaDriverVersion = vgaDriverVersion; } + public ClientHardwareInfoHolder(String info) + { + final String[] split = info.split(AccountVariables.HWIDSLIT_VAR); + _macAddress = split[0]; + _windowsPlatformId = Integer.valueOf(split[1]); + _windowsMajorVersion = Integer.valueOf(split[2]); + _windowsMinorVersion = Integer.valueOf(split[3]); + _windowsBuildNumber = Integer.valueOf(split[4]); + _directxVersion = Integer.valueOf(split[5]); + _directxRevision = Integer.valueOf(split[6]); + _cpuName = split[7]; + _cpuSpeed = Integer.valueOf(split[8]); + _cpuCoreCount = Integer.valueOf(split[9]); + _vgaCount = Integer.valueOf(split[10]); + _vgaPcxSpeed = Integer.valueOf(split[11]); + _physMemorySlot1 = Integer.valueOf(split[12]); + _physMemorySlot2 = Integer.valueOf(split[13]); + _physMemorySlot3 = Integer.valueOf(split[14]); + _videoMemory = Integer.valueOf(split[15]); + _vgaVersion = Integer.valueOf(split[16]); + _vgaName = split[17]; + _vgaDriverVersion = split[18]; + } + + /** + * Save hardware info to account variables for later use. + * @param player The PlayerInstance related with this hardware info. + */ + public void store(PlayerInstance player) + { + final StringBuilder sb = new StringBuilder(); + sb.append(_macAddress); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsPlatformId); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMajorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMinorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsBuildNumber); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxRevision); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuCoreCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaPcxSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot1); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot2); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot3); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_videoMemory); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaDriverVersion); + player.getAccountVariables().set(AccountVariables.HWID, sb.toString()); + } + /** * @return the macAddress */ @@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder { return _vgaDriverVersion; } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof ClientHardwareInfoHolder) + { + final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj; + if ((_macAddress.equals(info.getMacAddress())) && // + (_windowsPlatformId == info.getWindowsPlatformId()) && // + (_windowsMajorVersion == info.getWindowsMajorVersion()) && // + (_windowsMinorVersion == info.getWindowsMinorVersion()) && // + (_windowsBuildNumber == info.getWindowsBuildNumber()) && // + (_directxVersion == info.getDirectxVersion()) && // + (_directxRevision == info.getDirectxRevision()) && // + (_cpuName.equals(info.getCpuName())) && // + (_cpuSpeed == info.getCpuSpeed()) && // + (_cpuCoreCount == info.getCpuCoreCount()) && // + (_vgaCount == info.getVgaCount()) && // + (_vgaPcxSpeed == info.getVgaPcxSpeed()) && // + (_physMemorySlot1 == info.getPhysMemorySlot1()) && // + (_physMemorySlot2 == info.getPhysMemorySlot2()) && // + (_physMemorySlot3 == info.getPhysMemorySlot3()) && // + (_videoMemory == info.getVideoMemory()) && // + (_vgaVersion == info.getVgaVersion()) && // + (_vgaName.equals(info.getVgaName())) && // + (_vgaDriverVersion.equals(info.getVgaDriverVersion()))) + { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java index fc36c5f076..dbce4c8eea 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java @@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; + // Public variable names + public static final String HWID = "HWID"; + public static final String HWIDSLIT_VAR = " "; + private final String _accountName; public AccountVariables(String accountName) diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index 3dc6668851..2966100f2b 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.network.PacketReader; @@ -50,10 +53,12 @@ import org.l2jmobius.gameserver.model.entity.Fort; import org.l2jmobius.gameserver.model.entity.FortSiege; import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.Siege; +import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; +import org.l2jmobius.gameserver.model.variables.AccountVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.ConnectionState; @@ -110,7 +115,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil; */ public class EnterWorld implements IClientIncomingPacket { - private final int[][] tracert = new int[5][4]; + private static final Map TRACE_HWINFO = new ConcurrentHashMap<>(); + + private final int[][] _tracert = new int[5][4]; @Override public boolean read(GameClient client, PacketReader packet) @@ -119,7 +126,7 @@ public class EnterWorld implements IClientIncomingPacket { for (int o = 0; o < 4; o++) { - tracert[i][o] = packet.readC(); + _tracert[i][o] = packet.readC(); } } packet.readD(); // Unknown Value @@ -147,11 +154,11 @@ public class EnterWorld implements IClientIncomingPacket final String[] adress = new String[5]; for (int i = 0; i < 5; i++) { - adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; + adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3]; } LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); - client.setClientTracert(tracert); + client.setClientTracert(_tracert); player.broadcastUserInfo(); @@ -631,10 +638,69 @@ public class EnterWorld implements IClientIncomingPacket { ThreadPool.schedule(() -> { - if (client.getHardwareInfo() == null) + // Generate trace string. + final StringBuilder sb = new StringBuilder(); + for (int[] i : _tracert) { - Disconnection.of(client).defaultSequence(false); - return; + for (int j : i) + { + sb.append(j); + sb.append("."); + } + } + final String trace = sb.toString(); + + // Get hardware info from client. + ClientHardwareInfoHolder hwInfo = client.getHardwareInfo(); + if (hwInfo != null) + { + hwInfo.store(player); + TRACE_HWINFO.put(trace, hwInfo); + } + else + { + // Get hardware info from stored tracert map. + hwInfo = TRACE_HWINFO.get(trace); + if (hwInfo != null) + { + hwInfo.store(player); + client.setHardwareInfo(hwInfo); + } + // Get hardware info from account variables. + else + { + final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, ""); + if (!storedInfo.isEmpty()) + { + hwInfo = new ClientHardwareInfoHolder(storedInfo); + TRACE_HWINFO.put(trace, hwInfo); + client.setHardwareInfo(hwInfo); + } + } + } + + // Check max players. + if (Config.MAX_PLAYERS_PER_HWID > 0) + { + if (hwInfo == null) + { + Disconnection.of(client).defaultSequence(false); + } + else + { + int count = 0; + for (PlayerInstance plr : World.getInstance().getPlayers()) + { + if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo))) + { + count++; + } + } + if (count >= Config.MAX_PLAYERS_PER_HWID) + { + Disconnection.of(client).defaultSequence(false); + } + } } }, 5000); } diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java index aa5a94b85b..a824e87cb9 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java @@ -16,12 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; -import org.l2jmobius.gameserver.model.World; -import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; -import org.l2jmobius.gameserver.network.Disconnection; import org.l2jmobius.gameserver.network.GameClient; /** @@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket public void run(GameClient client) { client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); - if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0)) - { - int count = 0; - for (PlayerInstance player : World.getInstance().getPlayers()) - { - if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo()))) - { - count++; - } - } - if (count >= Config.MAX_PLAYERS_PER_HWID) - { - Disconnection.of(client).defaultSequence(false); - } - } } } diff --git a/L2J_Mobius_2.5_Underground/dist/game/config/Server.ini b/L2J_Mobius_2.5_Underground/dist/game/config/Server.ini index 26446decef..5fc968d4c3 100644 --- a/L2J_Mobius_2.5_Underground/dist/game/config/Server.ini +++ b/L2J_Mobius_2.5_Underground/dist/game/config/Server.ini @@ -158,13 +158,12 @@ RestartOnDeadlock = False # --------------------------------------------------------------------------- -# Player HWID settings (DO NOT USE) +# Player HWID settings # --------------------------------------------------------------------------- # Check if hardware information is sent upon login. # Players without hardware information are kicked from the game. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. -# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?) # Default: False EnableHardwareInfo = False diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java index 4a835b3931..0ddbf33e30 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.model.holders; +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.variables.AccountVariables; + /** * @author Mobius */ @@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder _vgaDriverVersion = vgaDriverVersion; } + public ClientHardwareInfoHolder(String info) + { + final String[] split = info.split(AccountVariables.HWIDSLIT_VAR); + _macAddress = split[0]; + _windowsPlatformId = Integer.valueOf(split[1]); + _windowsMajorVersion = Integer.valueOf(split[2]); + _windowsMinorVersion = Integer.valueOf(split[3]); + _windowsBuildNumber = Integer.valueOf(split[4]); + _directxVersion = Integer.valueOf(split[5]); + _directxRevision = Integer.valueOf(split[6]); + _cpuName = split[7]; + _cpuSpeed = Integer.valueOf(split[8]); + _cpuCoreCount = Integer.valueOf(split[9]); + _vgaCount = Integer.valueOf(split[10]); + _vgaPcxSpeed = Integer.valueOf(split[11]); + _physMemorySlot1 = Integer.valueOf(split[12]); + _physMemorySlot2 = Integer.valueOf(split[13]); + _physMemorySlot3 = Integer.valueOf(split[14]); + _videoMemory = Integer.valueOf(split[15]); + _vgaVersion = Integer.valueOf(split[16]); + _vgaName = split[17]; + _vgaDriverVersion = split[18]; + } + + /** + * Save hardware info to account variables for later use. + * @param player The PlayerInstance related with this hardware info. + */ + public void store(PlayerInstance player) + { + final StringBuilder sb = new StringBuilder(); + sb.append(_macAddress); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsPlatformId); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMajorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMinorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsBuildNumber); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxRevision); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuCoreCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaPcxSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot1); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot2); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot3); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_videoMemory); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaDriverVersion); + player.getAccountVariables().set(AccountVariables.HWID, sb.toString()); + } + /** * @return the macAddress */ @@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder { return _vgaDriverVersion; } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof ClientHardwareInfoHolder) + { + final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj; + if ((_macAddress.equals(info.getMacAddress())) && // + (_windowsPlatformId == info.getWindowsPlatformId()) && // + (_windowsMajorVersion == info.getWindowsMajorVersion()) && // + (_windowsMinorVersion == info.getWindowsMinorVersion()) && // + (_windowsBuildNumber == info.getWindowsBuildNumber()) && // + (_directxVersion == info.getDirectxVersion()) && // + (_directxRevision == info.getDirectxRevision()) && // + (_cpuName.equals(info.getCpuName())) && // + (_cpuSpeed == info.getCpuSpeed()) && // + (_cpuCoreCount == info.getCpuCoreCount()) && // + (_vgaCount == info.getVgaCount()) && // + (_vgaPcxSpeed == info.getVgaPcxSpeed()) && // + (_physMemorySlot1 == info.getPhysMemorySlot1()) && // + (_physMemorySlot2 == info.getPhysMemorySlot2()) && // + (_physMemorySlot3 == info.getPhysMemorySlot3()) && // + (_videoMemory == info.getVideoMemory()) && // + (_vgaVersion == info.getVgaVersion()) && // + (_vgaName.equals(info.getVgaName())) && // + (_vgaDriverVersion.equals(info.getVgaDriverVersion()))) + { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java index fc36c5f076..dbce4c8eea 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java @@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; + // Public variable names + public static final String HWID = "HWID"; + public static final String HWIDSLIT_VAR = " "; + private final String _accountName; public AccountVariables(String accountName) diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index e3e7f08cc1..979063963e 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.network.PacketReader; @@ -51,10 +54,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege; import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; +import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; +import org.l2jmobius.gameserver.model.variables.AccountVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.ConnectionState; @@ -115,7 +120,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil; */ public class EnterWorld implements IClientIncomingPacket { - private final int[][] tracert = new int[5][4]; + private static final Map TRACE_HWINFO = new ConcurrentHashMap<>(); + + private final int[][] _tracert = new int[5][4]; @Override public boolean read(GameClient client, PacketReader packet) @@ -124,7 +131,7 @@ public class EnterWorld implements IClientIncomingPacket { for (int o = 0; o < 4; o++) { - tracert[i][o] = packet.readC(); + _tracert[i][o] = packet.readC(); } } packet.readD(); // Unknown Value @@ -152,11 +159,11 @@ public class EnterWorld implements IClientIncomingPacket final String[] adress = new String[5]; for (int i = 0; i < 5; i++) { - adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; + adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3]; } LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); - client.setClientTracert(tracert); + client.setClientTracert(_tracert); player.broadcastUserInfo(); @@ -664,10 +671,69 @@ public class EnterWorld implements IClientIncomingPacket { ThreadPool.schedule(() -> { - if (client.getHardwareInfo() == null) + // Generate trace string. + final StringBuilder sb = new StringBuilder(); + for (int[] i : _tracert) { - Disconnection.of(client).defaultSequence(false); - return; + for (int j : i) + { + sb.append(j); + sb.append("."); + } + } + final String trace = sb.toString(); + + // Get hardware info from client. + ClientHardwareInfoHolder hwInfo = client.getHardwareInfo(); + if (hwInfo != null) + { + hwInfo.store(player); + TRACE_HWINFO.put(trace, hwInfo); + } + else + { + // Get hardware info from stored tracert map. + hwInfo = TRACE_HWINFO.get(trace); + if (hwInfo != null) + { + hwInfo.store(player); + client.setHardwareInfo(hwInfo); + } + // Get hardware info from account variables. + else + { + final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, ""); + if (!storedInfo.isEmpty()) + { + hwInfo = new ClientHardwareInfoHolder(storedInfo); + TRACE_HWINFO.put(trace, hwInfo); + client.setHardwareInfo(hwInfo); + } + } + } + + // Check max players. + if (Config.MAX_PLAYERS_PER_HWID > 0) + { + if (hwInfo == null) + { + Disconnection.of(client).defaultSequence(false); + } + else + { + int count = 0; + for (PlayerInstance plr : World.getInstance().getPlayers()) + { + if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo))) + { + count++; + } + } + if (count >= Config.MAX_PLAYERS_PER_HWID) + { + Disconnection.of(client).defaultSequence(false); + } + } } }, 5000); } diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java index aa5a94b85b..a824e87cb9 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java @@ -16,12 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; -import org.l2jmobius.gameserver.model.World; -import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; -import org.l2jmobius.gameserver.network.Disconnection; import org.l2jmobius.gameserver.network.GameClient; /** @@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket public void run(GameClient client) { client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); - if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0)) - { - int count = 0; - for (PlayerInstance player : World.getInstance().getPlayers()) - { - if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo()))) - { - count++; - } - } - if (count >= Config.MAX_PLAYERS_PER_HWID) - { - Disconnection.of(client).defaultSequence(false); - } - } } } diff --git a/L2J_Mobius_3.0_Helios/dist/game/config/Server.ini b/L2J_Mobius_3.0_Helios/dist/game/config/Server.ini index a1669e0ab4..d37a377bc7 100644 --- a/L2J_Mobius_3.0_Helios/dist/game/config/Server.ini +++ b/L2J_Mobius_3.0_Helios/dist/game/config/Server.ini @@ -158,13 +158,12 @@ RestartOnDeadlock = False # --------------------------------------------------------------------------- -# Player HWID settings (DO NOT USE) +# Player HWID settings # --------------------------------------------------------------------------- # Check if hardware information is sent upon login. # Players without hardware information are kicked from the game. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. -# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?) # Default: False EnableHardwareInfo = False diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java index 4a835b3931..0ddbf33e30 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.model.holders; +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.variables.AccountVariables; + /** * @author Mobius */ @@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder _vgaDriverVersion = vgaDriverVersion; } + public ClientHardwareInfoHolder(String info) + { + final String[] split = info.split(AccountVariables.HWIDSLIT_VAR); + _macAddress = split[0]; + _windowsPlatformId = Integer.valueOf(split[1]); + _windowsMajorVersion = Integer.valueOf(split[2]); + _windowsMinorVersion = Integer.valueOf(split[3]); + _windowsBuildNumber = Integer.valueOf(split[4]); + _directxVersion = Integer.valueOf(split[5]); + _directxRevision = Integer.valueOf(split[6]); + _cpuName = split[7]; + _cpuSpeed = Integer.valueOf(split[8]); + _cpuCoreCount = Integer.valueOf(split[9]); + _vgaCount = Integer.valueOf(split[10]); + _vgaPcxSpeed = Integer.valueOf(split[11]); + _physMemorySlot1 = Integer.valueOf(split[12]); + _physMemorySlot2 = Integer.valueOf(split[13]); + _physMemorySlot3 = Integer.valueOf(split[14]); + _videoMemory = Integer.valueOf(split[15]); + _vgaVersion = Integer.valueOf(split[16]); + _vgaName = split[17]; + _vgaDriverVersion = split[18]; + } + + /** + * Save hardware info to account variables for later use. + * @param player The PlayerInstance related with this hardware info. + */ + public void store(PlayerInstance player) + { + final StringBuilder sb = new StringBuilder(); + sb.append(_macAddress); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsPlatformId); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMajorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMinorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsBuildNumber); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxRevision); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuCoreCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaPcxSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot1); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot2); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot3); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_videoMemory); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaDriverVersion); + player.getAccountVariables().set(AccountVariables.HWID, sb.toString()); + } + /** * @return the macAddress */ @@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder { return _vgaDriverVersion; } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof ClientHardwareInfoHolder) + { + final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj; + if ((_macAddress.equals(info.getMacAddress())) && // + (_windowsPlatformId == info.getWindowsPlatformId()) && // + (_windowsMajorVersion == info.getWindowsMajorVersion()) && // + (_windowsMinorVersion == info.getWindowsMinorVersion()) && // + (_windowsBuildNumber == info.getWindowsBuildNumber()) && // + (_directxVersion == info.getDirectxVersion()) && // + (_directxRevision == info.getDirectxRevision()) && // + (_cpuName.equals(info.getCpuName())) && // + (_cpuSpeed == info.getCpuSpeed()) && // + (_cpuCoreCount == info.getCpuCoreCount()) && // + (_vgaCount == info.getVgaCount()) && // + (_vgaPcxSpeed == info.getVgaPcxSpeed()) && // + (_physMemorySlot1 == info.getPhysMemorySlot1()) && // + (_physMemorySlot2 == info.getPhysMemorySlot2()) && // + (_physMemorySlot3 == info.getPhysMemorySlot3()) && // + (_videoMemory == info.getVideoMemory()) && // + (_vgaVersion == info.getVgaVersion()) && // + (_vgaName.equals(info.getVgaName())) && // + (_vgaDriverVersion.equals(info.getVgaDriverVersion()))) + { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java index fc36c5f076..dbce4c8eea 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java @@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; + // Public variable names + public static final String HWID = "HWID"; + public static final String HWIDSLIT_VAR = " "; + private final String _accountName; public AccountVariables(String accountName) diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index e3e7f08cc1..979063963e 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.network.PacketReader; @@ -51,10 +54,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege; import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; +import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; +import org.l2jmobius.gameserver.model.variables.AccountVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.ConnectionState; @@ -115,7 +120,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil; */ public class EnterWorld implements IClientIncomingPacket { - private final int[][] tracert = new int[5][4]; + private static final Map TRACE_HWINFO = new ConcurrentHashMap<>(); + + private final int[][] _tracert = new int[5][4]; @Override public boolean read(GameClient client, PacketReader packet) @@ -124,7 +131,7 @@ public class EnterWorld implements IClientIncomingPacket { for (int o = 0; o < 4; o++) { - tracert[i][o] = packet.readC(); + _tracert[i][o] = packet.readC(); } } packet.readD(); // Unknown Value @@ -152,11 +159,11 @@ public class EnterWorld implements IClientIncomingPacket final String[] adress = new String[5]; for (int i = 0; i < 5; i++) { - adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; + adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3]; } LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); - client.setClientTracert(tracert); + client.setClientTracert(_tracert); player.broadcastUserInfo(); @@ -664,10 +671,69 @@ public class EnterWorld implements IClientIncomingPacket { ThreadPool.schedule(() -> { - if (client.getHardwareInfo() == null) + // Generate trace string. + final StringBuilder sb = new StringBuilder(); + for (int[] i : _tracert) { - Disconnection.of(client).defaultSequence(false); - return; + for (int j : i) + { + sb.append(j); + sb.append("."); + } + } + final String trace = sb.toString(); + + // Get hardware info from client. + ClientHardwareInfoHolder hwInfo = client.getHardwareInfo(); + if (hwInfo != null) + { + hwInfo.store(player); + TRACE_HWINFO.put(trace, hwInfo); + } + else + { + // Get hardware info from stored tracert map. + hwInfo = TRACE_HWINFO.get(trace); + if (hwInfo != null) + { + hwInfo.store(player); + client.setHardwareInfo(hwInfo); + } + // Get hardware info from account variables. + else + { + final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, ""); + if (!storedInfo.isEmpty()) + { + hwInfo = new ClientHardwareInfoHolder(storedInfo); + TRACE_HWINFO.put(trace, hwInfo); + client.setHardwareInfo(hwInfo); + } + } + } + + // Check max players. + if (Config.MAX_PLAYERS_PER_HWID > 0) + { + if (hwInfo == null) + { + Disconnection.of(client).defaultSequence(false); + } + else + { + int count = 0; + for (PlayerInstance plr : World.getInstance().getPlayers()) + { + if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo))) + { + count++; + } + } + if (count >= Config.MAX_PLAYERS_PER_HWID) + { + Disconnection.of(client).defaultSequence(false); + } + } } }, 5000); } diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java index aa5a94b85b..a824e87cb9 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java @@ -16,12 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; -import org.l2jmobius.gameserver.model.World; -import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; -import org.l2jmobius.gameserver.network.Disconnection; import org.l2jmobius.gameserver.network.GameClient; /** @@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket public void run(GameClient client) { client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); - if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0)) - { - int count = 0; - for (PlayerInstance player : World.getInstance().getPlayers()) - { - if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo()))) - { - count++; - } - } - if (count >= Config.MAX_PLAYERS_PER_HWID) - { - Disconnection.of(client).defaultSequence(false); - } - } } } diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/config/Server.ini b/L2J_Mobius_4.0_GrandCrusade/dist/game/config/Server.ini index 6a154d06cc..e946a2cb31 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/config/Server.ini +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/config/Server.ini @@ -158,13 +158,12 @@ RestartOnDeadlock = False # --------------------------------------------------------------------------- -# Player HWID settings (DO NOT USE) +# Player HWID settings # --------------------------------------------------------------------------- # Check if hardware information is sent upon login. # Players without hardware information are kicked from the game. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. -# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?) # Default: False EnableHardwareInfo = False diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java index 4a835b3931..0ddbf33e30 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.model.holders; +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.variables.AccountVariables; + /** * @author Mobius */ @@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder _vgaDriverVersion = vgaDriverVersion; } + public ClientHardwareInfoHolder(String info) + { + final String[] split = info.split(AccountVariables.HWIDSLIT_VAR); + _macAddress = split[0]; + _windowsPlatformId = Integer.valueOf(split[1]); + _windowsMajorVersion = Integer.valueOf(split[2]); + _windowsMinorVersion = Integer.valueOf(split[3]); + _windowsBuildNumber = Integer.valueOf(split[4]); + _directxVersion = Integer.valueOf(split[5]); + _directxRevision = Integer.valueOf(split[6]); + _cpuName = split[7]; + _cpuSpeed = Integer.valueOf(split[8]); + _cpuCoreCount = Integer.valueOf(split[9]); + _vgaCount = Integer.valueOf(split[10]); + _vgaPcxSpeed = Integer.valueOf(split[11]); + _physMemorySlot1 = Integer.valueOf(split[12]); + _physMemorySlot2 = Integer.valueOf(split[13]); + _physMemorySlot3 = Integer.valueOf(split[14]); + _videoMemory = Integer.valueOf(split[15]); + _vgaVersion = Integer.valueOf(split[16]); + _vgaName = split[17]; + _vgaDriverVersion = split[18]; + } + + /** + * Save hardware info to account variables for later use. + * @param player The PlayerInstance related with this hardware info. + */ + public void store(PlayerInstance player) + { + final StringBuilder sb = new StringBuilder(); + sb.append(_macAddress); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsPlatformId); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMajorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMinorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsBuildNumber); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxRevision); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuCoreCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaPcxSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot1); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot2); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot3); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_videoMemory); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaDriverVersion); + player.getAccountVariables().set(AccountVariables.HWID, sb.toString()); + } + /** * @return the macAddress */ @@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder { return _vgaDriverVersion; } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof ClientHardwareInfoHolder) + { + final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj; + if ((_macAddress.equals(info.getMacAddress())) && // + (_windowsPlatformId == info.getWindowsPlatformId()) && // + (_windowsMajorVersion == info.getWindowsMajorVersion()) && // + (_windowsMinorVersion == info.getWindowsMinorVersion()) && // + (_windowsBuildNumber == info.getWindowsBuildNumber()) && // + (_directxVersion == info.getDirectxVersion()) && // + (_directxRevision == info.getDirectxRevision()) && // + (_cpuName.equals(info.getCpuName())) && // + (_cpuSpeed == info.getCpuSpeed()) && // + (_cpuCoreCount == info.getCpuCoreCount()) && // + (_vgaCount == info.getVgaCount()) && // + (_vgaPcxSpeed == info.getVgaPcxSpeed()) && // + (_physMemorySlot1 == info.getPhysMemorySlot1()) && // + (_physMemorySlot2 == info.getPhysMemorySlot2()) && // + (_physMemorySlot3 == info.getPhysMemorySlot3()) && // + (_videoMemory == info.getVideoMemory()) && // + (_vgaVersion == info.getVgaVersion()) && // + (_vgaName.equals(info.getVgaName())) && // + (_vgaDriverVersion.equals(info.getVgaDriverVersion()))) + { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java index fc36c5f076..dbce4c8eea 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java @@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; + // Public variable names + public static final String HWID = "HWID"; + public static final String HWIDSLIT_VAR = " "; + private final String _accountName; public AccountVariables(String accountName) diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index 59caf69a13..05fe0b8192 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.network.PacketReader; @@ -51,10 +54,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege; import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; +import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; +import org.l2jmobius.gameserver.model.variables.AccountVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.ConnectionState; @@ -115,7 +120,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil; */ public class EnterWorld implements IClientIncomingPacket { - private final int[][] tracert = new int[5][4]; + private static final Map TRACE_HWINFO = new ConcurrentHashMap<>(); + + private final int[][] _tracert = new int[5][4]; @Override public boolean read(GameClient client, PacketReader packet) @@ -124,7 +131,7 @@ public class EnterWorld implements IClientIncomingPacket { for (int o = 0; o < 4; o++) { - tracert[i][o] = packet.readC(); + _tracert[i][o] = packet.readC(); } } packet.readD(); // Unknown Value @@ -152,11 +159,11 @@ public class EnterWorld implements IClientIncomingPacket final String[] adress = new String[5]; for (int i = 0; i < 5; i++) { - adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; + adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3]; } LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); - client.setClientTracert(tracert); + client.setClientTracert(_tracert); player.broadcastUserInfo(); @@ -664,10 +671,69 @@ public class EnterWorld implements IClientIncomingPacket { ThreadPool.schedule(() -> { - if (client.getHardwareInfo() == null) + // Generate trace string. + final StringBuilder sb = new StringBuilder(); + for (int[] i : _tracert) { - Disconnection.of(client).defaultSequence(false); - return; + for (int j : i) + { + sb.append(j); + sb.append("."); + } + } + final String trace = sb.toString(); + + // Get hardware info from client. + ClientHardwareInfoHolder hwInfo = client.getHardwareInfo(); + if (hwInfo != null) + { + hwInfo.store(player); + TRACE_HWINFO.put(trace, hwInfo); + } + else + { + // Get hardware info from stored tracert map. + hwInfo = TRACE_HWINFO.get(trace); + if (hwInfo != null) + { + hwInfo.store(player); + client.setHardwareInfo(hwInfo); + } + // Get hardware info from account variables. + else + { + final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, ""); + if (!storedInfo.isEmpty()) + { + hwInfo = new ClientHardwareInfoHolder(storedInfo); + TRACE_HWINFO.put(trace, hwInfo); + client.setHardwareInfo(hwInfo); + } + } + } + + // Check max players. + if (Config.MAX_PLAYERS_PER_HWID > 0) + { + if (hwInfo == null) + { + Disconnection.of(client).defaultSequence(false); + } + else + { + int count = 0; + for (PlayerInstance plr : World.getInstance().getPlayers()) + { + if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo))) + { + count++; + } + } + if (count >= Config.MAX_PLAYERS_PER_HWID) + { + Disconnection.of(client).defaultSequence(false); + } + } } }, 5000); } diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java index aa5a94b85b..a824e87cb9 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java @@ -16,12 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; -import org.l2jmobius.gameserver.model.World; -import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; -import org.l2jmobius.gameserver.network.Disconnection; import org.l2jmobius.gameserver.network.GameClient; /** @@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket public void run(GameClient client) { client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); - if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0)) - { - int count = 0; - for (PlayerInstance player : World.getInstance().getPlayers()) - { - if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo()))) - { - count++; - } - } - if (count >= Config.MAX_PLAYERS_PER_HWID) - { - Disconnection.of(client).defaultSequence(false); - } - } } } diff --git a/L2J_Mobius_5.0_Salvation/dist/game/config/Server.ini b/L2J_Mobius_5.0_Salvation/dist/game/config/Server.ini index 1ae7fe5ca4..6f77731773 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/config/Server.ini +++ b/L2J_Mobius_5.0_Salvation/dist/game/config/Server.ini @@ -158,13 +158,12 @@ RestartOnDeadlock = False # --------------------------------------------------------------------------- -# Player HWID settings (DO NOT USE) +# Player HWID settings # --------------------------------------------------------------------------- # Check if hardware information is sent upon login. # Players without hardware information are kicked from the game. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. -# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?) # Default: False EnableHardwareInfo = False diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java index 4a835b3931..0ddbf33e30 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.model.holders; +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.variables.AccountVariables; + /** * @author Mobius */ @@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder _vgaDriverVersion = vgaDriverVersion; } + public ClientHardwareInfoHolder(String info) + { + final String[] split = info.split(AccountVariables.HWIDSLIT_VAR); + _macAddress = split[0]; + _windowsPlatformId = Integer.valueOf(split[1]); + _windowsMajorVersion = Integer.valueOf(split[2]); + _windowsMinorVersion = Integer.valueOf(split[3]); + _windowsBuildNumber = Integer.valueOf(split[4]); + _directxVersion = Integer.valueOf(split[5]); + _directxRevision = Integer.valueOf(split[6]); + _cpuName = split[7]; + _cpuSpeed = Integer.valueOf(split[8]); + _cpuCoreCount = Integer.valueOf(split[9]); + _vgaCount = Integer.valueOf(split[10]); + _vgaPcxSpeed = Integer.valueOf(split[11]); + _physMemorySlot1 = Integer.valueOf(split[12]); + _physMemorySlot2 = Integer.valueOf(split[13]); + _physMemorySlot3 = Integer.valueOf(split[14]); + _videoMemory = Integer.valueOf(split[15]); + _vgaVersion = Integer.valueOf(split[16]); + _vgaName = split[17]; + _vgaDriverVersion = split[18]; + } + + /** + * Save hardware info to account variables for later use. + * @param player The PlayerInstance related with this hardware info. + */ + public void store(PlayerInstance player) + { + final StringBuilder sb = new StringBuilder(); + sb.append(_macAddress); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsPlatformId); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMajorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMinorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsBuildNumber); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxRevision); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuCoreCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaPcxSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot1); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot2); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot3); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_videoMemory); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaDriverVersion); + player.getAccountVariables().set(AccountVariables.HWID, sb.toString()); + } + /** * @return the macAddress */ @@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder { return _vgaDriverVersion; } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof ClientHardwareInfoHolder) + { + final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj; + if ((_macAddress.equals(info.getMacAddress())) && // + (_windowsPlatformId == info.getWindowsPlatformId()) && // + (_windowsMajorVersion == info.getWindowsMajorVersion()) && // + (_windowsMinorVersion == info.getWindowsMinorVersion()) && // + (_windowsBuildNumber == info.getWindowsBuildNumber()) && // + (_directxVersion == info.getDirectxVersion()) && // + (_directxRevision == info.getDirectxRevision()) && // + (_cpuName.equals(info.getCpuName())) && // + (_cpuSpeed == info.getCpuSpeed()) && // + (_cpuCoreCount == info.getCpuCoreCount()) && // + (_vgaCount == info.getVgaCount()) && // + (_vgaPcxSpeed == info.getVgaPcxSpeed()) && // + (_physMemorySlot1 == info.getPhysMemorySlot1()) && // + (_physMemorySlot2 == info.getPhysMemorySlot2()) && // + (_physMemorySlot3 == info.getPhysMemorySlot3()) && // + (_videoMemory == info.getVideoMemory()) && // + (_vgaVersion == info.getVgaVersion()) && // + (_vgaName.equals(info.getVgaName())) && // + (_vgaDriverVersion.equals(info.getVgaDriverVersion()))) + { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java index fc36c5f076..dbce4c8eea 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java @@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; + // Public variable names + public static final String HWID = "HWID"; + public static final String HWIDSLIT_VAR = " "; + private final String _accountName; public AccountVariables(String accountName) diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index bb5331b536..33c4b75ced 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.network.PacketReader; @@ -51,10 +54,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege; import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; +import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; +import org.l2jmobius.gameserver.model.variables.AccountVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.ConnectionState; @@ -113,7 +118,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil; */ public class EnterWorld implements IClientIncomingPacket { - private final int[][] tracert = new int[5][4]; + private static final Map TRACE_HWINFO = new ConcurrentHashMap<>(); + + private final int[][] _tracert = new int[5][4]; @Override public boolean read(GameClient client, PacketReader packet) @@ -122,7 +129,7 @@ public class EnterWorld implements IClientIncomingPacket { for (int o = 0; o < 4; o++) { - tracert[i][o] = packet.readC(); + _tracert[i][o] = packet.readC(); } } packet.readD(); // Unknown Value @@ -150,11 +157,11 @@ public class EnterWorld implements IClientIncomingPacket final String[] adress = new String[5]; for (int i = 0; i < 5; i++) { - adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; + adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3]; } LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); - client.setClientTracert(tracert); + client.setClientTracert(_tracert); player.broadcastUserInfo(); @@ -662,10 +669,69 @@ public class EnterWorld implements IClientIncomingPacket { ThreadPool.schedule(() -> { - if (client.getHardwareInfo() == null) + // Generate trace string. + final StringBuilder sb = new StringBuilder(); + for (int[] i : _tracert) { - Disconnection.of(client).defaultSequence(false); - return; + for (int j : i) + { + sb.append(j); + sb.append("."); + } + } + final String trace = sb.toString(); + + // Get hardware info from client. + ClientHardwareInfoHolder hwInfo = client.getHardwareInfo(); + if (hwInfo != null) + { + hwInfo.store(player); + TRACE_HWINFO.put(trace, hwInfo); + } + else + { + // Get hardware info from stored tracert map. + hwInfo = TRACE_HWINFO.get(trace); + if (hwInfo != null) + { + hwInfo.store(player); + client.setHardwareInfo(hwInfo); + } + // Get hardware info from account variables. + else + { + final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, ""); + if (!storedInfo.isEmpty()) + { + hwInfo = new ClientHardwareInfoHolder(storedInfo); + TRACE_HWINFO.put(trace, hwInfo); + client.setHardwareInfo(hwInfo); + } + } + } + + // Check max players. + if (Config.MAX_PLAYERS_PER_HWID > 0) + { + if (hwInfo == null) + { + Disconnection.of(client).defaultSequence(false); + } + else + { + int count = 0; + for (PlayerInstance plr : World.getInstance().getPlayers()) + { + if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo))) + { + count++; + } + } + if (count >= Config.MAX_PLAYERS_PER_HWID) + { + Disconnection.of(client).defaultSequence(false); + } + } } }, 5000); } diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java index aa5a94b85b..a824e87cb9 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java @@ -16,12 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; -import org.l2jmobius.gameserver.model.World; -import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; -import org.l2jmobius.gameserver.network.Disconnection; import org.l2jmobius.gameserver.network.GameClient; /** @@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket public void run(GameClient client) { client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); - if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0)) - { - int count = 0; - for (PlayerInstance player : World.getInstance().getPlayers()) - { - if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo()))) - { - count++; - } - } - if (count >= Config.MAX_PLAYERS_PER_HWID) - { - Disconnection.of(client).defaultSequence(false); - } - } } } diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/config/Server.ini b/L2J_Mobius_5.5_EtinasFate/dist/game/config/Server.ini index 078108163f..f3de20fc11 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/config/Server.ini +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/config/Server.ini @@ -158,13 +158,12 @@ RestartOnDeadlock = False # --------------------------------------------------------------------------- -# Player HWID settings (DO NOT USE) +# Player HWID settings # --------------------------------------------------------------------------- # Check if hardware information is sent upon login. # Players without hardware information are kicked from the game. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. -# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?) # Default: False EnableHardwareInfo = False diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java index 4a835b3931..0ddbf33e30 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.model.holders; +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.variables.AccountVariables; + /** * @author Mobius */ @@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder _vgaDriverVersion = vgaDriverVersion; } + public ClientHardwareInfoHolder(String info) + { + final String[] split = info.split(AccountVariables.HWIDSLIT_VAR); + _macAddress = split[0]; + _windowsPlatformId = Integer.valueOf(split[1]); + _windowsMajorVersion = Integer.valueOf(split[2]); + _windowsMinorVersion = Integer.valueOf(split[3]); + _windowsBuildNumber = Integer.valueOf(split[4]); + _directxVersion = Integer.valueOf(split[5]); + _directxRevision = Integer.valueOf(split[6]); + _cpuName = split[7]; + _cpuSpeed = Integer.valueOf(split[8]); + _cpuCoreCount = Integer.valueOf(split[9]); + _vgaCount = Integer.valueOf(split[10]); + _vgaPcxSpeed = Integer.valueOf(split[11]); + _physMemorySlot1 = Integer.valueOf(split[12]); + _physMemorySlot2 = Integer.valueOf(split[13]); + _physMemorySlot3 = Integer.valueOf(split[14]); + _videoMemory = Integer.valueOf(split[15]); + _vgaVersion = Integer.valueOf(split[16]); + _vgaName = split[17]; + _vgaDriverVersion = split[18]; + } + + /** + * Save hardware info to account variables for later use. + * @param player The PlayerInstance related with this hardware info. + */ + public void store(PlayerInstance player) + { + final StringBuilder sb = new StringBuilder(); + sb.append(_macAddress); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsPlatformId); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMajorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMinorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsBuildNumber); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxRevision); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuCoreCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaPcxSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot1); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot2); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot3); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_videoMemory); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaDriverVersion); + player.getAccountVariables().set(AccountVariables.HWID, sb.toString()); + } + /** * @return the macAddress */ @@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder { return _vgaDriverVersion; } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof ClientHardwareInfoHolder) + { + final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj; + if ((_macAddress.equals(info.getMacAddress())) && // + (_windowsPlatformId == info.getWindowsPlatformId()) && // + (_windowsMajorVersion == info.getWindowsMajorVersion()) && // + (_windowsMinorVersion == info.getWindowsMinorVersion()) && // + (_windowsBuildNumber == info.getWindowsBuildNumber()) && // + (_directxVersion == info.getDirectxVersion()) && // + (_directxRevision == info.getDirectxRevision()) && // + (_cpuName.equals(info.getCpuName())) && // + (_cpuSpeed == info.getCpuSpeed()) && // + (_cpuCoreCount == info.getCpuCoreCount()) && // + (_vgaCount == info.getVgaCount()) && // + (_vgaPcxSpeed == info.getVgaPcxSpeed()) && // + (_physMemorySlot1 == info.getPhysMemorySlot1()) && // + (_physMemorySlot2 == info.getPhysMemorySlot2()) && // + (_physMemorySlot3 == info.getPhysMemorySlot3()) && // + (_videoMemory == info.getVideoMemory()) && // + (_vgaVersion == info.getVgaVersion()) && // + (_vgaName.equals(info.getVgaName())) && // + (_vgaDriverVersion.equals(info.getVgaDriverVersion()))) + { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java index fc36c5f076..dbce4c8eea 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java @@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; + // Public variable names + public static final String HWID = "HWID"; + public static final String HWIDSLIT_VAR = " "; + private final String _accountName; public AccountVariables(String accountName) diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index f01b51ce45..e6a24df7c6 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.network.PacketReader; @@ -51,10 +54,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege; import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; +import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; +import org.l2jmobius.gameserver.model.variables.AccountVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.ConnectionState; @@ -113,7 +118,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil; */ public class EnterWorld implements IClientIncomingPacket { - private final int[][] tracert = new int[5][4]; + private static final Map TRACE_HWINFO = new ConcurrentHashMap<>(); + + private final int[][] _tracert = new int[5][4]; @Override public boolean read(GameClient client, PacketReader packet) @@ -122,7 +129,7 @@ public class EnterWorld implements IClientIncomingPacket { for (int o = 0; o < 4; o++) { - tracert[i][o] = packet.readC(); + _tracert[i][o] = packet.readC(); } } packet.readD(); // Unknown Value @@ -150,11 +157,11 @@ public class EnterWorld implements IClientIncomingPacket final String[] adress = new String[5]; for (int i = 0; i < 5; i++) { - adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; + adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3]; } LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); - client.setClientTracert(tracert); + client.setClientTracert(_tracert); player.broadcastUserInfo(); @@ -662,10 +669,69 @@ public class EnterWorld implements IClientIncomingPacket { ThreadPool.schedule(() -> { - if (client.getHardwareInfo() == null) + // Generate trace string. + final StringBuilder sb = new StringBuilder(); + for (int[] i : _tracert) { - Disconnection.of(client).defaultSequence(false); - return; + for (int j : i) + { + sb.append(j); + sb.append("."); + } + } + final String trace = sb.toString(); + + // Get hardware info from client. + ClientHardwareInfoHolder hwInfo = client.getHardwareInfo(); + if (hwInfo != null) + { + hwInfo.store(player); + TRACE_HWINFO.put(trace, hwInfo); + } + else + { + // Get hardware info from stored tracert map. + hwInfo = TRACE_HWINFO.get(trace); + if (hwInfo != null) + { + hwInfo.store(player); + client.setHardwareInfo(hwInfo); + } + // Get hardware info from account variables. + else + { + final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, ""); + if (!storedInfo.isEmpty()) + { + hwInfo = new ClientHardwareInfoHolder(storedInfo); + TRACE_HWINFO.put(trace, hwInfo); + client.setHardwareInfo(hwInfo); + } + } + } + + // Check max players. + if (Config.MAX_PLAYERS_PER_HWID > 0) + { + if (hwInfo == null) + { + Disconnection.of(client).defaultSequence(false); + } + else + { + int count = 0; + for (PlayerInstance plr : World.getInstance().getPlayers()) + { + if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo))) + { + count++; + } + } + if (count >= Config.MAX_PLAYERS_PER_HWID) + { + Disconnection.of(client).defaultSequence(false); + } + } } }, 5000); } diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java index aa5a94b85b..a824e87cb9 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java @@ -16,12 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; -import org.l2jmobius.gameserver.model.World; -import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; -import org.l2jmobius.gameserver.network.Disconnection; import org.l2jmobius.gameserver.network.GameClient; /** @@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket public void run(GameClient client) { client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); - if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0)) - { - int count = 0; - for (PlayerInstance player : World.getInstance().getPlayers()) - { - if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo()))) - { - count++; - } - } - if (count >= Config.MAX_PLAYERS_PER_HWID) - { - Disconnection.of(client).defaultSequence(false); - } - } } } diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/config/Server.ini b/L2J_Mobius_6.0_Fafurion/dist/game/config/Server.ini index 0573104821..6bcfd7a4e4 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/config/Server.ini +++ b/L2J_Mobius_6.0_Fafurion/dist/game/config/Server.ini @@ -158,13 +158,12 @@ RestartOnDeadlock = False # --------------------------------------------------------------------------- -# Player HWID settings (DO NOT USE) +# Player HWID settings # --------------------------------------------------------------------------- # Check if hardware information is sent upon login. # Players without hardware information are kicked from the game. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. -# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?) # Default: False EnableHardwareInfo = False diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java index 4a835b3931..0ddbf33e30 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.model.holders; +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.variables.AccountVariables; + /** * @author Mobius */ @@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder _vgaDriverVersion = vgaDriverVersion; } + public ClientHardwareInfoHolder(String info) + { + final String[] split = info.split(AccountVariables.HWIDSLIT_VAR); + _macAddress = split[0]; + _windowsPlatformId = Integer.valueOf(split[1]); + _windowsMajorVersion = Integer.valueOf(split[2]); + _windowsMinorVersion = Integer.valueOf(split[3]); + _windowsBuildNumber = Integer.valueOf(split[4]); + _directxVersion = Integer.valueOf(split[5]); + _directxRevision = Integer.valueOf(split[6]); + _cpuName = split[7]; + _cpuSpeed = Integer.valueOf(split[8]); + _cpuCoreCount = Integer.valueOf(split[9]); + _vgaCount = Integer.valueOf(split[10]); + _vgaPcxSpeed = Integer.valueOf(split[11]); + _physMemorySlot1 = Integer.valueOf(split[12]); + _physMemorySlot2 = Integer.valueOf(split[13]); + _physMemorySlot3 = Integer.valueOf(split[14]); + _videoMemory = Integer.valueOf(split[15]); + _vgaVersion = Integer.valueOf(split[16]); + _vgaName = split[17]; + _vgaDriverVersion = split[18]; + } + + /** + * Save hardware info to account variables for later use. + * @param player The PlayerInstance related with this hardware info. + */ + public void store(PlayerInstance player) + { + final StringBuilder sb = new StringBuilder(); + sb.append(_macAddress); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsPlatformId); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMajorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMinorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsBuildNumber); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxRevision); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuCoreCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaPcxSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot1); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot2); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot3); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_videoMemory); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaDriverVersion); + player.getAccountVariables().set(AccountVariables.HWID, sb.toString()); + } + /** * @return the macAddress */ @@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder { return _vgaDriverVersion; } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof ClientHardwareInfoHolder) + { + final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj; + if ((_macAddress.equals(info.getMacAddress())) && // + (_windowsPlatformId == info.getWindowsPlatformId()) && // + (_windowsMajorVersion == info.getWindowsMajorVersion()) && // + (_windowsMinorVersion == info.getWindowsMinorVersion()) && // + (_windowsBuildNumber == info.getWindowsBuildNumber()) && // + (_directxVersion == info.getDirectxVersion()) && // + (_directxRevision == info.getDirectxRevision()) && // + (_cpuName.equals(info.getCpuName())) && // + (_cpuSpeed == info.getCpuSpeed()) && // + (_cpuCoreCount == info.getCpuCoreCount()) && // + (_vgaCount == info.getVgaCount()) && // + (_vgaPcxSpeed == info.getVgaPcxSpeed()) && // + (_physMemorySlot1 == info.getPhysMemorySlot1()) && // + (_physMemorySlot2 == info.getPhysMemorySlot2()) && // + (_physMemorySlot3 == info.getPhysMemorySlot3()) && // + (_videoMemory == info.getVideoMemory()) && // + (_vgaVersion == info.getVgaVersion()) && // + (_vgaName.equals(info.getVgaName())) && // + (_vgaDriverVersion.equals(info.getVgaDriverVersion()))) + { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java index fc36c5f076..dbce4c8eea 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java @@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; + // Public variable names + public static final String HWID = "HWID"; + public static final String HWIDSLIT_VAR = " "; + private final String _accountName; public AccountVariables(String accountName) diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index f01b51ce45..e6a24df7c6 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.network.PacketReader; @@ -51,10 +54,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege; import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; +import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; +import org.l2jmobius.gameserver.model.variables.AccountVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.ConnectionState; @@ -113,7 +118,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil; */ public class EnterWorld implements IClientIncomingPacket { - private final int[][] tracert = new int[5][4]; + private static final Map TRACE_HWINFO = new ConcurrentHashMap<>(); + + private final int[][] _tracert = new int[5][4]; @Override public boolean read(GameClient client, PacketReader packet) @@ -122,7 +129,7 @@ public class EnterWorld implements IClientIncomingPacket { for (int o = 0; o < 4; o++) { - tracert[i][o] = packet.readC(); + _tracert[i][o] = packet.readC(); } } packet.readD(); // Unknown Value @@ -150,11 +157,11 @@ public class EnterWorld implements IClientIncomingPacket final String[] adress = new String[5]; for (int i = 0; i < 5; i++) { - adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; + adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3]; } LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); - client.setClientTracert(tracert); + client.setClientTracert(_tracert); player.broadcastUserInfo(); @@ -662,10 +669,69 @@ public class EnterWorld implements IClientIncomingPacket { ThreadPool.schedule(() -> { - if (client.getHardwareInfo() == null) + // Generate trace string. + final StringBuilder sb = new StringBuilder(); + for (int[] i : _tracert) { - Disconnection.of(client).defaultSequence(false); - return; + for (int j : i) + { + sb.append(j); + sb.append("."); + } + } + final String trace = sb.toString(); + + // Get hardware info from client. + ClientHardwareInfoHolder hwInfo = client.getHardwareInfo(); + if (hwInfo != null) + { + hwInfo.store(player); + TRACE_HWINFO.put(trace, hwInfo); + } + else + { + // Get hardware info from stored tracert map. + hwInfo = TRACE_HWINFO.get(trace); + if (hwInfo != null) + { + hwInfo.store(player); + client.setHardwareInfo(hwInfo); + } + // Get hardware info from account variables. + else + { + final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, ""); + if (!storedInfo.isEmpty()) + { + hwInfo = new ClientHardwareInfoHolder(storedInfo); + TRACE_HWINFO.put(trace, hwInfo); + client.setHardwareInfo(hwInfo); + } + } + } + + // Check max players. + if (Config.MAX_PLAYERS_PER_HWID > 0) + { + if (hwInfo == null) + { + Disconnection.of(client).defaultSequence(false); + } + else + { + int count = 0; + for (PlayerInstance plr : World.getInstance().getPlayers()) + { + if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo))) + { + count++; + } + } + if (count >= Config.MAX_PLAYERS_PER_HWID) + { + Disconnection.of(client).defaultSequence(false); + } + } } }, 5000); } diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java index aa5a94b85b..a824e87cb9 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java @@ -16,12 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; -import org.l2jmobius.gameserver.model.World; -import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; -import org.l2jmobius.gameserver.network.Disconnection; import org.l2jmobius.gameserver.network.GameClient; /** @@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket public void run(GameClient client) { client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); - if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0)) - { - int count = 0; - for (PlayerInstance player : World.getInstance().getPlayers()) - { - if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo()))) - { - count++; - } - } - if (count >= Config.MAX_PLAYERS_PER_HWID) - { - Disconnection.of(client).defaultSequence(false); - } - } } } diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/game/config/Server.ini b/L2J_Mobius_7.0_PreludeOfWar/dist/game/config/Server.ini index 1e3a9949d0..ee0448aad8 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/dist/game/config/Server.ini +++ b/L2J_Mobius_7.0_PreludeOfWar/dist/game/config/Server.ini @@ -158,13 +158,12 @@ RestartOnDeadlock = False # --------------------------------------------------------------------------- -# Player HWID settings (DO NOT USE) +# Player HWID settings # --------------------------------------------------------------------------- # Check if hardware information is sent upon login. # Players without hardware information are kicked from the game. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. -# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?) # Default: False EnableHardwareInfo = False diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java index 4a835b3931..0ddbf33e30 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.model.holders; +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.variables.AccountVariables; + /** * @author Mobius */ @@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder _vgaDriverVersion = vgaDriverVersion; } + public ClientHardwareInfoHolder(String info) + { + final String[] split = info.split(AccountVariables.HWIDSLIT_VAR); + _macAddress = split[0]; + _windowsPlatformId = Integer.valueOf(split[1]); + _windowsMajorVersion = Integer.valueOf(split[2]); + _windowsMinorVersion = Integer.valueOf(split[3]); + _windowsBuildNumber = Integer.valueOf(split[4]); + _directxVersion = Integer.valueOf(split[5]); + _directxRevision = Integer.valueOf(split[6]); + _cpuName = split[7]; + _cpuSpeed = Integer.valueOf(split[8]); + _cpuCoreCount = Integer.valueOf(split[9]); + _vgaCount = Integer.valueOf(split[10]); + _vgaPcxSpeed = Integer.valueOf(split[11]); + _physMemorySlot1 = Integer.valueOf(split[12]); + _physMemorySlot2 = Integer.valueOf(split[13]); + _physMemorySlot3 = Integer.valueOf(split[14]); + _videoMemory = Integer.valueOf(split[15]); + _vgaVersion = Integer.valueOf(split[16]); + _vgaName = split[17]; + _vgaDriverVersion = split[18]; + } + + /** + * Save hardware info to account variables for later use. + * @param player The PlayerInstance related with this hardware info. + */ + public void store(PlayerInstance player) + { + final StringBuilder sb = new StringBuilder(); + sb.append(_macAddress); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsPlatformId); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMajorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMinorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsBuildNumber); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxRevision); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuCoreCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaPcxSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot1); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot2); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot3); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_videoMemory); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaDriverVersion); + player.getAccountVariables().set(AccountVariables.HWID, sb.toString()); + } + /** * @return the macAddress */ @@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder { return _vgaDriverVersion; } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof ClientHardwareInfoHolder) + { + final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj; + if ((_macAddress.equals(info.getMacAddress())) && // + (_windowsPlatformId == info.getWindowsPlatformId()) && // + (_windowsMajorVersion == info.getWindowsMajorVersion()) && // + (_windowsMinorVersion == info.getWindowsMinorVersion()) && // + (_windowsBuildNumber == info.getWindowsBuildNumber()) && // + (_directxVersion == info.getDirectxVersion()) && // + (_directxRevision == info.getDirectxRevision()) && // + (_cpuName.equals(info.getCpuName())) && // + (_cpuSpeed == info.getCpuSpeed()) && // + (_cpuCoreCount == info.getCpuCoreCount()) && // + (_vgaCount == info.getVgaCount()) && // + (_vgaPcxSpeed == info.getVgaPcxSpeed()) && // + (_physMemorySlot1 == info.getPhysMemorySlot1()) && // + (_physMemorySlot2 == info.getPhysMemorySlot2()) && // + (_physMemorySlot3 == info.getPhysMemorySlot3()) && // + (_videoMemory == info.getVideoMemory()) && // + (_vgaVersion == info.getVgaVersion()) && // + (_vgaName.equals(info.getVgaName())) && // + (_vgaDriverVersion.equals(info.getVgaDriverVersion()))) + { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java index fc36c5f076..dbce4c8eea 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java @@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; + // Public variable names + public static final String HWID = "HWID"; + public static final String HWIDSLIT_VAR = " "; + private final String _accountName; public AccountVariables(String accountName) diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index 09bcd42305..1e1408f711 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.network.PacketReader; @@ -52,10 +55,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege; import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; +import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; +import org.l2jmobius.gameserver.model.variables.AccountVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.ConnectionState; @@ -115,7 +120,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil; */ public class EnterWorld implements IClientIncomingPacket { - private final int[][] tracert = new int[5][4]; + private static final Map TRACE_HWINFO = new ConcurrentHashMap<>(); + + private final int[][] _tracert = new int[5][4]; @Override public boolean read(GameClient client, PacketReader packet) @@ -124,7 +131,7 @@ public class EnterWorld implements IClientIncomingPacket { for (int o = 0; o < 4; o++) { - tracert[i][o] = packet.readC(); + _tracert[i][o] = packet.readC(); } } packet.readD(); // Unknown Value @@ -152,11 +159,11 @@ public class EnterWorld implements IClientIncomingPacket final String[] adress = new String[5]; for (int i = 0; i < 5; i++) { - adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; + adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3]; } LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); - client.setClientTracert(tracert); + client.setClientTracert(_tracert); player.broadcastUserInfo(); @@ -689,10 +696,69 @@ public class EnterWorld implements IClientIncomingPacket { ThreadPool.schedule(() -> { - if (client.getHardwareInfo() == null) + // Generate trace string. + final StringBuilder sb = new StringBuilder(); + for (int[] i : _tracert) { - Disconnection.of(client).defaultSequence(false); - return; + for (int j : i) + { + sb.append(j); + sb.append("."); + } + } + final String trace = sb.toString(); + + // Get hardware info from client. + ClientHardwareInfoHolder hwInfo = client.getHardwareInfo(); + if (hwInfo != null) + { + hwInfo.store(player); + TRACE_HWINFO.put(trace, hwInfo); + } + else + { + // Get hardware info from stored tracert map. + hwInfo = TRACE_HWINFO.get(trace); + if (hwInfo != null) + { + hwInfo.store(player); + client.setHardwareInfo(hwInfo); + } + // Get hardware info from account variables. + else + { + final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, ""); + if (!storedInfo.isEmpty()) + { + hwInfo = new ClientHardwareInfoHolder(storedInfo); + TRACE_HWINFO.put(trace, hwInfo); + client.setHardwareInfo(hwInfo); + } + } + } + + // Check max players. + if (Config.MAX_PLAYERS_PER_HWID > 0) + { + if (hwInfo == null) + { + Disconnection.of(client).defaultSequence(false); + } + else + { + int count = 0; + for (PlayerInstance plr : World.getInstance().getPlayers()) + { + if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo))) + { + count++; + } + } + if (count >= Config.MAX_PLAYERS_PER_HWID) + { + Disconnection.of(client).defaultSequence(false); + } + } } }, 5000); } diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java index aa5a94b85b..a824e87cb9 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java @@ -16,12 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; -import org.l2jmobius.gameserver.model.World; -import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; -import org.l2jmobius.gameserver.network.Disconnection; import org.l2jmobius.gameserver.network.GameClient; /** @@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket public void run(GameClient client) { client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); - if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0)) - { - int count = 0; - for (PlayerInstance player : World.getInstance().getPlayers()) - { - if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo()))) - { - count++; - } - } - if (count >= Config.MAX_PLAYERS_PER_HWID) - { - Disconnection.of(client).defaultSequence(false); - } - } } } diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/Server.ini b/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/Server.ini index 758fb2d4e9..0e4f2fa4bd 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/Server.ini +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/Server.ini @@ -158,13 +158,12 @@ RestartOnDeadlock = False # --------------------------------------------------------------------------- -# Player HWID settings (DO NOT USE) +# Player HWID settings # --------------------------------------------------------------------------- # Check if hardware information is sent upon login. # Players without hardware information are kicked from the game. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. -# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?) # Default: False EnableHardwareInfo = False diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java index 4a835b3931..0ddbf33e30 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.model.holders; +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.variables.AccountVariables; + /** * @author Mobius */ @@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder _vgaDriverVersion = vgaDriverVersion; } + public ClientHardwareInfoHolder(String info) + { + final String[] split = info.split(AccountVariables.HWIDSLIT_VAR); + _macAddress = split[0]; + _windowsPlatformId = Integer.valueOf(split[1]); + _windowsMajorVersion = Integer.valueOf(split[2]); + _windowsMinorVersion = Integer.valueOf(split[3]); + _windowsBuildNumber = Integer.valueOf(split[4]); + _directxVersion = Integer.valueOf(split[5]); + _directxRevision = Integer.valueOf(split[6]); + _cpuName = split[7]; + _cpuSpeed = Integer.valueOf(split[8]); + _cpuCoreCount = Integer.valueOf(split[9]); + _vgaCount = Integer.valueOf(split[10]); + _vgaPcxSpeed = Integer.valueOf(split[11]); + _physMemorySlot1 = Integer.valueOf(split[12]); + _physMemorySlot2 = Integer.valueOf(split[13]); + _physMemorySlot3 = Integer.valueOf(split[14]); + _videoMemory = Integer.valueOf(split[15]); + _vgaVersion = Integer.valueOf(split[16]); + _vgaName = split[17]; + _vgaDriverVersion = split[18]; + } + + /** + * Save hardware info to account variables for later use. + * @param player The PlayerInstance related with this hardware info. + */ + public void store(PlayerInstance player) + { + final StringBuilder sb = new StringBuilder(); + sb.append(_macAddress); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsPlatformId); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMajorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMinorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsBuildNumber); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxRevision); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuCoreCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaPcxSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot1); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot2); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot3); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_videoMemory); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaDriverVersion); + player.getAccountVariables().set(AccountVariables.HWID, sb.toString()); + } + /** * @return the macAddress */ @@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder { return _vgaDriverVersion; } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof ClientHardwareInfoHolder) + { + final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj; + if ((_macAddress.equals(info.getMacAddress())) && // + (_windowsPlatformId == info.getWindowsPlatformId()) && // + (_windowsMajorVersion == info.getWindowsMajorVersion()) && // + (_windowsMinorVersion == info.getWindowsMinorVersion()) && // + (_windowsBuildNumber == info.getWindowsBuildNumber()) && // + (_directxVersion == info.getDirectxVersion()) && // + (_directxRevision == info.getDirectxRevision()) && // + (_cpuName.equals(info.getCpuName())) && // + (_cpuSpeed == info.getCpuSpeed()) && // + (_cpuCoreCount == info.getCpuCoreCount()) && // + (_vgaCount == info.getVgaCount()) && // + (_vgaPcxSpeed == info.getVgaPcxSpeed()) && // + (_physMemorySlot1 == info.getPhysMemorySlot1()) && // + (_physMemorySlot2 == info.getPhysMemorySlot2()) && // + (_physMemorySlot3 == info.getPhysMemorySlot3()) && // + (_videoMemory == info.getVideoMemory()) && // + (_vgaVersion == info.getVgaVersion()) && // + (_vgaName.equals(info.getVgaName())) && // + (_vgaDriverVersion.equals(info.getVgaDriverVersion()))) + { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java index fc36c5f076..dbce4c8eea 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java @@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; + // Public variable names + public static final String HWID = "HWID"; + public static final String HWIDSLIT_VAR = " "; + private final String _accountName; public AccountVariables(String accountName) diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index f05797158c..8b66b25696 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.network.PacketReader; @@ -50,10 +53,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege; import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; +import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; +import org.l2jmobius.gameserver.model.variables.AccountVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.ConnectionState; @@ -112,7 +117,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil; */ public class EnterWorld implements IClientIncomingPacket { - private final int[][] tracert = new int[5][4]; + private static final Map TRACE_HWINFO = new ConcurrentHashMap<>(); + + private final int[][] _tracert = new int[5][4]; @Override public boolean read(GameClient client, PacketReader packet) @@ -121,7 +128,7 @@ public class EnterWorld implements IClientIncomingPacket { for (int o = 0; o < 4; o++) { - tracert[i][o] = packet.readC(); + _tracert[i][o] = packet.readC(); } } packet.readD(); // Unknown Value @@ -149,11 +156,11 @@ public class EnterWorld implements IClientIncomingPacket final String[] adress = new String[5]; for (int i = 0; i < 5; i++) { - adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; + adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3]; } LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); - client.setClientTracert(tracert); + client.setClientTracert(_tracert); player.broadcastUserInfo(); @@ -647,10 +654,69 @@ public class EnterWorld implements IClientIncomingPacket { ThreadPool.schedule(() -> { - if (client.getHardwareInfo() == null) + // Generate trace string. + final StringBuilder sb = new StringBuilder(); + for (int[] i : _tracert) { - Disconnection.of(client).defaultSequence(false); - return; + for (int j : i) + { + sb.append(j); + sb.append("."); + } + } + final String trace = sb.toString(); + + // Get hardware info from client. + ClientHardwareInfoHolder hwInfo = client.getHardwareInfo(); + if (hwInfo != null) + { + hwInfo.store(player); + TRACE_HWINFO.put(trace, hwInfo); + } + else + { + // Get hardware info from stored tracert map. + hwInfo = TRACE_HWINFO.get(trace); + if (hwInfo != null) + { + hwInfo.store(player); + client.setHardwareInfo(hwInfo); + } + // Get hardware info from account variables. + else + { + final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, ""); + if (!storedInfo.isEmpty()) + { + hwInfo = new ClientHardwareInfoHolder(storedInfo); + TRACE_HWINFO.put(trace, hwInfo); + client.setHardwareInfo(hwInfo); + } + } + } + + // Check max players. + if (Config.MAX_PLAYERS_PER_HWID > 0) + { + if (hwInfo == null) + { + Disconnection.of(client).defaultSequence(false); + } + else + { + int count = 0; + for (PlayerInstance plr : World.getInstance().getPlayers()) + { + if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo))) + { + count++; + } + } + if (count >= Config.MAX_PLAYERS_PER_HWID) + { + Disconnection.of(client).defaultSequence(false); + } + } } }, 5000); } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java index aa5a94b85b..a824e87cb9 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java @@ -16,12 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; -import org.l2jmobius.gameserver.model.World; -import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; -import org.l2jmobius.gameserver.network.Disconnection; import org.l2jmobius.gameserver.network.GameClient; /** @@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket public void run(GameClient client) { client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); - if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0)) - { - int count = 0; - for (PlayerInstance player : World.getInstance().getPlayers()) - { - if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo()))) - { - count++; - } - } - if (count >= Config.MAX_PLAYERS_PER_HWID) - { - Disconnection.of(client).defaultSequence(false); - } - } } } diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/Server.ini b/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/Server.ini index efe327a35c..b4b7ef6732 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/Server.ini +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/Server.ini @@ -158,13 +158,12 @@ RestartOnDeadlock = False # --------------------------------------------------------------------------- -# Player HWID settings (DO NOT USE) +# Player HWID settings # --------------------------------------------------------------------------- # Check if hardware information is sent upon login. # Players without hardware information are kicked from the game. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. -# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?) # Default: False EnableHardwareInfo = False diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java index 4a835b3931..0ddbf33e30 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.model.holders; +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.variables.AccountVariables; + /** * @author Mobius */ @@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder _vgaDriverVersion = vgaDriverVersion; } + public ClientHardwareInfoHolder(String info) + { + final String[] split = info.split(AccountVariables.HWIDSLIT_VAR); + _macAddress = split[0]; + _windowsPlatformId = Integer.valueOf(split[1]); + _windowsMajorVersion = Integer.valueOf(split[2]); + _windowsMinorVersion = Integer.valueOf(split[3]); + _windowsBuildNumber = Integer.valueOf(split[4]); + _directxVersion = Integer.valueOf(split[5]); + _directxRevision = Integer.valueOf(split[6]); + _cpuName = split[7]; + _cpuSpeed = Integer.valueOf(split[8]); + _cpuCoreCount = Integer.valueOf(split[9]); + _vgaCount = Integer.valueOf(split[10]); + _vgaPcxSpeed = Integer.valueOf(split[11]); + _physMemorySlot1 = Integer.valueOf(split[12]); + _physMemorySlot2 = Integer.valueOf(split[13]); + _physMemorySlot3 = Integer.valueOf(split[14]); + _videoMemory = Integer.valueOf(split[15]); + _vgaVersion = Integer.valueOf(split[16]); + _vgaName = split[17]; + _vgaDriverVersion = split[18]; + } + + /** + * Save hardware info to account variables for later use. + * @param player The PlayerInstance related with this hardware info. + */ + public void store(PlayerInstance player) + { + final StringBuilder sb = new StringBuilder(); + sb.append(_macAddress); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsPlatformId); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMajorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMinorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsBuildNumber); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxRevision); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuCoreCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaPcxSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot1); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot2); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot3); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_videoMemory); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaDriverVersion); + player.getAccountVariables().set(AccountVariables.HWID, sb.toString()); + } + /** * @return the macAddress */ @@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder { return _vgaDriverVersion; } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof ClientHardwareInfoHolder) + { + final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj; + if ((_macAddress.equals(info.getMacAddress())) && // + (_windowsPlatformId == info.getWindowsPlatformId()) && // + (_windowsMajorVersion == info.getWindowsMajorVersion()) && // + (_windowsMinorVersion == info.getWindowsMinorVersion()) && // + (_windowsBuildNumber == info.getWindowsBuildNumber()) && // + (_directxVersion == info.getDirectxVersion()) && // + (_directxRevision == info.getDirectxRevision()) && // + (_cpuName.equals(info.getCpuName())) && // + (_cpuSpeed == info.getCpuSpeed()) && // + (_cpuCoreCount == info.getCpuCoreCount()) && // + (_vgaCount == info.getVgaCount()) && // + (_vgaPcxSpeed == info.getVgaPcxSpeed()) && // + (_physMemorySlot1 == info.getPhysMemorySlot1()) && // + (_physMemorySlot2 == info.getPhysMemorySlot2()) && // + (_physMemorySlot3 == info.getPhysMemorySlot3()) && // + (_videoMemory == info.getVideoMemory()) && // + (_vgaVersion == info.getVgaVersion()) && // + (_vgaName.equals(info.getVgaName())) && // + (_vgaDriverVersion.equals(info.getVgaDriverVersion()))) + { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java index fc36c5f076..dbce4c8eea 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java @@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; + // Public variable names + public static final String HWID = "HWID"; + public static final String HWIDSLIT_VAR = " "; + private final String _accountName; public AccountVariables(String accountName) diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index 02ea9a9b20..07f50261ef 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.network.PacketReader; @@ -50,10 +53,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege; import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; +import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; +import org.l2jmobius.gameserver.model.variables.AccountVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.ConnectionState; @@ -112,7 +117,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil; */ public class EnterWorld implements IClientIncomingPacket { - private final int[][] tracert = new int[5][4]; + private static final Map TRACE_HWINFO = new ConcurrentHashMap<>(); + + private final int[][] _tracert = new int[5][4]; @Override public boolean read(GameClient client, PacketReader packet) @@ -121,7 +128,7 @@ public class EnterWorld implements IClientIncomingPacket { for (int o = 0; o < 4; o++) { - tracert[i][o] = packet.readC(); + _tracert[i][o] = packet.readC(); } } packet.readD(); // Unknown Value @@ -149,11 +156,11 @@ public class EnterWorld implements IClientIncomingPacket final String[] adress = new String[5]; for (int i = 0; i < 5; i++) { - adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; + adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3]; } LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); - client.setClientTracert(tracert); + client.setClientTracert(_tracert); player.broadcastUserInfo(); @@ -647,10 +654,69 @@ public class EnterWorld implements IClientIncomingPacket { ThreadPool.schedule(() -> { - if (client.getHardwareInfo() == null) + // Generate trace string. + final StringBuilder sb = new StringBuilder(); + for (int[] i : _tracert) { - Disconnection.of(client).defaultSequence(false); - return; + for (int j : i) + { + sb.append(j); + sb.append("."); + } + } + final String trace = sb.toString(); + + // Get hardware info from client. + ClientHardwareInfoHolder hwInfo = client.getHardwareInfo(); + if (hwInfo != null) + { + hwInfo.store(player); + TRACE_HWINFO.put(trace, hwInfo); + } + else + { + // Get hardware info from stored tracert map. + hwInfo = TRACE_HWINFO.get(trace); + if (hwInfo != null) + { + hwInfo.store(player); + client.setHardwareInfo(hwInfo); + } + // Get hardware info from account variables. + else + { + final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, ""); + if (!storedInfo.isEmpty()) + { + hwInfo = new ClientHardwareInfoHolder(storedInfo); + TRACE_HWINFO.put(trace, hwInfo); + client.setHardwareInfo(hwInfo); + } + } + } + + // Check max players. + if (Config.MAX_PLAYERS_PER_HWID > 0) + { + if (hwInfo == null) + { + Disconnection.of(client).defaultSequence(false); + } + else + { + int count = 0; + for (PlayerInstance plr : World.getInstance().getPlayers()) + { + if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo))) + { + count++; + } + } + if (count >= Config.MAX_PLAYERS_PER_HWID) + { + Disconnection.of(client).defaultSequence(false); + } + } } }, 5000); } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java index aa5a94b85b..a824e87cb9 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java @@ -16,12 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; -import org.l2jmobius.gameserver.model.World; -import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; -import org.l2jmobius.gameserver.network.Disconnection; import org.l2jmobius.gameserver.network.GameClient; /** @@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket public void run(GameClient client) { client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); - if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0)) - { - int count = 0; - for (PlayerInstance player : World.getInstance().getPlayers()) - { - if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo()))) - { - count++; - } - } - if (count >= Config.MAX_PLAYERS_PER_HWID) - { - Disconnection.of(client).defaultSequence(false); - } - } } } diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/Server.ini b/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/Server.ini index 997e24ab31..7501a6e53c 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/Server.ini +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/Server.ini @@ -158,13 +158,12 @@ RestartOnDeadlock = False # --------------------------------------------------------------------------- -# Player HWID settings (DO NOT USE) +# Player HWID settings # --------------------------------------------------------------------------- # Check if hardware information is sent upon login. # Players without hardware information are kicked from the game. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. -# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?) # Default: False EnableHardwareInfo = False diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java index 4a835b3931..0ddbf33e30 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.model.holders; +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.variables.AccountVariables; + /** * @author Mobius */ @@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder _vgaDriverVersion = vgaDriverVersion; } + public ClientHardwareInfoHolder(String info) + { + final String[] split = info.split(AccountVariables.HWIDSLIT_VAR); + _macAddress = split[0]; + _windowsPlatformId = Integer.valueOf(split[1]); + _windowsMajorVersion = Integer.valueOf(split[2]); + _windowsMinorVersion = Integer.valueOf(split[3]); + _windowsBuildNumber = Integer.valueOf(split[4]); + _directxVersion = Integer.valueOf(split[5]); + _directxRevision = Integer.valueOf(split[6]); + _cpuName = split[7]; + _cpuSpeed = Integer.valueOf(split[8]); + _cpuCoreCount = Integer.valueOf(split[9]); + _vgaCount = Integer.valueOf(split[10]); + _vgaPcxSpeed = Integer.valueOf(split[11]); + _physMemorySlot1 = Integer.valueOf(split[12]); + _physMemorySlot2 = Integer.valueOf(split[13]); + _physMemorySlot3 = Integer.valueOf(split[14]); + _videoMemory = Integer.valueOf(split[15]); + _vgaVersion = Integer.valueOf(split[16]); + _vgaName = split[17]; + _vgaDriverVersion = split[18]; + } + + /** + * Save hardware info to account variables for later use. + * @param player The PlayerInstance related with this hardware info. + */ + public void store(PlayerInstance player) + { + final StringBuilder sb = new StringBuilder(); + sb.append(_macAddress); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsPlatformId); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMajorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMinorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsBuildNumber); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxRevision); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuCoreCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaPcxSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot1); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot2); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot3); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_videoMemory); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaDriverVersion); + player.getAccountVariables().set(AccountVariables.HWID, sb.toString()); + } + /** * @return the macAddress */ @@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder { return _vgaDriverVersion; } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof ClientHardwareInfoHolder) + { + final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj; + if ((_macAddress.equals(info.getMacAddress())) && // + (_windowsPlatformId == info.getWindowsPlatformId()) && // + (_windowsMajorVersion == info.getWindowsMajorVersion()) && // + (_windowsMinorVersion == info.getWindowsMinorVersion()) && // + (_windowsBuildNumber == info.getWindowsBuildNumber()) && // + (_directxVersion == info.getDirectxVersion()) && // + (_directxRevision == info.getDirectxRevision()) && // + (_cpuName.equals(info.getCpuName())) && // + (_cpuSpeed == info.getCpuSpeed()) && // + (_cpuCoreCount == info.getCpuCoreCount()) && // + (_vgaCount == info.getVgaCount()) && // + (_vgaPcxSpeed == info.getVgaPcxSpeed()) && // + (_physMemorySlot1 == info.getPhysMemorySlot1()) && // + (_physMemorySlot2 == info.getPhysMemorySlot2()) && // + (_physMemorySlot3 == info.getPhysMemorySlot3()) && // + (_videoMemory == info.getVideoMemory()) && // + (_vgaVersion == info.getVgaVersion()) && // + (_vgaName.equals(info.getVgaName())) && // + (_vgaDriverVersion.equals(info.getVgaDriverVersion()))) + { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java index fc36c5f076..dbce4c8eea 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java @@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; + // Public variable names + public static final String HWID = "HWID"; + public static final String HWIDSLIT_VAR = " "; + private final String _accountName; public AccountVariables(String accountName) diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index 8beb464d4e..6404d6922c 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.network.PacketReader; @@ -50,10 +53,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege; import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; +import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; +import org.l2jmobius.gameserver.model.variables.AccountVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.ConnectionState; @@ -112,7 +117,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil; */ public class EnterWorld implements IClientIncomingPacket { - private final int[][] tracert = new int[5][4]; + private static final Map TRACE_HWINFO = new ConcurrentHashMap<>(); + + private final int[][] _tracert = new int[5][4]; @Override public boolean read(GameClient client, PacketReader packet) @@ -121,7 +128,7 @@ public class EnterWorld implements IClientIncomingPacket { for (int o = 0; o < 4; o++) { - tracert[i][o] = packet.readC(); + _tracert[i][o] = packet.readC(); } } packet.readD(); // Unknown Value @@ -149,11 +156,11 @@ public class EnterWorld implements IClientIncomingPacket final String[] adress = new String[5]; for (int i = 0; i < 5; i++) { - adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; + adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3]; } LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); - client.setClientTracert(tracert); + client.setClientTracert(_tracert); player.broadcastUserInfo(); @@ -649,10 +656,69 @@ public class EnterWorld implements IClientIncomingPacket { ThreadPool.schedule(() -> { - if (client.getHardwareInfo() == null) + // Generate trace string. + final StringBuilder sb = new StringBuilder(); + for (int[] i : _tracert) { - Disconnection.of(client).defaultSequence(false); - return; + for (int j : i) + { + sb.append(j); + sb.append("."); + } + } + final String trace = sb.toString(); + + // Get hardware info from client. + ClientHardwareInfoHolder hwInfo = client.getHardwareInfo(); + if (hwInfo != null) + { + hwInfo.store(player); + TRACE_HWINFO.put(trace, hwInfo); + } + else + { + // Get hardware info from stored tracert map. + hwInfo = TRACE_HWINFO.get(trace); + if (hwInfo != null) + { + hwInfo.store(player); + client.setHardwareInfo(hwInfo); + } + // Get hardware info from account variables. + else + { + final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, ""); + if (!storedInfo.isEmpty()) + { + hwInfo = new ClientHardwareInfoHolder(storedInfo); + TRACE_HWINFO.put(trace, hwInfo); + client.setHardwareInfo(hwInfo); + } + } + } + + // Check max players. + if (Config.MAX_PLAYERS_PER_HWID > 0) + { + if (hwInfo == null) + { + Disconnection.of(client).defaultSequence(false); + } + else + { + int count = 0; + for (PlayerInstance plr : World.getInstance().getPlayers()) + { + if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo))) + { + count++; + } + } + if (count >= Config.MAX_PLAYERS_PER_HWID) + { + Disconnection.of(client).defaultSequence(false); + } + } } }, 5000); } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java index aa5a94b85b..a824e87cb9 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java @@ -16,12 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; -import org.l2jmobius.gameserver.model.World; -import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; -import org.l2jmobius.gameserver.network.Disconnection; import org.l2jmobius.gameserver.network.GameClient; /** @@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket public void run(GameClient client) { client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); - if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0)) - { - int count = 0; - for (PlayerInstance player : World.getInstance().getPlayers()) - { - if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo()))) - { - count++; - } - } - if (count >= Config.MAX_PLAYERS_PER_HWID) - { - Disconnection.of(client).defaultSequence(false); - } - } } } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/Server.ini b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/Server.ini index 0af4c7b222..170cc74b69 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/Server.ini +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/Server.ini @@ -158,13 +158,12 @@ RestartOnDeadlock = False # --------------------------------------------------------------------------- -# Player HWID settings (DO NOT USE) +# Player HWID settings # --------------------------------------------------------------------------- # Check if hardware information is sent upon login. # Players without hardware information are kicked from the game. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. -# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?) # Default: False EnableHardwareInfo = False diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java index 4a835b3931..0ddbf33e30 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.model.holders; +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.variables.AccountVariables; + /** * @author Mobius */ @@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder _vgaDriverVersion = vgaDriverVersion; } + public ClientHardwareInfoHolder(String info) + { + final String[] split = info.split(AccountVariables.HWIDSLIT_VAR); + _macAddress = split[0]; + _windowsPlatformId = Integer.valueOf(split[1]); + _windowsMajorVersion = Integer.valueOf(split[2]); + _windowsMinorVersion = Integer.valueOf(split[3]); + _windowsBuildNumber = Integer.valueOf(split[4]); + _directxVersion = Integer.valueOf(split[5]); + _directxRevision = Integer.valueOf(split[6]); + _cpuName = split[7]; + _cpuSpeed = Integer.valueOf(split[8]); + _cpuCoreCount = Integer.valueOf(split[9]); + _vgaCount = Integer.valueOf(split[10]); + _vgaPcxSpeed = Integer.valueOf(split[11]); + _physMemorySlot1 = Integer.valueOf(split[12]); + _physMemorySlot2 = Integer.valueOf(split[13]); + _physMemorySlot3 = Integer.valueOf(split[14]); + _videoMemory = Integer.valueOf(split[15]); + _vgaVersion = Integer.valueOf(split[16]); + _vgaName = split[17]; + _vgaDriverVersion = split[18]; + } + + /** + * Save hardware info to account variables for later use. + * @param player The PlayerInstance related with this hardware info. + */ + public void store(PlayerInstance player) + { + final StringBuilder sb = new StringBuilder(); + sb.append(_macAddress); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsPlatformId); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMajorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMinorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsBuildNumber); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxRevision); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuCoreCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaPcxSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot1); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot2); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot3); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_videoMemory); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaDriverVersion); + player.getAccountVariables().set(AccountVariables.HWID, sb.toString()); + } + /** * @return the macAddress */ @@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder { return _vgaDriverVersion; } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof ClientHardwareInfoHolder) + { + final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj; + if ((_macAddress.equals(info.getMacAddress())) && // + (_windowsPlatformId == info.getWindowsPlatformId()) && // + (_windowsMajorVersion == info.getWindowsMajorVersion()) && // + (_windowsMinorVersion == info.getWindowsMinorVersion()) && // + (_windowsBuildNumber == info.getWindowsBuildNumber()) && // + (_directxVersion == info.getDirectxVersion()) && // + (_directxRevision == info.getDirectxRevision()) && // + (_cpuName.equals(info.getCpuName())) && // + (_cpuSpeed == info.getCpuSpeed()) && // + (_cpuCoreCount == info.getCpuCoreCount()) && // + (_vgaCount == info.getVgaCount()) && // + (_vgaPcxSpeed == info.getVgaPcxSpeed()) && // + (_physMemorySlot1 == info.getPhysMemorySlot1()) && // + (_physMemorySlot2 == info.getPhysMemorySlot2()) && // + (_physMemorySlot3 == info.getPhysMemorySlot3()) && // + (_videoMemory == info.getVideoMemory()) && // + (_vgaVersion == info.getVgaVersion()) && // + (_vgaName.equals(info.getVgaName())) && // + (_vgaDriverVersion.equals(info.getVgaDriverVersion()))) + { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java index fc36c5f076..dbce4c8eea 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java @@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; + // Public variable names + public static final String HWID = "HWID"; + public static final String HWIDSLIT_VAR = " "; + private final String _accountName; public AccountVariables(String accountName) diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index 8beb464d4e..6404d6922c 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.network.PacketReader; @@ -50,10 +53,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege; import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; +import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; +import org.l2jmobius.gameserver.model.variables.AccountVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.ConnectionState; @@ -112,7 +117,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil; */ public class EnterWorld implements IClientIncomingPacket { - private final int[][] tracert = new int[5][4]; + private static final Map TRACE_HWINFO = new ConcurrentHashMap<>(); + + private final int[][] _tracert = new int[5][4]; @Override public boolean read(GameClient client, PacketReader packet) @@ -121,7 +128,7 @@ public class EnterWorld implements IClientIncomingPacket { for (int o = 0; o < 4; o++) { - tracert[i][o] = packet.readC(); + _tracert[i][o] = packet.readC(); } } packet.readD(); // Unknown Value @@ -149,11 +156,11 @@ public class EnterWorld implements IClientIncomingPacket final String[] adress = new String[5]; for (int i = 0; i < 5; i++) { - adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; + adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3]; } LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); - client.setClientTracert(tracert); + client.setClientTracert(_tracert); player.broadcastUserInfo(); @@ -649,10 +656,69 @@ public class EnterWorld implements IClientIncomingPacket { ThreadPool.schedule(() -> { - if (client.getHardwareInfo() == null) + // Generate trace string. + final StringBuilder sb = new StringBuilder(); + for (int[] i : _tracert) { - Disconnection.of(client).defaultSequence(false); - return; + for (int j : i) + { + sb.append(j); + sb.append("."); + } + } + final String trace = sb.toString(); + + // Get hardware info from client. + ClientHardwareInfoHolder hwInfo = client.getHardwareInfo(); + if (hwInfo != null) + { + hwInfo.store(player); + TRACE_HWINFO.put(trace, hwInfo); + } + else + { + // Get hardware info from stored tracert map. + hwInfo = TRACE_HWINFO.get(trace); + if (hwInfo != null) + { + hwInfo.store(player); + client.setHardwareInfo(hwInfo); + } + // Get hardware info from account variables. + else + { + final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, ""); + if (!storedInfo.isEmpty()) + { + hwInfo = new ClientHardwareInfoHolder(storedInfo); + TRACE_HWINFO.put(trace, hwInfo); + client.setHardwareInfo(hwInfo); + } + } + } + + // Check max players. + if (Config.MAX_PLAYERS_PER_HWID > 0) + { + if (hwInfo == null) + { + Disconnection.of(client).defaultSequence(false); + } + else + { + int count = 0; + for (PlayerInstance plr : World.getInstance().getPlayers()) + { + if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo))) + { + count++; + } + } + if (count >= Config.MAX_PLAYERS_PER_HWID) + { + Disconnection.of(client).defaultSequence(false); + } + } } }, 5000); } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java index aa5a94b85b..a824e87cb9 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java @@ -16,12 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; -import org.l2jmobius.gameserver.model.World; -import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; -import org.l2jmobius.gameserver.network.Disconnection; import org.l2jmobius.gameserver.network.GameClient; /** @@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket public void run(GameClient client) { client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); - if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0)) - { - int count = 0; - for (PlayerInstance player : World.getInstance().getPlayers()) - { - if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo()))) - { - count++; - } - } - if (count >= Config.MAX_PLAYERS_PER_HWID) - { - Disconnection.of(client).defaultSequence(false); - } - } } } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/Server.ini b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/Server.ini index 2bfcfb5d0c..546e2fd8ef 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/Server.ini +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/Server.ini @@ -158,13 +158,12 @@ RestartOnDeadlock = False # --------------------------------------------------------------------------- -# Player HWID settings (DO NOT USE) +# Player HWID settings # --------------------------------------------------------------------------- # Check if hardware information is sent upon login. # Players without hardware information are kicked from the game. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. -# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?) # Default: False EnableHardwareInfo = False diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java index 4a835b3931..0ddbf33e30 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.model.holders; +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.variables.AccountVariables; + /** * @author Mobius */ @@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder _vgaDriverVersion = vgaDriverVersion; } + public ClientHardwareInfoHolder(String info) + { + final String[] split = info.split(AccountVariables.HWIDSLIT_VAR); + _macAddress = split[0]; + _windowsPlatformId = Integer.valueOf(split[1]); + _windowsMajorVersion = Integer.valueOf(split[2]); + _windowsMinorVersion = Integer.valueOf(split[3]); + _windowsBuildNumber = Integer.valueOf(split[4]); + _directxVersion = Integer.valueOf(split[5]); + _directxRevision = Integer.valueOf(split[6]); + _cpuName = split[7]; + _cpuSpeed = Integer.valueOf(split[8]); + _cpuCoreCount = Integer.valueOf(split[9]); + _vgaCount = Integer.valueOf(split[10]); + _vgaPcxSpeed = Integer.valueOf(split[11]); + _physMemorySlot1 = Integer.valueOf(split[12]); + _physMemorySlot2 = Integer.valueOf(split[13]); + _physMemorySlot3 = Integer.valueOf(split[14]); + _videoMemory = Integer.valueOf(split[15]); + _vgaVersion = Integer.valueOf(split[16]); + _vgaName = split[17]; + _vgaDriverVersion = split[18]; + } + + /** + * Save hardware info to account variables for later use. + * @param player The PlayerInstance related with this hardware info. + */ + public void store(PlayerInstance player) + { + final StringBuilder sb = new StringBuilder(); + sb.append(_macAddress); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsPlatformId); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMajorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMinorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsBuildNumber); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxRevision); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuCoreCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaPcxSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot1); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot2); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot3); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_videoMemory); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaDriverVersion); + player.getAccountVariables().set(AccountVariables.HWID, sb.toString()); + } + /** * @return the macAddress */ @@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder { return _vgaDriverVersion; } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof ClientHardwareInfoHolder) + { + final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj; + if ((_macAddress.equals(info.getMacAddress())) && // + (_windowsPlatformId == info.getWindowsPlatformId()) && // + (_windowsMajorVersion == info.getWindowsMajorVersion()) && // + (_windowsMinorVersion == info.getWindowsMinorVersion()) && // + (_windowsBuildNumber == info.getWindowsBuildNumber()) && // + (_directxVersion == info.getDirectxVersion()) && // + (_directxRevision == info.getDirectxRevision()) && // + (_cpuName.equals(info.getCpuName())) && // + (_cpuSpeed == info.getCpuSpeed()) && // + (_cpuCoreCount == info.getCpuCoreCount()) && // + (_vgaCount == info.getVgaCount()) && // + (_vgaPcxSpeed == info.getVgaPcxSpeed()) && // + (_physMemorySlot1 == info.getPhysMemorySlot1()) && // + (_physMemorySlot2 == info.getPhysMemorySlot2()) && // + (_physMemorySlot3 == info.getPhysMemorySlot3()) && // + (_videoMemory == info.getVideoMemory()) && // + (_vgaVersion == info.getVgaVersion()) && // + (_vgaName.equals(info.getVgaName())) && // + (_vgaDriverVersion.equals(info.getVgaDriverVersion()))) + { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java index fc36c5f076..dbce4c8eea 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java @@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; + // Public variable names + public static final String HWID = "HWID"; + public static final String HWIDSLIT_VAR = " "; + private final String _accountName; public AccountVariables(String accountName) diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index 8beb464d4e..6404d6922c 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.network.PacketReader; @@ -50,10 +53,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege; import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; +import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; +import org.l2jmobius.gameserver.model.variables.AccountVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.ConnectionState; @@ -112,7 +117,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil; */ public class EnterWorld implements IClientIncomingPacket { - private final int[][] tracert = new int[5][4]; + private static final Map TRACE_HWINFO = new ConcurrentHashMap<>(); + + private final int[][] _tracert = new int[5][4]; @Override public boolean read(GameClient client, PacketReader packet) @@ -121,7 +128,7 @@ public class EnterWorld implements IClientIncomingPacket { for (int o = 0; o < 4; o++) { - tracert[i][o] = packet.readC(); + _tracert[i][o] = packet.readC(); } } packet.readD(); // Unknown Value @@ -149,11 +156,11 @@ public class EnterWorld implements IClientIncomingPacket final String[] adress = new String[5]; for (int i = 0; i < 5; i++) { - adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; + adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3]; } LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); - client.setClientTracert(tracert); + client.setClientTracert(_tracert); player.broadcastUserInfo(); @@ -649,10 +656,69 @@ public class EnterWorld implements IClientIncomingPacket { ThreadPool.schedule(() -> { - if (client.getHardwareInfo() == null) + // Generate trace string. + final StringBuilder sb = new StringBuilder(); + for (int[] i : _tracert) { - Disconnection.of(client).defaultSequence(false); - return; + for (int j : i) + { + sb.append(j); + sb.append("."); + } + } + final String trace = sb.toString(); + + // Get hardware info from client. + ClientHardwareInfoHolder hwInfo = client.getHardwareInfo(); + if (hwInfo != null) + { + hwInfo.store(player); + TRACE_HWINFO.put(trace, hwInfo); + } + else + { + // Get hardware info from stored tracert map. + hwInfo = TRACE_HWINFO.get(trace); + if (hwInfo != null) + { + hwInfo.store(player); + client.setHardwareInfo(hwInfo); + } + // Get hardware info from account variables. + else + { + final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, ""); + if (!storedInfo.isEmpty()) + { + hwInfo = new ClientHardwareInfoHolder(storedInfo); + TRACE_HWINFO.put(trace, hwInfo); + client.setHardwareInfo(hwInfo); + } + } + } + + // Check max players. + if (Config.MAX_PLAYERS_PER_HWID > 0) + { + if (hwInfo == null) + { + Disconnection.of(client).defaultSequence(false); + } + else + { + int count = 0; + for (PlayerInstance plr : World.getInstance().getPlayers()) + { + if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo))) + { + count++; + } + } + if (count >= Config.MAX_PLAYERS_PER_HWID) + { + Disconnection.of(client).defaultSequence(false); + } + } } }, 5000); } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java index aa5a94b85b..a824e87cb9 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java @@ -16,12 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; -import org.l2jmobius.gameserver.model.World; -import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; -import org.l2jmobius.gameserver.network.Disconnection; import org.l2jmobius.gameserver.network.GameClient; /** @@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket public void run(GameClient client) { client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); - if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0)) - { - int count = 0; - for (PlayerInstance player : World.getInstance().getPlayers()) - { - if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo()))) - { - count++; - } - } - if (count >= Config.MAX_PLAYERS_PER_HWID) - { - Disconnection.of(client).defaultSequence(false); - } - } } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/Server.ini b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/Server.ini index 4ea84292ad..81e8ec2dc1 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/Server.ini +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/Server.ini @@ -158,13 +158,12 @@ RestartOnDeadlock = False # --------------------------------------------------------------------------- -# Player HWID settings (DO NOT USE) +# Player HWID settings # --------------------------------------------------------------------------- # Check if hardware information is sent upon login. # Players without hardware information are kicked from the game. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. -# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?) # Default: False EnableHardwareInfo = False diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java index 4a835b3931..0ddbf33e30 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.model.holders; +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.variables.AccountVariables; + /** * @author Mobius */ @@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder _vgaDriverVersion = vgaDriverVersion; } + public ClientHardwareInfoHolder(String info) + { + final String[] split = info.split(AccountVariables.HWIDSLIT_VAR); + _macAddress = split[0]; + _windowsPlatformId = Integer.valueOf(split[1]); + _windowsMajorVersion = Integer.valueOf(split[2]); + _windowsMinorVersion = Integer.valueOf(split[3]); + _windowsBuildNumber = Integer.valueOf(split[4]); + _directxVersion = Integer.valueOf(split[5]); + _directxRevision = Integer.valueOf(split[6]); + _cpuName = split[7]; + _cpuSpeed = Integer.valueOf(split[8]); + _cpuCoreCount = Integer.valueOf(split[9]); + _vgaCount = Integer.valueOf(split[10]); + _vgaPcxSpeed = Integer.valueOf(split[11]); + _physMemorySlot1 = Integer.valueOf(split[12]); + _physMemorySlot2 = Integer.valueOf(split[13]); + _physMemorySlot3 = Integer.valueOf(split[14]); + _videoMemory = Integer.valueOf(split[15]); + _vgaVersion = Integer.valueOf(split[16]); + _vgaName = split[17]; + _vgaDriverVersion = split[18]; + } + + /** + * Save hardware info to account variables for later use. + * @param player The PlayerInstance related with this hardware info. + */ + public void store(PlayerInstance player) + { + final StringBuilder sb = new StringBuilder(); + sb.append(_macAddress); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsPlatformId); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMajorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMinorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsBuildNumber); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxRevision); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuCoreCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaPcxSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot1); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot2); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot3); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_videoMemory); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaDriverVersion); + player.getAccountVariables().set(AccountVariables.HWID, sb.toString()); + } + /** * @return the macAddress */ @@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder { return _vgaDriverVersion; } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof ClientHardwareInfoHolder) + { + final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj; + if ((_macAddress.equals(info.getMacAddress())) && // + (_windowsPlatformId == info.getWindowsPlatformId()) && // + (_windowsMajorVersion == info.getWindowsMajorVersion()) && // + (_windowsMinorVersion == info.getWindowsMinorVersion()) && // + (_windowsBuildNumber == info.getWindowsBuildNumber()) && // + (_directxVersion == info.getDirectxVersion()) && // + (_directxRevision == info.getDirectxRevision()) && // + (_cpuName.equals(info.getCpuName())) && // + (_cpuSpeed == info.getCpuSpeed()) && // + (_cpuCoreCount == info.getCpuCoreCount()) && // + (_vgaCount == info.getVgaCount()) && // + (_vgaPcxSpeed == info.getVgaPcxSpeed()) && // + (_physMemorySlot1 == info.getPhysMemorySlot1()) && // + (_physMemorySlot2 == info.getPhysMemorySlot2()) && // + (_physMemorySlot3 == info.getPhysMemorySlot3()) && // + (_videoMemory == info.getVideoMemory()) && // + (_vgaVersion == info.getVgaVersion()) && // + (_vgaName.equals(info.getVgaName())) && // + (_vgaDriverVersion.equals(info.getVgaDriverVersion()))) + { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java index fc36c5f076..dbce4c8eea 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java @@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; + // Public variable names + public static final String HWID = "HWID"; + public static final String HWIDSLIT_VAR = " "; + private final String _accountName; public AccountVariables(String accountName) diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index c938d9e1cc..10c01ed90f 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.network.PacketReader; @@ -51,10 +54,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege; import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; +import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; +import org.l2jmobius.gameserver.model.variables.AccountVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.ConnectionState; @@ -114,7 +119,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil; */ public class EnterWorld implements IClientIncomingPacket { - private final int[][] tracert = new int[5][4]; + private static final Map TRACE_HWINFO = new ConcurrentHashMap<>(); + + private final int[][] _tracert = new int[5][4]; @Override public boolean read(GameClient client, PacketReader packet) @@ -123,7 +130,7 @@ public class EnterWorld implements IClientIncomingPacket { for (int o = 0; o < 4; o++) { - tracert[i][o] = packet.readC(); + _tracert[i][o] = packet.readC(); } } packet.readD(); // Unknown Value @@ -151,11 +158,11 @@ public class EnterWorld implements IClientIncomingPacket final String[] adress = new String[5]; for (int i = 0; i < 5; i++) { - adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; + adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3]; } LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); - client.setClientTracert(tracert); + client.setClientTracert(_tracert); player.broadcastUserInfo(); @@ -669,10 +676,69 @@ public class EnterWorld implements IClientIncomingPacket { ThreadPool.schedule(() -> { - if (client.getHardwareInfo() == null) + // Generate trace string. + final StringBuilder sb = new StringBuilder(); + for (int[] i : _tracert) { - Disconnection.of(client).defaultSequence(false); - return; + for (int j : i) + { + sb.append(j); + sb.append("."); + } + } + final String trace = sb.toString(); + + // Get hardware info from client. + ClientHardwareInfoHolder hwInfo = client.getHardwareInfo(); + if (hwInfo != null) + { + hwInfo.store(player); + TRACE_HWINFO.put(trace, hwInfo); + } + else + { + // Get hardware info from stored tracert map. + hwInfo = TRACE_HWINFO.get(trace); + if (hwInfo != null) + { + hwInfo.store(player); + client.setHardwareInfo(hwInfo); + } + // Get hardware info from account variables. + else + { + final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, ""); + if (!storedInfo.isEmpty()) + { + hwInfo = new ClientHardwareInfoHolder(storedInfo); + TRACE_HWINFO.put(trace, hwInfo); + client.setHardwareInfo(hwInfo); + } + } + } + + // Check max players. + if (Config.MAX_PLAYERS_PER_HWID > 0) + { + if (hwInfo == null) + { + Disconnection.of(client).defaultSequence(false); + } + else + { + int count = 0; + for (PlayerInstance plr : World.getInstance().getPlayers()) + { + if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo))) + { + count++; + } + } + if (count >= Config.MAX_PLAYERS_PER_HWID) + { + Disconnection.of(client).defaultSequence(false); + } + } } }, 5000); } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java index aa5a94b85b..a824e87cb9 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java @@ -16,12 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; -import org.l2jmobius.gameserver.model.World; -import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; -import org.l2jmobius.gameserver.network.Disconnection; import org.l2jmobius.gameserver.network.GameClient; /** @@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket public void run(GameClient client) { client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); - if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0)) - { - int count = 0; - for (PlayerInstance player : World.getInstance().getPlayers()) - { - if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo()))) - { - count++; - } - } - if (count >= Config.MAX_PLAYERS_PER_HWID) - { - Disconnection.of(client).defaultSequence(false); - } - } } } diff --git a/L2J_Mobius_Classic_Interlude/dist/game/config/Server.ini b/L2J_Mobius_Classic_Interlude/dist/game/config/Server.ini index 993f745851..d1fa573611 100644 --- a/L2J_Mobius_Classic_Interlude/dist/game/config/Server.ini +++ b/L2J_Mobius_Classic_Interlude/dist/game/config/Server.ini @@ -158,13 +158,12 @@ RestartOnDeadlock = False # --------------------------------------------------------------------------- -# Player HWID settings (DO NOT USE) +# Player HWID settings # --------------------------------------------------------------------------- # Check if hardware information is sent upon login. # Players without hardware information are kicked from the game. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. -# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?) # Default: False EnableHardwareInfo = False diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java index 4a835b3931..0ddbf33e30 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/holders/ClientHardwareInfoHolder.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.model.holders; +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.variables.AccountVariables; + /** * @author Mobius */ @@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder _vgaDriverVersion = vgaDriverVersion; } + public ClientHardwareInfoHolder(String info) + { + final String[] split = info.split(AccountVariables.HWIDSLIT_VAR); + _macAddress = split[0]; + _windowsPlatformId = Integer.valueOf(split[1]); + _windowsMajorVersion = Integer.valueOf(split[2]); + _windowsMinorVersion = Integer.valueOf(split[3]); + _windowsBuildNumber = Integer.valueOf(split[4]); + _directxVersion = Integer.valueOf(split[5]); + _directxRevision = Integer.valueOf(split[6]); + _cpuName = split[7]; + _cpuSpeed = Integer.valueOf(split[8]); + _cpuCoreCount = Integer.valueOf(split[9]); + _vgaCount = Integer.valueOf(split[10]); + _vgaPcxSpeed = Integer.valueOf(split[11]); + _physMemorySlot1 = Integer.valueOf(split[12]); + _physMemorySlot2 = Integer.valueOf(split[13]); + _physMemorySlot3 = Integer.valueOf(split[14]); + _videoMemory = Integer.valueOf(split[15]); + _vgaVersion = Integer.valueOf(split[16]); + _vgaName = split[17]; + _vgaDriverVersion = split[18]; + } + + /** + * Save hardware info to account variables for later use. + * @param player The PlayerInstance related with this hardware info. + */ + public void store(PlayerInstance player) + { + final StringBuilder sb = new StringBuilder(); + sb.append(_macAddress); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsPlatformId); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMajorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsMinorVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_windowsBuildNumber); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_directxRevision); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_cpuCoreCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaCount); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaPcxSpeed); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot1); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot2); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_physMemorySlot3); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_videoMemory); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaVersion); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaName); + sb.append(AccountVariables.HWIDSLIT_VAR); + sb.append(_vgaDriverVersion); + player.getAccountVariables().set(AccountVariables.HWID, sb.toString()); + } + /** * @return the macAddress */ @@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder { return _vgaDriverVersion; } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof ClientHardwareInfoHolder) + { + final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj; + if ((_macAddress.equals(info.getMacAddress())) && // + (_windowsPlatformId == info.getWindowsPlatformId()) && // + (_windowsMajorVersion == info.getWindowsMajorVersion()) && // + (_windowsMinorVersion == info.getWindowsMinorVersion()) && // + (_windowsBuildNumber == info.getWindowsBuildNumber()) && // + (_directxVersion == info.getDirectxVersion()) && // + (_directxRevision == info.getDirectxRevision()) && // + (_cpuName.equals(info.getCpuName())) && // + (_cpuSpeed == info.getCpuSpeed()) && // + (_cpuCoreCount == info.getCpuCoreCount()) && // + (_vgaCount == info.getVgaCount()) && // + (_vgaPcxSpeed == info.getVgaPcxSpeed()) && // + (_physMemorySlot1 == info.getPhysMemorySlot1()) && // + (_physMemorySlot2 == info.getPhysMemorySlot2()) && // + (_physMemorySlot3 == info.getPhysMemorySlot3()) && // + (_videoMemory == info.getVideoMemory()) && // + (_vgaVersion == info.getVgaVersion()) && // + (_vgaName.equals(info.getVgaName())) && // + (_vgaDriverVersion.equals(info.getVgaDriverVersion()))) + { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java index fc36c5f076..dbce4c8eea 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/variables/AccountVariables.java @@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; + // Public variable names + public static final String HWID = "HWID"; + public static final String HWIDSLIT_VAR = " "; + private final String _accountName; public AccountVariables(String accountName) diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index 3f0c94597a..8d2846eeff 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -16,6 +16,9 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.network.PacketReader; @@ -50,10 +53,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege; import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; +import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; +import org.l2jmobius.gameserver.model.variables.AccountVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.ConnectionState; @@ -111,7 +116,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil; */ public class EnterWorld implements IClientIncomingPacket { - private final int[][] tracert = new int[5][4]; + private static final Map TRACE_HWINFO = new ConcurrentHashMap<>(); + + private final int[][] _tracert = new int[5][4]; @Override public boolean read(GameClient client, PacketReader packet) @@ -120,7 +127,7 @@ public class EnterWorld implements IClientIncomingPacket { for (int o = 0; o < 4; o++) { - tracert[i][o] = packet.readC(); + _tracert[i][o] = packet.readC(); } } packet.readD(); // Unknown Value @@ -148,11 +155,11 @@ public class EnterWorld implements IClientIncomingPacket final String[] adress = new String[5]; for (int i = 0; i < 5; i++) { - adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; + adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3]; } LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); - client.setClientTracert(tracert); + client.setClientTracert(_tracert); player.broadcastUserInfo(); @@ -647,10 +654,69 @@ public class EnterWorld implements IClientIncomingPacket { ThreadPool.schedule(() -> { - if (client.getHardwareInfo() == null) + // Generate trace string. + final StringBuilder sb = new StringBuilder(); + for (int[] i : _tracert) { - Disconnection.of(client).defaultSequence(false); - return; + for (int j : i) + { + sb.append(j); + sb.append("."); + } + } + final String trace = sb.toString(); + + // Get hardware info from client. + ClientHardwareInfoHolder hwInfo = client.getHardwareInfo(); + if (hwInfo != null) + { + hwInfo.store(player); + TRACE_HWINFO.put(trace, hwInfo); + } + else + { + // Get hardware info from stored tracert map. + hwInfo = TRACE_HWINFO.get(trace); + if (hwInfo != null) + { + hwInfo.store(player); + client.setHardwareInfo(hwInfo); + } + // Get hardware info from account variables. + else + { + final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, ""); + if (!storedInfo.isEmpty()) + { + hwInfo = new ClientHardwareInfoHolder(storedInfo); + TRACE_HWINFO.put(trace, hwInfo); + client.setHardwareInfo(hwInfo); + } + } + } + + // Check max players. + if (Config.MAX_PLAYERS_PER_HWID > 0) + { + if (hwInfo == null) + { + Disconnection.of(client).defaultSequence(false); + } + else + { + int count = 0; + for (PlayerInstance plr : World.getInstance().getPlayers()) + { + if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo))) + { + count++; + } + } + if (count >= Config.MAX_PLAYERS_PER_HWID) + { + Disconnection.of(client).defaultSequence(false); + } + } } }, 5000); } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java index aa5a94b85b..a824e87cb9 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestHardWareInfo.java @@ -16,12 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; -import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; -import org.l2jmobius.gameserver.model.World; -import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; -import org.l2jmobius.gameserver.network.Disconnection; import org.l2jmobius.gameserver.network.GameClient; /** @@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket public void run(GameClient client) { client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); - if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0)) - { - int count = 0; - for (PlayerInstance player : World.getInstance().getPlayers()) - { - if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo()))) - { - count++; - } - } - if (count >= Config.MAX_PLAYERS_PER_HWID) - { - Disconnection.of(client).defaultSequence(false); - } - } } }