Add a user-defined name to vehicle definitions.

This also adds partial support for a custom vehicle graphic.
This commit is contained in:
2025-02-22 22:07:55 -05:00
committed by Celtic Minstrel
parent f4bdf95617
commit 8ab663b620
7 changed files with 66 additions and 1 deletions

View File

@@ -336,6 +336,24 @@ void writeScenarioToXml(ticpp::Printer&& data, cScenario& scenario) {
data.PushAttribute("id", scenario.journal_strs.size() - 1);
data.CloseElement("journal");
}
for(size_t i = 0; i < scenario.boats.size(); i++) {
if(scenario.boats[i].name.empty() && scenario.boats[i].pic == 0) continue;
data.OpenElement("vehicle");
data.PushAttribute("type", "boat");
data.PushAttribute("id", i + 1);
if(!scenario.boats[i].name.empty()) data.PushElement("name", scenario.boats[i].name);
if(scenario.boats[i].pic > 0) data.PushElement("pic", scenario.boats[i].pic);
data.CloseElement("vehicle");
}
for(size_t i = 0; i < scenario.horses.size(); i++) {
if(scenario.horses[i].name.empty() && scenario.horses[i].pic == 0) continue;
data.OpenElement("vehicle");
data.PushAttribute("type", "horse");
data.PushAttribute("id", i + 1);
if(!scenario.horses[i].name.empty()) data.PushElement("name", scenario.horses[i].name);
if(scenario.horses[i].pic > 0) data.PushElement("pic", scenario.horses[i].pic);
data.CloseElement("vehicle");
}
data.CloseElement("game");
data.OpenElement("editor");
data.PushElement("default-ground", scenario.default_ground);