Opened 8 years ago
Closed 4 years ago
#3883 closed defect (fixed)
[PATCH] Persist match settings should only save some settings
Reported by: | elexis | Owned by: | elexis |
---|---|---|---|
Priority: | Must Have | Milestone: | Alpha 24 |
Component: | UI – Game setup | Keywords: | patch |
Cc: | Patch: | Phab:D2483 |
Description (last modified by )
Currently the persist-matchsettings function (see gamesetup.js
) store all mapsettings and load it the nexttime.
But some tags shouldn't be saved.
- For example this author tag removed in r17980 was present in every replay due to this bug once the map was started once.
- Another example is
DisabledTemplates
. Belgian Uplands is the only map that disables the ptolemian lighthouse. But the persistmatchsettings will save this value and when selecting a map that doesn't set it, it actually disables them due to the remains in the persistmatchsettings-file.
Only known settings (which can be changed by the host) should be restored - every other setting ignored (notice on skirmish and scenario maps, less settings can be changed).
As mentioned in comment:7, this issue is not limited to persist-matchsettings but also applies to selecting maps itself.
Attachments (11)
Change History (34)
by , 8 years ago
Attachment: | roughsketch.patch added |
---|
comment:1 by , 8 years ago
Is this patch not working or is something missing? Are you working on this patch? If not I would try to make a patch/finish your patch.
comment:2 by , 8 years ago
The patch is only a rough sketch of how I imagine this specific thing to work. It should only load settings from that file that are allowed by a whitelist. The construction of the whitelist depends on the maptype (as the user can't change all settings on skirmish/scenario maps for example) and is not correct nor complete in that patch. Knock yourself out on that one.
comment:3 by , 8 years ago
Owner: | set to |
---|
by , 8 years ago
Attachment: | persist_match_settings.patch added |
---|
Only restore the settings the user can change (Based on elexis' roughsketch.patch)
comment:4 by , 8 years ago
Keywords: | review patch added |
---|---|
Summary: | Persist match settings should only save some settings → [PATCH] Persist match settings should only save some settings |
comment:5 by , 8 years ago
Settings like ceasefire can be changed on both skirmish and random maps. So you should add those only once if mapType == "skirmish" || mapType == "random"
. This way you omit the duplicate array entries.
by , 8 years ago
Attachment: | persist_match_settings_v4.patch added |
---|
added one parenthesis, because !
has a higher precedence then ... in ...
by , 8 years ago
Attachment: | persist_match_settings_v5.patch added |
---|
by , 8 years ago
Attachment: | persist_match_settings_v6.patch added |
---|
by , 8 years ago
Attachment: | persist_match_settings_v7.patch added |
---|
comment:6 by , 8 years ago
Milestone: | Backlog → Alpha 21 |
---|
by , 8 years ago
Attachment: | persist_match_settings_v8.patch added |
---|
Removed an else and added the ugly !!
;)
comment:7 by , 8 years ago
Keywords: | review removed |
---|
For the persist-match-settings, the patch seems okay.
However the problem described in the ticket is bigger, as the examples mentioned also occur when changing the map. selectMap
basically persists matchsettings as well.
For example pick the random map "belgian uplands". By typing warn(uneval(g_GameAttributes.settings.DisabledTemplate));
to the JS console, you will see that the ptolemian lighthouse is disabled. If you change to a different map, that attribute will still be remaining, even if the map does not specify it.
The whitelist-filter should become a global function that is used by both selectMap
and loadPersistMatchSettings
. Be careful as there might be some pitfalls.
by , 8 years ago
Attachment: | persist_match_settings_v9.patch added |
---|
remove the settings the user can not change also when changing the map
comment:8 by , 8 years ago
Keywords: | review added |
---|
by , 8 years ago
Attachment: | persist_match_settings_v9.1.patch added |
---|
removed some unneeded code and renamed cleanUpSettings
comment:10 by , 8 years ago
The idea behind the !! was to not have the RatingEnabled variable in the gameattributes if its not true. So it would be undefined and thus throw an error without !!.
follow-up: 12 comment:11 by , 8 years ago
- With the latest sketch of #3994 we can nicely decide whether a given setting can be changed on a maptype, so that one array would become obsolescent.
- I'm not completely excited about the fact that we check whether the option can be changed, but that we don't test whether the option can actually be changed to the given attribute.
The linked rewrite also doesn't provide a method to derive the changed attribute from the gameAttributes
name (with which one could call the dropdown methods to verify the integrity of that setting). In #3806 you run into the exact same issue.
Using a mapping g_GameAttributes.settings.PlayerData[i].Color
-> playerColorPicker
to do that seems ugly.
A hopefully less ugly alternative is to change the persist-matchsettings to not save gameattributes directly but only the current GUI object names and the values it sets things to, for example `[{"mapType":"skirmish"}, {"playerColor": "red", "idx": 4}, {"mapSize": 320}].
comment:12 by , 8 years ago
Replying to elexis:
A hopefully less ugly alternative is to change the persist-matchsettings to not save gameattributes directly but only the current GUI object names and the values it sets things to, for example `[{"mapType":"skirmish"}, {"playerColor": "red", "idx": 4}, {"mapSize": 320}].
This sounds like a very good idea. Also increases readability of stored settings
comment:13 by , 8 years ago
Keywords: | review removed |
---|
Removing review as we would have to rewrite the specific code again if we also want to check for the integrity of the values, though the patch probably works as advertized and solves the original issues reported in the ticket. If #3806 will fail for any reason, we can take another look, but the rewrite should be merged asap.
comment:19 by , 6 years ago
Description: | modified (diff) |
---|---|
Keywords: | simple removed |
comment:20 by , 5 years ago
Component: | UI & Simulation → Game setup |
---|
Move tickets to Game Setup
as UI & Simulation
got some sub components.
comment:21 by , 4 years ago
Milestone: | Backlog → Alpha 24 |
---|---|
Owner: | changed from | to
Patch: | → Phab:D2483 |
comment:23 by , 4 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
In order to remove unintended tags,
loadPersistMatchSettings()
ingamesetup.js
needs to delete all properties of theattrs
object which can't be changed by the user.