Patch for removal of broken code

Progress reports and musings from the developers on the current gaming tools.

Moderators: dorpond, trevor, Azhrei

Post Reply
User avatar
Flibbles
Kobold
Posts: 4
Joined: Tue May 29, 2012 2:41 am

Patch for removal of broken code

Post by Flibbles »

This patch includes the removal of some a bad distance method which is quite likely part of the java.lang.IllegalArgumentException thrown when using Java 7. Function is removed since a corresponding method exists within the Point2D class.

This fix was originally discussed in this thread.

The following is a patch file for the maptool trunk.

Code: Select all

Index: src/net/rptools/maptool/client/ui/zone/vbl/AreaMeta.java
===================================================================
--- src/net/rptools/maptool/client/ui/zone/vbl/AreaMeta.java	(revision 5862)
+++ src/net/rptools/maptool/client/ui/zone/vbl/AreaMeta.java	(working copy)
@@ -87,7 +87,7 @@
 		// TODO: This works ... in concept, but in practice it can create holes that pop outside of their parent bounds
 		// for really thin diagonal lines.  At some point this could be moved to a post processing step, after the 
 		// islands have been placed into their oceans.  But that's an optimization for another day
-//		if (lastPointNode != null && GeometryUtil.getDistance(lastPointNode.point, new Point2D.Float(x, y)) < 1.5) {
+//		if (lastPointNode != null && lastPointNode.point.distance(new Point2D.Float(x, y)) < 1.5) {
 //			skippedPoints++;
 //			return;
 //		}
Index: src/net/rptools/maptool/client/ui/zone/vbl/VisibleAreaSegment.java
===================================================================
--- src/net/rptools/maptool/client/ui/zone/vbl/VisibleAreaSegment.java	(revision 5862)
+++ src/net/rptools/maptool/client/ui/zone/vbl/VisibleAreaSegment.java	(working copy)
@@ -18,7 +18,6 @@
 import java.util.LinkedList;
 import java.util.List;
 
-import net.rptools.lib.GeometryUtil;
 import net.rptools.maptool.util.GraphicsUtil;
 
 public class VisibleAreaSegment implements Comparable<VisibleAreaSegment> {
@@ -40,7 +39,7 @@
 	}
 
 	public double getDistanceFromOrigin() {
-		return GeometryUtil.getDistance(getCenterPoint(), origin);
+		return origin.distance(getCenterPoint());
 	}
 
 	public Point2D getCenterPoint() {
@@ -115,8 +114,9 @@
 			throw new NullPointerException("compareTo() parameter is null");
 
 		double odist = o.getDistanceFromOrigin();
+		double dist = getDistanceFromOrigin();
 		// FJE Wouldn't it work to just use the following?
-		//		return getDistanceFromOrigin() - odist;
-		return getDistanceFromOrigin() < odist ? -1 : getDistanceFromOrigin() == odist ? 0 : 1;
+		//		return dist - odist;
+		return dist < odist ? -1 : dist == odist ? 0 : 1;
 	}
 }
And the following is for the rptool trunk

Code: Select all

Index: src/net/rptools/lib/GeometryUtil.java
===================================================================
--- src/net/rptools/lib/GeometryUtil.java	(revision 5862)
+++ src/net/rptools/lib/GeometryUtil.java	(working copy)
@@ -95,12 +95,6 @@
 		}
 	}
 
-	public static double getDistance(Point2D p1, Point2D p2) {
-		double a = p2.getX() - p1.getX();
-		double b = p2.getY() - p1.getY();
-		return Math.abs(Math.sqrt(a+b));
-	}
-	
 	public static Set<Line2D> getFrontFaces(PointNode nodeList, Point2D origin) {
 		
 		Set<Line2D> frontFaces = new HashSet<Line2D>();
If I'm making any mistake about how I'm submitting these patch files, please let me know. This is my first time submitting a patch.

I will also send these patch files to Azhrei.

username
Dragon
Posts: 277
Joined: Sun Sep 04, 2011 7:01 am

Re: Patch for removal of broken code

Post by username »

Thanks. Patches are preferred as text file attachment. But Azhrei can handle your way of delivery, I know that from experience :-)

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Patch for removal of broken code

Post by Azhrei »

I've received the patch and will commit it once I've looked at it. Just had two wisdom teeth pulled so it may be a day or two before I get to it. :)

Post Reply

Return to “Developer Notes”