From ca209725bea816c1d69739001021c06aaf1b4830 Mon Sep 17 00:00:00 2001 From: iobyte Date: Sun, 25 Sep 2022 18:56:58 +0000 Subject: [PATCH] trackeditor: add debug validateLinks git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@8550 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 3b76c09a0138c7432b42fe3df877068e9f0bf702 Former-commit-id: 9962b28293f786d7e6bb7b4f5c982b84746eab44 --- .../trackeditor/gui/view/CircuitView.java | 6 +-- .../trackeditor/utils/SegmentVector.java | 52 +++++++++++++++++++ 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/src/tools/trackeditor/gui/view/CircuitView.java b/src/tools/trackeditor/gui/view/CircuitView.java index 3791d2b8f..f5ca6def3 100644 --- a/src/tools/trackeditor/gui/view/CircuitView.java +++ b/src/tools/trackeditor/gui/view/CircuitView.java @@ -444,7 +444,7 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene Editor.getProperties().setCurveNameCount(count2); newShape2.setName("curve " + count2); data.insertElementAt(newShape2, pos + 1); - //Undo.add(new UndoSplitSegment(cloneShape, newShape2)); + //Undo.add(new UndoSplitSegment(editorFrame, oldShape, cloneShape, newShape2)); break; } case "rgt": @@ -500,7 +500,7 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene Editor.getProperties().setCurveNameCount(count2); newShape2.setName("curve " + count2); data.insertElementAt(newShape2, pos + 1); - //Undo.add(new UndoSplitSegment(cloneShape, newShape2)); + //Undo.add(new UndoSplitSegment(editorFrame, oldShape, cloneShape, newShape2)); break; } case "str": @@ -534,7 +534,7 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene Editor.getProperties().setStraightNameCount(count3); newShape3.setName("straight " + count3); data.insertElementAt(newShape3, pos + 1); - //Undo.add(new UndoSplitSegment(cloneShape, newShape3)); + //Undo.add(new UndoSplitSegment(editorFrame, oldShape, cloneShape, newShape3)); break; } default: diff --git a/src/tools/trackeditor/utils/SegmentVector.java b/src/tools/trackeditor/utils/SegmentVector.java index 2dad16c43..d7c7c5ffc 100644 --- a/src/tools/trackeditor/utils/SegmentVector.java +++ b/src/tools/trackeditor/utils/SegmentVector.java @@ -118,4 +118,56 @@ public class SegmentVector extends Vector (get(i).nextShape != null ? get(i).nextShape.getName() : "null")); } } + + public boolean validateLinks() + { + boolean valid = true; + if (size() > 0) + { + if (get(0).getPreviousShape() != null) + { + System.out.println("segment[0] previousShape not null"); + valid = false; + } + + if (get(size() - 1).getNextShape() != null) + { + System.out.println("segment[" + (size() - 1) + "] nextShape not null"); + valid = false; + } + } + + for (int i = 0; i < size(); i++) + { + Segment segment = get(i); + + if (segment.previousShape == null && i != 0) + { + System.out.println("segment[" + i + "] previousShape null"); + valid = false; + } + + if (segment.previousShape != null && segment.previousShape.nextShape != null && + !segment.previousShape.nextShape.getName().equals(segment.getName())) + { + System.out.println("segment[" + i + "] previousShape bad"); + valid = false; + } + + if (segment.nextShape == null && i != size() - 1) + { + System.out.println("segment[" + i + "] nextShape null"); + valid = false; + } + + if (segment.nextShape != null && segment.nextShape.previousShape != null && + !segment.nextShape.previousShape.getName().equals(segment.getName())) + { + System.out.println("segment[" + i + "] nextShape bad"); + valid = false; + } + } + + return valid; + } }