|
|
|
@@ -56,14 +56,14 @@ static std::string boolstr(bool b) {
|
|
|
|
|
return b ? "true" : "false";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> void ticpp::Printer::PushElement(std::string tagName, location pos) {
|
|
|
|
|
template<> void ticpp::Printer::PushElement(std::string tagName, location pos, bool) {
|
|
|
|
|
OpenElement(tagName);
|
|
|
|
|
PushAttribute("x", pos.x);
|
|
|
|
|
PushAttribute("y", pos.y);
|
|
|
|
|
CloseElement(tagName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> void ticpp::Printer::PushElement(std::string tagName, rectangle rect) {
|
|
|
|
|
template<> void ticpp::Printer::PushElement(std::string tagName, rectangle rect, bool) {
|
|
|
|
|
OpenElement(tagName);
|
|
|
|
|
PushAttribute("top", rect.top);
|
|
|
|
|
PushAttribute("left", rect.left);
|
|
|
|
@@ -72,7 +72,7 @@ template<> void ticpp::Printer::PushElement(std::string tagName, rectangle rect)
|
|
|
|
|
CloseElement(tagName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> void ticpp::Printer::PushElement(std::string tagName, cMonster::cAttack attack) {
|
|
|
|
|
template<> void ticpp::Printer::PushElement(std::string tagName, cMonster::cAttack attack, bool) {
|
|
|
|
|
OpenElement(tagName);
|
|
|
|
|
PushAttribute("type", attack.type);
|
|
|
|
|
std::ostringstream strength;
|
|
|
|
@@ -81,7 +81,7 @@ template<> void ticpp::Printer::PushElement(std::string tagName, cMonster::cAtta
|
|
|
|
|
CloseElement(tagName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> void ticpp::Printer::PushElement(std::string tagName, cOutdoors::cWandering enc) {
|
|
|
|
|
template<> void ticpp::Printer::PushElement(std::string tagName, cOutdoors::cWandering enc, bool) {
|
|
|
|
|
OpenElement(tagName);
|
|
|
|
|
PushAttribute("can-flee", !enc.cant_flee);
|
|
|
|
|
for(size_t i = 0; i < enc.monst.size(); i++) {
|
|
|
|
@@ -100,20 +100,16 @@ template<> void ticpp::Printer::PushElement(std::string tagName, cOutdoors::cWan
|
|
|
|
|
CloseElement(tagName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> void ticpp::Printer::PushElement(std::string tagName, info_rect_t rect) {
|
|
|
|
|
template<> void ticpp::Printer::PushElement(std::string tagName, info_rect_t rect, bool cdata) {
|
|
|
|
|
OpenElement(tagName);
|
|
|
|
|
PushAttribute("top", rect.top);
|
|
|
|
|
PushAttribute("left", rect.left);
|
|
|
|
|
PushAttribute("bottom", rect.bottom);
|
|
|
|
|
PushAttribute("right", rect.right);
|
|
|
|
|
PushText(rect.descr);
|
|
|
|
|
PushText(rect.descr, cdata);
|
|
|
|
|
CloseElement(tagName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool is_minmax(int lo, int hi, int val) {
|
|
|
|
|
return minmax(lo, hi, val) == val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void writeScenarioToXml(ticpp::Printer&& data, cScenario& scenario) {
|
|
|
|
|
data.OpenElement("scenario");
|
|
|
|
|
data.PushAttribute("boes", scenario.format_ed_version());
|
|
|
|
@@ -131,8 +127,15 @@ void writeScenarioToXml(ticpp::Printer&& data, cScenario& scenario) {
|
|
|
|
|
data.PushElement("teaser", scenario.who_wrote[1]);
|
|
|
|
|
if(scenario.intro_pic != scenario.intro_mess_pic)
|
|
|
|
|
data.PushElement("icon", scenario.intro_mess_pic);
|
|
|
|
|
for(int i = 0; i < 6; i++)
|
|
|
|
|
data.PushElement("intro-msg", scenario.intro_strs[i]);
|
|
|
|
|
{
|
|
|
|
|
int last = -1;
|
|
|
|
|
for(int i = 0; i < 6; i++) {
|
|
|
|
|
if(!scenario.intro_strs[i].empty())
|
|
|
|
|
last = i;
|
|
|
|
|
}
|
|
|
|
|
for(int i = 0; i <= last; i++)
|
|
|
|
|
data.PushElement("intro-msg", scenario.intro_strs[i], true);
|
|
|
|
|
}
|
|
|
|
|
data.CloseElement("text");
|
|
|
|
|
data.OpenElement("ratings");
|
|
|
|
|
switch(scenario.rating) {
|
|
|
|
@@ -158,7 +161,8 @@ void writeScenarioToXml(ticpp::Printer&& data, cScenario& scenario) {
|
|
|
|
|
data.PushElement("num-towns", scenario.towns.size());
|
|
|
|
|
data.PushElement("out-width", scenario.outdoors.width());
|
|
|
|
|
data.PushElement("out-height", scenario.outdoors.height());
|
|
|
|
|
data.PushElement("on-init", scenario.init_spec);
|
|
|
|
|
if(scenario.init_spec >= 0)
|
|
|
|
|
data.PushElement("on-init", scenario.init_spec);
|
|
|
|
|
data.PushElement("start-town", scenario.which_town_start);
|
|
|
|
|
data.PushElement("town-start", scenario.where_start);
|
|
|
|
|
data.PushElement("outdoor-start", scenario.out_sec_start);
|
|
|
|
@@ -189,7 +193,7 @@ void writeScenarioToXml(ticpp::Printer&& data, cScenario& scenario) {
|
|
|
|
|
data.PushAttribute("useable", boolstr(scenario.special_items[i].flags % 10));
|
|
|
|
|
data.PushAttribute("special", scenario.special_items[i].special);
|
|
|
|
|
data.PushElement("name", scenario.special_items[i].name);
|
|
|
|
|
data.PushElement("description", scenario.special_items[i].descr);
|
|
|
|
|
data.PushElement("description", scenario.special_items[i].descr, true);
|
|
|
|
|
data.CloseElement("special-item");
|
|
|
|
|
}
|
|
|
|
|
for(size_t i = 0; i < scenario.quests.size(); i++) {
|
|
|
|
@@ -217,7 +221,7 @@ void writeScenarioToXml(ticpp::Printer&& data, cScenario& scenario) {
|
|
|
|
|
if(quest.bank2 >= 0)
|
|
|
|
|
data.PushElement("bank", quest.bank2);
|
|
|
|
|
data.PushElement("name", quest.name);
|
|
|
|
|
data.PushElement("description", quest.descr);
|
|
|
|
|
data.PushElement("description", quest.descr, true);
|
|
|
|
|
data.CloseElement("quest");
|
|
|
|
|
}
|
|
|
|
|
for(size_t i = 0; i < scenario.shops.size(); i++) {
|
|
|
|
@@ -250,7 +254,7 @@ void writeScenarioToXml(ticpp::Printer&& data, cScenario& scenario) {
|
|
|
|
|
case eShopItemType::CALL_SPECIAL:
|
|
|
|
|
data.OpenElement("special");
|
|
|
|
|
data.PushElement("name", entry.item.full_name);
|
|
|
|
|
data.PushElement("description", entry.item.desc);
|
|
|
|
|
data.PushElement("description", entry.item.desc, true);
|
|
|
|
|
data.PushElement("node", entry.item.item_level);
|
|
|
|
|
if(entry.quantity == 0)
|
|
|
|
|
data.PushElement("quantity", "infinite");
|
|
|
|
@@ -300,14 +304,14 @@ void writeScenarioToXml(ticpp::Printer&& data, cScenario& scenario) {
|
|
|
|
|
if(scenario.spec_strs[i].empty()) continue;
|
|
|
|
|
data.OpenElement("string");
|
|
|
|
|
data.PushAttribute("id", i);
|
|
|
|
|
data.PushText(scenario.spec_strs[i]);
|
|
|
|
|
data.PushText(scenario.spec_strs[i], true);
|
|
|
|
|
data.CloseElement("string");
|
|
|
|
|
}
|
|
|
|
|
for(size_t i = 0; i < scenario.journal_strs.size(); i++) {
|
|
|
|
|
if(scenario.journal_strs[i].empty()) continue;
|
|
|
|
|
data.OpenElement("journal");
|
|
|
|
|
data.PushAttribute("id", i);
|
|
|
|
|
data.PushText(scenario.journal_strs[i]);
|
|
|
|
|
data.PushText(scenario.journal_strs[i], true);
|
|
|
|
|
data.CloseElement("journal");
|
|
|
|
|
}
|
|
|
|
|
data.CloseElement("game");
|
|
|
|
@@ -446,7 +450,7 @@ static void writeItemsToXml(ticpp::Printer&& data) {
|
|
|
|
|
data.PushElement("use-flag", item.magic_use_type);
|
|
|
|
|
data.CloseElement("ability");
|
|
|
|
|
}
|
|
|
|
|
if(!item.desc.empty()) data.PushElement("description", item.desc);
|
|
|
|
|
if(!item.desc.empty()) data.PushElement("description", item.desc, true);
|
|
|
|
|
data.CloseElement("item");
|
|
|
|
|
}
|
|
|
|
|
data.CloseElement("items");
|
|
|
|
@@ -617,7 +621,7 @@ static void writeOutdoorsToXml(ticpp::Printer&& data, cOutdoors& sector) {
|
|
|
|
|
if(sector.sign_locs[i].text.empty()) continue;
|
|
|
|
|
data.OpenElement("sign");
|
|
|
|
|
data.PushAttribute("id", i);
|
|
|
|
|
data.PushText(sector.sign_locs[i].text);
|
|
|
|
|
data.PushText(sector.sign_locs[i].text, true);
|
|
|
|
|
data.CloseElement("sign");
|
|
|
|
|
}
|
|
|
|
|
for(auto& area : sector.info_rect) {
|
|
|
|
@@ -628,7 +632,7 @@ static void writeOutdoorsToXml(ticpp::Printer&& data, cOutdoors& sector) {
|
|
|
|
|
if(sector.spec_strs[i].empty()) continue;
|
|
|
|
|
data.OpenElement("string");
|
|
|
|
|
data.PushAttribute("id", i);
|
|
|
|
|
data.PushText(sector.spec_strs[i]);
|
|
|
|
|
data.PushText(sector.spec_strs[i], true);
|
|
|
|
|
data.CloseElement("string");
|
|
|
|
|
}
|
|
|
|
|
data.CloseElement("sector");
|
|
|
|
@@ -761,14 +765,14 @@ static void writeTownToXml(ticpp::Printer&& data, cTown& town) {
|
|
|
|
|
if(town.sign_locs[i].text.empty()) continue;
|
|
|
|
|
data.OpenElement("sign");
|
|
|
|
|
data.PushAttribute("id", i);
|
|
|
|
|
data.PushText(town.sign_locs[i].text);
|
|
|
|
|
data.PushText(town.sign_locs[i].text, true);
|
|
|
|
|
data.CloseElement("sign");
|
|
|
|
|
}
|
|
|
|
|
for(size_t i = 0; i < town.spec_strs.size(); i++) {
|
|
|
|
|
if(town.spec_strs[i].empty()) continue;
|
|
|
|
|
data.OpenElement("string");
|
|
|
|
|
data.PushAttribute("id", i);
|
|
|
|
|
data.PushText(town.spec_strs[i]);
|
|
|
|
|
data.PushText(town.spec_strs[i], true);
|
|
|
|
|
data.CloseElement("string");
|
|
|
|
|
}
|
|
|
|
|
data.CloseElement("town");
|
|
|
|
@@ -781,10 +785,12 @@ static void writeDialogueToXml(ticpp::Printer&& data, cSpeech& talk, int town_nu
|
|
|
|
|
cPersonality& who = talk.people[i];
|
|
|
|
|
data.OpenElement("personality");
|
|
|
|
|
data.PushAttribute("id", i + 10 * town_num);
|
|
|
|
|
data.PushElement("title", who.title);
|
|
|
|
|
data.PushElement("look", who.look);
|
|
|
|
|
data.PushElement("name", who.name);
|
|
|
|
|
data.PushElement("job", who.job);
|
|
|
|
|
data.PushElement("title", who.title, true);
|
|
|
|
|
data.PushElement("look", who.look, true);
|
|
|
|
|
data.PushElement("name", who.name, true);
|
|
|
|
|
data.PushElement("job", who.job, true);
|
|
|
|
|
if(!who.dunno.empty())
|
|
|
|
|
data.PushElement("unknown", who.dunno, true);
|
|
|
|
|
data.CloseElement("personality");
|
|
|
|
|
}
|
|
|
|
|
for(size_t i = 0; i < talk.talk_nodes.size(); i++) {
|
|
|
|
@@ -809,10 +815,10 @@ static void writeDialogueToXml(ticpp::Printer&& data, cSpeech& talk, int town_nu
|
|
|
|
|
if(node.extras[3] >= 0)
|
|
|
|
|
data.PushElement("param", node.extras[3]);
|
|
|
|
|
if(!node.str1.empty())
|
|
|
|
|
data.PushElement("text", node.str1);
|
|
|
|
|
data.PushElement("text", node.str1, true);
|
|
|
|
|
else data.PushElement("text");
|
|
|
|
|
if(!node.str2.empty())
|
|
|
|
|
data.PushElement("text", node.str2);
|
|
|
|
|
data.PushElement("text", node.str2, true);
|
|
|
|
|
data.CloseElement("node");
|
|
|
|
|
}
|
|
|
|
|
data.CloseElement("dialogue");
|
|
|
|
|