1
0
forked from 0ad/0ad

Move GenericName, History and Icon from the civ-JSON to cmpIdentity.

Since the players/civs already have cmpIdentity, use it.
This forces civs to have corresponding XML in the `special/players/`
folder.

Also moves the files from `special/player/` to `special/players/`
consistent with other folders. And moves the generic `player.xml` one
level up.

Differential revision: https://code.wildfiregames.com/D4473
Help and comments by: @Stan, @wraitii
This was SVN commit r26298.
This commit is contained in:
Freagarach 2022-02-05 06:24:45 +00:00
parent 37aa0456c8
commit ea72437739
80 changed files with 431 additions and 253 deletions

View File

@ -7,7 +7,7 @@
function loadCivFiles(selectableOnly)
{
let propertyNames = [
"Code", "Culture", "Name", "Emblem", "History", "Music", "CivBonuses", "StartEntities",
"Code", "Culture", "Music", "CivBonuses", "StartEntities",
"Formations", "AINames", "SkirmishReplacements", "SelectableInGameSetup"];
let civData = {};
@ -20,8 +20,15 @@ function loadCivFiles(selectableOnly)
if (data[prop] === undefined)
throw new Error(filename + " doesn't contain " + prop);
if (!selectableOnly || data.SelectableInGameSetup)
civData[data.Code] = data;
if (selectableOnly && !data.SelectableInGameSetup)
continue;
const template = Engine.GetTemplate("special/players/" + data.Code);
data.Name = template.Identity.GenericName;
data.Emblem = template.Identity.Icon;
data.History = template.Identity.History;
civData[data.Code] = data;
}
return civData;

View File

@ -222,11 +222,13 @@ class TemplateLoader
*/
buildPlayerTemplateName(civCode)
{
let templateName = this.PlayerPath + this.PlayerTemplatePrefix + civCode;
let templateName = this.PlayerPath + civCode;
if (Engine.TemplateExists(templateName))
return templateName;
return this.PlayerPath + this.PlayerTemplateFallback;
warn("No template found for civ " + civCode + ".");
return this.PlayerPath + this.DefaultCiv;
}
/**
@ -321,17 +323,11 @@ class TemplateLoader
* 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/player/";
TemplateLoader.prototype.PlayerPath = "special/players/";
TemplateLoader.prototype.TechnologyPath = "simulation/data/technologies/";
TemplateLoader.prototype.DefaultCiv = "gaia";
/**
* Expected prefix for player templates, and the file to use if a civ doesn't have its own.
*/
TemplateLoader.prototype.PlayerTemplatePrefix = "player_";
TemplateLoader.prototype.PlayerTemplateFallback = "player";
/**
* Keys of template values that are to be translated on load.
*/

View File

@ -12,13 +12,22 @@
],
"options": {
"keywords": [
"Name",
"Description",
"History",
"Special",
"AINames"
]
}
},
{
"extractor": "xml",
"filemasks": [
"simulation/templates/special/players/**.xml"
],
"options": {
"keywords": [
"GenericName": {},
"History": {}
]
}
}
]
},

View File

@ -1,3 +1,13 @@
Engine.GetTemplate = (path) => {
return {
"Identity": {
"GenericName": null,
"Icon": null,
"History": null
}
};
};
Engine.LoadLibrary("rmgen");
var g_MapSettings = { "Size": 512 };

View File

