Opened 2 years ago

Last modified 23 months ago

#6553 closed defect

Unknown string loaded from matchsettings.json disables the game — at Initial Version

Reported by: Langbart Owned by:
Priority: Must Have Milestone: Alpha 26
Component: UI – Game setup Keywords: regression
Cc: Patch:

Description

With [26913] the string for Capture The Relic was changed which caused a problem for gameboy.

to reproduce

  • Open your existing matchsettings.json and modify a string under VictoryConditions e.g. "conquest" => "con"
  • Open the game (make sure the option Persist match settings is enabled)
  • Select Single Player => Matches
  • Errors should fill the screen

errors

0 A.D. (0.0.26) Main log (warnings and errors only)
ERROR: JavaScript error: gamesettings/attributes/VictoryConditions.js line 73 this.conditions[name] is undefined _add@gamesettings/attributes/VictoryConditions.js:73:7 fromInitAttributes@gamesettings/attributes/VictoryConditions.js:38:10 fromInitAttributes@gamesettings/GameSettings.js:90:17 parseSettings@gui/gamesetup/Controllers/GameSettingsController.js:191:18 onLoad@gui/gamesetup/Controllers/GameSettingsController.js:89:10 SetupWindow@gui/gamesetup/SetupWindow.js:61:11 init@gui/gamesetup/gamesetup.js:47:18 onPress@gui/pregame/MainMenuItems.js:99:13 performButtonAction@gui/pregame/MainMenuItemHandler.js:77:9 pressButton@gui/pregame/MainMenuItemHandler.js:63:10

ERROR: GUI page 'page_gamesetup.xml': Failed to call init() function

possible solution

Check if the value loaded from the matchsettings.json is real.
Example: gamesettings/attributes/VictoryConditions

    fromInitAttributes(attribs)
    {
        let legacy = this.getLegacySetting(attribs, "VictoryConditions");
+       const checkForExistence = legacy.filter(x => Object.keys(this.conditions).some(y => x === y));
+       legacy = checkForExistence.length === 0 ? "" : checkForExistence;
        if (legacy)
        {
            this.disabled = new Set();
            this.active = new Set();

Change History (0)

Note: See TracTickets for help on using tickets.