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

[Bug]: Lib:Elevation 1.0b8 does NOT restore VBL/MBL correctly on MapTool 1.12.0 Beta 3 but does on MapTool 1.11.5 #3620

Closed
adventuremagic123 opened this issue Sep 10, 2022 · 9 comments
Labels

Comments

@adventuremagic123
Copy link

Describe the Bug

Using "test2a_1.11.5_version.cmpgn" (unzip the following file):

test2a_1.11.5_version.cmpgn.zip

When you change elevations back-and-forth using the "Elevation:" overlay, as you keep doing it and it only takes a few times, the VBL/MBL is completely lost for the elevations in MapTool 1.12.0 Beta 3 but is reliably restored in MapTool 1.11.5.

For elevation "0 - Ground", this is how the VBL/MBL should look:

Screenshot 2022-09-10 131319

But, by double-clicking on the elevation names in the overlay, switching back and forth between "20 - Fly 20'" and "0 - Ground" just one time causes the VBL/MBL to be completely lost for elevation "0 - Ground" so that it looks as follows:

Screenshot 2022-09-10 131744

To Reproduce

  1. Start MapTool.
  2. Start the server using the following options:

Screenshot 2022-09-06 203150

  1. Unzip the following file and load the campaign:

test2a_1.11.5_version.cmpgn.zip

  1. Look at the VBL/MBL (click the "eye" toolbar button to enable VBL/MBL viewing and editing). Notice the VBL/MBL on elevation "0 - Ground".

  2. Click the "Interaction Tools" toolbar button and double-click "20 - Fly 20'" to change to that elevation.

  3. Wait about 5 seconds (mostly unnecessary), double-click "0 - Ground" to change to that elevation.

  4. Look at the VBL/MBL (click the "eye" toolbar button to enable VBL/MBL viewing and editing). Notice the VBL/MBL on elevation "0 - Ground" -- it's all gone in MapTool 1.12.0 Beta 3.

For step 7, in MapTool 1.11.5, all the VBL/MBL that was previously on elevation "0 - Ground" is completely restored.

Expected Behaviour

All the VBL/MBL that was present in step 4 should have been restored in step 7 in MapTool 1.12.0 Beta 3 just as it is in MapTool 1.11.5.

Screenshots

No response

MapTool Info

MapTool 1.12.0 Beta 3

Desktop

Windows 10

Additional Context

Lib:Elevation is critical to my campaigns because it enables me to very easily deal with elevation in my campaigns. Tokens that are flying and have their elevation property set are affected by VBL/MBL created for that elevation. So, a token flying at an elevation of 20 feet is affected by different VBL/MBL than a token at 0 feet elevation (ground level). When changing elevations, it is critical that the correct VBL/MBL is restored to the map.

Lib:Elevation is a brilliant feature provided by melek#4527 (Discord) and is actually much easier to use than a corresponding feature provided for Foundry VTT in the "Wall Height" module -- and is a major strategic advantage for the MapTool community.

@adventuremagic123 adventuremagic123 changed the title [Bug]: Lib:Elevation 1.0b8 does NOT restore VBL/MBL correctly on MapTool 1.12.0 Beta 2 but does on MapTool 1.11.5 [Bug]: Lib:Elevation 1.0b8 does NOT restore VBL/MBL correctly on MapTool 1.12.0 Beta 3 but does on MapTool 1.11.5 Sep 10, 2022
@Phergus
Copy link
Contributor

Phergus commented Sep 11, 2022

@melek Can you confirm?

@melek
Copy link
Collaborator

melek commented Sep 12, 2022

Testing @adventuremagic123's campaign, I can confirm that my library is not saving elevations properly in 1.12b3, but it works fine in 1.11.5. I'm able to reproduce this issue on a fresh campaign for any elevation which doesn't have every kind of blocking layer.

@adventuremagic123 A workaround for now is to add a small rectangle of VBL+PVBL+HVBL+MBL anywhere on the map before switching layers. If any blocking layer has no data on the layer, it won't save the layer's data on switch in 1.12b3.

I found the following difference in the getMBL function and similar functions which I think is causing the problem for my library; Running this on a blank map I get different results in the beta than 1.11.5:

[h:rectangle = "{'shape':'rectangle','x':-50,'y':-50,'w':100,'h':100,'fill':1,'thickness':1,'scale':0}"]
<pre>[r: json.indent(getHillVBL(rectangle , 0))]</pre>

In 1.11.5 this produces an array with a single object and no points:

[{   "generated": 1,   "shape": "polygon",   "fill": 1,   "close": 1,   "thickness": 0,   "points": [] }]

And here is the result in 1.12.0b3, an empty array:

[]

I admit I'm not 100% if this is the issue, but it seems likely. If this is an intended change in behavior, I can adjust my library. Let me know, @Phergus !

@kwvanderlinde
Copy link
Collaborator

@melek This is indeed an intended change in behaviour to fix #2763.

@kwvanderlinde
Copy link
Collaborator

Actually, if memory serves, the doors lib also handles that sort of case, so might be similarly affected.

@Phergus
Copy link
Contributor

Phergus commented Sep 12, 2022

@melek thanks for looking into this. Looks like you'll need to update your code to detect the empty array.

@adventuremagic123
Copy link
Author

Thank you, everyone.

@adventuremagic123
Copy link
Author

BTW, we modified lib:elevation 1.0b8a to work with MapTool 1.12.0 and above. However, backward compatibility was broken for the lib:elevation 1.0b8 that worked with MapTool 1.11.X. Not sure whether there is a desire to address that, so I won't make a declaration for this issue.

Instructions for modifying 1.0b8 have been given as follows:

To fix Lib:Elevation in 1.12

  • Edit the loadElevationLayer macro in macro group 1.2 - Elevation Layer UDFs
  • Replace lines 33 through 42 with the following code:
[h, if(json.type(vLayerVBL) == "ARRAY" && json.length(vLayerVBL) > 0): 
    vHasVBL = json.length(json.get(json.get(vLayerVBL, 0), "points"));
    vHasVBL = 0]
[h, if(json.type(vLayerMBL) == "ARRAY" && json.length(vLayerMBL) > 0): 
    vHasMBL = json.length(json.get(json.get(vLayerMBL, 0), "points"));
    vHasMBL = 0]
[h, if(json.type(vLayerPitVBL) == "ARRAY" && json.length(vLayerPitVBL) > 0): 
    vHasPitVBL = json.length(json.get(json.get(vLayerPitVBL, 0), "points"));
    vHasPitVBL = 0]
[h, if(json.type(vLayerHillVBL) == "ARRAY" && json.length(vLayerHillVBL) > 0): 
    vHasHillVBL = json.length(json.get(json.get(vLayerHillVBL, 0), "points"));
    vHasHillVBL = 0]

Lib_Elevation_1.0b8.rptok.zip

Lib_Elevation_1.0b8a.rptok.zip

Lib_Elevation Manual - RPTools Wiki.pdf

@adventuremagic123
Copy link
Author

After making these changes to create the 1.0b8a version, lib:elevation works as expected.

@Phergus
Copy link
Contributor

Phergus commented Nov 28, 2022

@melek have you incorporated this changes into your release?

@Phergus Phergus closed this as completed Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants