MAX_VIEW_DISTANCE versus hardcoded 60

I’m looking to pick up, with the eventual goal of making the size of the reality bubble into compile time option, or more preferably, something that can be selected from a list, either during world creation or during play.

game_constants.h defines MAX_VIEW_DISTANCE as ( SEEX * int( MAPSIZE / 2 ) ), which normally works out as 60. But lightmap.cpp and player.cpp hardcode max distance to 60.

Is that 60 in lightmap.cpp (cast_zlight and build_seen_cache) and player.cpp (unimpaired_range) really supposed to be MAX_VIEW_DISTANCE? If so, I’m guessing that directly adjusting MAX_VIEW_DISTANCE will break things. What breaks if I set MAPSIZE to 13?

So, replacing those instances of 60 with MAX_VIEW_DISTANCE, and then setting MAPSIZE to 15, sets the view distance to 84, as evidenced on the screen shot.

I need to adjust the air transparency - it’s currently set to go to dim at 60 tiles - but this looks like a very promising avenue of exploration.

sniper breathing intensifies


The review comments in the pr are pretty trivial, the main thing that needs fixing is adding a formula to adjust air transparency as you noted.

I didn’t have time to experiment with this, but I think it’s not enough to change LIGHT_TRANSPARENCY_OPEN_AIR. Because LIGHT_RANGE depends on that value, which means the effective illumination of a given light will change.

I think all those values will need to be recalculated as the viewing distance changes. Not a huge deal, it’s just math.

Oh, and player::sight_range() should call LIGHT_RANGE instead of rederiving the formula.