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

Error when setting empty earlier retrieved VBL on Token #2763

Closed
BlackwingNL opened this issue Jun 20, 2021 · 2 comments
Closed

Error when setting empty earlier retrieved VBL on Token #2763

BlackwingNL opened this issue Jun 20, 2021 · 2 comments
Assignees
Labels
bug tested This issue has been QA tested by someone other than the developer.

Comments

@BlackwingNL
Copy link
Contributor

Describe the bug
When retrieving the Token VBL through getTokenVBL() and then at a later point setting that retrieved VBL with setTokenVBL() an error is given if the retrieved VBL is empty.

If the token never had any VBL the retrieved VBL is an empty string and the error message is:
Unknown JSON type """" in function "setTokenVBL"

If the token had it's VBL cleared through the Clear Token VBL button on the VBL tab of the Edit Token Dialog, or set to an empty VBL by setting it's VBL to "{'shape':'none'}" with setTokenVBL() the error message is the following:
Invalid end index "2" for array (size of 0) in function "setTokenVBL[Polygon]"

To Reproduce
Steps to reproduce the behavior:

  1. Create a new token.
  2. Add a new Macro to the token, uncheck "Allow Players to Edit Macro". Contents of the Macro are:
[h: vbl = getTokenVBL()]
[h: broadcast("VBL: " + vbl)]
[h: setTokenVBL(vbl)]
  1. Run the macro on the token. At this point the Unknown JSON type """" in function "setTokenVBL" message is given
  2. Open the Edit Dialog for the token. Go To the VBL tab and click the "Clear Token VBL" button, then clik on "OK" to close the dialog.
  3. Run the macro on the token again. At this point the Invalid end index "2" for array (size of 0) in function "setTokenVBL[Polygon]" message is given.

Expected behavior
Retrieving the VBL from a Token and then later setting the VBL again with the retrieved VBL should always result in the original situation with exactly the same VBL (empty or not) on the token without errors.

Screenshots
If applicable, add screenshots to help explain your problem.

MapTool Info

  • Version: 1.9.0
  • Install: New (uninstalled 1.9.0 beta 3, then installed 1.9.0 in separate directory)

Desktop (please complete the following information):

  • OS: Windows 10 Pro
  • Version 10 - 2004
@Phergus Phergus added the up for grabs Minimal context and are well-suited for new contributors label Oct 24, 2021
@kwvanderlinde kwvanderlinde self-assigned this Jan 15, 2022
@kwvanderlinde
Copy link
Collaborator

For the Unknown JSON type... message, this is the result of getTokenVBL() exposing an implementation detail. If the token's VBL has never been set, and is therefore null, it returns an empty string. But if the VBL has been set and clear, it is now an empty Area and a polygon is returned (see below for more on this case). If we just change the null case to return an array as is done in the non-null case, the issue would go away.

The second message (Invalid end index...) equally affects getTokenVBL(), getVBL(), getHillVBL() and getPitVBL(). Each of these functions - when the retrieved VBL area is empty - will return a singleton array containing an empty polygon, which is not a valid shape. If these getters would instead return an empty array, then the setters would be able to consume the results.

@Phergus Phergus removed the up for grabs Minimal context and are well-suited for new contributors label Jan 15, 2022
@Phergus
Copy link
Contributor

Phergus commented Jul 9, 2022

Tested all 4 functions mentioned above. They now return an empty array as described.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug tested This issue has been QA tested by someone other than the developer.
Projects
None yet
Development

No branches or pull requests

3 participants