Ver Fonte

BETA: L2PcInstance _reuseTimeStamps and _cubics use L2TIntObjectHashMap instead of shared fastmap :)

Nik há 13 anos atrás
pai
commit
19e750a90c

+ 12 - 11
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -265,6 +265,7 @@ import com.l2jserver.gameserver.templates.item.L2WeaponType;
 import com.l2jserver.gameserver.templates.skills.L2EffectType;
 import com.l2jserver.gameserver.templates.skills.L2SkillType;
 import com.l2jserver.gameserver.util.FloodProtectors;
+import com.l2jserver.gameserver.util.L2TIntObjectHashMap;
 import com.l2jserver.gameserver.util.PlayerEventStatus;
 import com.l2jserver.gameserver.util.Point3D;
 import com.l2jserver.gameserver.util.Util;
@@ -704,7 +705,7 @@ public final class L2PcInstance extends L2Playable
 	
 	protected boolean _inventoryDisable = false;
 	
-	protected Map<Integer, L2CubicInstance> _cubics = new FastMap<Integer, L2CubicInstance>().shared();
+	protected L2TIntObjectHashMap<L2CubicInstance> _cubics = new L2TIntObjectHashMap<L2CubicInstance>();
 	
 	/** Active shots. */
 	protected FastSet<Integer> _activeSoulShots = new FastSet<Integer>().shared();