@ -1,3 +1,13 @@
Engine.GetTemplate = (path) => {
return {
"Identity": {
"GenericName": null,
"Icon": null,
"History": null
}
};
};
Engine.LoadLibrary("rmgen");
{

View File

@ -1,3 +1,13 @@
Engine.GetTemplate = (path) => {
return {
"Identity": {
"GenericName": null,
"Icon": null,
"History": null
}
};
};
Engine.LoadLibrary("rmgen");
var g_MapSettings = { "Size": 512 };

View File

@ -1,3 +1,13 @@
Engine.GetTemplate = (path) => {
return {
"Identity": {
"GenericName": null,
"Icon": null,
"History": null
}
};
};
Engine.LoadLibrary("rmgen");
var g_MapSettings = { "Size": 512 };

View File

@ -1,3 +1,13 @@
Engine.GetTemplate = (path) => {
return {
"Identity": {
"GenericName": null,
"Icon": null,
"History": null
}
};
};
Engine.LoadLibrary("rmgen");
var g_MapSettings = { "Size": 512 };

View File

@ -1,3 +1,13 @@
Engine.GetTemplate = (path) => {
return {
"Identity": {
"GenericName": null,
"Icon": null,
"History": null
}
};
};
Engine.LoadLibrary("rmgen");
var g_MapSettings = { "Size": 512 };

View File

@ -43,7 +43,7 @@ Builder.prototype.GetEntitiesList = function()
if (cmpIdentity)
string = string.replace(/\{native\}/g, cmpIdentity.GetCiv());
let entities = string.replace(/\{civ\}/g, cmpPlayer.GetCiv()).split(/\s+/);
const entities = string.replace(/\{civ\}/g, QueryOwnerInterface(this.entity, IID_Identity).GetCiv()).split(/\s+/);
let disabledTemplates = cmpPlayer.GetDisabledTemplates();

View File

@ -62,12 +62,14 @@ GuiInterface.prototype.GetSimulationState = function()
let numPlayers = cmpPlayerManager.GetNumPlayers();
for (let i = 0; i < numPlayers; ++i)
{
let cmpPlayer = QueryPlayerIDInterface(i);
let cmpPlayerEntityLimits = QueryPlayerIDInterface(i, IID_EntityLimits);
const playerEnt = cmpPlayerManager.GetPlayerByID(i);
const cmpPlayer = Engine.QueryInterface(playerEnt, IID_Player);
const cmpPlayerEntityLimits = Engine.QueryInterface(playerEnt, IID_EntityLimits);
const cmpIdentity = Engine.QueryInterface(playerEnt, IID_Identity);
// Work out which phase we are in.
let phase = "";
let cmpTechnologyManager = QueryPlayerIDInterface(i, IID_TechnologyManager);
const cmpTechnologyManager = Engine.QueryInterface(playerEnt, IID_TechnologyManager);
if (cmpTechnologyManager)
{
if (cmpTechnologyManager.IsTechnologyResearched("phase_city"))
@ -92,8 +94,8 @@ GuiInterface.prototype.GetSimulationState = function()
}
ret.players.push({
"name": cmpPlayer.GetName(),
"civ": cmpPlayer.GetCiv(),
"name": cmpIdentity.GetName(),
"civ": cmpIdentity.GetCiv(),
"color": cmpPlayer.GetColor(),
"controlsAll": cmpPlayer.CanControlAllUnits(),
"popCount": cmpPlayer.GetPopulationCount(),

View File

@ -181,6 +181,22 @@ Identity.prototype.SetPhenotype = function(phenotype)
this.phenotype = phenotype;
};
/**
* @param {string} newName -
*/
Identity.prototype.SetName = function(newName)
{
this.name = newName;
};
/**
* @return {string} -
*/
Identity.prototype.GetName = function()
{
return this.name || this.template.GenericName;
};
function IdentityMirage() {}
IdentityMirage.prototype.Init = function(cmpIdentity)
{

View File

@ -50,8 +50,6 @@ var panelEntityClasses = "Hero Relic";
Player.prototype.Init = function()
{
this.playerID = undefined;
this.name = undefined; // Define defaults elsewhere (supporting other languages).
this.civ = undefined;
this.color = undefined;
this.diplomacyColor = undefined;
this.displayDiplomacyColor = false;
@ -112,34 +110,6 @@ Player.prototype.GetPlayerID = function()
return this.playerID;
};
Player.prototype.SetName = function(name)
{
this.name = name;
};
Player.prototype.GetName = function()
{
return this.name;
};
Player.prototype.SetCiv = function(civcode)
{
let oldCiv = this.civ;
this.civ = civcode;
// Normally, the civ is only set once. But in Atlas, map designers can change civs at any time.
if (oldCiv && this.playerID && oldCiv != civcode)
Engine.BroadcastMessage(MT_CivChanged, {
"player": this.playerID,
"from": oldCiv,
"to": civcode
});
};
Player.prototype.GetCiv = function()
{
return this.civ;
};
Player.prototype.SetColor = function(r, g, b)
{
let colorInitialized = !!this.color;
@ -773,9 +743,10 @@ Player.prototype.OnGlobalInitGame = function(msg)
// Replace the "{civ}" code with this civ ID.
let disabledTemplates = this.disabledTemplates;
this.disabledTemplates = {};
const civ = Engine.QueryInterface(this.entity, IID_Identity).GetCiv();
for (let template in disabledTemplates)
if (disabledTemplates[template])
this.disabledTemplates[template.replace(/\{civ\}/g, this.civ)] = true;
this.disabledTemplates[template.replace(/\{civ\}/g, civ)] = true;
};
/**

View File

@ -180,18 +180,26 @@ Researcher.prototype.GetTechnologiesList = function()
if (!string)
return [];
const cmpTechnologyManager = QueryOwnerInterface(this.entity, IID_TechnologyManager);
const owner = Engine.QueryInterface(this.entity, IID_Ownership)?.GetOwner();
if (!owner || owner === INVALID_PLAYER)
return [];
const playerEnt = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetPlayerByID(owner);
if (!playerEnt)
return [];
const cmpTechnologyManager = Engine.QueryInterface(playerEnt, IID_TechnologyManager);
if (!cmpTechnologyManager)
return [];
const cmpPlayer = QueryOwnerInterface(this.entity);
const cmpPlayer = Engine.QueryInterface(playerEnt, IID_Player);
if (!cmpPlayer)
return [];
const civ = cmpPlayer.GetCiv();
let techs = string.split(/\s+/);
// Replace the civ specific technologies.
const civ = Engine.QueryInterface(playerEnt, IID_Identity).GetCiv();
for (let i = 0; i < techs.length; ++i)
{
const tech = techs[i];

View File

@ -28,11 +28,10 @@ SkirmishReplacer.prototype.OnOwnershipChanged = function(msg)
SkirmishReplacer.prototype.ReplaceEntities = function()
{
var cmpPlayer = QueryOwnerInterface(this.entity);
if (!cmpPlayer)
const civ = QueryOwnerInterface(this.entity, IID_Identity)?.GetCiv();
if (!civ)
return;
var civ = cmpPlayer.GetCiv();
var replacementEntities = getReplacementEntities(civ);
var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);

View File

@ -316,7 +316,7 @@ TechnologyManager.prototype.CanResearch = function(tech)
if (this.IsTechnologyResearched(tech))
return false;
return this.CheckTechnologyRequirements(DeriveTechnologyRequirements(template, Engine.QueryInterface(this.entity, IID_Player).GetCiv()));
return this.CheckTechnologyRequirements(DeriveTechnologyRequirements(template, Engine.QueryInterface(this.entity, IID_Identity).GetCiv()));
};
/**

View File

@ -513,7 +513,7 @@ Trainer.prototype.CalculateEntitiesMap = function()
toks.push(tok);
const nativeCiv = Engine.QueryInterface(this.entity, IID_Identity)?.GetCiv();
const playerCiv = cmpPlayer?.GetCiv();
const playerCiv = QueryOwnerInterface(this.entity, IID_Identity)?.GetCiv();
const addedDict = addedTokens.reduce((out, token) => { out[token] = true; return out; }, {});
this.entitiesMap = toks.reduce((entMap, token) => {

View File

@ -40,11 +40,14 @@ function testEntitiesList()
});
AddMock(playerEntityID, IID_Player, {
"GetCiv": () => "iber",
"GetDisabledTemplates": () => ({}),
"GetPlayerID": () => playerId
});
AddMock(playerEntityID, IID_Identity, {
"GetCiv": () => "iber",
});
AddMock(builderId, IID_Ownership, {
"GetOwner": () => playerId
});
@ -66,7 +69,6 @@ function testEntitiesList()
});
AddMock(playerEntityID, IID_Player, {
"GetCiv": () => "iber",
"GetDisabledTemplates": () => ({ "structures/athen/barracks": true }),
"GetPlayerID": () => playerId
});
@ -74,7 +76,6 @@ function testEntitiesList()
TS_ASSERT_UNEVAL_EQUALS(cmpBuilder.GetEntitiesList(), ["structures/iber/barracks", "structures/iber/civil_centre", "structures/iber/house"]);
AddMock(playerEntityID, IID_Player, {
"GetCiv": () => "iber",
"GetDisabledTemplates": () => ({ "structures/iber/barracks": true }),
"GetPlayerID": () => playerId
});
@ -82,11 +83,14 @@ function testEntitiesList()
TS_ASSERT_UNEVAL_EQUALS(cmpBuilder.GetEntitiesList(), ["structures/iber/civil_centre", "structures/iber/house"]);
AddMock(playerEntityID, IID_Player, {
"GetCiv": () => "athen",
"GetDisabledTemplates": () => ({ "structures/athen/barracks": true }),
"GetPlayerID": () => playerId
});
AddMock(playerEntityID, IID_Identity, {
"GetCiv": () => "athen",
});
TS_ASSERT_UNEVAL_EQUALS(cmpBuilder.GetEntitiesList(), ["structures/athen/civil_centre", "structures/iber/house"]);
TS_ASSERT_UNEVAL_EQUALS(cmpBuilder.GetRange(), { "max": 2, "min": 0 });

View File

@ -100,8 +100,6 @@ AddMock(SYSTEM_ENTITY, IID_Timer, {
});
AddMock(100, IID_Player, {
"GetName": function() { return "Player 1"; },
"GetCiv": function() { return "gaia"; },
"GetColor": function() { return { "r": 1, "g": 1, "b": 1, "a": 1 }; },
"CanControlAllUnits": function() { return false; },
"GetPopulationCount": function() { return 10; },
@ -128,6 +126,11 @@ AddMock(100, IID_Player, {
"HasSharedLos": function() { return false; }
});
AddMock(100, IID_Identity, {
"GetName": function() { return "Player 1"; },
"GetCiv": function() { return "gaia"; },
});
AddMock(100, IID_EntityLimits, {
"GetLimits": function() { return { "Foo": 10 }; },
"GetCounts": function() { return { "Foo": 5 }; },
@ -188,8 +191,6 @@ AddMock(100, IID_StatisticsTracker, {
});
AddMock(101, IID_Player, {
"GetName": function() { return "Player 2"; },
"GetCiv": function() { return "mace"; },
"GetColor": function() { return { "r": 1, "g": 0, "b": 0, "a": 1 }; },
"CanControlAllUnits": function() { return true; },
"GetPopulationCount": function() { return 40; },
@ -216,6 +217,11 @@ AddMock(101, IID_Player, {
"HasSharedLos": function() { return false; }
});
AddMock(101, IID_Identity, {
"GetName": function() { return "Player 2"; },
"GetCiv": function() { return "mace"; },
});
AddMock(101, IID_EntityLimits, {
"GetLimits": function() { return { "Bar": 20 }; },
"GetCounts": function() { return { "Bar": 0 }; },

View File

@ -23,10 +23,13 @@ AddMock(SYSTEM_ENTITY, IID_PlayerManager, {
});
AddMock(playerEntityID, IID_Player, {
"GetCiv": () => "iber",
"GetDisabledTechnologies": () => ({}) // ToDo: Should be in the techmanager.
});
AddMock(playerEntityID, IID_Identity, {
"GetCiv": () => "iber",
});
AddMock(playerEntityID, IID_TechnologyManager, {
"CheckTechnologyRequirements": () => true,
"IsInProgress": () => false,
@ -53,9 +56,11 @@ TS_ASSERT_UNEVAL_EQUALS(
);
AddMock(playerEntityID, IID_Player, {
"GetCiv": () => "athen",
"GetDisabledTechnologies": () => ({ "gather_fishing_net": true })
});
AddMock(playerEntityID, IID_Identity, {
"GetCiv": () => "athen",
});
TS_ASSERT_UNEVAL_EQUALS(cmpResearcher.GetTechnologiesList(), ["phase_town_athen", "phase_city_athen"]);
AddMock(playerEntityID, IID_TechnologyManager, {
@ -66,9 +71,11 @@ AddMock(playerEntityID, IID_TechnologyManager, {
TS_ASSERT_UNEVAL_EQUALS(cmpResearcher.GetTechnologiesList(), [undefined, "phase_city_athen"]);
AddMock(playerEntityID, IID_Player, {
"GetCiv": () => "iber",
"GetDisabledTechnologies": () => ({})
});
AddMock(playerEntityID, IID_Identity, {
"GetCiv": () => "iber",
});
TS_ASSERT_UNEVAL_EQUALS(
cmpResearcher.GetTechnologiesList(),
["gather_fishing_net", "phase_town_generic", "phase_city_generic"]
@ -95,10 +102,13 @@ Engine.RegisterGlobal("TechnologyTemplates", {
});
const cmpPlayer = AddMock(playerEntityID, IID_Player, {
"GetCiv": () => "iber",
"GetDisabledTechnologies": () => ({}),
"GetPlayerID": () => playerID,
});
AddMock(playerEntityID, IID_Identity, {
"GetCiv": () => "iber",
});
const techManager = AddMock(playerEntityID, IID_TechnologyManager, {
"CheckTechnologyRequirements": () => true,
"IsInProgress": () => false,

View File

@ -74,7 +74,9 @@ AddMock(researcherID, IID_Ownership, {
AddMock(SYSTEM_ENTITY, IID_PlayerManager, {
"GetPlayerByID": id => playerEntityID
});
AddMock(playerEntityID, IID_Identity, {
"GetCiv": () => "gaia"
});
template.cost = {
"food": 100
};

View File

@ -39,11 +39,14 @@ AddMock(SYSTEM_ENTITY, IID_PlayerManager, {
});
AddMock(playerEntityID, IID_Player, {
"GetCiv": () => "iber",
"GetDisabledTemplates": () => ({}),
"GetPlayerID": () => playerID
});
AddMock(playerEntityID, IID_Identity, {
"GetCiv": () => "iber",
});
AddMock(entityID, IID_Ownership, {
"GetOwner": () => playerID
});
@ -72,7 +75,6 @@ AddMock(SYSTEM_ENTITY, IID_TemplateManager, {
});
AddMock(playerEntityID, IID_Player, {
"GetCiv": () => "iber",
"GetDisabledTemplates": () => ({ "units/athen/infantry_swordsman_b": true }),
"GetPlayerID": () => playerID
});
@ -84,7 +86,6 @@ TS_ASSERT_UNEVAL_EQUALS(
);
AddMock(playerEntityID, IID_Player, {
"GetCiv": () => "iber",
"GetDisabledTemplates": () => ({ "units/iber/infantry_swordsman_b": true }),
"GetPlayerID": () => playerID
});
@ -96,11 +97,14 @@ TS_ASSERT_UNEVAL_EQUALS(
);
AddMock(playerEntityID, IID_Player, {
"GetCiv": () => "athen",
"GetDisabledTemplates": () => ({ "units/athen/infantry_swordsman_b": true }),
"GetPlayerID": () => playerID
});
AddMock(playerEntityID, IID_Identity, {
"GetCiv": () => "athen",
});
cmpTrainer.CalculateEntitiesMap();
TS_ASSERT_UNEVAL_EQUALS(
cmpTrainer.GetEntitiesList(),
@ -108,11 +112,14 @@ TS_ASSERT_UNEVAL_EQUALS(
);
AddMock(playerEntityID, IID_Player, {
"GetCiv": () => "iber",
"GetDisabledTemplates": () => ({ "units/iber/infantry_swordsman_b": false }),
"GetPlayerID": () => playerID
});
AddMock(playerEntityID, IID_Identity, {
"GetCiv": () => "iber",
});
cmpTrainer.CalculateEntitiesMap();
TS_ASSERT_UNEVAL_EQUALS(
cmpTrainer.GetEntitiesList(),
@ -150,7 +157,6 @@ AddMock(SYSTEM_ENTITY, IID_GuiInterface, {
const cmpPlayer = AddMock(playerEntityID, IID_Player, {
"BlockTraining": () => {},
"GetCiv": () => "iber",
"GetPlayerID": () => playerID,
"RefundResources": (resources) => {
TS_ASSERT_UNEVAL_EQUALS(resources, cost);

View File

@ -1,9 +1,6 @@
{
"Code": "athen",
"Culture": "hele",
"Name": "Athenians",
"Emblem": "session/portraits/emblems/emblem_athenians.png",
"History": "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.",
"Music": [
{
"File": "Harvest_Festival.ogg",

View File

@ -1,9 +1,6 @@
{
"Code": "brit",
"Culture": "celt",
"Name": "Britons",
"Emblem": "session/portraits/emblems/emblem_britons.png",
"History": "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.",
"Music": [
{
"File": "Highland_Mist.ogg",

View File

@ -1,9 +1,6 @@
{
"Code": "cart",
"Culture": "cart",
"Name": "Carthaginians",
"Emblem": "session/portraits/emblems/emblem_carthaginians.png",
"History": "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.",
"Music": [
{
"File": "Mediterranean_Waves.ogg",

View File

@ -1,9 +1,6 @@
{
"Code": "gaul",
"Culture": "celt",
"Name": "Gauls",
"Emblem": "session/portraits/emblems/emblem_celts.png",
"History": "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.",
"Music": [
{
"File": "Celtic_Pride.ogg",

View File

@ -1,9 +1,6 @@
{
"Code": "iber",
"Culture": "iber",
"Name": "Iberians",
"Emblem": "session/portraits/emblems/emblem_iberians.png",
"History": "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.",
"Music": [
{
"File": "An_old_Warhorse_goes_to_Pasture.ogg",

View File

@ -1,9 +1,6 @@
{
"Code": "kush",
"Culture": "egyptian",
"Name": "Kushites",
"Emblem": "session/portraits/emblems/emblem_kushites.png",
"History": "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.",
"Music": [
{
"File": "Ammon-Ra.ogg",

View File

@ -1,9 +1,6 @@
{
"Code": "mace",
"Culture": "hele",
"Name": "Macedonians",
"Emblem": "session/portraits/emblems/emblem_macedonians.png",
"History": "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.",
"Music": [
{
"File": "Rise_of_Macedon.ogg",

View File

@ -1,9 +1,6 @@
{
"Code": "maur",
"Culture": "maur",
"Name": "Mauryas",
"Emblem": "session/portraits/emblems/emblem_mauryas.png",
"History": "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.",
"Music": [
{
"File": "An_old_Warhorse_goes_to_Pasture.ogg",

View File

@ -1,9 +1,6 @@
{
"Code": "pers",
"Culture": "pers",
"Name": "Persians",
"Emblem": "session/portraits/emblems/emblem_persians.png",
"History": "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.",
"Music": [
{
"File": "Eastern_Dreams.ogg",

View File

@ -1,9 +1,6 @@
{
"Code": "ptol",
"Culture": "ptol",
"Name": "Ptolemies",
"Emblem": "session/portraits/emblems/emblem_ptolemies.png",
"History": "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.",
"Music": [
{
"File": "Ammon-Ra.ogg",

View File

@ -1,9 +1,6 @@
{
"Code": "rome",
"Culture": "rome",
"Name": "Romans",
"Emblem": "session/portraits/emblems/emblem_romans.png",
"History": "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.",
"Music": [
{
"File": "Juno_Protect_You.ogg",

View File

@ -1,9 +1,6 @@
{
"Code": "sele",
"Culture": "sele",
"Name": "Seleucids",
"Emblem": "session/portraits/emblems/emblem_seleucids.png",
"History": "The Macedonian-Greek dynasty that ruled most of Alexander's former empire.",
"Music": [
{
"File": "Rise_of_Macedon.ogg",

View File

@ -1,9 +1,6 @@
{
"Code": "spart",
"Culture": "hele",
"Name": "Spartans",
"Emblem": "session/portraits/emblems/emblem_spartans.png",
"History": "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.",
"Music": [
{
"File": "Helen_Leaves_Sparta.ogg",

View File

@ -75,11 +75,10 @@ function LoadPlayerSettings(settings, newPlayers)
// Initialize the player data
for (var i = 0; i < numPlayers; ++i)
{
let cmpPlayer = QueryPlayerIDInterface(i);
cmpPlayer.SetName(getSetting(playerData, playerDefaults, i, "Name"));
cmpPlayer.SetCiv(getSetting(playerData, playerDefaults, i, "Civ"));
QueryPlayerIDInterface(i, IID_Identity).SetName(getSetting(playerData, playerDefaults, i, "Name"));
var color = getSetting(playerData, playerDefaults, i, "Color");
const cmpPlayer = QueryPlayerIDInterface(i);
cmpPlayer.SetColor(color.r, color.g, color.b);
// Special case for gaia
@ -181,12 +180,7 @@ function getSetting(settings, defaults, idx, property)
function GetPlayerTemplateName(civ)
{
let path = "special/player/player";
if (Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager).TemplateExists(path + "_" + civ))
return path + "_" + civ;
return path;
return "special/players/" + civ;
}
/**

View File

@ -53,8 +53,6 @@
</LimitRemovers>
</EntityLimits>
<Identity>
<Civ/>
<GenericName>Player</GenericName>
<Classes datatype="tokens">Player</Classes>
<Undeletable>true</Undeletable>
</Identity>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player/player">
<Auras datatype="tokens">
teambonuses/athen_player_teambonus
</Auras>
</Entity>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player/player">
<Auras datatype="tokens">
teambonuses/brit_player_teambonus
</Auras>
</Entity>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player/player">
<Auras datatype="tokens">
teambonuses/cart_player_teambonus
</Auras>
</Entity>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player/player">
<Auras datatype="tokens">
teambonuses/gaul_player_teambonus
</Auras>
</Entity>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player/player">
<Auras datatype="tokens">
teambonuses/iber_player_teambonus
</Auras>
</Entity>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player/player">
<Auras datatype="tokens">
teambonuses/kush_player_teambonus
</Auras>
</Entity>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player/player">
<Auras datatype="tokens">
teambonuses/mace_player_teambonus
</Auras>
</Entity>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player/player">
<Auras datatype="tokens">
teambonuses/maur_player_teambonus
</Auras>
</Entity>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player/player">
<Auras datatype="tokens">
teambonuses/pers_player_teambonus
</Auras>
</Entity>

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player/player">
<Auras datatype="tokens">
teambonuses/ptol_player_teambonus
</Auras>
<EntityLimits>
<LimitRemovers>
<CivilCentre>
<RequiredTechs datatype="tokens">phase_town</RequiredTechs>
<RequiredClasses datatype="tokens">Hero</RequiredClasses>
</CivilCentre>
</LimitRemovers>
</EntityLimits>
</Entity>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player/player">
<Auras datatype="tokens">
teambonuses/rome_player_teambonus
</Auras>
</Entity>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player/player">
<Auras datatype="tokens">teambonuses/spart_player_teambonus</Auras>
</Entity>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player">
<Auras datatype="tokens">
teambonuses/athen_player_teambonus
</Auras>
<Identity>
<Civ>athen</Civ>
<GenericName>Athenians</GenericName>
<History>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.</History>
<Icon>session/portraits/emblems/emblem_athenians.png</Icon>
</Identity>
</Entity>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player">
<Auras datatype="tokens">
teambonuses/brit_player_teambonus
</Auras>
<Identity>
<Civ>brit</Civ>
<GenericName>Britons</GenericName>
<History>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.</History>
<Icon>session/portraits/emblems/emblem_britons.png</Icon>
</Identity>
</Entity>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player">
<Auras datatype="tokens">
teambonuses/cart_player_teambonus
</Auras>
<Identity>
<Civ>cart</Civ>
<GenericName>Carthaginians</GenericName>
<History>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.</History>
<Icon>session/portraits/emblems/emblem_carthaginians.png</Icon>
</Identity>
</Entity>

View File

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity>
<Identity>
<Civ>gaia</Civ>
<GenericName>Gaia</GenericName>
<Undeletable>true</Undeletable>
</Identity>
<Player>
<SharedLosTech/>
<SharedDropsitesTech/>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player">
<Auras datatype="tokens">
teambonuses/gaul_player_teambonus
</Auras>
<Identity>
<Civ>gaul</Civ>
<GenericName>Gauls</GenericName>
<History>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.</History>
<Icon>session/portraits/emblems/emblem_celts.png</Icon>
</Identity>
</Entity>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player">
<Auras datatype="tokens">
teambonuses/iber_player_teambonus
</Auras>
<Identity>
<Civ>iber</Civ>
<GenericName>Iberians</GenericName>
<History>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.</History>
<Icon>session/portraits/emblems/emblem_iberians.png</Icon>
</Identity>
</Entity>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player">
<Auras datatype="tokens">
teambonuses/kush_player_teambonus
</Auras>
<Identity>
<Civ>kush</Civ>
<GenericName>Kushites</GenericName>
<History>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.</History>
<Icon>session/portraits/emblems/emblem_kushites.png</Icon>
</Identity>
</Entity>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player">
<Auras datatype="tokens">
teambonuses/mace_player_teambonus
</Auras>
<Identity>
<Civ>mace</Civ>
<GenericName>Macedonians</GenericName>
<History>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.</History>
<Icon>session/portraits/emblems/emblem_macedonians.png</Icon>
</Identity>
</Entity>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player">
<Auras datatype="tokens">
teambonuses/maur_player_teambonus
</Auras>
<Identity>
<Civ>maur</Civ>
<GenericName>Mauryas</GenericName>
<History>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.</History>
<Icon>session/portraits/emblems/emblem_mauryas.png</Icon>
</Identity>
</Entity>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player">
<Auras datatype="tokens">
teambonuses/pers_player_teambonus
</Auras>
<Identity>
<Civ>pers</Civ>
<GenericName>Persians</GenericName>
<History>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.</History>
<Icon>session/portraits/emblems/emblem_persians.png</Icon>
</Identity>
</Entity>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player">
<Auras datatype="tokens">
teambonuses/ptol_player_teambonus
</Auras>
<EntityLimits>
<LimitRemovers>
<CivilCentre>
<RequiredTechs datatype="tokens">phase_town</RequiredTechs>
<RequiredClasses datatype="tokens">Hero</RequiredClasses>
</CivilCentre>
</LimitRemovers>
</EntityLimits>
<Identity>
<Civ>ptol</Civ>
<GenericName>Ptolemies</GenericName>
<History>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.</History>
<Icon>session/portraits/emblems/emblem_ptolemies.png</Icon>
</Identity>
</Entity>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player">
<Auras datatype="tokens">
teambonuses/rome_player_teambonus
</Auras>
<Identity>
<Civ>rome</Civ>
<GenericName>Romans</GenericName>
<History>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.</History>
<Icon>session/portraits/emblems/emblem_romans.png</Icon>
</Identity>
</Entity>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player/player">
<Entity parent="special/player">
<Auras datatype="tokens">
teambonuses/sele_player_teambonus
</Auras>
@ -11,4 +11,10 @@
</CivilCentre>
</LimitRemovers>
</EntityLimits>
<Identity>
<Civ>sele</Civ>
<GenericName>Seleucids</GenericName>
<History>The Macedonian-Greek dynasty that ruled most of Alexander's former empire.</History>
<Icon>session/portraits/emblems/emblem_seleucids.png</Icon>
</Identity>
</Entity>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="special/player">
<Auras datatype="tokens">teambonuses/spart_player_teambonus</Auras>
<Identity>
<Civ>spart</Civ>
<GenericName>Spartans</GenericName>
<History>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.</History>
<Icon>session/portraits/emblems/emblem_spartans.png</Icon>
</Identity>
</Entity>

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -105,6 +105,21 @@ static Status AddToTemplates(const VfsPath& pathname, const CFileInfo& UNUSED(fi
return INFO::OK;
}
static Status AddToTemplatesUnrestricted(const VfsPath& pathname, const CFileInfo& UNUSED(fileInfo), const uintptr_t cbData)
{
std::vector<std::string>& templates = *(std::vector<std::string>*)cbData;
VfsPath pathstem = pathname.ChangeExtension(L"");
std::string name = pathstem.string8().substr(ARRAY_SIZE(TEMPLATE_ROOT)-1);
// We want to ignore template_*.xml templates, since they may be incomplete.
if (name.substr(0, 9) == "template_")
return INFO::OK;
templates.push_back(name);
return INFO::OK;
}
static Status AddActorToTemplates(const VfsPath& pathname, const CFileInfo& UNUSED(fileInfo), const uintptr_t cbData)
{
std::vector<std::string>& templates = *(std::vector<std::string>*)cbData;
@ -144,6 +159,17 @@ std::vector<std::string> CTemplateLoader::FindTemplates(const std::string& path,
return templates;
}
std::vector<std::string> CTemplateLoader::FindTemplatesUnrestricted(const std::string& path, bool includeSubdirectories) const
{
std::vector<std::string> 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<std::string, CParamNode>::const_iterator it = m_TemplateFileData.find(templateName); it != m_TemplateFileData.end())

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -67,6 +67,12 @@ public:
*/
std::vector<std::string> 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<std::string> FindTemplatesUnrestricted(const std::string& path, bool includeSubdirectories) const;
private:
/**
* (Re)loads the given template, regardless of whether it exists already,

View File

@ -945,11 +945,6 @@ std::vector<std::string> CSimulation2::GetRMSData()
return GetJSONData(L"maps/random/");
}
std::vector<std::string> CSimulation2::GetCivData()
{
return GetJSONData(L"simulation/data/civs/");
}
std::vector<std::string> CSimulation2::GetVictoryConditiondData()
{
return GetJSONData(L"simulation/data/settings/victory_conditions/");

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -248,13 +248,6 @@ public:
*/
std::vector<std::string> GetRMSData();
/**
* Get civilization data
*
* @return vector of strings containing JSON format data
*/
std::vector<std::string> GetCivData();
/**
* Get victory condition data
*

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -269,13 +269,13 @@ void CCmpRallyPointRenderer::UpdateMarkers()
if (!cmpPlayerManager)
continue;
CmpPtr<ICmpPlayer> cmpPlayer(GetSimContext(), cmpPlayerManager->GetPlayerByID(ownerId));
if (!cmpPlayer)
CmpPtr<ICmpIdentity> cmpIdentity(GetSimContext(), cmpPlayerManager->GetPlayerByID(ownerId));
if (!cmpIdentity)
continue;
CmpPtr<ICmpVisual> cmpVisualActor(GetSimContext(), m_MarkerEntityIds[i]);
if (cmpVisualActor)
cmpVisualActor->SetVariant("civ", CStrW(cmpPlayer->GetCiv()).ToUTF8());
cmpVisualActor->SetVariant("civ", CStrW(cmpIdentity->GetCiv()).ToUTF8());
}
m_LastMarkerCount = m_RallyPoints.size() - 1;
}

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -26,6 +26,7 @@
#include "renderer/Renderer.h"
#include "simulation2/MessageTypes.h"
#include "simulation2/components/ICmpFootprint.h"
#include "simulation2/components/ICmpIdentity.h"
#include "simulation2/components/ICmpObstructionManager.h"
#include "simulation2/components/ICmpOwnership.h"
#include "simulation2/components/ICmpPathfinder.h"

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -113,6 +113,8 @@ public:
virtual std::vector<std::string> FindAllTemplates(bool includeActors) const;
virtual std::vector<std::vector<std::wstring>> GetCivData();
virtual std::vector<std::string> FindUsedTemplates() const;
virtual std::vector<entity_id_t> GetEntitiesUsingTemplate(const std::string& templateName) const;
@ -215,6 +217,23 @@ std::vector<std::string> CCmpTemplateManager::FindAllTemplates(bool includeActor
return m_templateLoader.FindTemplates("", true, templatesType);
}
std::vector<std::vector<std::wstring>> CCmpTemplateManager::GetCivData()
{
std::vector<std::vector<std::wstring>> data;
std::vector<std::string> names = m_templateLoader.FindTemplatesUnrestricted("special/players/", false);
data.reserve(names.size());
for (const std::string& name : names)
{
const CParamNode& identity = GetTemplate(name)->GetChild("Identity");
data.push_back(std::vector<std::wstring> {
identity.GetChild("Civ").ToWString(),
identity.GetChild("GenericName").ToWString()
});
}
return data;
}
std::vector<std::string> CCmpTemplateManager::FindUsedTemplates() const
{
std::vector<std::string> usedTemplates;

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2019 Wildfire Games.
/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -40,6 +40,11 @@ public:
{
return m_Script.Call<std::wstring>("GetPhenotype");
}
virtual std::wstring GetCiv()
{
return m_Script.Call<std::wstring>("GetCiv");
}
};
REGISTER_COMPONENT_SCRIPT_WRAPPER(IdentityScripted)

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2019 Wildfire Games.
/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -31,6 +31,8 @@ public:
virtual std::wstring GetPhenotype() = 0;
virtual std::wstring GetCiv() = 0;
DECLARE_INTERFACE_TYPE(Identity)
};

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2019 Wildfire Games.
/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -37,11 +37,6 @@ public:
return m_Script.Call<CColor>("GetDisplayedColor");
}
virtual std::wstring GetCiv()
{
return m_Script.Call<std::wstring>("GetCiv");
}
virtual CFixedVector3D GetStartingCameraPos()
{
return m_Script.Call<CFixedVector3D>("GetStartingCameraPos");

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2018 Wildfire Games.
/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -33,7 +33,6 @@ class ICmpPlayer : public IComponent
{
public:
virtual CColor GetDisplayedColor() = 0;
virtual std::wstring GetCiv() = 0;
virtual CFixedVector3D GetStartingCameraPos() = 0;
virtual CFixedVector3D GetStartingCameraRot() = 0;

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -27,5 +27,6 @@ DEFINE_INTERFACE_METHOD("GetTemplateWithoutValidation", ICmpTemplateManager, Get
DEFINE_INTERFACE_METHOD("TemplateExists", ICmpTemplateManager, TemplateExists)
DEFINE_INTERFACE_METHOD("GetCurrentTemplateName", ICmpTemplateManager, GetCurrentTemplateName)
DEFINE_INTERFACE_METHOD("FindAllTemplates", ICmpTemplateManager, FindAllTemplates)
DEFINE_INTERFACE_METHOD("GetCivData", ICmpTemplateManager, GetCivData)
DEFINE_INTERFACE_METHOD("GetEntitiesUsingTemplate", ICmpTemplateManager, GetEntitiesUsingTemplate)
END_INTERFACE_WRAPPER(TemplateManager)

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2017 Wildfire Games.
/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -103,6 +103,12 @@ public:
*/
virtual std::vector<std::string> FindAllTemplates(bool includeActors) const = 0;
/**
* Returns some data of the civs from the templates.
* Intended for use by the map editor.
*/
virtual std::vector<std::vector<std::wstring>> GetCivData() = 0;
/**
* Returns a list of strings that could be validly passed as @c templateName to LoadTemplate.
* Intended for use by the AI manager.

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -583,12 +583,11 @@ void PlayerSettingsControl::CreateWidgets()
wxArrayString civCodes;
AtlasMessage::qGetCivData qryCiv;
qryCiv.Post();
std::vector<std::string> civData = *qryCiv.data;
for (size_t i = 0; i < civData.size(); ++i)
std::vector<std::vector<std::wstring>> civData = *qryCiv.data;
for (const std::vector<std::wstring>& civ : civData)
{
AtObj civ = AtlasObject::LoadFromJSON(civData[i]);
civNames.Add(wxString::FromUTF8(civ["Name"]));
civCodes.Add(wxString::FromUTF8(civ["Code"]));
civCodes.Add(civ[0]);
civNames.Add(civ[1]);
}
// Load AI data

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2011 Wildfire Games.
/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -21,13 +21,14 @@
#include "ps/Game.h"
#include "simulation2/Simulation2.h"
#include "simulation2/components/ICmpTemplateManager.h"
namespace AtlasMessage {
QUERYHANDLER(GetCivData)
{
msg->data = g_Game->GetSimulation2()->GetCivData();
CmpPtr<ICmpTemplateManager> cmpTemplateManager(*g_Game->GetSimulation2(), SYSTEM_ENTITY);
msg->data = cmpTemplateManager->GetCivData();
}
QUERYHANDLER(GetPlayerDefaults)

View File

@ -243,7 +243,7 @@ QUERY(VFSFileRealPath,
QUERY(GetCivData,
,
((std::vector<std::string>, data))
((std::vector<std::vector<std::wstring>>, data))
);
QUERY(GetVictoryConditionData,

View File

@ -536,8 +536,6 @@ sub add_civs
my $civ = parse_json_file($f);
push @deps, [ $f, "art/textures/ui/" . $civ->{Emblem} ] if $civ->{Emblem};
push @deps, [ $f, "audio/music/" . $_->{File} ] for @{$civ->{Music}};
}
}