Index: binaries/data/mods/public/globalscripts/Templates.js =================================================================== --- binaries/data/mods/public/globalscripts/Templates.js +++ binaries/data/mods/public/globalscripts/Templates.js @@ -23,7 +23,7 @@ if (selectableOnly && !data.SelectableInGameSetup) continue; - const template = Engine.GetTemplate("special/players/" + data.Code); + const template = Engine.GetTemplate("players/" + data.Code); data.Name = template.Identity.GenericName; data.Emblem = "session/portraits/" + template.Identity.Icon; data.History = template.Identity.History; Index: binaries/data/mods/public/gui/reference/common/TemplateLoader.js =================================================================== --- binaries/data/mods/public/gui/reference/common/TemplateLoader.js +++ binaries/data/mods/public/gui/reference/common/TemplateLoader.js @@ -323,7 +323,7 @@ * It might be nice if we could get these from somewhere, instead of having them hardcoded here. */ TemplateLoader.prototype.AuraPath = "simulation/data/auras/"; -TemplateLoader.prototype.PlayerPath = "special/players/"; +TemplateLoader.prototype.PlayerPath = "players/"; TemplateLoader.prototype.TechnologyPath = "simulation/data/technologies/"; TemplateLoader.prototype.DefaultCiv = "gaia"; Index: binaries/data/mods/public/gui/reference/common/TemplateParser.js =================================================================== --- binaries/data/mods/public/gui/reference/common/TemplateParser.js +++ binaries/data/mods/public/gui/reference/common/TemplateParser.js @@ -225,7 +225,7 @@ } /** - * Load and parse the relevant player_{civ}.xml template. + * Load and parse the relevant {civ}.xml template. */ getPlayer(civCode) { Index: binaries/data/mods/public/maps/scenarios/units_demo.js =================================================================== --- binaries/data/mods/public/maps/scenarios/units_demo.js +++ binaries/data/mods/public/maps/scenarios/units_demo.js @@ -30,9 +30,13 @@ */ let gap = 14; -let cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); -for (let template of cmpTemplateManager.FindAllTemplates(actors)) +const cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); +for (const template of cmpTemplateManager.FindAllTemplates(actors)) { + const templateData = cmpTemplateManager.GetTemplate(template); + if (!templateData?.Position) + continue; + print(template + "...\n"); let ent = Engine.AddEntity(template); @@ -42,19 +46,17 @@ continue; } - let cmpFootprint = Engine.QueryInterface(ent, IID_Footprint); - if (!cmpFootprint) + let w = h = 1; + const cmpFootprint = Engine.QueryInterface(ent, IID_Footprint); + if (cmpFootprint) { - print(template + " has no footprint\n"); - continue; - } - - let shape = cmpFootprint.GetShape(); - let w = shape.width; - let h = shape.depth; + let shape = cmpFootprint.GetShape(); + let w = shape.width; + let h = shape.depth; - if (shape.type == 'circle') - w = h = shape.radius * 2; + if (shape.type == 'circle') + w = h = shape.radius * 2; + } if (x + w >= stopX) { Index: binaries/data/mods/public/simulation/helpers/Player.js =================================================================== --- binaries/data/mods/public/simulation/helpers/Player.js +++ binaries/data/mods/public/simulation/helpers/Player.js @@ -129,7 +129,7 @@ function GetPlayerTemplateName(civ) { - return "special/players/" + civ; + return "players/" + civ; } /** Index: binaries/data/mods/public/simulation/templates/special/players/athen.xml =================================================================== --- binaries/data/mods/public/simulation/templates/special/players/athen.xml +++ binaries/data/mods/public/simulation/templates/special/players/athen.xml @@ -1,17 +0,0 @@ - - - - teambonuses/athen_player_teambonus - - - athen - Athenians - As the cradle of Western civilization and the birthplace of democracy, Athens was famed as a center for the arts, learning and philosophy. The Athenians were also powerful warriors, particularly at sea. At its peak, Athens dominated a large part of the Hellenic world for several decades. - emblems/emblem_athenians.png - - - - special/formations/phalanx - - - Index: binaries/data/mods/public/simulation/templates/special/players/brit.xml =================================================================== --- binaries/data/mods/public/simulation/templates/special/players/brit.xml +++ binaries/data/mods/public/simulation/templates/special/players/brit.xml @@ -1,12 +0,0 @@ - - - - teambonuses/brit_player_teambonus - - - brit - Britons - The Britons were the Celtic tribes of the British Isles. Using chariots, longswordsmen and powerful melee soldiers, they staged fearsome revolts against Rome to protect their customs and interests. Also, they built thousands of unique structures such as hill forts, crannogs and brochs. - emblems/emblem_britons.png - - Index: binaries/data/mods/public/simulation/templates/special/players/cart.xml =================================================================== --- binaries/data/mods/public/simulation/templates/special/players/cart.xml +++ binaries/data/mods/public/simulation/templates/special/players/cart.xml @@ -1,17 +0,0 @@ - - - - teambonuses/cart_player_teambonus - - - cart - Carthaginians - Carthage, a city-state in modern-day Tunisia, was a formidable force in the western Mediterranean, eventually taking over much of North Africa and modern-day Spain in the third century B.C. The sailors of Carthage were among the fiercest contenders on the high seas, and masters of naval trade. They deployed towered War Elephants on the battlefield to fearsome effect, and had defensive walls so strong, they were never breached. - emblems/emblem_carthaginians.png - - - - special/formations/phalanx - - - Index: binaries/data/mods/public/simulation/templates/special/players/gaia.xml =================================================================== --- binaries/data/mods/public/simulation/templates/special/players/gaia.xml +++ binaries/data/mods/public/simulation/templates/special/players/gaia.xml @@ -1,45 +0,0 @@ - - - - gaia - Gaia - emblems/emblem_gaia.png - true - - - - - 1.0 - - - 1.0 - 1.0 - 1.0 - 1.0 - - - 1.0 - 1.0 - 1.0 - 1.0 - - - - special/formations/null - special/formations/box - special/formations/column_closed - special/formations/line_closed - special/formations/column_open - special/formations/line_open - special/formations/flank - special/formations/battle_line - special/formations/skirmish - special/formations/wedge - special/formations/phalanx - special/formations/syntagma - special/formations/testudo - special/formations/anti_cavalry - special/formations/scatter - - - Index: binaries/data/mods/public/simulation/templates/special/players/gaul.xml =================================================================== --- binaries/data/mods/public/simulation/templates/special/players/gaul.xml +++ binaries/data/mods/public/simulation/templates/special/players/gaul.xml @@ -1,12 +0,0 @@ - - - - teambonuses/gaul_player_teambonus - - - gaul - Gauls - The Gauls were the Celtic tribes of continental Europe. Dominated by a priestly class of Druids, they featured a sophisticated culture of advanced metalworking, agriculture, trade and even road engineering. With heavy infantry and cavalry, Gallic warriors valiantly resisted Caesar's campaign of conquest and Rome's authoritarian rule. - emblems/emblem_celts.png - - Index: binaries/data/mods/public/simulation/templates/special/players/han.xml =================================================================== --- binaries/data/mods/public/simulation/templates/special/players/han.xml +++ binaries/data/mods/public/simulation/templates/special/players/han.xml @@ -1,25 +0,0 @@ - - - - teambonuses/han_player_teambonus - - - - 1 - 1 - 1 - 9 - - - - han - Han - The Han dynasty (206 BC – AD 220) was the second imperial dynasty of China, preceded by the Qin dynasty (221–207 BC) and succeeded by the Three Kingdoms period (AD 220–280). It is considered a golden age in Chinese history, and China made significant progress in arts and sciences during the Han period. The core of the Han empire was around the Wei River, and the Han capital was Chang'an, very close to the Qin capital Xianyang (both are now part of Xi'an, Shaanxi). - emblems/emblem_han.png - - - - special/formations/anti_cavalry - - - Index: binaries/data/mods/public/simulation/templates/special/players/iber.xml =================================================================== --- binaries/data/mods/public/simulation/templates/special/players/iber.xml +++ binaries/data/mods/public/simulation/templates/special/players/iber.xml @@ -1,12 +0,0 @@ - - - - teambonuses/iber_player_teambonus - - - iber - Iberians - The Iberians were a people of mysterious origins and language, with a strong tradition of horsemanship and metalworking. A relatively peaceful culture, they usually fought in other's battles only as mercenaries. However, they proved tenacious when Rome sought to take their land and freedom from them, and employed pioneering guerrilla tactics and flaming javelins as they fought back. - emblems/emblem_iberians.png - - Index: binaries/data/mods/public/simulation/templates/special/players/kush.xml =================================================================== --- binaries/data/mods/public/simulation/templates/special/players/kush.xml +++ binaries/data/mods/public/simulation/templates/special/players/kush.xml @@ -1,17 +0,0 @@ - - - - teambonuses/kush_player_teambonus - - - kush - Kushites - The Kingdom of Kush was an ancient African kingdom situated on the confluences of the Blue Nile, White Nile and River Atbara in what is now the Republic of Sudan. The Kushite era of rule in the region was established after the Bronze Age collapse of the New Kingdom of Egypt, and it was centered at Napata in its early phase. They invaded Egypt in the 8th century BC, and the Kushite emperors ruled as Pharaohs of the Twenty-fifth dynasty of Egypt for a century, until they were expelled by the Assyrians. Kushite culture was influenced heavily by the Egyptians, with Kushite pyramid building and monumental temple architecture still extent. The Kushites even worshipped many Egyptian gods, including Amun. During Classical antiquity, the Kushite imperial capital was at Meroe. In early Greek geography, the Meroitic kingdom was known as Aethiopia. The Kushite kingdom persisted until the 4th century AD, when it weakened and disintegrated due to internal rebellion, eventually succumbing to the rising power of Axum. - emblems/emblem_kushites.png - - - - special/formations/syntagma - - - Index: binaries/data/mods/public/simulation/templates/special/players/mace.xml =================================================================== --- binaries/data/mods/public/simulation/templates/special/players/mace.xml +++ binaries/data/mods/public/simulation/templates/special/players/mace.xml @@ -1,18 +0,0 @@ - - - - teambonuses/mace_player_teambonus - - - mace - Macedonians - Macedonia was an ancient Greek kingdom, centered in the northeastern part of the Greek peninsula. Under the leadership of Alexander the Great, Macedonian forces and allies took over most of the world they knew, including Egypt, Persia and parts of the Indian subcontinent, allowing a diffusion of Hellenic and eastern cultures for years to come. - emblems/emblem_macedonians.png - - - - special/formations/phalanx - special/formations/syntagma - - - Index: binaries/data/mods/public/simulation/templates/special/players/maur.xml =================================================================== --- binaries/data/mods/public/simulation/templates/special/players/maur.xml +++ binaries/data/mods/public/simulation/templates/special/players/maur.xml @@ -1,12 +0,0 @@ - - - - teambonuses/maur_player_teambonus - - - maur - Mauryas - Founded in 322 B.C. by Chandragupta Maurya, the Mauryan Empire was the first to rule most of the Indian subcontinent, and was one of the largest and most populous empires of antiquity. Its military featured bowmen who used the long-range bamboo longbow, fierce female warriors, chariots, and thousands of armored war elephants. Its philosophers, especially the famous Acharya Chanakya, contributed to such varied fields such as economics, religion, diplomacy, warfare, and good governance. Under the rule of Ashoka the Great, the empire saw 40 years of peace, harmony, and prosperity. - emblems/emblem_mauryas.png - - Index: binaries/data/mods/public/simulation/templates/special/players/pers.xml =================================================================== --- binaries/data/mods/public/simulation/templates/special/players/pers.xml +++ binaries/data/mods/public/simulation/templates/special/players/pers.xml @@ -1,17 +0,0 @@ - - - - teambonuses/pers_player_teambonus - - - pers - Persians - The Persian Empire, when ruled by the Achaemenid dynasty, was one of the greatest empires of antiquity, stretching at its zenith from the Indus Valley in the east to Greece in the west. The Persians were the pioneers of empire-building of the ancient world, successfully imposing a centralized rule over various peoples with different customs, laws, religions and languages, and building a cosmopolitan army made up of contingents from each of these nations. - emblems/emblem_persians.png - - - - special/formations/phalanx - - - Index: binaries/data/mods/public/simulation/templates/special/players/ptol.xml =================================================================== --- binaries/data/mods/public/simulation/templates/special/players/ptol.xml +++ binaries/data/mods/public/simulation/templates/special/players/ptol.xml @@ -1,26 +0,0 @@ - - - - teambonuses/ptol_player_teambonus - - - - - phase_town - Hero - - - - - ptol - Ptolemies - The Ptolemaic dynasty was a Macedonian Greek royal family which ruled the Ptolemaic Empire in Egypt during the Hellenistic period. Their rule lasted for 275 years, from 305 BC to 30 BC. They were the last dynasty of ancient Egypt. - emblems/emblem_ptolemies.png - - - - special/formations/phalanx - special/formations/syntagma - - - Index: binaries/data/mods/public/simulation/templates/special/players/rome.xml =================================================================== --- binaries/data/mods/public/simulation/templates/special/players/rome.xml +++ binaries/data/mods/public/simulation/templates/special/players/rome.xml @@ -1,18 +0,0 @@ - - - - teambonuses/rome_player_teambonus - - - rome - Romans - The Romans controlled one of the largest empires of the ancient world, stretching at its peak from southern Scotland to the Sahara Desert, and containing between 60 million and 80 million inhabitants, one quarter of the Earth's population at that time. Rome also remained one of the strongest nations on earth for almost 800 years. The Romans were the supreme builders of the ancient world, excelled at siege warfare and had an exquisite infantry and navy. - emblems/emblem_romans.png - - - - special/formations/testudo - special/formations/anti_cavalry - - - Index: binaries/data/mods/public/simulation/templates/special/players/sele.xml =================================================================== --- binaries/data/mods/public/simulation/templates/special/players/sele.xml +++ binaries/data/mods/public/simulation/templates/special/players/sele.xml @@ -1,26 +0,0 @@ - - - - teambonuses/sele_player_teambonus - - - - - phase_town - Hero - - - - - sele - Seleucids - The Macedonian-Greek dynasty that ruled most of Alexander's former empire. - emblems/emblem_seleucids.png - - - - special/formations/phalanx - special/formations/syntagma - - - Index: binaries/data/mods/public/simulation/templates/special/players/spart.xml =================================================================== --- binaries/data/mods/public/simulation/templates/special/players/spart.xml +++ binaries/data/mods/public/simulation/templates/special/players/spart.xml @@ -1,15 +0,0 @@ - - - teambonuses/spart_player_teambonus - - spart - Spartans - Sparta was a prominent city-state in ancient Greece, and its dominant military power on land from circa 650 B.C. Spartan culture was obsessed with military training and excellence, with rigorous training for boys beginning at age seven. Thanks to its military might, Sparta led a coalition of Greek forces during the Greco-Persian Wars, and won over Athens in the Peloponnesian Wars, though at great cost. - emblems/emblem_spartans.png - - - - special/formations/phalanx - - - Index: source/ps/TemplateLoader.h =================================================================== --- source/ps/TemplateLoader.h +++ source/ps/TemplateLoader.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2022 Wildfire Games. +/* Copyright (C) 2023 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -67,12 +67,6 @@ */ std::vector FindTemplates(const std::string& path, bool includeSubdirectories, ETemplatesType templatesType) const; - /** - * Returns a list of strings that could validly be passed as @c templateName to LoadTemplateFile. - * Not ignoring any special directories. - */ - std::vector FindTemplatesUnrestricted(const std::string& path, bool includeSubdirectories) const; - private: /** * (Re)loads the given template, regardless of whether it exists already, Index: source/ps/TemplateLoader.cpp =================================================================== --- source/ps/TemplateLoader.cpp +++ source/ps/TemplateLoader.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2022 Wildfire Games. +/* Copyright (C) 2023 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -159,17 +159,6 @@ return templates; } -std::vector CTemplateLoader::FindTemplatesUnrestricted(const std::string& path, bool includeSubdirectories) const -{ - std::vector templates; - - size_t flags = includeSubdirectories ? vfs::DIR_RECURSIVE : 0; - - WARN_IF_ERR(vfs::ForEachFile(g_VFS, VfsPath(TEMPLATE_ROOT) / path, AddToTemplatesUnrestricted, (uintptr_t)&templates, L"*.xml", flags)); - - return templates; -} - const CParamNode& CTemplateLoader::GetTemplateFileData(const std::string& templateName) { if (std::unordered_map::const_iterator it = m_TemplateFileData.find(templateName); it != m_TemplateFileData.end()) Index: source/simulation2/components/CCmpTemplateManager.cpp =================================================================== --- source/simulation2/components/CCmpTemplateManager.cpp +++ source/simulation2/components/CCmpTemplateManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2022 Wildfire Games. +/* Copyright (C) 2023 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -221,10 +221,12 @@ { std::vector> data; - std::vector names = m_templateLoader.FindTemplatesUnrestricted("special/players/", false); - data.reserve(names.size()); + std::vector names = FindAllTemplates(false); for (const std::string& name : names) { + if (!GetTemplate(name)->GetChild("Player").IsOk()) + continue; + const CParamNode& identity = GetTemplate(name)->GetChild("Identity"); data.push_back(std::vector { identity.GetChild("Civ").ToWString(), Index: source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp =================================================================== --- source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp +++ source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2023 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -50,6 +50,7 @@ #include "simulation2/components/ICmpTemplateManager.h" #include "simulation2/components/ICmpVisual.h" #include "simulation2/helpers/Selection.h" +#include "simulation2/system/ParamNode.h" #include "ps/XML/XMLWriter.h" namespace AtlasMessage @@ -99,6 +100,9 @@ for (std::vector::iterator it = names.begin(); it != names.end(); ++it) { + if (!cmpTemplateManager->GetTemplate(*it)->GetChild("Position").IsOk()) + continue; + std::wstring name(it->begin(), it->end()); sObjectsListItem e;