Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lighting on maps loaded after SSlighting init #4797

Merged
merged 1 commit into from
Jan 28, 2025

Conversation

out-of-phaze
Copy link
Member

Fixes a regression caused by #4756.

Maploading only goes through new() and not changeturf. If we're loading a turf during mapload, and it's not in changeturf, and SSlighting init has already run, then we need to build the lighting overlay for that turf in Initialize().

I decided to do this rather than making it do a pass after expanding the world bounds (runs before the actual map loading is done, will do basically nothing because unsim filler turfs fail TIDLU) or after finishing loading a map (multiple relevant points, complicated for planets/etc., can result in missing some turfs or processing others twice.

Definitely needs proper review by @Lohikar to make sure I don't do an oopsie again and that I'm not overlooking a better solution.

@out-of-phaze out-of-phaze added the ready for review This PR is ready for review and merge. label Jan 23, 2025
MistakeNot4892
MistakeNot4892 previously approved these changes Jan 24, 2025
@@ -57,7 +57,7 @@ SUBSYSTEM_DEF(lighting)
var/datum/level_data/level = SSmapping.levels_by_z[zlevel]
for (var/turf/tile as anything in block(1, 1, zlevel, level.level_max_width, level.level_max_height)) // include TRANSITIONEDGE turfs
if (TURF_IS_DYNAMICALLY_LIT_UNSAFE(tile))
tile.lighting_build_overlay()
new /atom/movable/lighting_overlay(tile)
Copy link
Member

@Lohikar Lohikar Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should check that there's no existing overlay, they'll just be orphaned if they somehow exist.

Given that's an error/impossible case, just logging is all that should be necessary.

@out-of-phaze out-of-phaze force-pushed the fix/lighting-post-init branch 3 times, most recently from 788d5b7 to d59493e Compare January 24, 2025 01:37
@@ -57,7 +57,10 @@ SUBSYSTEM_DEF(lighting)
var/datum/level_data/level = SSmapping.levels_by_z[zlevel]
for (var/turf/tile as anything in block(1, 1, zlevel, level.level_max_width, level.level_max_height)) // include TRANSITIONEDGE turfs
if (TURF_IS_DYNAMICALLY_LIT_UNSAFE(tile))
tile.lighting_build_overlay()
if(!isnull(tile.lighting_overlay))
log_warning("Attempted to create lighting_overlay on tile that already had one.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log_warning("Attempted to create lighting_overlay on tile that already had one.")
log_warning("Attempted to create lighting_overlay on tile ([tile.x],[tile.y],[tile.z]) that already had one.")

@out-of-phaze out-of-phaze force-pushed the fix/lighting-post-init branch from d59493e to 2344d71 Compare January 28, 2025 06:43
@MistakeNot4892 MistakeNot4892 merged commit fc2dec8 into NebulaSS13:dev Jan 28, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review This PR is ready for review and merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants