소스 검색

PF node fixes and few mem leaks fixes

Julian 16 년 전
부모
커밋
7e3da6298c

+ 1 - 1
L2_GameServer/java/net/sf/l2j/gameserver/datatables/SkillTable.java

@@ -48,7 +48,7 @@ public class SkillTable
 		SkillsEngine.getInstance().loadAllSkills(_skills);
 	}
 	
-	public void reload()
+	public static void reload()
 	{
 		_instance = new SkillTable();
 	}

+ 20 - 9
L2_GameServer/java/net/sf/l2j/gameserver/model/L2Clan.java

@@ -690,10 +690,11 @@ public class L2Clan
 	public void updateClanInDB()
 	{
 		Connection con = null;
+		PreparedStatement statement = null;
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("UPDATE clan_data SET leader_id=?,ally_id=?,ally_name=?,reputation_score=?,ally_penalty_expiry_time=?,ally_penalty_type=?,char_penalty_expiry_time=?,dissolving_expiry_time=? WHERE clan_id=?");
+			statement = con.prepareStatement("UPDATE clan_data SET leader_id=?,ally_id=?,ally_name=?,reputation_score=?,ally_penalty_expiry_time=?,ally_penalty_type=?,char_penalty_expiry_time=?,dissolving_expiry_time=? WHERE clan_id=?");
 			statement.setInt(1, getLeaderId());
 			statement.setInt(2, getAllyId());
 			statement.setString(3, getAllyName());
@@ -704,7 +705,6 @@ public class L2Clan
 			statement.setLong(8, getDissolvingExpiryTime());
 			statement.setInt(9, getClanId());
 			statement.execute();
-			statement.close();
 			if (Config.DEBUG) _log.fine("New clan leader saved in db: "+getClanId());
 		}
 		catch (Exception e)
@@ -713,13 +713,24 @@ public class L2Clan
 		}
 		finally
 		{
-			try
-            {
-                con.close();
-            }
-            catch (Exception e)
-            {
-            }
+			if (statement != null)
+				try
+				{
+					statement.close();
+				}
+				catch (Exception e)
+				{
+					e.printStackTrace();
+				}
+			if (con != null)
+				try
+				{
+					con.close();
+				}
+				catch (Exception e)
+				{
+					e.printStackTrace();
+				}
 		}
 	}
 

+ 34 - 12
L2_GameServer/java/net/sf/l2j/gameserver/pathfinding/Node.java

@@ -70,16 +70,38 @@ public class Node
 	}
 
 	/**
-	 * @see java.lang.Object#equals(java.lang.Object)
-	 */
-	@Override
-	public boolean equals(Object arg0)
-	{
-		if(!(arg0 instanceof Node))
-			return false;
-		Node n = (Node)arg0;
-		
-		return _loc.getX() == n.getLoc().getX() && _loc.getY() == n.getLoc().getY()
-		&& _loc.getZ() == n.getLoc().getZ();
-	}
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode()
+    {
+	    final int prime = 31;
+	    int result = 1;
+	    result = prime * result + ((_loc == null) ? 0 : _loc.hashCode());
+	    return result;
+    }
+
+	/**
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(Object obj)
+    {
+	    if (this == obj)
+		    return true;
+	    if (obj == null)
+		    return false;
+	    if (!(obj instanceof Node))
+		    return false;
+	    final Node other = (Node) obj;
+	    if (_loc == null)
+	    {
+		    if (other._loc != null)
+			    return false;
+	    }
+	    else if (!_loc.equals(other._loc))
+		    return false;
+	    return true;
+    }
+	
 }

+ 36 - 0
L2_GameServer/java/net/sf/l2j/gameserver/pathfinding/cellnodes/NodeLoc.java

@@ -86,4 +86,40 @@ public class NodeLoc extends AbstractNodeLoc
 		return _y;
 	}
 
+	/**
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode()
+    {
+	    final int prime = 31;
+	    int result = 1;
+	    result = prime * result + _x;
+	    result = prime * result + _y;
+	    result = prime * result + _z;
+	    return result;
+    }
+
+	/**
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(Object obj)
+    {
+	    if (this == obj)
+		    return true;
+	    if (obj == null)
+		    return false;
+	    if (!(obj instanceof NodeLoc))
+		    return false;
+	    final NodeLoc other = (NodeLoc) obj;
+	    if (_x != other._x)
+		    return false;
+	    if (_y != other._y)
+		    return false;
+	    if (_z != other._z)
+		    return false;
+	    return true;
+    }
+
 }

+ 36 - 0
L2_GameServer/java/net/sf/l2j/gameserver/pathfinding/geonodes/GeoNodeLoc.java

@@ -79,4 +79,40 @@ public class GeoNodeLoc extends AbstractNodeLoc
 		return _y;
 	}
 
+	/**
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode()
+    {
+	    final int prime = 31;
+	    int result = 1;
+	    result = prime * result + _x;
+	    result = prime * result + _y;
+	    result = prime * result + _z;
+	    return result;
+    }
+
+	/**
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(Object obj)
+    {
+	    if (this == obj)
+		    return true;
+	    if (obj == null)
+		    return false;
+	    if (!(obj instanceof GeoNodeLoc))
+		    return false;
+	    final GeoNodeLoc other = (GeoNodeLoc) obj;
+	    if (_x != other._x)
+		    return false;
+	    if (_y != other._y)
+		    return false;
+	    if (_z != other._z)
+		    return false;
+	    return true;
+    }
+
 }

+ 1 - 1
L2_GameServer/java/net/sf/l2j/status/GameStatusThread.java

@@ -714,7 +714,7 @@ public class GameStatusThread extends Thread
                 		else if(type.equals("skill"))
                 		{
                 			_print.print("Reloading skills... ");
-                			SkillTable.getInstance().reload();
+                			SkillTable.reload();
                 			_print.print("done\n");
                 		}
                 		else if(type.equals("npc"))