瀏覽代碼

BETA: Cubic related fixes:
* Moving cubics back to FastMap (reverting that from [4797]).
* Fixed cubics not removed on subclass change, etc (stopCubics() method) by Starter, thanks.
* Cleaned up for useless booleans, etc.
* AttackStanceTaskManager logic fix.
* Avoiding using accessors inside the class where the field is declared.

Zoey76 13 年之前
父節點
當前提交
bbef185e0e

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

@@ -281,7 +281,6 @@ import com.l2jserver.gameserver.scripting.scriptengine.listeners.player.Professi
 import com.l2jserver.gameserver.scripting.scriptengine.listeners.player.TransformListener;
 import com.l2jserver.gameserver.scripting.scriptengine.listeners.player.TransformListener;
 import com.l2jserver.gameserver.taskmanager.AttackStanceTaskManager;
 import com.l2jserver.gameserver.taskmanager.AttackStanceTaskManager;
 import com.l2jserver.gameserver.util.FloodProtectors;
 import com.l2jserver.gameserver.util.FloodProtectors;
-import com.l2jserver.gameserver.util.L2TIntObjectHashMap;
 import com.l2jserver.gameserver.util.PlayerEventStatus;
 import com.l2jserver.gameserver.util.PlayerEventStatus;
 import com.l2jserver.gameserver.util.Point3D;
 import com.l2jserver.gameserver.util.Point3D;
 import com.l2jserver.gameserver.util.Util;
 import com.l2jserver.gameserver.util.Util;
@@ -653,7 +652,7 @@ public final class L2PcInstance extends L2Playable
 	private boolean _minimapAllowed = false;
 	private boolean _minimapAllowed = false;
 	
 	
 	// client radar
 	// client radar
-	//TODO: This needs to be better intergrated and saved/loaded
+	//TODO: This needs to be better integrated and saved/loaded
 	private L2Radar _radar;
 	private L2Radar _radar;
 	
 	
 	// Party matching
 	// Party matching
@@ -758,7 +757,7 @@ public final class L2PcInstance extends L2Playable
 	
 	
 	protected boolean _inventoryDisable = false;
 	protected boolean _inventoryDisable = false;
 	
 	
-	private L2TIntObjectHashMap<L2CubicInstance> _cubics = new L2TIntObjectHashMap<>();
+	private final FastMap<Integer, L2CubicInstance> _cubics = new FastMap<>();
 	
 	
 	/** Active shots. */
 	/** Active shots. */
 	protected FastSet<Integer> _activeSoulShots = new FastSet<Integer>().shared();
 	protected FastSet<Integer> _activeSoulShots = new FastSet<Integer>().shared();
@@ -1294,6 +1293,8 @@ public final class L2PcInstance extends L2Playable
 		_radar = new L2Radar(this);
 		_radar = new L2Radar(this);
 		
 		
 		startVitalityTask();
 		startVitalityTask();
+		
+		_cubics.shared();
 	}
 	}
 	
 	
 	private L2PcInstance(int objectId)
 	private L2PcInstance(int objectId)
@@ -5699,12 +5700,11 @@ public final class L2PcInstance extends L2Playable
 		// Unsummon Cubics
 		// Unsummon Cubics
 		if (!_cubics.isEmpty())
 		if (!_cubics.isEmpty())
 		{
 		{
-			for (L2CubicInstance cubic : _cubics.values(new L2CubicInstance[0]))
+			for (L2CubicInstance cubic : _cubics.values())
 			{
 			{
 				cubic.stopAction();
 				cubic.stopAction();
 				cubic.cancelDisappear();
 				cubic.cancelDisappear();
 			}
 			}
-			
 			_cubics.clear();
 			_cubics.clear();
 		}
 		}
 		
 		
@@ -9871,36 +9871,32 @@ public final class L2PcInstance extends L2Playable
 	
 	
 	public final void stopCubics()
 	public final void stopCubics()
 	{
 	{
-		if (getCubics() != null)
+		if (!_cubics.isEmpty())
 		{
 		{
-			boolean removed = false;
-			for (L2CubicInstance cubic : _cubics.values(new L2CubicInstance[0]))
+			for (L2CubicInstance cubic : _cubics.values())
 			{
 			{
 				cubic.stopAction();
 				cubic.stopAction();
-				delCubic(cubic.getId());
-				removed = true;
+				cubic.cancelDisappear();
 			}
 			}
-			if (removed)
-				broadcastUserInfo();
+			_cubics.clear();
+			broadcastUserInfo();
 		}
 		}
 	}
 	}
 	
 	
 	public final void stopCubicsByOthers()
 	public final void stopCubicsByOthers()
 	{
 	{
-		if (getCubics() != null)
+		if (!_cubics.isEmpty())
 		{
 		{
-			boolean removed = false;
-			for (L2CubicInstance cubic : _cubics.values(new L2CubicInstance[0]))
+			for (L2CubicInstance cubic : _cubics.values())
 			{
 			{
 				if (cubic.givenByOther())
 				if (cubic.givenByOther())
 				{
 				{
 					cubic.stopAction();
 					cubic.stopAction();
-					delCubic(cubic.getId());
-					removed = true;
+					cubic.cancelDisappear();
 				}
 				}
 			}
 			}
-			if (removed)
-				broadcastUserInfo();
+			_cubics.clear();
+			broadcastUserInfo();
 		}
 		}
 	}
 	}
 	
 	
