Store talk node type in scenario file as enumerator instead of numer
- Also, don't write empty CDATA sections when dialogue name/look/job sections are completely empty.
This commit is contained in:
@@ -47,7 +47,7 @@
|
|||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:sequence>
|
<xs:sequence>
|
||||||
<xs:element name="keyword" minOccurs="1" maxOccurs="2" type="xs:string"/>
|
<xs:element name="keyword" minOccurs="1" maxOccurs="2" type="xs:string"/>
|
||||||
<xs:element name="type" type="xs:integer"/>
|
<xs:element name="type" type="xs:token"/>
|
||||||
<xs:element name="param" minOccurs="0" maxOccurs="4" type="xs:integer"/>
|
<xs:element name="param" minOccurs="0" maxOccurs="4" type="xs:integer"/>
|
||||||
<xs:element name="text" minOccurs="1" maxOccurs="2" type="xs:string"/>
|
<xs:element name="text" minOccurs="1" maxOccurs="2" type="xs:string"/>
|
||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
|
@@ -167,7 +167,7 @@
|
|||||||
<xs:element name='description' type='xs:string'/>
|
<xs:element name='description' type='xs:string'/>
|
||||||
<xs:element name='node' type='xs:integer'/>
|
<xs:element name='node' type='xs:integer'/>
|
||||||
<xs:element name='quantity' type='shop-amount'/>
|
<xs:element name='quantity' type='shop-amount'/>
|
||||||
<xs:element name='cost' type='xs:integer' minOccurs="0"/>
|
<xs:element name='cost' type='xs:integer'/>
|
||||||
<xs:element name='icon' type='xs:integer'/>
|
<xs:element name='icon' type='xs:integer'/>
|
||||||
</xs:all>
|
</xs:all>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
|
@@ -139,7 +139,7 @@
|
|||||||
</xs:simpleContent>
|
</xs:simpleContent>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
<xs:element name="item">
|
<xs:element name="item" minOccurs="0">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:all>
|
<xs:all>
|
||||||
<xs:element name="type" type="xs:integer"/>
|
<xs:element name="type" type="xs:integer"/>
|
||||||
@@ -152,7 +152,7 @@
|
|||||||
<xs:attribute name="id" type="xs:integer"/>
|
<xs:attribute name="id" type="xs:integer"/>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
<xs:element name="creature">
|
<xs:element name="creature" minOccurs="0">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:all>
|
<xs:all>
|
||||||
<xs:element name="type" type="xs:integer"/>
|
<xs:element name="type" type="xs:integer"/>
|
||||||
|
@@ -596,3 +596,23 @@ std::istream& operator>> (std::istream& in, eLighting& light) {
|
|||||||
in.setstate(std::ios::failbit);
|
in.setstate(std::ios::failbit);
|
||||||
return in;
|
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;
|
||||||
|
}
|
||||||
|
@@ -54,4 +54,7 @@ public:
|
|||||||
void writeTo(std::ostream& file) const;
|
void writeTo(std::ostream& file) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::ostream& operator<< (std::ostream& out, eTalkNode node);
|
||||||
|
std::istream& operator>> (std::istream& in, eTalkNode& node);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -786,9 +786,9 @@ static void writeDialogueToXml(ticpp::Printer&& data, cSpeech& talk, int town_nu
|
|||||||
data.OpenElement("personality");
|
data.OpenElement("personality");
|
||||||
data.PushAttribute("id", i + 10 * town_num);
|
data.PushAttribute("id", i + 10 * town_num);
|
||||||
data.PushElement("title", who.title);
|
data.PushElement("title", who.title);
|
||||||
data.PushElement("look", who.look, true);
|
data.PushElement("look", who.look, !who.look.empty());
|
||||||
data.PushElement("name", who.name, true);
|
data.PushElement("name", who.name, !who.look.empty());
|
||||||
data.PushElement("job", who.job, true);
|
data.PushElement("job", who.job, !who.look.empty());
|
||||||
if(!who.dunno.empty())
|
if(!who.dunno.empty())
|
||||||
data.PushElement("unknown", who.dunno, true);
|
data.PushElement("unknown", who.dunno, true);
|
||||||
data.CloseElement("personality");
|
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));
|
data.PushElement("keyword", std::string(node.link1, 4));
|
||||||
if(std::string(node.link2, 4) != "xxxx")
|
if(std::string(node.link2, 4) != "xxxx")
|
||||||
data.PushElement("keyword", std::string(node.link2, 4));
|
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)
|
if(node.extras[0] >= 0 || node.extras[1] >= 0 || node.extras[2] >= 0 || node.extras[3] >= 0)
|
||||||
data.PushElement("param", node.extras[0]);
|
data.PushElement("param", node.extras[0]);
|
||||||
if(node.extras[1] >= 0 || node.extras[2] >= 0 || node.extras[3] >= 0)
|
if(node.extras[1] >= 0 || node.extras[2] >= 0 || node.extras[3] >= 0)
|
||||||
|
@@ -1789,9 +1789,7 @@ static void readDialogueFromXml(ticpp::Document&& data, cSpeech& talk, int town_
|
|||||||
else throw xBadNode(type, node->Row(), node->Column(), fname);
|
else throw xBadNode(type, node->Row(), node->Column(), fname);
|
||||||
num_keys++;
|
num_keys++;
|
||||||
} else if(type == "type") {
|
} else if(type == "type") {
|
||||||
int type;
|
node->GetText(&talk.talk_nodes[num_nodes].type);
|
||||||
node->GetText(&type);
|
|
||||||
talk.talk_nodes[num_nodes].type = eTalkNode(type);
|
|
||||||
got_type = true;
|
got_type = true;
|
||||||
} else if(type == "param") {
|
} else if(type == "param") {
|
||||||
if(num_params >= 4)
|
if(num_params >= 4)
|
||||||
|
Reference in New Issue
Block a user