Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix this thing aka RouteDrawer again... #1231

Merged
merged 2 commits into from
Sep 14, 2016
Merged

Fix this thing aka RouteDrawer again... #1231

merged 2 commits into from
Sep 14, 2016

Conversation

RoiEXLab
Copy link
Member

@RoiEXLab RoiEXLab commented Sep 13, 2016

Hopefully forever!
@DanVanAtta I was too lazy to undo all the changes, so I created a fix!
I removed a couple of usages of the normalizePoint method!
The only possible downside of this could be, that maybe when scrolling to far away from a route (when watching history the route may become invisible if this ever happens we need to simply increase the mirroring radius from 2 -> 9 screens to 3 -> 16 screens which means less performance for the user)

Based on pre #1199

If you didn't guess already this fixes #1056


This change is Reviewable

Hopefully forever
@@ -190,6 +244,7 @@ private int getAlternativePointArrayCount() {
result.add(new Line2D.Double(points[0], points[1]));
}
}
result.forEach(e -> e = null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are all elements being set to null.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woooops forgot this

new Point2D.Double(point.getX() + mapWidth, point.getY() - mapHeight),
new Point2D.Double(point.getX() + mapWidth, point.getY() + mapHeight)));
}
if (isInfiniteX) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If both isInfiniteX and isInfiniteY are true, this if statement will also be executed. Given the points are added, they look redundant, yet are different. What is the purpose of these points that are being added, and how are we computing the indexes? It's not clear the reasoning behind these values.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intended! When isInfiniteY we want the point-clones above and below the center..., when isInfiniteX we want the ones left and right the center, but if both are we also want the clones in the upper left, upper right, lower right and lower left.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, please note that in the code as a comment so we have that context there. (I prefer when code is self documenting through method and variable names, but the point is to get the contextual information of why this is being done captured in the code one way or another.) I recently had to look at a git history, back track changes to their commit dates, look for PRs on those dates to then find review discussion that actually told me why some code was the way it was. You can probably guess that was an enjoyable and efficient process ;)

@RoiEXLab
Copy link
Member Author

@DanVanAtta It's very hard to explain here how my system works.
Basically we are calculating the shortest route - independent of mapBorders. After that we are cloning this route between 0 to 2 to 8 times (Thats the reason for the weird values) with a map length offset so that we are seeing the same route drawn 1 map length in NW N NE W C E SW S SE if those regions are available (on a only x infinite map we only need W C E).

@RoiEXLab
Copy link
Member Author

RoiEXLab commented Sep 13, 2016

@DanVanAtta I understand your good intentions, but my time is limited, and therefore it might take a day or two until I added tests etc.
If thats not fast enough you have 2 options:
Either you merge this without further work and I'll promise you that I'm going to add the tests right after JavFX,
or you use the new github PR feature and implement those tests/documentation on your own.
Don't get me wrong, but I'm currently just happy, that this fix was that easy and want it to be pushed as soon as possible...

@DanVanAtta
Copy link
Member

Gave the route drawer a good testing on WaW, and on HexGlobe (has both X + Y wrap) - looked good 👍

@DanVanAtta
Copy link
Member

I might be able to give you a hand with retrofitting some unit tests.

In hindsight, making sure everything is pretty solid, tested, and potentially shipped sooner, is paramount. I don't think the mass regression test has been that successful. .. With that said, yeah. Let's get 1.9 out.. @RoiEXLab , I 'll hold you to your word to revisit the route drawer!

@DanVanAtta DanVanAtta merged commit ab10cf0 into triplea-game:master Sep 14, 2016
@RoiEXLab RoiEXLab deleted the fixRouteDrawer branch September 14, 2016 09:11
@RoiEXLab
Copy link
Member Author

@DanVanAtta Thanks! I wont let you down!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Arrow drawing bug- unnecessary horizontal line being drawn
2 participants