Parcourir la source

BETA: Misc fixes:
* Fixing little npe from [5565]
* Reported by: Nik
* Excluding GMs from flood protector checks.
* Adding useful method getPlayersCountInRadius() in Util.
* Patch by: Tryskell
* Removing 1 useless method in L2PcInstance.

Rumen Nikiforov il y a 12 ans
Parent
commit
6acc3ec3de

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/AntiFeedManager.java

@@ -150,7 +150,7 @@ public class AntiFeedManager
 			return false; // no such event registered
 
 		final Integer addrHash = Integer.valueOf(client.getConnectionAddress().hashCode());
-		int limit = Config.L2JMOD_DUALBOX_CHECK_WHITELIST.get(addrHash);
+		int limit = Config.L2JMOD_DUALBOX_CHECK_WHITELIST.containsKey(addrHash) ? Config.L2JMOD_DUALBOX_CHECK_WHITELIST.get(addrHash) : 0;
 		limit = limit < 0 ? Integer.MAX_VALUE : limit + max;
 
 		Connections conns;

+ 22 - 29
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -10534,44 +10534,37 @@ public final class L2PcInstance extends L2Playable
 	}
 	
 	public void sendSkillList()
-	{
-		sendSkillList(this);
-	}
-	
-	public void sendSkillList(L2PcInstance player)
 	{
 		boolean isDisabled = false;
 		SkillList sl = new SkillList();
-		if (player != null)
+		
+		for (L2Skill s : getAllSkills())
 		{
-			for (L2Skill s : player.getAllSkills())
+			if (s == null)
+				continue;
+			if (s.getId() > 9000 && s.getId() < 9007)
+				continue; // Fake skills to change base stats
+			if (_transformation != null && (!containsAllowedTransformSkill(s.getId()) && !s.allowOnTransform()))
+				continue;
+			if (getClan() != null)
+				isDisabled = s.isClanSkill() && getClan().getReputationScore() < 0;
+			
+			boolean isEnchantable = SkillTable.getInstance().isEnchantable(s.getId());
+			if (isEnchantable)
 			{
-				if (s == null)
-					continue;
-				if (s.getId() > 9000 && s.getId() < 9007)
-					continue; // Fake skills to change base stats
-				if (_transformation != null && (!containsAllowedTransformSkill(s.getId()) && !s.allowOnTransform()))
-					continue;
-				if (player.getClan() != null)
-					isDisabled = s.isClanSkill() && player.getClan().getReputationScore() < 0;
-				
-				boolean isEnchantable = SkillTable.getInstance().isEnchantable(s.getId());
-				if (isEnchantable)
+				L2EnchantSkillLearn esl = EnchantGroupsData.getInstance().getSkillEnchantmentBySkillId(s.getId());
+				if (esl != null)
 				{
-					L2EnchantSkillLearn esl = EnchantGroupsData.getInstance().getSkillEnchantmentBySkillId(s.getId());
-					if (esl != null)
-					{
-						//if player dont have min level to enchant
-						if (s.getLevel() < esl.getBaseLevel())
-							isEnchantable = false;
-					}
-					// if no enchant data
-					else
+					// if player dont have min level to enchant
+					if (s.getLevel() < esl.getBaseLevel())
 						isEnchantable = false;
 				}
-				
-				sl.addSkill(s.getDisplayId(), s.getLevel(), s.isPassive(), isDisabled, isEnchantable);
+				// if no enchant data
+				else
+					isEnchantable = false;
 			}
+			
+			sl.addSkill(s.getDisplayId(), s.getLevel(), s.isPassive(), isDisabled, isEnchantable);
 		}
 		
 		sendPacket(sl);

+ 5 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/util/FloodProtectorAction.java

@@ -79,6 +79,11 @@ public final class FloodProtectorAction
 	{
 		final int curTick = GameTimeController.getGameTicks();
 		
+		if (_client.getActiveChar() != null && _client.getActiveChar().isGM())
+		{
+			return true;
+		}
+		
 		if ((curTick < _nextGameTick) || _punishmentInProgress)
 		{
 			if (_config.LOG_FLOODING && !_logged && _log.isLoggable(Level.WARNING))

+ 35 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/util/Util.java

@@ -17,6 +17,7 @@ package com.l2jserver.gameserver.util;
 import java.io.File;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
+import java.util.Collection;
 import java.util.Date;
 import java.util.List;
 
@@ -24,6 +25,7 @@ import javolution.text.TextBuilder;
 import javolution.util.FastList;
 
 import com.l2jserver.Config;
+import com.l2jserver.gameserver.GeoData;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.model.L2Object;
 import com.l2jserver.gameserver.model.actor.L2Character;
@@ -578,4 +580,37 @@ public final class Util
 		arg.add("0");
 		activeChar.sendPacket(new ShowBoard(arg));
 	}
+	
+	/**
+	 * Return the number of players in a defined radius.<br>
+	 * @param range : the radius.
+	 * @param npc : the object to make the test on.
+	 * @param playable : true counts summons and pets.
+	 * @param invisible : true counts invisible characters.
+	 * @return the number of targets found.
+	 */
+	public static int getPlayersCountInRadius(int range, L2Object npc, boolean playable, boolean invisible)
+	{
+		int count = 0;
+		final Collection<L2Object> objs = npc.getKnownList().getKnownObjects().values();
+		for (L2Object obj : objs)
+		{
+			if (obj != null && ((obj.isPlayable() && playable) || obj.isPet()))
+			{
+				if (obj.isPlayer() && !invisible)
+				{
+					if (obj.getActingPlayer().getAppearance().getInvisible())
+						continue;
+				}
+				
+				final L2Character cha = (L2Character) obj;
+				if (cha.getZ() < (npc.getZ() - 100) && cha.getZ() > (npc.getZ() + 100) || !(GeoData.getInstance().canSeeTarget(cha.getX(), cha.getY(), cha.getZ(), npc.getX(), npc.getY(), npc.getZ())))
+					continue;
+				
+				if (Util.checkIfInRange(range, npc, obj, true) && !cha.isDead())
+					count++;
+			}
+		}
+		return count;
+	}
 }