RPTools.net

Discussion and Support

Skip to content

It is currently Sun Nov 19, 2017 11:05 am 




Forum rules


Posting now open to all registered forum users.



Reply to topic  [ 9 posts ] 

Previous topic | Next topic 

  Print view

Author Message
 Offline
Kobold
 
Joined: Thu Mar 05, 2015 4:31 pm
Posts: 11
 Post subject: NullPointerException when using removeFromInitiative()
PostPosted: Thu Jun 08, 2017 11:07 am 
Hi all!

I'm working on a Feng Shui 2 framework that takes a different view of initiative. Each time your character acts, your initiative decreases. My attack macro decreases the attacker's initiative, then if they KO the target it removes the target from the initiative list. Finally, at the end it sorts the initiative list. If the KO macro removes the token from the initiative list (removeFromInitiative()) and the macro is on a library token, then I get an exception (stack trace below) when the attacker's initiative is lower than the target's initiative.

I tried creating a simple test case campaign file to show this more clearly, but didn't get the exception. I can provide my campaign file if that will help, the problem shows up regularly there. This problem occurs on MapTools 1.4.0.5.

Also, while searching the forum I found this thread which seems to be very similar. viewtopic.php?f=20&t=13012&p=136903&hilit=removeFromInitiative#p136903

While I'm here I just want to say "Thank you!" for all of the effort on MapTool over the years. I really love the flexibility it provides and hope it continues to develop and get even stronger.

-------------------------
java.lang.NullPointerException
at net.rptools.maptool.client.ClientMethodHandler$1.run(ClientMethodHandler.java:506)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at net.rptools.maptool.client.swing.MapToolEventQueue.dispatchEvent(MapToolEventQueue.java:36)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7947
Location: Bay Area
 Post subject: Re: NullPointerException when using removeFromInitiative()
PostPosted: Thu Jun 08, 2017 12:16 pm 
null pointer is essentially not finding what you're looking for. So, for example if you try to remove a token from init but there is no impersonated token then it could give an error. Can't really get more detailed without seeing some code.

_________________
Downloads:


Top
 Profile  
 
 Offline
Kobold
 
Joined: Thu Mar 05, 2015 4:31 pm
Posts: 11
 Post subject: Re: NullPointerException when using removeFromInitiative()
PostPosted: Thu Jun 08, 2017 2:28 pm 
OK, so to be a little more specific, in the campaign macro I call the KO macro on the library token with the target token name as the parameter:

[h: target = some_token_name]

...

[macro( "KO@Lib:ZC-FengShui2" ): target ]

----
Inside the KO macro I have:

[h: targetToken = macro.args]

[token( targetToken ), CODE: {
[h: setState( "Sitting Duck", 0 )]
[h: setState( "Incapacitated1", 0 )]
[h: setState( "Incapacitated2", 0 )]
[h: setState( "KO", 1 )]
[h: removeFromInitiative()]
}]
----

If I delete the call to removeFromInitiative(), I don't get the exception, and the states get cleared correctly. The exception still happens if I am impersonating the attacker token. One interesting thing is that I don't get the exception if I move the call to removeFromInitiative() from the library macro into the campaign macro:

[macro( "KO@Lib:ZC-FengShui2" ): target ]
[h, token( target: removeFromInitiative()]


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7947
Location: Bay Area
 Post subject: Re: NullPointerException when using removeFromInitiative()
PostPosted: Thu Jun 08, 2017 5:45 pm 
try replacing token(targetToken) and code braces with switchToken(targetToken) and see if it makes a difference.

_________________
Downloads:


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9419
Location: Netherlands
 Post subject: Re: NullPointerException when using removeFromInitiative()
PostPosted: Fri Jun 09, 2017 1:00 am 
i always forget but is the passed on argument not [some_token_name] instead of some_token_name which is what you assume it to be in your code. It would explain the error

_________________
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC

My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent and
DPI.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS


Top
 Profile  
 
 Offline
Kobold
 
Joined: Thu Mar 05, 2015 4:31 pm
Posts: 11
 Post subject: Re: NullPointerException when using removeFromInitiative()
PostPosted: Fri Jun 09, 2017 3:27 pm 
OK, I tried replacing the token roll option with switchToken(), but I can still get the same error.

[h:switchToken( targetToken )]
[h: setState( "Sitting Duck", 0 )]
[h: setState( "Incapacitated1", 0 )]
[h: setState( "Incapacitated2", 0 )]
[h: setState( "KO", 1 )]
[h: removeFromInitiative()]


Top
 Profile  
 
 Offline
Kobold
 
Joined: Thu Mar 05, 2015 4:31 pm
Posts: 11
 Post subject: Re: NullPointerException when using removeFromInitiative()
PostPosted: Fri Jun 09, 2017 3:32 pm 
@wolph42, I'm guessing you're asking if some_token_name is an array?

I believe it is a string that has the name of a token. It's value is selected by a user through a list in an input dialog:
"target| " + json.toList( targets ) + "| My target is: | LIST | VALUE=STRING",

targets comes from getTokenNames( "json" )

Checking for the JSON type gives me:
macro args type = [r: json.type( macro.args) ]<br>
...
macro args type = UNKNOWN


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7947
Location: Bay Area
 Post subject: Re: NullPointerException when using removeFromInitiative()
PostPosted: Fri Jun 09, 2017 4:25 pm 
I have a feeling it may be an MT timing thing when drawing the token and removing it from the panel. It may not like something that's going on. Put an input pause just before the remove token. Does it error? May as well make sure targetToken is valid as well.

_________________
Downloads:


Top
 Profile  
 
 Offline
Kobold
 
Joined: Thu Mar 05, 2015 4:31 pm
Posts: 11
 Post subject: Re: NullPointerException when using removeFromInitiative()
PostPosted: Tue Jun 13, 2017 9:49 am 
It does feel like a timing issue. If I put the removeFromInitiative() call into the calling macro instead of the KO macro, the problem is much reduced, although I do still see the issue occasionally.

I put an input dialog before the removeFromInitiative() call inside the macro as suggested and that too seems to fix the problem.

I guess for me, I'll stick with putting the call outside of the KO macro since I don't want another dialog popup.

Thanks for the help!


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 9 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 243 on Sun Nov 04, 2012 6:14 am

Users browsing this forum: No registered users and 1 guest





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman