Преглед изворни кода

to make you all happy, thx Intrepid and Cobra

janiii пре 15 година
родитељ
комит
d67dee93d9

+ 3 - 0
L2_GameServer/java/com/l2jserver/Config.java

@@ -678,6 +678,7 @@ public final class Config
 	public static List<String> L2JMOD_MULTILANG_ALLOWED = new ArrayList<String>();
 	public static String L2JMOD_MULTILANG_DEFAULT;
 	public static boolean L2JMOD_MULTILANG_VOICED_ALLOW;
+	public static boolean L2WALKER_PROTECTION;
 
 	//--------------------------------------------------
 	// NPC Settings
@@ -2250,6 +2251,8 @@ public final class Config
 					if (!L2JMOD_MULTILANG_ALLOWED.contains(L2JMOD_MULTILANG_DEFAULT))
 						_log.warning("MultiLang[Config.load()]: default language: " + L2JMOD_MULTILANG_DEFAULT + " is not in allowed list !");
 					L2JMOD_MULTILANG_VOICED_ALLOW = Boolean.parseBoolean(L2JModSettings.getProperty("MultiLangVoiceCommand", "True"));
+					
+					L2WALKER_PROTECTION = Boolean.parseBoolean(L2JModSettings.getProperty("L2WalkerProtection", "False"));
 				}
 				catch (Exception e)
 				{

+ 46 - 42
L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/MoveBackwardToLocation.java

@@ -23,7 +23,7 @@ import com.l2jserver.gameserver.model.L2CharPosition;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
 import com.l2jserver.gameserver.network.serverpackets.PartyMemberPosition;
-
+import com.l2jserver.gameserver.util.Util;
 
 /**
  * This class ...
@@ -34,48 +34,53 @@ public class MoveBackwardToLocation extends L2GameClientPacket
 {
 	//private static Logger _log = Logger.getLogger(MoveBackwardToLocation.class.getName());
 	// cdddddd
-	private       int _targetX;
-	private       int _targetY;
-	private       int _targetZ;
+	private int _targetX;
+	private int _targetY;
+	private int _targetZ;
 	@SuppressWarnings("unused")
-    private int _originX;
+	private int _originX;
 	@SuppressWarnings("unused")
-    private int _originY;
+	private int _originY;
 	@SuppressWarnings("unused")
-    private int _originZ;
-	private       int _moveMovement;
-
-    //For geodata
-    private       int _curX;
-    private       int _curY;
-    @SuppressWarnings("unused")
-    private       int _curZ;
-
-	public TaskPriority getPriority() { return TaskPriority.PR_HIGH; }
-
+	private int _originZ;
+	private int _moveMovement;
+	
+	//For geodata
+	private int _curX;
+	private int _curY;
+	@SuppressWarnings("unused")
+	private int _curZ;
+	
+	public TaskPriority getPriority()
+	{
+		return TaskPriority.PR_HIGH;
+	}
+	
 	private static final String _C__01_MOVEBACKWARDTOLOC = "[C] 01 MoveBackwardToLoc";
-
-
+	
 	@Override
 	protected void readImpl()
 	{
-		_targetX  = readD();
-		_targetY  = readD();
-		_targetZ  = readD();
-		_originX  = readD();
-		_originY  = readD();
-		_originZ  = readD();
+		_targetX = readD();
+		_targetY = readD();
+		_targetZ = readD();
+		_originX = readD();
+		_originY = readD();
+		_originZ = readD();
 		try
 		{
 			_moveMovement = readD(); // is 0 if cursor keys are used  1 if mouse is used
 		}
 		catch (BufferUnderflowException e)
 		{
-			// ignore for now
+			if (Config.L2WALKER_PROTECTION)
+			{
+				L2PcInstance activeChar = getClient().getActiveChar();
+				Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is trying to use L2Walker and got kicked.", Config.DEFAULT_PUNISH);
+			}
 		}
 	}
-
-
+	
 	@Override
 	protected void runImpl()
 	{
@@ -91,10 +96,10 @@ public class MoveBackwardToLocation extends L2GameClientPacket
 		_targetZ += activeChar.getTemplate().collisionHeight;
 		
 		_curX = activeChar.getX();
-        _curY = activeChar.getY();
-        _curZ = activeChar.getZ();
-
-		if(activeChar.isInBoat())
+		_curY = activeChar.getY();
+		_curZ = activeChar.getZ();
+		
+		if (activeChar.isInBoat())
 		{
 			activeChar.setInBoat(false);
 		}
@@ -106,29 +111,28 @@ public class MoveBackwardToLocation extends L2GameClientPacket
 			activeChar.teleToLocation(_targetX, _targetY, _targetZ, false);
 			return;
 		}
-
+		
 		if (_moveMovement == 0 && Config.GEODATA < 1) // cursor movement without geodata is disabled
 		{
 			activeChar.sendPacket(ActionFailed.STATIC_PACKET);
 		}
 		else
 		{
-			double dx = _targetX-_curX;
-			double dy = _targetY-_curY;
+			double dx = _targetX - _curX;
+			double dy = _targetY - _curY;
 			// Can't move if character is confused, or trying to move a huge distance
-			if (activeChar.isOutOfControl() || ((dx*dx+dy*dy) > 98010000)) // 9900*9900
+			if (activeChar.isOutOfControl() || ((dx * dx + dy * dy) > 98010000)) // 9900*9900
 			{
 				activeChar.sendPacket(ActionFailed.STATIC_PACKET);
 				return;
 			}
-			activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO,
-					new L2CharPosition(_targetX, _targetY, _targetZ, 0));
-
-			if(activeChar.getParty() != null)
-				activeChar.getParty().broadcastToPartyMembers(activeChar,new PartyMemberPosition(activeChar));
+			activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(_targetX, _targetY, _targetZ, 0));
+			
+			if (activeChar.getParty() != null)
+				activeChar.getParty().broadcastToPartyMembers(activeChar, new PartyMemberPosition(activeChar));
 		}
 	}
-
+	
 	/* (non-Javadoc)
 	 * @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
 	 */

+ 40 - 12
L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/Say2.java

@@ -27,6 +27,7 @@ import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.network.SystemMessageId;
 import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
+import com.l2jserver.gameserver.util.Util;
 
 
 /**
@@ -39,7 +40,7 @@ public final class Say2 extends L2GameClientPacket
 	private static final String _C__38_SAY2 = "[C] 38 Say2";
 	private static Logger _log = Logger.getLogger(Say2.class.getName());
 	private static Logger _logChat = Logger.getLogger("chat");
-
+	
 	public final static int ALL = 0;
 	public final static int SHOUT = 1; //!
 	public final static int TELL = 2;
@@ -51,12 +52,18 @@ public final class Say2 extends L2GameClientPacket
 	public final static int TRADE = 8; //+
 	public final static int ALLIANCE = 9; //$
 	public final static int ANNOUNCEMENT = 10;
+	public final static int CUSTOM = 11;
+	public final static int L2FRIEND = 12;
+	public final static int MSNCHAT = 13;
 	public final static int PARTYMATCH_ROOM = 14;
 	public final static int PARTYROOM_COMMANDER = 15; //(Yellow)
 	public final static int PARTYROOM_ALL = 16; //(Red)
 	public final static int HERO_VOICE = 17;
+	public final static int CRITICAL_ANNOUNCE = 18;
+	public final static int SCREEN_ANNOUNCE = 19;
 	public final static int BATTLEFIELD = 20;
-
+	public final static int MPCC_ROOM = 21;
+	
 	private final static String[] CHAT_NAMES =
 	{
 		"ALL",
@@ -70,22 +77,27 @@ public final class Say2 extends L2GameClientPacket
 		"TRADE",
 		"ALLIANCE",
 		"ANNOUNCEMENT", //10
-		"WILLCRASHCLIENT:)",
-		"FAKEALL?",
-		"FAKEALL?",
+		"CUSTOM",
+		"L2FRIEND",
+		"MSNCHAT",
 		"PARTYMATCH_ROOM",
-		"PARTYROOM_ALL",
 		"PARTYROOM_COMMANDER",
+		"PARTYROOM_ALL",
 		"HERO_VOICE",
-		"UNKNOWN",
-		"UNKNOWN",
-		"BATTLEFIELD"
+		"CRITICAL_ANNOUNCE",
+		"SCREEN_ANNOUNCE",
+		"BATTLEFIELD",
+		"MPCC_ROOM"
 	};
-
+	
+	private static final String[] WALKER_COMMAND_LIST = { "USESKILL", "USEITEM", "BUYITEM", "SELLITEM", "SAVEITEM", "LOADITEM", "MSG", "SET", "DELAY", "LABEL", "JMP", "CALL",
+		"RETURN", "MOVETO", "NPCSEL", "NPCDLG", "DLGSEL", "CHARSTATUS", "POSOUTRANGE", "POSINRANGE", "GOHOME", "SAY", "EXIT", "PAUSE", "STRINDLG", "STRNOTINDLG", "CHANGEWAITTYPE",
+		"FORCEATTACK", "ISMEMBER", "REQUESTJOINPARTY", "REQUESTOUTPARTY", "QUITPARTY", "MEMBERSTATUS", "CHARBUFFS", "ITEMCOUNT", "FOLLOWTELEPORT" };
+	
 	private String _text;
 	private int _type;
 	private String _target;
-
+	
 	@Override
 	protected void readImpl()
 	{
@@ -93,7 +105,7 @@ public final class Say2 extends L2GameClientPacket
 		_type = readD();
 		_target = (_type == TELL) ? readS() : null;
 	}
-
+	
 	@Override
 	protected void runImpl()
 	{
@@ -123,6 +135,12 @@ public final class Say2 extends L2GameClientPacket
 			activeChar.sendPacket(new SystemMessage(SystemMessageId.DONT_SPAM));
 			return;
 		}
+		
+		if (Config.L2WALKER_PROTECTION && _type == TELL && checkBot(_text))
+		{
+			Util.handleIllegalPlayerAction(activeChar, "Client Emulator Detect: Player " + activeChar.getName() + " using l2walker.", Config.DEFAULT_PUNISH);
+			return;
+		}
 
 		if (activeChar.isCursedWeaponEquipped() && (_type == TRADE || _type == SHOUT))
 		{
@@ -178,6 +196,16 @@ public final class Say2 extends L2GameClientPacket
 			handler.handleChat(_type, activeChar, _target, _text);
 	}
 	
+	private boolean checkBot(String text)
+	{
+		for (String botCommand : WALKER_COMMAND_LIST)
+		{
+			if (text.startsWith(botCommand))
+				return true;
+		}
+		return false;
+	}
+	
 	private void checkText()
 	{
 		String filteredText = _text;

+ 8 - 0
L2_GameServer/java/config/l2jmods.properties

@@ -277,6 +277,7 @@ DisplayServerTime = False
 ScreenWelcomeMessageEnable = False
 
 # Screen welcome message text to show on character login if enabled
+# ('#' for a new line, but message can have max 2 lines)
 ScreenWelcomeMessageText = Welcome to L2J server!
 
 # Show screen welcome message for x seconds when character log in to game if enabled
@@ -355,3 +356,10 @@ MultiLangDefault = en
 # Default: True
 MultiLangVoiceCommand = True
 
+
+# ---------------------------------------------------------------------------
+# Walker/Bot protection
+# ---------------------------------------------------------------------------
+# Basic protection against L2Walker.
+# Default: False
+L2WalkerProtection = False