@@ -9952,7 +9948,7 @@ public final class L2PcInstance extends L2Playable
 		}
 		}
 	}
 	}
 	
 	
-	public L2TIntObjectHashMap<L2CubicInstance> getCubics()
+	public FastMap<Integer, L2CubicInstance> getCubics()
 	{
 	{
 		return _cubics;
 		return _cubics;
 	}
 	}
@@ -9971,10 +9967,10 @@ public final class L2PcInstance extends L2Playable
 	public void addCubic(int id, int level, double matk, int activationtime, int activationchance, int maxcount, int totalLifetime, boolean givenByOther)
 	public void addCubic(int id, int level, double matk, int activationtime, int activationchance, int maxcount, int totalLifetime, boolean givenByOther)
 	{
 	{
 		if (Config.DEBUG)
 		if (Config.DEBUG)
+		{
 			_log.info("L2PcInstance(" + getName() + "): addCubic(" + id + "|" + level + "|" + matk + ")");
 			_log.info("L2PcInstance(" + getName() + "): addCubic(" + id + "|" + level + "|" + matk + ")");
-		L2CubicInstance cubic = new L2CubicInstance(this, id, level, (int) matk, activationtime, activationchance, maxcount, totalLifetime, givenByOther);
-		
-		_cubics.put(id, cubic);
+		}
+		_cubics.put(id, new L2CubicInstance(this, id, level, (int) matk, activationtime, activationchance, maxcount, totalLifetime, givenByOther));
 	}
 	}
 	
 	
 	/**
 	/**
@@ -10377,15 +10373,14 @@ public final class L2PcInstance extends L2Playable
 		
 		
 		stopEffects(L2EffectType.HIDE);
 		stopEffects(L2EffectType.HIDE);
 		
 		
-		if (!getCubics().isEmpty())
+		if (!_cubics.isEmpty())
 		{
 		{
-			for (L2CubicInstance cubic : _cubics.values(new L2CubicInstance[0]))
+			for (L2CubicInstance cubic : _cubics.values())
 			{
 			{
 				cubic.stopAction();
 				cubic.stopAction();
 				cubic.cancelDisappear();
 				cubic.cancelDisappear();
 			}
 			}
-			
-			getCubics().clear();
+			_cubics.clear();
 		}
 		}
 		
 		
 		if (getParty() != null)
 		if (getParty() != null)

+ 2 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillSummon.java

@@ -164,13 +164,12 @@ public class L2SkillSummon extends L2Skill
 					int mastery = player.getSkillLevel(SKILL_CUBIC_MASTERY);
 					int mastery = player.getSkillLevel(SKILL_CUBIC_MASTERY);
 					if (mastery < 0)
 					if (mastery < 0)
 						mastery = 0;
 						mastery = 0;
-					if (mastery == 0 && !player.getCubics().isEmpty())
+					if ((mastery == 0) && !player.getCubics().isEmpty())
 					{
 					{
 						// Player can have only 1 cubic - we should replace old cubic with new one
 						// Player can have only 1 cubic - we should replace old cubic with new one
-						for (L2CubicInstance c: player.getCubics().values(new L2CubicInstance[0]))
+						for (L2CubicInstance c : player.getCubics().values())
 						{
 						{
 							c.stopAction();
 							c.stopAction();
-							c = null;
 						}
 						}
 						player.getCubics().clear();
 						player.getCubics().clear();
 					}
 					}

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

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

+ 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());
 		writeD(_activeChar.getPvpKills());
 		
 		
 		writeH(_activeChar.getCubics().size());
 		writeH(_activeChar.getCubics().size());
-		for (int id : _activeChar.getCubics().keys())
+		for (int id : _activeChar.getCubics().keySet())
 			writeH(id);
 			writeH(id);
 		
 		
 		writeC(_activeChar.isInPartyMatchRoom() ? 1 : 0);
 		writeC(_activeChar.isInPartyMatchRoom() ? 1 : 0);

+ 3 - 8
L2J_Server_BETA/java/com/l2jserver/gameserver/taskmanager/AttackStanceTaskManager.java

@@ -48,15 +48,10 @@ public class AttackStanceTaskManager
 	
 	
 	public void addAttackStanceTask(L2Character actor)
 	public void addAttackStanceTask(L2Character actor)
 	{
 	{
-		if (actor instanceof L2Summon)
-		{
-			L2Summon summon = (L2Summon) actor;
-			actor = summon.getOwner();
-		}
-		if (actor instanceof L2PcInstance)
+		if ((actor != null) && actor.isPlayable())
 		{
 		{
-			L2PcInstance player = (L2PcInstance) actor;
-			for (L2CubicInstance cubic : player.getCubics().values(new L2CubicInstance[0]))
+			final L2PcInstance player = actor.getActingPlayer();
+			for (L2CubicInstance cubic : player.getCubics().values())
 			{
 			{
 				if (cubic.getId() != L2CubicInstance.LIFE_CUBIC)
 				if (cubic.getId() != L2CubicInstance.LIFE_CUBIC)
 				{
 				{