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 dimming lights in Leorics chamber #3292

Merged
merged 1 commit into from
Apr 18, 2023
Merged

Conversation

ThomasChr
Copy link
Contributor

@ThomasChr ThomasChr commented Oct 26, 2021

Fixes #1410

@ThomasChr
Copy link
Contributor Author

ThomasChr commented Oct 26, 2021

This does indeed fix #1410.
The problems to me seems that all light Objects save in _oVar1 if their lightsource has already been added to them.
When we are saving the leveldata (SaveLevel()) it doesn't make sense (to me) to save this variable on light objects, because all of their light sources should be added back again when loading the level (LoadGameLevel->LoadLevel())
It does work when using the stairs because in ProcessObjects->UpdateObjectLight we are setting the variable _oVar1 to 0 when light object is far enough away that we don't see it in anymore.

@ThomasChr
Copy link
Contributor Author

The same thing should happen when Saving and Loading, because there also our torches are loaded with _oVar1 set to 1. But something seems to go another way here because the light sources get added. I'll investigate that further.

@AJenbo AJenbo marked this pull request as draft October 26, 2021 18:04
@AJenbo
Copy link
Member

AJenbo commented Oct 26, 2021

Converting to a draft as it has draft in the title and i keep getting notifications for it when it's being updated.

@AJenbo AJenbo changed the title Draft: fix #1410 Fix dimming lights in Leorics chamber Oct 26, 2021
@ThomasChr
Copy link
Contributor Author

ThomasChr commented Oct 26, 2021

... Simply adding Draft: in the title does not work? ...pretty sure in gitlab that does work.
So I'm not quite sure here what to do. My fix should work. But it does seems a little bit too much.
And I think I know why loading from a save does work. Because real savegames (instead of level saves) also save the light sources with them. Those simple level saves don't do that.

So I think the last thing to do would be to check if we are a simple save, in which cases we set all light objects to unseen, or if we are a big save in which case the light objects can be saved as already seen because the lights will also get saved along.

Does that sound feasible?

@AJenbo
Copy link
Member

AJenbo commented Oct 26, 2021

.pretty sure in gitlab that does work.

Yes, but not in github

@AJenbo
Copy link
Member

AJenbo commented Oct 26, 2021

Does that sound feasible?

I'm unable to think about this atm, catch me in a week or so.

@ThomasChr
Copy link
Contributor Author

@AJenbo Take your time. I think this solution now should work, it won't change anything when saving "real savegames" but it will mark all light objects unseen when saving level change data.
I'm pretty sure I will remember pinging you in a week or so. I think I'll leave this is draft until then.

@ThomasChr
Copy link
Contributor Author

@AJenbo Care to take a look?

Copy link
Member

@qndel qndel left a comment

Choose a reason for hiding this comment

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

looks good, just change make torches unseen to make dynamic light sources unseen as technically they aren't all torches :D

@ThomasChr
Copy link
Contributor Author

As usual, you are right @qndel :-)
Thanks for looking into it!

@qndel
Copy link
Member

qndel commented Nov 12, 2021

Please don't include issue # in commit - it causes quite a spam on github

…l change data (instead of real save data) does not save light source and if the light objects will be marked as seen there lights won't be created and they stay dark
@qndel
Copy link
Member

qndel commented Nov 12, 2021

This definitely feels like a proper fix, but requires some tweaks. Do valor torches behave the same way? Atm this fixes leoric chamber light issues but might cause new ones - in regular dungeons I believe all stuff like torches etc. is saved into dPreLight, with this PR they all get activated even if you aren't close to them.

To test:
Add this to X hotkey

	keymapper.AddAction({
	    "DebugToggle",
	    'X',
	    [] {
		    SDL_Log("ACTIVE LIGHT COUNT: %d", ActiveLightCount);
		    DebugToggle = !DebugToggle;
	    },
	    [&]() { return true; },
	});

After leaving leoric's tomb without your change, I had 2 active lights, after your change I instantly had 8+ active lights. So the question is if it should affect regular levels at all - if valor torches work fine, I'd only limit it to quest levels.

qndel
qndel previously approved these changes Nov 12, 2021
@qndel qndel dismissed their stale review November 12, 2021 08:10

because I can

@qndel
Copy link
Member

qndel commented Nov 12, 2021

Tested valor, it doesn't need this fix so can safely be limited only to quest levels.

@AJenbo AJenbo added this to the 1.5.0 milestone Apr 3, 2022
@AJenbo AJenbo merged commit c91feb7 into diasurgical:master Apr 18, 2023
@AJenbo
Copy link
Member

AJenbo commented Apr 18, 2023

nice work

@Chance4us
Copy link
Contributor

Many thanks @ThomasChr this one PR is really great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using town portals in leorics tomb causes the light to dim down
4 participants