Skip to content

[Bug]: moveToken is one square off every N calls for tokens smaller than medium #5968

Description

@SherbanWisperwald

Describe the Bug

[moveToken(0, 0, 1, getSelected())] called repeatedly sometimes moves the token to (-1, -1).
This happens only for tokens with size smaller than "medium".
This happens only for "units" = 1, moveToken(0, 0, 0, ...) works as expected.
If the token is small, it lands every 8 calls on (-1, -1)
If the token is tiny or smaller it lands every 4 calls on (-1, -1)

Without understanding quite what happens here, I suspect this code might be the problem:
Its in TokenLocationFunctions.java:moveToken

if (useDistance) {
      // Remove pixel offset, so that getTokenX / getTokenY and coordinates match. Fixes #1757.
      Point offset = getInstance().getTokenPixelLocationOffset(token);
      x -= offset.x;
      y -= offset.y;
    }
    ZonePoint zp = getZonePoint(x, y, useDistance);
    MapTool.serverCommand().updateTokenProperty(token, Token.Update.setXY, zp.x, zp.y);

This happens with other coordinates, too, (0, 0) is just an example.

To Reproduce

Add a token to your map, select it and set its size to smaller than "medium".
Execute [moveToken(0, 0, 1, getSelected())] in the chat window repeatedly.

If you impersonate the token, [moveToken(0, 0)] will give the same buggy result.

Expected Behaviour

The Token is moved to (0, 0) and stays there for every subsequent call.

Screenshots

No response

MapTool Info

1.18.6, Jar-Install

Desktop

Linux (Gentoo)

Additional Context

==== MapTool Information ====
MapTool Version: 1.18.6
MapTool Home...: /home/stephan/.maptool-rptools
MapTool Install: /home/stephan/Anwendungen/MapTool-1.18.6/lib/app
Max mem avail..: 23 GB
Max mem used...: 272 MB
Custom Property: -DMAPTOOL_LOGDIR=/home/stephan/.maptool-rptools/logs
Custom Property: -DMAPTOOL_DATADIR=.maptool-rptools

==== Java Information ====
Java Home......: /home/stephan/Anwendungen/MapTool-1.18.6/lib/runtime
Java Vendor....: Eclipse Adoptium
Java Version...: 21.0.1
Java Parameters:
-Djpackage.app-version=1.0
-Xss8M
-Dsun.java2d.d3d=true
-Dsentry.environment=Production
-Dfile.encoding=UTF-8
-Dpolyglot.engine.WarnInterpreterOnly=false
-Djava.util.Arrays.useLegacyMergeSort=true
-XX:+ShowCodeDetailsInExceptionMessages
--add-opens=java.desktop/java.awt=ALL-UNNAMED
--add-opens=java.desktop/java.awt.geom=ALL-UNNAMED
--add-opens=java.desktop/sun.awt.geom=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
--add-opens=javafx.web/javafx.scene.web=ALL-UNNAMED
--add-opens=javafx.web/com.sun.webkit=ALL-UNNAMED
--add-opens=javafx.web/com.sun.webkit.dom=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.desktop/sun.awt=ALL-UNNAMED
--add-opens=java.desktop/sun.java2d=ALL-UNNAMED
--add-opens=java.desktop/javax.swing=ALL-UNNAMED
--add-opens=java.desktop/sun.awt.shell=ALL-UNNAMED
--add-opens=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED
-Duser.country=DE
-Duser.language=de
-Djava.io.tmpdir=/home/stephan/tmp
-Djpackage.app-path=/home/stephan/Anwendungen/MapTool-1.18.6/bin/MapTool

==== OS Information ====
OS Name........: Linux
OS Version.....: 6.18.32-gentoo-r2
OS Architecture: amd64
PATH...........: /usr/local/sbin:/usr/local/bin:/usr/bin:/opt/bin:/usr/lib/llvm/21/bin:/usr/lib/llvm/20/bin:/opt/cuda/bin:/home/stephan/.local/share/JetBrains/Toolbox/scripts
Number of Procs: 28

==== User Information ====
User Name: stephan
User Home: /home/stephan
User Dir.: /home/stephan/Anwendungen/MapTool-1.18.6

==== Network Interfaces ====
Display Name..: eno1
Interface Name: eno1
Address...: 192.168.14.6

Display Name..: lo
Interface Name: lo
Address...: 127.0.0.1

Host Address...: 127.0.0.1
Default Gateway: 192.168.14.1

==== Locale Information ====
Country.: Germany
Language: German
Locale..: German (Germany)
Variant.:

==== Encoding Information ====
Default Locale: de_DE
Default Charset: UTF-8
file.encoding: UTF-8
sun.jnu.encoding: UTF-8
Default Encoding: UTF8

==== Display Information ====
Number of Displays: 3
Display 1: 5760x1080(-1)
Display 2: 1920x1080(-1)
Display 3: 1920x1080(-1)

==== Internet Gateway Devices ====
No IGDs Found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions