Index: binaries/data/mods/public/gui/structree/load.js =================================================================== --- binaries/data/mods/public/gui/structree/load.js +++ binaries/data/mods/public/gui/structree/load.js @@ -16,7 +16,7 @@ { build = build.replace("{civ}", g_SelectedCiv); unit.production.units.push(build); - if (g_Lists.units.indexOf(build) < 0) + if (Engine.TemplateExists(build) && g_Lists.units.indexOf(build) < 0) g_Lists.units.push(build); } } @@ -36,7 +36,7 @@ for (let build of template.Builder.Entities._string.split(" ")) { build = build.replace("{civ}", g_SelectedCiv); - if (g_Lists.structures.indexOf(build) < 0) + if (Engine.TemplateExists(build) && g_Lists.structures.indexOf(build) < 0) g_Lists.structures.push(build); } @@ -63,7 +63,7 @@ { build = build.replace("{civ}", g_SelectedCiv); structure.production.units.push(build); - if (g_Lists.units.indexOf(build) < 0) + if (Engine.TemplateExists(build) && g_Lists.units.indexOf(build) < 0) g_Lists.units.push(build); } @@ -166,7 +166,7 @@ } /** - * Loads the names of all phases required to research the given technologies. + * Determine order of phases. * * @param techs The current available store of techs * @@ -210,6 +210,10 @@ phaseList.splice(reqPhasePos+1, 0, myPhase); phaseList.splice(myPhasePos, 1); } + else if (reqPhasePos < 0 && myPhasePos < 0) + // If neither phase is in the list, then add them both to the end and + // rely on later iterations relocating them to their correct place. + phaseList.push(reqPhase, myPhase); } return phaseList;