maptool icon indicating copy to clipboard operation
maptool copied to clipboard

[Bug]: Load campaign, start server, and token imported from Hero Lab loses binding (Hero Lab not needed to investigate this issue)

Open adventuremagic123 opened this issue 2 years ago • 18 comments

Describe the Bug

My "Melee Attack" macro for the "Galirex Hellbane" token works until you start the server at which point the token appears to lose a binding that causing the Hero Lab part of the API to break (the Hero Lab MapTool macros).

You do NOT need Hero Lab to investigate this issue. Everything you need is included in this issue posting.

See reproduction steps.

To Reproduce

  1. Start MapTool 1.12.0 Beta 2.
  2. Load the "test.cmpgn" (you must unzip "test.zip"):

test.zip

  1. Go to the Campaign window.
  2. Select the "Galirex Hellbane" token on the "Grasslands" map.
  3. Click "Melee Attack".
  4. Choose "No" (so that as GM you do not do this in secret).
  5. Choose "bite (kitsune) (melee)".
  6. Click "Okay".
  7. Leave the default "No" selected for "Is this a coup de grace?".
  8. Click "Okay & Include Temporary Changes" (yes, there's multiple buttons like this and it doesn't matter which one you click).
  9. Notice in the Chat window that it worked.
  10. Now, start the server with the options illustrated in the attachment:

Screenshot 2022-09-04 203428

  1. Repeat steps 2 through 4 and notice that now you get the following error:

java.lang.NullPointerException: Cannot invoke "java.io.File.getAbsolutePath()" because the return value of "net.rptools.maptool.model.HeroLabData.getPortfolioFile()" is null error executing expression heroLabInfo = herolab.getInfo(). Error trace : TokenHeroLabSync@Lib:CharacterSheet <<< TokenUpdateToLatestMacroVersion@Lib:CharacterSheet <<< Melee Attack@campaign

  1. The "maptool.log" created from the point where MapTool 1.12.0 Beta 2 is started till the above error is attached below:

maptool.log

Expected Behaviour

Clicking the "Melee Attack" macro with the "Galirex Hellbane" token selected should still work. You should not get an error.

Screenshots

No response

MapTool Info

MapTool 1.12.0 Beta 2

Desktop

Windows 10

Additional Context

This issue might be related to an issue reported in #3280.

adventuremagic123 avatar Sep 05 '22 01:09 adventuremagic123

test.cmpgn is inside test.zip. Unzip test.zip.

adventuremagic123 avatar Sep 05 '22 01:09 adventuremagic123

Just like in #3280, if you start the server BEFORE loading "test.cmpgn" everything works as expected -- there is no error.

However, if you encounter the problem as described by this bug and you save "test.cmpgn", the issue will be persisted to "test.cmpgn", so if you load it again with a freshly started MapTool application you will continue to see the issue whether or not the server is started.

adventuremagic123 avatar Sep 05 '22 01:09 adventuremagic123

If you do the "To reproduce" steps AND replace step 5 with doing a double click on the token to open the "Edit Token" dialog, you get a stack trace:

java.lang.NullPointerException: Cannot invoke "net.rptools.maptool.model.Token.getOwners()" because the return value of "net.rptools.maptool.client.ui.token.EditTokenDialog.getModel()" is null at net.rptools.maptool.client.ui.token.EditTokenDialog$OwnerListModel.(EditTokenDialog.java:2171) at net.rptools.maptool.client.ui.token.EditTokenDialog.lambda$bind$0(EditTokenDialog.java:299) at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.desktop/java.awt.EventQueue$4.run(Unknown Source) at java.desktop/java.awt.EventQueue$4.run(Unknown Source) at java.base/java.security.AccessController.doPrivileged(Unknown Source) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source) at net.rptools.maptool.client.swing.MapToolEventQueue.dispatchEvent(MapToolEventQueue.java:54) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.desktop/java.awt.WaitDispatchSupport$2.run(Unknown Source) at java.desktop/java.awt.WaitDispatchSupport$4.run(Unknown Source) at java.desktop/java.awt.WaitDispatchSupport$4.run(Unknown Source) at java.base/java.security.AccessController.doPrivileged(Unknown Source) at java.desktop/java.awt.WaitDispatchSupport.enter(Unknown Source) at java.desktop/java.awt.Dialog.show(Unknown Source) at java.desktop/java.awt.Component.show(Unknown Source) at java.desktop/java.awt.Component.setVisible(Unknown Source) at java.desktop/java.awt.Window.setVisible(Unknown Source) at java.desktop/java.awt.Dialog.setVisible(Unknown Source) at net.rptools.maptool.client.swing.MapToolEventQueue.displayPopup(MapToolEventQueue.java:109) at net.rptools.maptool.client.swing.MapToolEventQueue.dispatchEvent(MapToolEventQueue.java:73) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)

The "maptool.log" created from the point where MapTool 1.12.0 Beta 2 is started till the above error is attached below:

maptool.log

adventuremagic123 avatar Sep 05 '22 02:09 adventuremagic123

Work-around: I'll stress that the current work-around is to start the server BEFORE loading campaign files and everything is okay.

adventuremagic123 avatar Sep 05 '22 02:09 adventuremagic123

