ondras / rot.js

ROguelike Toolkit in JavaScript. Cool dungeon-related stuff, interactive manual, documentation, tests!
https://ondras.github.io/rot.js/hp/
BSD 3-Clause "New" or "Revised" License
2.33k stars 254 forks source link

Recursive Shadowcasting range #151

Open mingos777 opened 5 years ago

mingos777 commented 5 years ago

While testing Recursive Shadowcasting, I ran into an issue with its range treatment. I pass in Infinity to the compute method, hoping it will just stop when the map transparency is false. It does not and instead, it enters an infinite loop:

_castVisibility(...args) {
        if (visSlopeStart < visSlopeEnd) { return; }
        for (let i = row; i <= radius; i++) {
...

The for loop above never terminates.

For the record, both Precise and Discrete accept Infinity and terminate properly whenever the map says it's not transparent anymore.

ondras commented 5 years ago

Good find!

/cc @thesnarky1, because he is the author of the Recursive Shadowcasting impl.