maptool icon indicating copy to clipboard operation
maptool copied to clipboard

[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

Open adventuremagic123 opened this issue 2 years ago • 6 comments

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 avatar Sep 10 '22 18:09 adventuremagic123

@melek Can you confirm?

Phergus avatar Sep 11 '22 04:09 Phergus

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 !

melek avatar Sep 12 '22 04:09 melek

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

kwvanderlinde avatar Sep 12 '22 04:09 kwvanderlinde

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

kwvanderlinde avatar Sep 12 '22 05:09 kwvanderlinde

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

Phergus avatar Sep 12 '22 15:09 Phergus

Thank you, everyone.

adventuremagic123 avatar Sep 13 '22 01:09 adventuremagic123

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 avatar Nov 27 '22 16:11 adventuremagic123

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

adventuremagic123 avatar Nov 27 '22 16:11 adventuremagic123

@melek have you incorporated this changes into your release?

Phergus avatar Nov 28 '22 16:11 Phergus