diff --git a/rsrc/schemas/dialogue.xsd b/rsrc/schemas/dialogue.xsd index 0b3497e2..b1dcce6e 100644 --- a/rsrc/schemas/dialogue.xsd +++ b/rsrc/schemas/dialogue.xsd @@ -47,7 +47,7 @@ - + diff --git a/rsrc/schemas/scenario.xsd b/rsrc/schemas/scenario.xsd index 40c56b6e..65ca6957 100644 --- a/rsrc/schemas/scenario.xsd +++ b/rsrc/schemas/scenario.xsd @@ -167,7 +167,7 @@ - + diff --git a/rsrc/schemas/town.xsd b/rsrc/schemas/town.xsd index 051ea9b1..4d2cad94 100644 --- a/rsrc/schemas/town.xsd +++ b/rsrc/schemas/town.xsd @@ -139,7 +139,7 @@ - + @@ -152,7 +152,7 @@ - + diff --git a/src/classes/estreams.cpp b/src/classes/estreams.cpp index 52c9cce1..a8b692b2 100644 --- a/src/classes/estreams.cpp +++ b/src/classes/estreams.cpp @@ -596,3 +596,23 @@ std::istream& operator>> (std::istream& in, eLighting& light) { in.setstate(std::ios::failbit); return in; } + +// MARK: eTalkNode + +cEnumLookup talk_nodes = { + "reg","if-sdf","set-sdf","inn","if-time","if-event","if-town","shop","train","jobs", + "","","","sell-weap","sell-prot","sell-any","id","ench","buy-info","buy-sdf", + "buy-ship","buy-horse","buy-spec-item","quest","buy-town","end-force","end-fight","end-alarm","end-die","call-local", + "call-global", +}; + +std::ostream& operator<< (std::ostream& out, eTalkNode node) { + writeEnum(out, node, talk_nodes, "reg"); + return out; +} + +std::istream& operator>> (std::istream& in, eTalkNode& node) { + if(!readEnum(in, node, talk_nodes, eTalkNode::REGULAR)) + in.setstate(std::ios::failbit); + return in; +} diff --git a/src/classes/talking.hpp b/src/classes/talking.hpp index e4f7d34b..79e90175 100644 --- a/src/classes/talking.hpp +++ b/src/classes/talking.hpp @@ -54,4 +54,7 @@ public: void writeTo(std::ostream& file) const; }; +std::ostream& operator<< (std::ostream& out, eTalkNode node); +std::istream& operator>> (std::istream& in, eTalkNode& node); + #endif diff --git a/src/scenedit/scen.fileio.cpp b/src/scenedit/scen.fileio.cpp index 2b990597..30937faa 100644 --- a/src/scenedit/scen.fileio.cpp +++ b/src/scenedit/scen.fileio.cpp @@ -786,9 +786,9 @@ static void writeDialogueToXml(ticpp::Printer&& data, cSpeech& talk, int town_nu data.OpenElement("personality"); data.PushAttribute("id", i + 10 * town_num); data.PushElement("title", who.title); - data.PushElement("look", who.look, true); - data.PushElement("name", who.name, true); - data.PushElement("job", who.job, true); + data.PushElement("look", who.look, !who.look.empty()); + data.PushElement("name", who.name, !who.look.empty()); + data.PushElement("job", who.job, !who.look.empty()); if(!who.dunno.empty()) data.PushElement("unknown", who.dunno, true); data.CloseElement("personality"); @@ -805,7 +805,7 @@ static void writeDialogueToXml(ticpp::Printer&& data, cSpeech& talk, int town_nu data.PushElement("keyword", std::string(node.link1, 4)); if(std::string(node.link2, 4) != "xxxx") data.PushElement("keyword", std::string(node.link2, 4)); - data.PushElement("type", int(node.type)); + data.PushElement("type", node.type); if(node.extras[0] >= 0 || node.extras[1] >= 0 || node.extras[2] >= 0 || node.extras[3] >= 0) data.PushElement("param", node.extras[0]); if(node.extras[1] >= 0 || node.extras[2] >= 0 || node.extras[3] >= 0) diff --git a/src/tools/fileio_scen.cpp b/src/tools/fileio_scen.cpp index d2a1e40f..0ad2eadf 100644 --- a/src/tools/fileio_scen.cpp +++ b/src/tools/fileio_scen.cpp @@ -1789,9 +1789,7 @@ static void readDialogueFromXml(ticpp::Document&& data, cSpeech& talk, int town_ else throw xBadNode(type, node->Row(), node->Column(), fname); num_keys++; } else if(type == "type") { - int type; - node->GetText(&type); - talk.talk_nodes[num_nodes].type = eTalkNode(type); + node->GetText(&talk.talk_nodes[num_nodes].type); got_type = true; } else if(type == "param") { if(num_params >= 4)