Feature flags + Real example features #591
Reference in New Issue
Block a user
No description provided.
Delete Branch "feature-flags"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Here's a 2nd attempt at the feature flags system.
Fix #555 Fix #146 Fix #635
Okay… this still feels like something is missing, though that might be inevitable since currently no feature flags exist.
With this system, can the existing "legacy" flag be replaced by one or more feature flags? We don't have to actually replace it, but it seems like a good test of whether the feature flag system does what it needs to do.
There's something I still need to fix here....
Ok I had realized I made get_feature_version() less than useful.
I have clarified its purpose: The game will call
get_feature_version()to find out which version of a feature should be active. So if a scenario requests an outdated feature, the game will be able to check and find that out easily. For flags that have nothing to do with scenarios, such as bugfixes, this function returns the behavior that the replay used.Did you miss my previous comment in this thread? You commented at the exact same time, so maybe it slipped through your notice…
I saw it. Yeah, I'm planning to write up a little example -- just also working on other issues and PRs.
Just rebased onto master. Today, I'm going to implement some features and fixes as part of this PR -- that way, I can make sure the system does what I want it to, and you can see concrete examples of that vision.
Ok. I've added 2 features which demonstrate how I see feature flags being useful:
Since we don't have a stable release, technically we could make these changes without the flags--especially the 2nd one, because replay files are pretty ephemeral right now, we're not maintaining many of them in the actual repo. But these 2 features show how, if we did have a stable release, we could add new features without breaking things.
I just want to get the foundation of feature flags into the code before 2.0 beta. One thing that's definitely needed, but can wait for a later milestone, is the ability to modify/update a scenario's feature flags in the editor.
The scenario feature flag example still doesn't quite make sense to me. Based on my understanding of how it should work, the logic should amount to "if this feature flag is not present, then don't do anything". Or, to put it another way, "if this feature flag is present, then do the new feature". To me, that implies that the result of
has_feature()should have been passed as theanim_pictargument. As it currently stands, that argument appears to do nothing.I think the overall result technically does fit my understand as described above, but it is done in a confusing way.
Oh--I remember adding that argument purely for its default value to be false. This wasn't to keep legacy scenarios from using the feature, it was to keep unrelated callers of the function to behave the same way they used to. If I had added only the two integer arguments with default values, then every caller would suddenly be animating things.
Alternatively, I could have made an overload of the function.
I added another replay-related feature flag: the Give Item debug action now tries to give to the active PC first.
To test that it would still fall through to give to the first PC with empty space, I added a debug action that stuffs the active PC's inventory with weightless junk items.
@@ -2005,13 +2007,41 @@ void debug_give_item() {int i = get_num_response(0, univ.scenario.scen_items.size()-1, "Which item?", item_names);I have two comments on this feature.
@@ -2005,13 +2007,41 @@ void debug_give_item() {int i = get_num_response(0, univ.scenario.scen_items.size()-1, "Which item?", item_names);I went with weightless thinking it was necessary so the weight limit wouldn't stop the function from filling every slot. Now I see there's a flag GIVE_ALLOW_OVERLOAD that can do that.
@@ -2005,13 +2007,41 @@ void debug_give_item() {int i = get_num_response(0, univ.scenario.scen_items.size()-1, "Which item?", item_names);Now they're heavy and it's a preset.
The above commit is squashed from the first two commits in this PR, in other words, the actual core of the feature. The remaining commits are left as examples of how feature flags might work, until such time as GitHub decides to collect the garbage.
Pull request closed