yellowstonegames / SquidLib

Useful tools for roguelike, role-playing, strategy, and other grid-based games in Java. Feedback is welcome!
Other
454 stars 46 forks source link

BurstAOE uses a null resistanceMap to calculate its FOV #197

Closed Rakaneth closed 6 years ago

Rakaneth commented 6 years ago

I am not sure why this is, but at the moment, this causes BurstAOE.apply to blow up with a NullPointerException.

tommyettinger commented 6 years ago

Are you calling BurstAOE.setMap() before... whatever method is blowing up? That call should set resistanceMap based on the given char[][]. Calling setMap() is mentioned throughout the AOE-related docs as a necessary step, but it's possible there's some methods that can be called without needing it, while others will throw exceptions if the map isn't up-to-date. You may have encountered mostly the former kind of method, so there wasn't a need for setMap() in your code until now, maybe?

EDIT: Ah, apply() is a method on Technique, which is what was confusing me. Technique also has a setMap() method; it should be used since it will call BurstAOE.setMap() as well as set the origin for the BurstAOE.

Rakaneth commented 6 years ago

setMap() gets called in the constructor for WolfSkill (my Technique wrapper).

Here is line 517 in BurstAOE.java:

return AreaUtils.arrayToHashMap(fov.calculateFOV(null, center.x, center.y, radius, radiusType));
tommyettinger commented 6 years ago

This should be fixed now. I also checked for any other usages of calculateFOV that passed null directly, and I couldn't find any. Thanks for finding this.