@@ -5447,7 +5448,7 @@ public final class L2PcInstance extends L2Playable
 		// Unsummon Cubics
 		if (!_cubics.isEmpty())
 		{
-			for (L2CubicInstance cubic : _cubics.values())
+			for (L2CubicInstance cubic : _cubics.getValues(new L2CubicInstance[_cubics.size()]))
 			{
 				cubic.stopAction();
 				cubic.cancelDisappear();
@@ -7794,7 +7795,7 @@ public final class L2PcInstance extends L2Playable
 			
 			// Store the reuse delays of remaining skills which
 			// lost effect but still under reuse delay. 'restore_type' 1.
-			for (int hash : _reuseTimeStamps.keySet())
+			for (int hash : _reuseTimeStamps.keys())
 			{
 				if (storedSkills.contains(hash))
 					continue;
@@ -9441,7 +9442,7 @@ public final class L2PcInstance extends L2Playable
 		if (getCubics() != null)
 		{
 			boolean removed = false;
-			for (L2CubicInstance cubic : getCubics().values())
+			for (L2CubicInstance cubic : _cubics.getValues(new L2CubicInstance[_cubics.size()]))
 			{
 				cubic.stopAction();
 				delCubic(cubic.getId());
@@ -9457,7 +9458,7 @@ public final class L2PcInstance extends L2Playable
 		if (getCubics() != null)
 		{
 			boolean removed = false;
-			for (L2CubicInstance cubic : getCubics().values())
+			for (L2CubicInstance cubic : _cubics.getValues(new L2CubicInstance[_cubics.size()]))
 			{
 				if (cubic.givenByOther())
 				{
@@ -9519,7 +9520,7 @@ public final class L2PcInstance extends L2Playable
 		}
 	}
 	
-	public Map<Integer, L2CubicInstance> getCubics()
+	public L2TIntObjectHashMap<L2CubicInstance> getCubics()
 	{
 		return _cubics;
 	}
@@ -9935,7 +9936,7 @@ public final class L2PcInstance extends L2Playable
 		
 		if (!getCubics().isEmpty())
 		{
-			for (L2CubicInstance cubic : getCubics().values())
+			for (L2CubicInstance cubic : _cubics.getValues(new L2CubicInstance[_cubics.size()]))
 			{
 				cubic.stopAction();
 				cubic.cancelDisappear();
@@ -12980,17 +12981,17 @@ public final class L2PcInstance extends L2Playable
 			addSkill(SkillTable.getInstance().getInfo(5076, getDeathPenaltyBuffLevel()), false);
 	}
 	
-	private final FastMap<Integer, TimeStamp> _reuseTimeStamps = new FastMap<Integer, TimeStamp>().shared();
+	private final L2TIntObjectHashMap<TimeStamp> _reuseTimeStamps = new L2TIntObjectHashMap<TimeStamp>();
 	private boolean _canFeed;
 	private int _eventEffectId = 0;
 	private boolean _isInSiege;
 	
-	public Collection<TimeStamp> getReuseTimeStamps()
+	public TimeStamp[] getReuseTimeStamps()
 	{
-		return _reuseTimeStamps.values();
+		return _reuseTimeStamps.getValues(new TimeStamp[_reuseTimeStamps.size()]);
 	}
 	
-	public FastMap<Integer, TimeStamp> getReuseTimeStamp()
+	public L2TIntObjectHashMap<TimeStamp> getReuseTimeStamp()
 	{
 		return _reuseTimeStamps;
 	}

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/CharInfo.java

@@ -398,7 +398,7 @@ public class CharInfo extends L2GameServerPacket
 			writeC(_activeChar.getPrivateStoreType());   //  1 - sellshop
 			
 			writeH(_activeChar.getCubics().size());
-			for (int id : _activeChar.getCubics().keySet())
+			for (int id : _activeChar.getCubics().keys())
 				writeH(id);
 			
 			writeC(_activeChar.isInPartyMatchRoom() ? 1 : 0);

+ 9 - 8
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/SkillCoolTime.java

@@ -14,8 +14,9 @@
  */
 package com.l2jserver.gameserver.network.serverpackets;
 
-import java.util.Collection;
-import java.util.Iterator;
+import java.util.Collections;
+
+import javolution.util.FastList;
 
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance.TimeStamp;
@@ -27,16 +28,16 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance.TimeStamp;
  */
 public class SkillCoolTime extends L2GameServerPacket
 {
-	public Collection<TimeStamp> _reuseTimeStamps;
+	public FastList<TimeStamp> _reuseTimeStamps;
 	
 	public SkillCoolTime(L2PcInstance cha)
 	{
-		_reuseTimeStamps = cha.getReuseTimeStamps();
-		Iterator<TimeStamp> iter = _reuseTimeStamps.iterator();
-		while (iter.hasNext())
+		_reuseTimeStamps = new FastList<TimeStamp>();
+		Collections.addAll(_reuseTimeStamps, cha.getReuseTimeStamps());
+		for (TimeStamp ts : _reuseTimeStamps)
 		{
-			if (!iter.next().hasNotPassed()) // remove expired timestamps
-				iter.remove();
+			if (!ts.hasNotPassed())
+				_reuseTimeStamps.remove(ts);
 		}
 	}
 	

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java

@@ -330,7 +330,7 @@ public final class UserInfo extends L2GameServerPacket
 		writeD(_activeChar.getPvpKills());
 		
 		writeH(_activeChar.getCubics().size());
-		for (int id : _activeChar.getCubics().keySet())
+		for (int id : _activeChar.getCubics().keys())
 			writeH(id);
 		
 		writeC(_activeChar.isInPartyMatchRoom() ? 1 : 0);

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/skills/l2skills/L2SkillSummon.java

@@ -161,7 +161,7 @@ public class L2SkillSummon extends L2Skill
 					if (mastery == 0 && !player.getCubics().isEmpty())
 					{
 						// Player can have only 1 cubic - we shuld replace old cubic with new one
-						for (L2CubicInstance c: player.getCubics().values())
+						for (L2CubicInstance c: player.getCubics().getValues(new L2CubicInstance[player.getCubics().size()]))
 						{
 							c.stopAction();
 							c = null;

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/taskmanager/AttackStanceTaskManager.java

@@ -64,7 +64,7 @@ public class AttackStanceTaskManager
 		if (actor instanceof L2PcInstance)
 		{
 			L2PcInstance player = (L2PcInstance) actor;
-			for (L2CubicInstance cubic : player.getCubics().values())
+			for (L2CubicInstance cubic : player.getCubics().getValues(new L2CubicInstance[player.getCubics().size()]))
 				if (cubic.getId() != L2CubicInstance.LIFE_CUBIC)
 					cubic.doAction();
 		}