Explorar el Código

BETA: Misc rework:
* Rework of Point3D:
* Replacing x, y, z variables with Atomic and removing all sync blocks.
* Dropped all not used methods.
* Implemented IPositionable interface.
* Fixed some wrong spelled javadocs.
* Removed some other misc fixes.

Rumen Nikiforov hace 11 años
padre
commit
3d3aa8c2c8

+ 3 - 16
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/AdminTable.java

@@ -30,7 +30,6 @@ import javolution.util.FastMap;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 
-import com.l2jserver.Config;
 import com.l2jserver.gameserver.engines.DocumentParser;
 import com.l2jserver.gameserver.model.L2AccessLevel;
 import com.l2jserver.gameserver.model.L2AdminCommandAccessRight;
@@ -47,20 +46,16 @@ public class AdminTable extends DocumentParser
 {
 	private static final Map<Integer, L2AccessLevel> _accessLevels = new HashMap<>();
 	private static final Map<String, L2AdminCommandAccessRight> _adminCommandAccessRights = new HashMap<>();
-	private static final FastMap<L2PcInstance, Boolean> _gmList = new FastMap<>();
+	private static final Map<L2PcInstance, Boolean> _gmList = new FastMap<L2PcInstance, Boolean>().shared();
 	private int _highestLevel = 0;
 	
-	/**
-	 * Instantiates a new admin table.
-	 */
 	protected AdminTable()
 	{
-		_gmList.shared();
 		load();
 	}
 	
 	@Override
-	public void load()
+	public synchronized void load()
 	{
 		_accessLevels.clear();
 		_adminCommandAccessRights.clear();
@@ -188,7 +183,7 @@ public class AdminTable extends DocumentParser
 	 */
 	public boolean requireConfirm(String command)
 	{
-		L2AdminCommandAccessRight acar = _adminCommandAccessRights.get(command);
+		final L2AdminCommandAccessRight acar = _adminCommandAccessRights.get(command);
 		if (acar == null)
 		{
 			_log.info(getClass().getSimpleName() + ": No rights defined for admin command " + command + ".");
@@ -244,10 +239,6 @@ public class AdminTable extends DocumentParser
 	 */
 	public void addGm(L2PcInstance player, boolean hidden)
 	{
-		if (Config.DEBUG)
-		{
-			_log.fine("added gm: " + player.getName());
-		}
 		_gmList.put(player, hidden);
 	}
 	
@@ -257,10 +248,6 @@ public class AdminTable extends DocumentParser
 	 */
 	public void deleteGm(L2PcInstance player)
 	{
-		if (Config.DEBUG)
-		{
-			_log.fine("deleted gm: " + player.getName());
-		}
 		_gmList.remove(player);
 	}
 	

+ 5 - 6
L2J_Server_BETA/java/com/l2jserver/gameserver/model/L2AdminCommandAccessRight.java

@@ -25,9 +25,7 @@ import com.l2jserver.gameserver.datatables.AdminTable;
  */
 public class L2AdminCommandAccessRight
 {
-	/** The admin command */
-	private String _adminCommand = null;
-	/** The access levels which can use the admin command. */
+	private final String _adminCommand;
 	private final int _accessLevel;
 	private final boolean _requireConfirm;
 	
@@ -46,7 +44,6 @@ public class L2AdminCommandAccessRight
 	}
 	
 	/**
-	 * Returns the admin command the access right belongs to
 	 * @return the admin command the access right belongs to
 	 */
 	public String getAdminCommand()
@@ -55,9 +52,8 @@ public class L2AdminCommandAccessRight
 	}
 	
 	/**
-	 * Checks if the given characterAccessLevel is allowed to use the admin command which belongs to this access right.
 	 * @param characterAccessLevel
-	 * @return true if characterAccessLevel is allowed to use the admin command which belongs to this access right, otherwise false<br>
+	 * @return {@code true} if characterAccessLevel is allowed to use the admin command which belongs to this access right, {@code false} otherwise
 	 */
 	public boolean hasAccess(L2AccessLevel characterAccessLevel)
 	{
@@ -65,6 +61,9 @@ public class L2AdminCommandAccessRight
 		return ((accessLevel.getLevel() == characterAccessLevel.getLevel()) || characterAccessLevel.hasChildAccess(accessLevel));
 	}
 	
+	/**
+	 * @return {@code true} if admin command requires confirmation before execution, {@code false} otherwise.
+	 */
 	public boolean getRequireConfirm()
 	{
 		return _requireConfirm;

+ 8 - 10
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/ExStorageMaxCount.java

@@ -27,7 +27,6 @@ import com.l2jserver.gameserver.model.stats.Stats;
  */
 public class ExStorageMaxCount extends L2GameServerPacket
 {
-	private final L2PcInstance _activeChar;
 	private final int _inventory;
 	private final int _warehouse;
 	private final int _clan;
@@ -38,17 +37,16 @@ public class ExStorageMaxCount extends L2GameServerPacket
 	private final int _inventoryExtraSlots;
 	private final int _inventoryQuestItems;
 	
-	public ExStorageMaxCount(L2PcInstance character)
+	public ExStorageMaxCount(L2PcInstance activeChar)
 	{
-		_activeChar = character;
-		_inventory = _activeChar.getInventoryLimit();
-		_warehouse = _activeChar.getWareHouseLimit();
-		_privateSell = _activeChar.getPrivateSellStoreLimit();
-		_privateBuy = _activeChar.getPrivateBuyStoreLimit();
+		_inventory = activeChar.getInventoryLimit();
+		_warehouse = activeChar.getWareHouseLimit();
+		_privateSell = activeChar.getPrivateSellStoreLimit();
+		_privateBuy = activeChar.getPrivateBuyStoreLimit();
 		_clan = Config.WAREHOUSE_SLOTS_CLAN;
-		_receipeD = _activeChar.getDwarfRecipeLimit();
-		_recipe = _activeChar.getCommonRecipeLimit();
-		_inventoryExtraSlots = (int) _activeChar.getStat().calcStat(Stats.INV_LIM, 0, null, null);
+		_receipeD = activeChar.getDwarfRecipeLimit();
+		_recipe = activeChar.getCommonRecipeLimit();
+		_inventoryExtraSlots = (int) activeChar.getStat().calcStat(Stats.INV_LIM, 0, null, null);
 		_inventoryQuestItems = Config.INVENTORY_MAXIMUM_QUEST_ITEMS;
 	}
 	

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

@@ -22,7 +22,7 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.entity.RecoBonus;
 
 /**
- * ExVoteSystemInfo packet implemetation.
+ * ExVoteSystemInfo packet implementation.
  * @author Gnacik
  */
 public class ExVoteSystemInfo extends L2GameServerPacket

+ 53 - 88
L2J_Server_BETA/java/com/l2jserver/gameserver/util/Point3D.java

@@ -19,139 +19,104 @@
 package com.l2jserver.gameserver.util;
 
 import java.io.Serializable;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import com.l2jserver.gameserver.model.Location;
+import com.l2jserver.gameserver.model.interfaces.IPositionable;
 
 /**
- * This class ...
- * @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
+ * @author Unknown, UnAfraid
  */
-public class Point3D implements Serializable
+public class Point3D implements Serializable, IPositionable
 {
-	/**
-	 * Comment for <code>serialVersionUID</code>
-	 */
 	private static final long serialVersionUID = 4638345252031872576L;
 	
-	private volatile int _x, _y, _z;
-	
-	public Point3D(int pX, int pY, int pZ)
-	{
-		_x = pX;
-		_y = pY;
-		_z = pZ;
-	}
-	
-	public Point3D(int pX, int pY)
-	{
-		_x = pX;
-		_y = pY;
-		_z = 0;
-	}
+	private final AtomicInteger _x = new AtomicInteger();
+	private final AtomicInteger _y = new AtomicInteger();
+	private final AtomicInteger _z = new AtomicInteger();
 	
-	/**
-	 * @param worldPosition
-	 */
-	public Point3D(Point3D worldPosition)
+	public Point3D(int x, int y, int z)
 	{
-		_x = worldPosition._x;
-		_y = worldPosition._y;
-		_z = worldPosition._z;
+		_x.set(x);
+		_y.set(y);
+		_z.set(z);
 	}
 	
-	public synchronized void setTo(Point3D point)
+	public boolean equals(int x, int y, int z)
 	{
-		_x = point._x;
-		_y = point._y;
-		_z = point._z;
+		return (getX() == x) && (getY() == y) && (getZ() == z);
 	}
 	
 	@Override
-	public String toString()
+	public int getX()
 	{
-		return "(" + _x + ", " + _y + ", " + _z + ")";
+		return _x.get();
 	}
 	
-	@Override
-	public int hashCode()
+	public void setX(int x)
 	{
-		return _x ^ _y ^ _z;
+		_x.set(x);
 	}
 	
 	@Override
-	public boolean equals(Object o)
-	{
-		if (this == o)
-		{
-			return true;
-		}
-		if (o instanceof Point3D)
-		{
-			Point3D point3D = (Point3D) o;
-			boolean ret = (point3D._x == _x) && (point3D._y == _y) && (point3D._z == _z);
-			return ret;
-		}
-		return false;
-	}
-	
-	public boolean equals(int pX, int pY, int pZ)
-	{
-		return (_x == pX) && (_y == pY) && (_z == pZ);
-	}
-	
-	public long distanceSquaredTo(Point3D point)
-	{
-		long dx, dy;
-		dx = _x - point._x;
-		dy = _y - point._y;
-		return (dx * dx) + (dy * dy);
-	}
-	
-	public static long distanceSquared(Point3D point1, Point3D point2)
+	public int getY()
 	{
-		long dx, dy;
-		dx = point1._x - point2._x;
-		dy = point1._y - point2._y;
-		return (dx * dx) + (dy * dy);
+		return _y.get();
 	}
 	
-	public static boolean distanceLessThan(Point3D point1, Point3D point2, double distance)
+	public void setY(int y)
 	{
-		return distanceSquared(point1, point2) < (distance * distance);
+		_y.set(y);
 	}
 	
-	public int getX()
+	@Override
+	public int getZ()
 	{
-		return _x;
+		return _z.get();
 	}
 	
-	public synchronized void setX(int pX)
+	public void setZ(int z)
 	{
-		_x = pX;
+		_z.set(z);
 	}
 	
-	public int getY()
+	public void setXYZ(int x, int y, int z)
 	{
-		return _y;
+		_x.set(x);
+		_y.set(y);
+		_z.set(z);
 	}
 	
-	public synchronized void setY(int pY)
+	@Override
+	public Location getLocation()
 	{
-		_y = pY;
+		return new Location(getX(), getY(), getZ());
 	}
 	
-	public int getZ()
+	@Override
+	public String toString()
 	{
-		return _z;
+		return "(" + _x + ", " + _y + ", " + _z + ")";
 	}
 	
-	public synchronized void setZ(int pZ)
+	@Override
+	public int hashCode()
 	{
-		_z = pZ;
+		return getX() ^ getY() ^ getZ();
 	}
 	
-	public synchronized void setXYZ(int pX, int pY, int pZ)
+	@Override
+	public boolean equals(Object o)
 	{
-		_x = pX;
-		_y = pY;
-		_z = pZ;
+		if (this == o)
+		{
+			return true;
+		}
+		if (o instanceof Point3D)
+		{
+			final Point3D point3D = (Point3D) o;
+			return (point3D.getX() == getX()) && (point3D.getY() == getY()) && (point3D.getZ() == getZ());
+		}
+		return false;
 	}
 }