Page MenuHomeWildfire Games

Fix undefined property g_GameAttributes.settings.Keywords in autostarted games
ClosedPublic

Authored by elexis on Apr 8 2018, 4:39 PM.

Details

Summary

When starting a match in observermode from commandline, for example

-autostart="random/anatolian_plateau" -autostart-seed=-1 -autostart-players=2 -autostart-civ=1:athen -autostart-civ=2:brit -autostart-ai=1:petra -autostart-ai=2:petra -autostart-player=-1

and switch to gaia, we get this error following rP21464:

WARNING: JavaScript warning: gui/session/session.js line 672
reference to undefined property g_GameAttributes.settings.Keywords
ERROR: JavaScript error: gui/session/session.js line 672
TypeError: g_GameAttributes.settings.Keywords is undefined
  updateTopPanel@gui/session/session.js:672:3
  selectViewPlayer@gui/session/session.js:568:2
  __eventhandler112 (selectionchange)@viewPlayer selectionchange:0:1
Test Plan

We either have to add another condition Keywords && Keywords contains trigger or we simplify and generalize it. Pick one.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

elexis created this revision.Apr 8 2018, 4:39 PM
elexis retitled this revision from Summary: to Fix undefined property g_GameAttributes.settings.Keywords in autostarted games.Apr 8 2018, 4:41 PM
Vulcan added a subscriber: Vulcan.Apr 8 2018, 6:13 PM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Default...
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 6 tabs but found 5.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
| 407| 407| 				// Players see colors depending on diplomacy
| 408| 408| 				g_DisplayedPlayerColors[i] =
| 409| 409| 					g_ViewedPlayer == i ? getDiplomacyColor("self") :
| 410|    |-					g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") :
|    | 410|+						g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") :
| 411| 411| 					g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") :
| 412| 412| 					getDiplomacyColor("enemy");
| 413| 413| 
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 7 tabs but found 5.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
| 408| 408| 				g_DisplayedPlayerColors[i] =
| 409| 409| 					g_ViewedPlayer == i ? getDiplomacyColor("self") :
| 410| 410| 					g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") :
| 411|    |-					g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") :
|    | 411|+							g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") :
| 412| 412| 					getDiplomacyColor("enemy");
| 413| 413| 
| 414| 414| 		g_DisplayedPlayerColors[0] = g_Players[0].color;
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 8 tabs but found 5.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
| 409| 409| 					g_ViewedPlayer == i ? getDiplomacyColor("self") :
| 410| 410| 					g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") :
| 411| 411| 					g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") :
| 412|    |-					getDiplomacyColor("enemy");
|    | 412|+								getDiplomacyColor("enemy");
| 413| 413| 
| 414| 414| 		g_DisplayedPlayerColors[0] = g_Players[0].color;
| 415| 415| 	}
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 4 tabs but found 3.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
| 665| 665| 					"civ": setStringTags(g_CivData[g_Players[g_ViewedPlayer].civ].Name, { "font": "sans-bold-stroke-14" }),
| 666| 666| 					"hotkey_civinfo": colorizeHotkey("%(hotkey)s", "civinfo"),
| 667| 667| 					"hotkey_structree": colorizeHotkey("%(hotkey)s", "structree")
| 668|    |-			});
|    | 668|+				});
| 669| 669| 	}
| 670| 670| 
| 671| 671| 	// Following gaia can be interesting on scripted maps
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 3 tabs but found 2.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|1255|1255| 
|1256|1256| 	let orderHotkeyTooltip = Object.keys(viewablePlayerStates).length <= 1 ? "" :
|1257|1257| 		"\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), {
|1258|    |-		"hotkey": setStringTags("\\[Click]", g_HotkeyTags),
|    |1258|+			"hotkey": setStringTags("\\[Click]", g_HotkeyTags),
|1259|1259| 		"order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending")
|1260|1260| 	});
|1261|1261| 
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 3 tabs but found 2.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|1256|1256| 	let orderHotkeyTooltip = Object.keys(viewablePlayerStates).length <= 1 ? "" :
|1257|1257| 		"\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), {
|1258|1258| 		"hotkey": setStringTags("\\[Click]", g_HotkeyTags),
|1259|    |-		"order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending")
|    |1259|+			"order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending")
|1260|1260| 	});
|1261|1261| 
|1262|1262| 	let resCodes = g_ResourceData.GetCodes();
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 1.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|1257|1257| 		"\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), {
|1258|1258| 		"hotkey": setStringTags("\\[Click]", g_HotkeyTags),
|1259|1259| 		"order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending")
|1260|    |-	});
|    |1260|+		});
|1261|1261| 
|1262|1262| 	let resCodes = g_ResourceData.GetCodes();
|1263|1263| 	for (let r = 0; r < resCodes.length; ++r)
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 1 tab but found 3.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|1755|1755| 	for (let rct of resourcesCounterTypes)
|1756|1756| 		for (let rt of resourcesTypes)
|1757|1757| 			reportObject[rt + rct.substr(9)] = playerStatistics[rct][rt];
|1758|    |-			// eg. rt = food rct.substr = Gathered rct = resourcesGathered
|    |1758|+	// eg. rt = food rct.substr = Gathered rct = resourcesGathered
|1759|1759| 
|1760|1760| 	reportObject.vegetarianFoodGathered = playerStatistics.resourcesGathered.vegetarianFood;
|1761|1761| 	for (let type of unitsClasses)

binaries/data/mods/public/gui/session/session.js
|1083| »   let·getPanelEntNameTooltip·=·panelEntState·=>·"[font=\"sans-bold-16\"]"·+·template.name.specific·+·"[/font]";
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'panelEntState' is already declared in the upper scope.

binaries/data/mods/public/gui/session/session.js
|1158| »   »   button.onpress·=·(function(i)·{·return·function()·{·performGroup((Engine.HotkeyIsPressed("selection.add")·?·"add"·:·"select"),·i);·};·})(i);
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'i' is already declared in the upper scope.

binaries/data/mods/public/gui/session/session.js
|1159| »   »   button.ondoublepress·=·(function(i)·{·return·function()·{·performGroup("snap",·i);·};·})(i);
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'i' is already declared in the upper scope.

binaries/data/mods/public/gui/session/session.js
|1160| »   »   button.onpressright·=·(function(i)·{·return·function()·{·performGroup("breakUp",·i);·};·})(i);
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'i' is already declared in the upper scope.

Link to build: https://jenkins.wildfiregames.com/job/differential/364/display/redirect

bb accepted this revision.Apr 8 2018, 11:30 PM
bb added a subscriber: bb.

Cannot reproduce the error, but any looks good and correct and doesn't seems to break anything. Agree with the picked option to not depend on that keyword for gui settings.

This revision is now accepted and ready to land.Apr 8 2018, 11:30 PM
elexis edited the summary of this revision. (Show Details)Apr 11 2018, 3:35 PM

Seems only slightly better to have the nicer code while showing an option in the other 98% of the cases where it is useless.
There were plans to teach Petra that gaia attacks can occur on survival, maybe that flag could be reused here eventually if we prefer the inconsistent variant.
Thanks for the review.

This revision was automatically updated to reflect the committed changes.
Owners added a subscriber: Restricted Owners Package.Apr 11 2018, 3:42 PM