Don't exit on losing all lemmings (feature development)

Started by Simon, January 10, 2024, 11:42:06 AM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

Simon

I'm sitting in Mumble. Join anytime.

BRB in 20 minutes (17:30 UTC). Back.

-- Simon

Dullstar

Quote from: WillLem on May 09, 2024, 12:09:56 AM
I understand your desire for the singular option, but there are benefits to keeping them separate (and, identified by strings rather than numbers). My instinct on this one is, let's keep it as it is at least for now.

I agree with Simon here regarding the use of an enum. There *should* always be one and exactly one of the options active, but an enum will consistently enforce it across the entire codebase. Even if everything's correct now, this has maintenance benefits long-term. It shows that it's intended that exactly one of the options is true, and you won't have to worry about any bad behavior as a result of attempting to run multiple options at once (sure, maybe setting them all to true doesn't misbehave for now... until some other change happens and it no longer gets handled gracefully but nobody checked).

You can still identify them with strings in the options file, and the enum values have names so it's not like you need to remember that "OptionA" is 0, "OptionB" is 1... keeping track of that is the compiler's responsibility.

WillLem

Quote from: Simon on May 13, 2024, 05:11:04 PM
I'm sitting in Mumble. Join anytime.

Hi Simon, I've ended up being super busy this evening with IRL stuff. If you're free another evening this week I'll make sure to get it in the calendar. I could try to do the PR by myself, but would much prefer to do it with your guidance.

Quote from: Dullstar on May 13, 2024, 07:55:33 PM
I agree with Simon here regarding the use of an enum. There *should* always be one and exactly one of the options active, but an enum will consistently enforce it across the entire codebase. Even if everything's correct now, this has maintenance benefits long-term.

OK, I'll give it a try. Can't promise anything, because I currently have no idea what an enum is, let alone how it works or how to properly implement it. With that said, lack of prior knowledge hasn't exactly stopped me so far ;P

I'll aim to get something done before Simon and I next meet.

Simon

All right, leaving Mumble and going to bed.

Quote from: WillLem on May 13, 2024, 09:58:26 PM
another evening this week I'll make sure to get it in the calendar.

Wednesday, 16th, from 16:00 UTC is good. I'll have time until 21:00 UTC. Please choose a definite starting time beforehand, and I'll confirm it.

-- Simon

Dullstar

Quote from: WillLem on May 13, 2024, 09:58:26 PM
OK, I'll give it a try. Can't promise anything, because I currently have no idea what an enum is, let alone how it works or how to properly implement it. With that said, lack of prior knowledge hasn't exactly stopped me so far ;P

The syntax will of course vary by language, but I think an example will be the easiest way to show it:

Note that this example isn't Delphi, as it's not a language I've worked with. This is more about the concept of enums in general, not how to write them in your language of choice.
enum Colors
{
    Red,
    Orange,
    Yellow,
    Green,
    Blue,
    Purple
}


Basically we've just created a new type* that can only hold these values**. Internally, they're probably just ints where Red = 0, Orange = 1... Purple = 5, but code that wants a Color doesn't need to care about that. When saving/loading from a file, we can convert them to/from strings as needed; some languages offer features to do this automatically, but if not, well, if we had to do some if/else to read/write anyway without the enums, we can do it with enums too. Many languages allow you to explicitly choose an underlying type and assign your own values, but there will usually be sensible defaults.

*Well, symbolically anyway. Languages vary in whether their type system considers enums to be different from their underlying types.

**Among languages that consider it to be a separate type, they also vary in whether or not you can force it to convert a value from the underlying type to the enum type even if that value isn't part of the enum, but fortunately in many (most?) languages it's difficult to do this accidentally.


---

Well, there's also the somewhat more complex Rust enums which basically merge unions and enums into one feature, but let's not worry about those.

Simon


WillLem

Quote from: Simon on May 13, 2024, 10:42:22 PM
Wednesday, 16th, from 16:00 UTC is good. I'll have time until 21:00 UTC. Please choose a definite starting time beforehand, and I'll confirm it.

I assume you mean Weds 15th? I should be able to make 1900 GMT (so, 1800 UTC?) that day, possibly even earlier. I've added it to the calendar. W

Simon

Yes, Wednesday, 15th, not 16th, sorry. All right, 18:00 UTC it is, i.e., 19:00 English daylight savings.

See you tomorrow!

-- Simon

WillLem

Quote from: Simon on May 14, 2024, 06:46:50 PM
Yes, Wednesday, 15th ... 18:00 UTC it is, i.e., 19:00 English daylight savings.

See you tomorrow!

Confirmed, see you then! :lemcat:

WillLem

#129
NL 12.13 Exp V8 (commit a9709ba)

EDIT: Attachment removed due to release of NL 12.13-RC

Simon

We refactored the three bools into one enum.

I tested the Exp 8 (from WillLem's previous post) and it all looks good. The default behavior is to exit if save requirement met. Options load and save correctly, and behave accordingly during play. Icho's Lemmings United mass-tests identically in this Exp 8 as it did in the Exp 6, i.e., everything looks good here, too.

Pull request is up for namida to review. WillLem and I are both happy to give high-level overviews of the source changes; namida: Ask here or in IRC or anywhere. The diff is moderately large: 9 files changed (7 source files and 2 new images), 211 insertions, 61 deletions, but overall it stayed surprisingly manageable.

Thanks, WillLem, for your patience and for ironing it all out!

-- Simon

namida

I've merged the pull request (along with the GR32v3 update, which at a quick check had one minor, purely visual bug that I quickly fixed but otherwise works fine). It will be more difficulty than it's worth to backport this to 12.12; instead I'm going to try and wrap up the remaining issues for 12.13 and move that into RC soon.
My projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)
Non-Lemmings: Commander Keen: Galaxy Reimagined (a Commander Keen fangame)

Simon


namida

My projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)
Non-Lemmings: Commander Keen: Galaxy Reimagined (a Commander Keen fangame)