[messages] [Developers] Test builds for 3.3.0

Malnorma malnormacxio at gmail.com
Sun Oct 20 05:27:37 CEST 2019


On the null reference error, I believe I've found an explanation.  It
happens when the max visible size of the Deck is less than the total
number of cards in it, because the return value of
StackMetrics.getContents is ignored, but it has not populated the entire
positions array.  This patch avoids the issue (but there may be a better
fix, I do not know the project that well):


Code:

Index: src/VASSAL/build/module/map/StackMetrics.java
===================================================================
--- src/VASSAL/build/module/map/StackMetrics.java	(revision 9280)
+++ src/VASSAL/build/module/map/StackMetrics.java	(working copy)
@@ -320,7 +320,7 @@
     Rectangle region = visibleRect == null ? null :
map.mapRectangle(visibleRect);
     Point[] positions = new Point[stack.getPieceCount()];
     Rectangle[] bounds = region == null ? null : new
Rectangle[stack.getPieceCount()];
-    getContents(stack, positions, null, bounds, mapLocation.x,
mapLocation.y);
+    int limit = getContents(stack, positions, null, bounds,
mapLocation.x, mapLocation.y);
 
     for (PieceIterator e = new PieceIterator(stack.getPiecesIterator(),
                                              unselectedVisible);
@@ -327,6 +327,7 @@
          e.hasMoreElements();) {
       GamePiece next = e.nextPiece();
       int index = stack.indexOf(next);
+      if (index >= limit) continue;
       Point pt = map.componentCoordinates(positions[index]);
       if (bounds == null || isVisible(region, bounds[index])) {
         if (stack.isExpanded() || !e.hasMoreElements()) {




_______________________________________________
Read this topic online here:
http://www.vassalengine.org/forum/viewtopic.php?p=57812#p57812


More information about the messages mailing list