"test.cmpgn" is virgin MapTool 1.12.0 Beta 2. In other words, while all the macros and the campaign properties were created in MapTool 1.11.5 (and have a lineage all the way back to MapTool 1.4.x), "test.cmpgn" was created directly in MapTool 1.12.0 Beta 2.

adventuremagic123 avatar Sep 05 '22 02:09 adventuremagic123

You should not need the Hero Lab file NOR Hero Lab, but I've attached the Hero Lab file. Unzip "Galirex_Hellbane.zip", which contains "Galirex_Hellbane.por". You might have trouble using it in your Hero Lab because it requires a beefy license (but again, you should NOT need Hero Lab for this issue).

Galirex_Hellbane.zip

If you decide to import your own Hero Lab PC or NPC (such as "Galirex_Hellbane.por"), you'll need to select it and click the "Sync & Optimize Token With Hero Lab(R) POR File" macro on the GM window to make it work with the "Melee Attack" macro on the Campaign window (as described in my steps-to-reproduce) -- but all of this is unnecessary, I think.

adventuremagic123 avatar Sep 05 '22 02:09 adventuremagic123

I can reproduce this in the beta build, but not with the current code in the dev branch, so hopefully, this is already fixed.

cwisniew avatar Sep 08 '22 11:09 cwisniew

Thank you. Will retest in next beta release.

adventuremagic123 avatar Sep 09 '22 05:09 adventuremagic123

I'm able to reproduce this issue with MapTool 1.12.0 Beta 3.

I think the problem is that somehow the fix for this issue and #3280 exists in the DEV branch but is not being included in the releases. No idea why.

These problems do NOT exist in MapTool 1.10.4.

adventuremagic123 avatar Sep 10 '22 02:09 adventuremagic123

@Phergus are you able to try this? I am not able to reproduce with code in develop branch of 1.12 beta 3. Starting to wonder what I am doing wrong :)

cwisniew avatar Sep 10 '22 12:09 cwisniew

@cwisniew Nope. Tried with the campaign file originally provided and with the standalone .por file in both beta 3 and with current dev code. No errors seen running melee attack macro. No problems opening edit token dialog.

Phergus avatar Sep 10 '22 13:09 Phergus

It's critical that you load the campaign BEFORE starting the server -- then start the server otherwise you won't see a problem.

Once you start the server with the campaign already loaded, you'll have problems running the melee attack macro and opening the edit token dialog. Worse is that if you save the campaign like this, it will be permanently messed up.

Here I am reproducing the problem with the "Edit Token" dialog and MapTool 1.12.0 Beta 3:

Screenshot 2022-09-10 105724

adventuremagic123 avatar Sep 10 '22 15:09 adventuremagic123

Yes. I loaded the campaign before starting the server.

Phergus avatar Sep 10 '22 19:09 Phergus

Very puzzling. I can reproduce this everytime on different PCs. I wonder if having Hero Lab installed makes a difference. I'll try this tomorrow on a laptop where I don't have Hero Lab.

adventuremagic123 avatar Sep 11 '22 06:09 adventuremagic123

I don't know what the difference is between the environments on your PCs versus mine -- but I can reproduce this issue every time on 3 of my PCs with or without Hero Lab installed using MapTool 1.12.0 Beta 3.

One improvement, though, since I first started seeing this issue in MapTool 1.11.X is that at least MapTool no longer suffers a fatal exception where the whole application aborts (where it exits) as reported in #3280.

This issue does NOT exist at all in MapTool 1.10.4.

adventuremagic123 avatar Sep 11 '22 14:09 adventuremagic123

@Phergus, I just had a thought. The most likely environment difference between my PCs and yours are the server start and preferences menu item settings. The problem must be burried in one of those options.

I'll do some testing to see if I can find it.

adventuremagic123 avatar Sep 16 '22 07:09 adventuremagic123

These are the preferences I'm using on a PC where I am able to reproduce this problem (the server start options can be found above):

Screenshot 2022-09-18 110930

Screenshot 2022-09-18 111139

Screenshot 2022-09-18 111158

Screenshot 2022-09-18 111225

Screenshot 2022-09-18 111248

Screenshot 2022-09-18 111313

adventuremagic123 avatar Sep 18 '22 16:09 adventuremagic123

The MapTool.cfg I used to reproduce this problem is attached below (unzip the file):

MapTool.zip

adventuremagic123 avatar Sep 18 '22 16:09 adventuremagic123

This is a big problem because I can reproduce it everytime also when I have a campaign loaded and stop the server. If I forget to save my campaign before stopping the server, after the server is stopped, all of my Hero Lab tokens throw the exception I provided above and in the same way. Effectively, my campaign is lost.

This is un MapTool 1.11.X through 1.12.X (the current version as of this writing).

adventuremagic123 avatar Dec 31 '22 14:12 adventuremagic123

Just to be clear. The work-around for this problem goes like this:

  1. If you're planning on starting the server, load the campaign AFTER the server is started.

  2. If you're planning on shutting down the server, save your campaign FIRST -- if you do it after all your Hero Lab tokens will be messed up as described above.

  3. If you're simply developing a campaign and have no plans to start or shutdown the server, then there is no problem.

adventuremagic123 avatar May 10 '23 02:05 adventuremagic123