Thread: Lighting issues
View Single Post
Old April 1, 2020, 10:33   #7
PowerWyrm
Prophet
 
PowerWyrm's Avatar
 
Join Date: Apr 2008
Posts: 2,762
PowerWyrm is on a distinguished road
Quote:
Originally Posted by PowerWyrm View Post
- change squares that have negative light to LIGHTING_DARK
Hmm this doesn't work since squares with negative light are automatically marked as "not seen". I need to do something like "squares that are in LOS with negative light" instead.

By the way:

Code:
if (g->in_view) {
		g->lighting = LIGHTING_LOS;

		/* Darkness or torchlight */
		if (!square_isglow(cave, grid)) {
			if (player_has(player, PF_UNLIGHT) && !square_islit(cave, grid)) {
				g->lighting = LIGHTING_DARK;
			} else if (OPT(player, view_yellow_light)) {
				g->lighting = LIGHTING_TORCH;
			}
		} else if (square_iswall(cave, grid)) {
			/* Lit walls only show as lit if we are looking from the room
			 * that's lighting them */
			if (!square_islitwall(cave, grid)) {
				if (square_islit(cave, grid)) {
					if (OPT(player, view_yellow_light)) {
						g->lighting = LIGHTING_TORCH;
					} else if (player_has(player, PF_UNLIGHT)) {
						g->lighting = LIGHTING_DARK;
					} else {
						g->lighting = LIGHTING_LOS;
					}
				} else {
					g->lighting = LIGHTING_LIT;
				}
			}
		}

		/* Remember seen feature */
		square_memorize(cave, grid);
	} else if (!square_isknown(cave, grid)) {
		g->f_idx = FEAT_NONE;
	} else if (square_isglow(cave, grid)) {
		g->lighting = LIGHTING_LIT;
	}
If g->in_view is true then square_islit is true. So:
- first red block is always false and can be removed
- second red block is always true so the condition can be removed and the else block can be removed
- last red block is dead code since LIGHTING_LIT is the default
__________________
PWMAngband variant maintainer - check http://powerwyrm.monsite-orange.fr (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!
PowerWyrm is online now   Reply With Quote