﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	resolution	keywords	cc	phab_field
6553	Unknown string loaded from matchsettings.json disables the game	Langbart		"With [26913] the string for `Capture The Relic` was changed which caused a problem for `gameboy`.
* Related forum thread: [https://wildfiregames.com/forum/topic/81837-unable-to-start-the-game/ Unable to start the game.] (31/May/22)

==== 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: [https://code.wildfiregames.com/source/0ad/browse/ps/trunk/binaries/data/mods/public/gamesettings/attributes/VictoryConditions.js$32 gamesettings/attributes/VictoryConditions]
{{{#!diff
 	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();
}}}"	defect	new	Should Have	Alpha 26	UI – Game setup				
