Possible Bug 3.7.0? Negative Increments and wrap-around in IncrementProperty

Hi all;
This my first Technical problem so hope I get this right…

Problem : I have a Toggle Switch called “Long Range missions” that appears when the Expansion “Queen In Germany” is activated. When you click on the toggle switch it supposed to change a Level on the Tactical display, a click sound is heard, and the toggle flicks up with a Green Light. This worked fine in 3.6.19 - it does not work in 3.7.0, instead I get a Internal error notification which I have filled out and sent this error to you.

The log file for this error is below…

2023-09-09 17:28:42,134 [6016-main] INFO  VASSAL.launch.StartUp - Starting
2023-09-09 17:28:42,134 [6016-main] INFO  VASSAL.launch.StartUp - OS Windows 11 10.0 amd64
2023-09-09 17:28:42,134 [6016-main] INFO  VASSAL.launch.StartUp - Java version 20.0.2
2023-09-09 17:28:42,134 [6016-main] INFO  VASSAL.launch.StartUp - Java home C:\Program Files\VASSAL-3.7.0\jre
2023-09-09 17:28:42,134 [6016-main] INFO  VASSAL.launch.StartUp - VASSAL version 3.7.0
2023-09-09 17:28:42,243 [6016-AWT-EventQueue-0] INFO  VASSAL.launch.ModuleManager - Manager
2023-09-09 17:28:43,454 [6016-SwingWorker-pool-2-thread-1] INFO  VASSAL.launch.AbstractLaunchAction - Loading module file C:\Users\Intel i9 SSD\Desktop\B-17 - Copy.vmod
2023-09-09 17:28:44,047 [6016-SwingWorker-pool-2-thread-1] INFO  VASSAL.launch.TilingHandler - No images to tile.
2023-09-09 17:28:44,047 [6016-SwingWorker-pool-2-thread-1] INFO  VASSAL.launch.AbstractLaunchAction - Loading module B-17 Queen Of The Skies
2023-09-09 17:28:44,063 [6016-SwingWorker-pool-2-thread-1] INFO  VASSAL.tools.io.ProcessLauncher - launching C:\Program Files\VASSAL-3.7.0\jre\bin\java -Xms1024M -Xmx1024M -javaagent:lib\vassal-agent.jar --add-opens java.desktop/sun.awt.shell=ALL-UNNAMED -Duser.home=C:\Users\Intel i9 SSD -Duser.dir=C:\Program Files\VASSAL-3.7.0 -cp lib\Vengine.jar VASSAL.launch.Editor --edit -- C:\Users\Intel i9 SSD\Desktop\B-17 - Copy.vmod
2023-09-09 17:28:45,832 [7812-main] INFO  VASSAL.launch.StartUp - Starting
2023-09-09 17:28:45,879 [7812-main] INFO  VASSAL.launch.StartUp - OS Windows 11 10.0 amd64
2023-09-09 17:28:45,879 [7812-main] INFO  VASSAL.launch.StartUp - Java version 20.0.2
2023-09-09 17:28:45,879 [7812-main] INFO  VASSAL.launch.StartUp - Java home C:\Program Files\VASSAL-3.7.0\jre
2023-09-09 17:28:45,879 [7812-main] INFO  VASSAL.launch.StartUp - VASSAL version 3.7.0
2023-09-09 17:28:45,879 [7812-main] INFO  VASSAL.launch.Launcher - Editor
2023-09-09 17:28:50,259 [7812-AWT-EventQueue-0] INFO  VASSAL.build.GameModule - B-17 Queen Of The Skies version 1.0
2023-09-09 17:31:08,115 [7812-AWT-EventQueue-0] ERROR VASSAL.tools.ErrorDialog - 
java.lang.ArithmeticException: / by zero
	at VASSAL.build.module.properties.IncrementProperty.getNewValue(IncrementProperty.java:85)
	at VASSAL.counters.SetGlobalProperty.myKeyEvent(SetGlobalProperty.java:240)
	at VASSAL.counters.Decorator.keyEvent(Decorator.java:609)
	at VASSAL.counters.Decorator.keyEvent(Decorator.java:611)
	at VASSAL.counters.Decorator.keyEvent(Decorator.java:610)
	at VASSAL.counters.Decorator.keyEvent(Decorator.java:610)
	at VASSAL.counters.Decorator.keyEvent(Decorator.java:610)
	at VASSAL.counters.Decorator.keyEvent(Decorator.java:610)
	at VASSAL.counters.Decorator.keyEvent(Decorator.java:610)
	at VASSAL.counters.GlobalCommandVisitor.apply(GlobalCommandVisitor.java:152)
	at VASSAL.counters.GlobalCommandVisitor.apply(GlobalCommandVisitor.java:121)
	at VASSAL.counters.GlobalCommandVisitor.visitDefault(GlobalCommandVisitor.java:116)
	at VASSAL.counters.PieceVisitorDispatcher.accept(PieceVisitorDispatcher.java:46)
	at VASSAL.counters.DeckVisitorDispatcher.accept(DeckVisitorDispatcher.java:37)
	at VASSAL.counters.GlobalCommand.apply(GlobalCommand.java:842)
	at VASSAL.counters.CounterGlobalKeyCommand.apply(CounterGlobalKeyCommand.java:323)
	at VASSAL.counters.CounterGlobalKeyCommand.myKeyEvent(CounterGlobalKeyCommand.java:171)
	at VASSAL.counters.Decorator.keyEvent(Decorator.java:609)
	at VASSAL.counters.TriggerAction.keyEvent(TriggerAction.java:164)
	at VASSAL.counters.Decorator.keyEvent(Decorator.java:610)
	at VASSAL.counters.Decorator.keyEvent(Decorator.java:610)
	at VASSAL.counters.Decorator.keyEvent(Decorator.java:610)
	at VASSAL.counters.Decorator.keyEvent(Decorator.java:610)
	at VASSAL.counters.ActionButton$ButtonPusher.doClick(ActionButton.java:704)
	at VASSAL.counters.ActionButton$ButtonPusher$MapMouseListener.mouseReleased(ActionButton.java:758)
	at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:298)
	at VASSAL.build.module.Map.mouseReleased(Map.java:2029)
	at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
	at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
	at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
	at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
	at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
	at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
	at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
	at java.desktop/java.awt.Component.processMouseEvent(Component.java:6620)
	at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3398)
	at java.desktop/java.awt.Component.processEvent(Component.java:6385)
	at java.desktop/java.awt.Container.processEvent(Container.java:2266)
	at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4995)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4827)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
	at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2780)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4827)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:775)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:98)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:747)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:744)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

