Fast implementation of RequestHardWareInfo packet.

This commit is contained in:
MobiusDev
2016-08-13 13:37:16 +00:00
parent 16f47a60b1
commit 3f51a97be6
13 changed files with 471 additions and 3 deletions

View File

@@ -261,7 +261,7 @@ public enum ExIncomingPackets implements IIncomingPackets<L2GameClient>
REQUEST_GOODS_INVENTORY_ITEM(0xAB, null, ConnectionState.IN_GAME),
REQUEST_FIRST_PLAY_START(0xAC, null, ConnectionState.IN_GAME),
REQUEST_FLY_MOVE_START(0xAD, RequestFlyMoveStart::new, ConnectionState.IN_GAME),
REQUEST_HARDWARE_INFO(0xAE, null, ConnectionState.IN_GAME),
REQUEST_HARDWARE_INFO(0xAE, RequestHardWareInfo::new, ConnectionState.IN_GAME),
SEND_CHANGE_ATTRIBUTE_TARGET_ITEM(0xB0, null, ConnectionState.IN_GAME),
REQUEST_CHANGE_ATTRIBUTE_ITEM(0xB1, null, ConnectionState.IN_GAME),
REQUEST_CHANGE_ATTRIBUTE_CANCEL(0xB2, null, ConnectionState.IN_GAME),

View File

@@ -53,6 +53,7 @@ import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.L2Event;
import com.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import com.l2jmobius.gameserver.model.olympiad.OlympiadManager;
import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.network.SystemMessageId;
@@ -86,7 +87,7 @@ public final class L2GameClient extends ChannelInboundHandler<L2GameClient>
private L2PcInstance _activeChar;
private final ReentrantLock _activeCharLock = new ReentrantLock();
private SecondaryPasswordAuth _secondaryAuth;
private ClientHardwareInfoHolder _hardwareInfo;
private boolean _isAuthedGG;
private final long _connectionStartTime = System.currentTimeMillis();
private CharSelectInfoPackage[] _charSlotMapping = null;
@@ -941,4 +942,20 @@ public final class L2GameClient extends ChannelInboundHandler<L2GameClient>
{
return _crypt;
}
/**
* @return the hardwareInfo
*/
public ClientHardwareInfoHolder getHardwareInfo()
{
return _hardwareInfo;
}
/**
* @param hardwareInfo
*/
public void setHardwareInfo(ClientHardwareInfoHolder hardwareInfo)
{
_hardwareInfo = hardwareInfo;
}
}

View File

@@ -94,6 +94,7 @@ import com.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListAll;
import com.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListUpdate;
import com.l2jmobius.gameserver.network.serverpackets.PledgeSkillList;
import com.l2jmobius.gameserver.network.serverpackets.QuestList;
import com.l2jmobius.gameserver.network.serverpackets.ServerClose;
import com.l2jmobius.gameserver.network.serverpackets.ShortCutInit;
import com.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
import com.l2jmobius.gameserver.network.serverpackets.SkillList;
@@ -138,6 +139,32 @@ public class EnterWorld implements IClientIncomingPacket
@Override
public void run(L2GameClient client)
{
// HWID
if (Config.HARDWARE_INFO_ENABLED)
{
if (client.getHardwareInfo() == null)
{
client.close(ServerClose.STATIC_PACKET);
return;
}
if (Config.MAX_PLAYERS_PER_HWID > 0)
{
int count = 0;
for (L2PcInstance player : L2World.getInstance().getPlayers())
{
if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo())))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
client.close(ServerClose.STATIC_PACKET);
return;
}
}
}
final L2PcInstance activeChar = client.getActiveChar();
if (activeChar == null)
{

View File

@@ -0,0 +1,85 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.network.clientpackets;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import com.l2jmobius.gameserver.network.client.L2GameClient;
/**
* @author Mobius
*/
public final class RequestHardWareInfo implements IClientIncomingPacket
{
private String _macAddress;
private int _windowsPlatformId;
private int _windowsMajorVersion;
private int _windowsMinorVersion;
private int _windowsBuildNumber;
private int _directxVersion;
private int _directxRevision;
private String _cpuName;
private int _cpuSpeed;
private int _cpuCoreCount;
private int _vgaCount;
private int _vgaPcxSpeed;
private int _physMemorySlot1;
private int _physMemorySlot2;
private int _physMemorySlot3;
private int _videoMemory;
private int _vgaVersion;
private String _vgaName;
private String _vgaDriverVersion;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
_macAddress = packet.readS();
_windowsPlatformId = packet.readD();
_windowsMajorVersion = packet.readD();
_windowsMinorVersion = packet.readD();
_windowsBuildNumber = packet.readD();
_directxVersion = packet.readD();
_directxRevision = packet.readD();
for (int i = 0; i < 16; i++)
{
packet.readC();
}
_cpuName = packet.readS();
_cpuSpeed = packet.readD();
_cpuCoreCount = packet.readC();
packet.readD();
_vgaCount = packet.readD();
_vgaPcxSpeed = packet.readD();
_physMemorySlot1 = packet.readD();
_physMemorySlot2 = packet.readD();
_physMemorySlot3 = packet.readD();
packet.readC();
_videoMemory = packet.readD();
packet.readD();
_vgaVersion = packet.readD();
_vgaName = packet.readS();
_vgaDriverVersion = packet.readS();
return true;
}
@Override
public void run(L2GameClient client)
{
client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion));
}
}