devilutionX
devilutionX copied to clipboard
Draft: allow for more light sources
I'm capping this to 255 for the moment because we're using it with an uint_8. Can be further increased if we change the uint_8 in lighting.h and lighting.cpp.
lighting.h, Line 43
extern uint8_t ActiveLights[MAXLIGHTS];
lighting.cpp, Line 21
uint8_t ActiveLights[MAXLIGHTS];
Draft because: Untested. See also PR #3122
In LoadGame()
(loadsave.cpp:1751) loading a non-town save file expects exactly 32 light indexes/IDs followed by a max of 32 chunks of data representing each light. This will need to have logic added to save the first 32 active lights, then put the rest somewhere else while also ensuring that ActiveLightCount is 32 in old versions but gets the correct value for versions supporting more lights.
Draft because: Untested. See also PR #3122
When you're ready you can use the Ready for review button that appears in the workflow status area:
The mark as draft "button" is disguised as a text link, that appears in the side menu at the bottom of the Reviewers section, it'll be in the region I marked with a yellow box in this screenshot, but looks like a link:
I'm capping this to 255 for the moment because we're using it with an uint_8.
It is used with int_8, cap it to 127.
https://github.com/diasurgical/devilutionX/blob/master/Source/monster.h#L218
It's a lot of noise for a single int change 😉
I'm working on the save right now. Should have a test version today... It's a little bit more tricky then I thought.
Just to note here: We‘re also saving:
- The number of active lights - which we need to reduce by the number of berserk light.
- The whole active lights array. Which has MAXLIGHTS Entrys. Also here we need only save 32 id's and no berserk light ids.
- For every active light the details.
So there are little more tricks to do. I find it strange that we‘re saving the whole activelights array even if most of them are in fact not really active.
It was much more complicated then I thought at first. The code does seem to work right now. I will test a little more and remove the debug messages.
crashes when saving with active firewall (missle light)...
crash solved. Needs more testing and tidying up
@AJenbo Do we favor single line if-, or for-loops with-, or without braces?
if (true)
doWork();
for (int i; i <= 10; i++)
doWork(i);
or
if (true) {
doWork();
}
for (int i; i <= 10; i++) {
doWork(i);
}
I did find both styles
With is usually best since it's safer
Perfect. I personally prefer with braces!
Once this gets merged it would be nice if you wold work on the same for missiles :)
... you change the line endings in loadsave.cpp so now it looks like all of it is rewritten
Yay! Seems that I've triggered a bug... https://youtrack.jetbrains.com/issue/IDEA-262067
As noted in https://github.com/diasurgical/devilutionX/pull/3292 It should also be possible to not save lights for light objects (torches...). Because they will be applied in the game loop anyways. So we don't save:
- Berserk Monsters
- Missiles
- Light Objects
What else is there left? I know that we have light sources for unique monsters (which also can be applied after loading), and all the other light sources I can think of (player, golem...) can also be applied AFTER loading. To me there is no sense in saving lights at all. Am I wrong?