To duplicate this problem start game > click “Queen In Germany” tab > Activate. The toggle should appear then you mouse-click on the toggle. The toggle switch is located within A Place Marker Trait located here…

Module Download HERE

Vassal Version: 3.7.0
System: Windows 11 x64 22H2
RAM: 32 GB
CPU: Intel(R) Core™ i9-9900KF CPU @ 3.60GHz 3.60 GHz
GPU:

Regards;
Darren

PS: Since posting this I have also tried removing The Action Button Trait and replacing with a Right-Click menu but the same problem occurs.

The immediate problem is with this line in IncrementProperty:

 value = min + ((value - min + incr) % (max - min + incr));

You’re getting a division by zero error, so max - min + incr must be zero.

1 Like

Hello Joel & thanks for your reply;
That must be Java code or something it doesn’t mean much to me but I started looking for Incremental values (IncrementProperty) that were linked to the command sent by this toggle switch and one of those was the SGP for the Strategic Display which is…

…and I found this…

…so changed it from a negative to just “1” and now everything works. So nothing to do with the Place Marker Trait at all but weird that this still worked with Vassal 3.6.19. :confused: Thanks for your help.

Regards;
Darren

In 3.7.0-beta1 we made the following change, listed in the change log:

11913: Numeric global properties with increments other than 1 and -1 now wrap around correctly

Wrap-around was completely broken for any other increment values before that. It looks like we don’t quite have it right yet for negative increments.

I’ll see about fixing this for 3.7.1.

1 Like
value = min + ((value - min + incr) % (max - min + incr));

should be

value = min + (((value - min + incr) % (max - min + 1)) + (max - min + 1) % (max - min + 1);

or, with repeated terms replaced:

final int range = max - min + 1;
value = min + ((value - min + incr) % range + range) % range;

You can find builds with the name VASSAL-3.7.1-SNAPSHOT-eb51b3f-increment_wrap_around in our builds archive which contain this change. Would you please try the build appropriate for your OS and let us know if this solves the problem for you?

1 Like

Hello Joel ;
Yes, with the Increment value restored to -1 using…

VASSAL-3.7.1-SNAPSHOT-eb51b3f-increment_wrap_around

…the Toggle works correctly again. The module saved in 3.7.1 still has the same issue when opened in 3.7.0, so I guess will have to continue with 3.7.0 and an increment of “1” until the next fix comes along. Thank you for your time.

Regards;
Darren

1 Like

I changed the subject of this thread to something more accurate in case others have the same problem.

Regards;
Darren

It would, because the relevant code isn’t in the module. 3.7.0 will continue to behave as it was.

You won’t have to wait long for 3.7.1; I expect we’ll release it in a few days.

2 Likes

Vassal Devs are awesome, my hat’s off to you sir. :+1:t2:

2 Likes