Opened 2 years ago

Closed 2 years ago

#6548 closed defect (fixed)

Error with maps created in the atlas with the victory condition "Conquest Civic Centers"

Reported by: Langbart Owned by: Freagarach
Priority: Should Have Milestone: Alpha 26
Component: UI – Game setup Keywords: simple
Cc: Patch:

Description

to reproduce

  • Start the Scenario Editor (aka Atlas)
  • Tick Conquest Civic Centers and save the map.
  • Start it normally from the GUI with the 0 A.D. app.
  • Errors appear when selecting the map in the game setup.

errors

ERROR: Error in timer: TypeError: this.conditions[name] is undefined _add@gamesettings/attributes/VictoryConditions.js:73:7 onMapChange@gamesettings/attributes/VictoryConditions.js:53:9 init/<@gamesettings/attributes/VictoryConditions.js:14:38 _trigger@gui/common/Observable.js:45:12 set@gui/common/Observable.js:35:11 selectMap@gamesettings/attributes/Map.js:44:3 call@gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/MapSelection.js:124:23 updateTimers@gui/common/timer.js:61:8 onTick@gui/gamesetup/SetupWindow.js:107:3 @gui/gamesetup/SetupWindow.js:57:64

What is the issue?

The VictoryConditions in the newly created .xml file lists conquest_civic_centres.

Line 
1 ],
2 "Preview": "",
3 "RevealMap": false,
4 "VictoryConditions": [
5 "conquest_civic_centres"
6 ]
7}
8]]></ScriptSettings>

The Map.cpp file takes the Title of the VictoryConditions makes it lower case and fills the gaps with an underscore.

Line 
189 for (const std::string& victoryConditionJson : victoryConditionData)
190 {
191 AtObj victoryCondition = AtlasObject::LoadFromJSON(victoryConditionJson);
192 long index = wxWindow::NewControlId();
193 wxString title = wxString::FromUTF8(victoryCondition["Data"]["Title"]);
194 std::string escapedTitle = title.Lower().ToStdString();
195 std::replace(escapedTitle.begin(), escapedTitle.end(), ' ', '_');
196 AtObj updateCondition = *(victoryCondition["Data"]["Title"]);
197 updateCondition.setString(escapedTitle.c_str());
198 m_VictoryConditions.insert(std::pair<long, AtObj>(index, victoryCondition));
199 CREATE_CHECKBOX(this, vcGridSizer, title, "Select " + title + " victory condition.", index);
200 }

In the game setup the function loadVictoryConditions checks for the filename NOT the title.

Line 
215/**
216 * Loads available victoryCondtions from json files.
217 *
218 * @returns {Array|undefined}
219 */
220function loadVictoryConditions()
221{
222 let subdir = "victory_conditions/";
223
224 let victoryConditions = listFiles(g_SettingsDirectory + subdir, ".json", false).map(victoryScriptName => {
225 let victoryCondition = loadSettingValuesFile(subdir + victoryScriptName + ".json");
226 if (victoryCondition)
227 victoryCondition.Name = victoryScriptName;
228 return victoryCondition;
229 });
230
231 if (victoryConditions.some(victoryCondition => victoryCondition == undefined))
232 return undefined;
233
234 return victoryConditions.sort((a, b) => a.GUIOrder - b.GUIOrder || (a.Title > b.Title ? 1 : a.Title > b.Title ? -1 : 0));
235}

The end result differs from the actual file name conquest_civiccentres.json. The issue does not occur with capture_the_relic.json.

reproducible

Issue can be reproduced up to A25, in A24 there was no option in Atlas to do this. It was added with [25422].

possible solution

Simplest solution is changing the file name from conquest_civiccentres.json to conquest_civic_centres.json.

Change History (3)

comment:1 by Langbart, 2 years ago

Also change the string from centre to center.
See comment: D3530#171291 by nwtour (17/May/21).

Ref: wiki/EnglishStyleGuide#Englishspelling

comment:2 by Stan, 2 years ago

Care to make a patch for the rename + centre to center ?

comment:3 by Freagarach, 2 years ago

Owner: set to Freagarach
Resolution: fixed
Status: newclosed

In 26913:

Fix maps with conquest CC victory conditions.

Rename the file to be consistent with its title.
Also centre -> center as per the style guide. Reported by @nwtour at https://code.wildfiregames.com/D3530#171291.

Reported by: @Langbart
Essentially a patch by: @Langbart
Fixes #6548

Note: See TracTickets for help on using tickets.