# MAX\_VIEW\_DISTANCE versus hardcoded 60

**URL:** <https://discourse.cataclysmdda.org/t/max-view-distance-versus-hardcoded-60/15871>\
**Category:** The Lab\
**Created:** [July 12, 2018, 6:17pm UTC](https://discourse.cataclysmdda.org/t/max-view-distance-versus-hardcoded-60/15871 "2018-07-12T18:17:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlangsdorf](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/mlangsdorf/32/2462_2.png) [@mlangsdorf](https://discourse.cataclysmdda.org/u/mlangsdorf)\
**Post date:** [July 12, 2018, 6:17pm UTC](https://discourse.cataclysmdda.org/t/max-view-distance-versus-hardcoded-60/15871/1 "2018-07-12T18:17:34Z")

</div>

I’m looking to pick up [https://github.com/CleverRaven/Cataclysm-DDA/pull/23376](https://github.com/CleverRaven/Cataclysm-DDA/pull/23376), 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?

---

<div class="post-metadata">

**Author:** ![mlangsdorf](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/mlangsdorf/32/2462_2.png) [@mlangsdorf](https://discourse.cataclysmdda.org/u/mlangsdorf)\
**Post date:** [July 12, 2018, 6:59pm UTC](https://discourse.cataclysmdda.org/t/max-view-distance-versus-hardcoded-60/15871/2 "2018-07-12T18:59:12Z")

</div>

![success](https://us1.discourse-cdn.com/flex016/uploads/cataclysmdda/original/2X/9/94149ac8ed3ac18af5b934404fefdc5b73f00edf.png)

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.

---

<div class="post-metadata">

**Author:** ![DeWolf](https://avatars.discourse-cdn.com/v4/letter/d/df705f/32.png) [@DeWolf](https://discourse.cataclysmdda.org/u/DeWolf)\
**Post date:** [July 12, 2018, 7:49pm UTC](https://discourse.cataclysmdda.org/t/max-view-distance-versus-hardcoded-60/15871/3 "2018-07-12T19:49:28Z")

</div>

_sniper breathing intensifies_

---

<div class="post-metadata">

**Author:** ![kevin.granade](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/kevin.granade/32/1316_2.png) [@kevin.granade](https://discourse.cataclysmdda.org/u/kevin.granade)\
**Post date:** [July 12, 2018, 11:12pm UTC](https://discourse.cataclysmdda.org/t/max-view-distance-versus-hardcoded-60/15871/4 "2018-07-12T23:12:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mlangsdorf](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/mlangsdorf/32/2462_2.png) [@mlangsdorf](https://discourse.cataclysmdda.org/u/mlangsdorf)\
**Post date:** [July 13, 2018, 1:25am UTC](https://discourse.cataclysmdda.org/t/max-view-distance-versus-hardcoded-60/15871/5 "2018-07-13T01:25:54Z")

</div>

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.
